Event callback still called after deiniting it
Posted: Sun Feb 12, 2023 7:35 pm
I am trying to develop a mesh application where at the root node, it checks for the existence of the router. If it wasn't there after N seconds, it will make a local mesh network instead.
This is the code I wrote to restart the esp-mesh
A short time between mwifi_deinit() and esp_wifi_stop() the event callback is erroneously called again which causes a panic in my application, even though I have deinitialized it in the first line! Why is that? Here are the logs I see on the terminal before the panic
I (12712) wifi:Set ps type: 0 I (12712) mesh: 452<stop> W (12712) mesh: [mesh.c,455] <stop>vendor ie W (12716) mesh: [mesh.c,458] <stop>send block W (12720) mesh: [mesh.c,461] <stop>rx task W (12724) mesh: [mesh_schedule.c,2119] <break>tx I (12729) mesh: 1942<flush>xon(req:0, rsp:0), mgmt:0, bcast:0, down:0, donw-be:0, ps(active:0, tx:0) W (12737) mesh: [mesh_schedule.c,2525] <done>MESH_STOP_EVENT_BIT_TX W (12743) mesh: [mesh_schedule.c,2526] <stop>tx W (12748) mesh: [mesh_schedule.c,2752] <break>xon I (12752) mesh: 1974<flush>up:0, up-be:0, ps(active:0, tx:0) W (12757) mesh: [mesh_schedule.c,3253] <done>MESH_STOP_EVENT_BIT_XON W (12763) mesh: [mesh_schedule.c,3254] <stop>xon W (12768) mesh: [mesh.c,464] <stop>tx task W (12782) mesh: [mesh.c,467] <stop>nwk task W (12783) mesh: [mesh.c,472] <stop>route W (12783) mesh: [mesh.c,477] <stop>free mesh_myself_mbox W (12784) [mwifi, 1344]: <ESP_ERR_MESH_NOT_START> Node failed to receive packets W (12785) mesh: [mesh.c,415] <done>MESH_STOP_EVENT_BIT_TODS W (12798) mesh: [mesh.c,482] <stop>free mesh_tcpip_mbox W (12803) mesh: [mesh.c,486] <stop>is_receiving:0 W (12807) mesh: [mesh.c,497] <stop>free mesh_xmit_state_mbox W (12812) mesh: [mesh.c,510] <stop>nvs task I (12824) wifi:Total power save buffer number: 16 I (12827) mesh: 552<end> I (12828) [mwifi, 232]: MESH is stopped W (12828) [mdf_event_loop, 69]: <MDF_ERR_NOT_INIT> The event loop isn't initialized W (12886) wifi:age timer already deinit I (12886) wifi:mode : sta (98ac:81:63:58) W (12889) wifi:age timer already deinit I (12892) wifi:flush txq I (12893) wifi:stop sw txq I (12896) wifi:lmac stop hw txq I (12899) [router_example, 282]: Root receive, addr: 00:00:00:00:00:00, size: 0, data:
This is the code I wrote to restart the esp-mesh
Code: Select all
mdf_event_loop_deinit();
mwifi_stop();
mwifi_deinit();
esp_wifi_stop();
esp_wifi_deinit();
MDF_ERROR_ASSERT(mdf_event_loop_init(event_loop_cb));
MDF_ERROR_ASSERT(wifi_init());
MDF_ERROR_ASSERT(mwifi_init(&cfg));
MDF_ERROR_ASSERT(mwifi_set_config(&config));
MDF_ERROR_ASSERT(mwifi_start());
I (12712) wifi:Set ps type: 0 I (12712) mesh: 452<stop> W (12712) mesh: [mesh.c,455] <stop>vendor ie W (12716) mesh: [mesh.c,458] <stop>send block W (12720) mesh: [mesh.c,461] <stop>rx task W (12724) mesh: [mesh_schedule.c,2119] <break>tx I (12729) mesh: 1942<flush>xon(req:0, rsp:0), mgmt:0, bcast:0, down:0, donw-be:0, ps(active:0, tx:0) W (12737) mesh: [mesh_schedule.c,2525] <done>MESH_STOP_EVENT_BIT_TX W (12743) mesh: [mesh_schedule.c,2526] <stop>tx W (12748) mesh: [mesh_schedule.c,2752] <break>xon I (12752) mesh: 1974<flush>up:0, up-be:0, ps(active:0, tx:0) W (12757) mesh: [mesh_schedule.c,3253] <done>MESH_STOP_EVENT_BIT_XON W (12763) mesh: [mesh_schedule.c,3254] <stop>xon W (12768) mesh: [mesh.c,464] <stop>tx task W (12782) mesh: [mesh.c,467] <stop>nwk task W (12783) mesh: [mesh.c,472] <stop>route W (12783) mesh: [mesh.c,477] <stop>free mesh_myself_mbox W (12784) [mwifi, 1344]: <ESP_ERR_MESH_NOT_START> Node failed to receive packets W (12785) mesh: [mesh.c,415] <done>MESH_STOP_EVENT_BIT_TODS W (12798) mesh: [mesh.c,482] <stop>free mesh_tcpip_mbox W (12803) mesh: [mesh.c,486] <stop>is_receiving:0 W (12807) mesh: [mesh.c,497] <stop>free mesh_xmit_state_mbox W (12812) mesh: [mesh.c,510] <stop>nvs task I (12824) wifi:Total power save buffer number: 16 I (12827) mesh: 552<end> I (12828) [mwifi, 232]: MESH is stopped W (12828) [mdf_event_loop, 69]: <MDF_ERR_NOT_INIT> The event loop isn't initialized W (12886) wifi:age timer already deinit I (12886) wifi:mode : sta (98ac:81:63:58) W (12889) wifi:age timer already deinit I (12892) wifi:flush txq I (12893) wifi:stop sw txq I (12896) wifi:lmac stop hw txq I (12899) [router_example, 282]: Root receive, addr: 00:00:00:00:00:00, size: 0, data: