1 // Copyright 2018 Espressif Systems (Shanghai) PTE LTD
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
16 #include "esp_event.h"
19 /* mesh event callback handler */
20 mesh_event_cb_t g_mesh_event_cb = NULL;
22 esp_err_t esp_event_mesh_hook(system_event_t *event)
24 if (event->event_id == SYSTEM_EVENT_STA_GOT_IP || event->event_id == SYSTEM_EVENT_STA_LOST_IP) {
25 if (g_mesh_event_cb) {
27 if (event->event_id == SYSTEM_EVENT_STA_GOT_IP) {
28 mevent.id = MESH_EVENT_ROOT_GOT_IP;
29 memcpy(&mevent.info.got_ip, &event->event_info.got_ip, sizeof(system_event_sta_got_ip_t));
31 mevent.id = MESH_EVENT_ROOT_LOST_IP;
33 g_mesh_event_cb(mevent);