esp-mesh-lite icon indicating copy to clipboard operation
esp-mesh-lite copied to clipboard

Disabling & enabling esp-mesh-lite in run time (IDFGH-13150) (AEGHB-1009)

Open harigt99 opened this issue 1 year ago • 1 comments

Answers checklist.

  • [X] I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • [X] I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • [X] I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.2

Espressif SoC revision.

ESP32-WROOM-32

Operating System used.

Windows

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

ESP 32 DEVKIT V1

Power Supply used.

USB

What is the expected behavior?

I am using esp-mesh-lite to establish a network. I want to deinitalize & initialize the esp-mesh-lite stack during run time. There are no proper apis provided in esp-mesh-lite to deinitialize during runtime. So, I tried tracing the apis used during initializing, and, I have deinitialized/unregistered all those apis in the following order:

esp_mesh_lite_deinit(); esp_event_loop_delete_default(); esp_netif_deinit();

esp_mesh_lite_deinit() looks like this:

xTimerStop(report_timer, portMAX_DELAY); xTimerStop(root_timer, portMAX_DELAY); xTimerDelete(report_timer, portMAX_DELAY); xTimerDelete(root_timer, portMAX_DELAY);

esp_mesh_lite_msg_action_list_unregister(node_report_action);
esp_event_handler_instance_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, &ip_event);

esp_now_unregister_recv_cb();
esp_now_deinit();

esp_event_handler_instance_unregister(ESP_MESH_LITE_EVENT, ESP_EVENT_ANY_ID, &mesh_event);

`

The expected behavior is that I should be able to reinitialize esp-mesh-lite properly & the node should be able to connect to the desired AP.

What is the actual behavior?

On reinitializing I am getting an error "E (119513) [ESP_Mesh_Lite_Comm]: Bind error Address already in use" which I am not able to find anywhere in the source code esp-mesh-lite. I figure it is from the static libraries provided for the esp-mesh-lite. Hence, am not able to figure out how the sockets have been initialized & also in which port they are running.

Attached logs below for your reference. For initializing, I am using the same init apis provided in "mesh_local_control.c" file in

Steps to reproduce.

  1. Step
  2. Step
  3. Step ... Step1: Initialize esp-mesh-lite Step2: Deinitalize esp-mesh-lite with the provided apis in the expected behavior section Step3: Then try reinitialize the esp-mesh-lite again as shown in "mesh_local_control" example provided in esp-mesh-lite

Debug Logs.

W (119413) mqtt_examples: <MESH_WIFI_STATE_INITIALIZE> Wifi state is inactive
I (119423) mqtt_examples: mesh_init() -> esp_netif_init
I (119433) mqtt_examples: mesh_init() -> esp_event_loop_create_default()
I (119433) mqtt_examples: mesh_init() -> esp_bridge_create_all_netif()
I (119443) mqtt_examples: mesh_init() -> if_init() done
I (119453) bridge_wifi: [esp_bridge_wifi_set_config] sta ssid: Hariharan password: youyouyou
I (119463) bridge_wifi: [esp_bridge_wifi_set_config] softap ssid: ESP_Bridge password: 12345678
I (119473) wifi:Total power save buffer number: 16
I (119473) bridge_wifi: SoftAP config changed, deauth all station
I (119483) Mesh-Lite: esp-mesh-lite component version: 0.10.5
I (119483) ESPNOW: espnow [version: 1.0] init
I (119493) [vendor_ie]: Mesh-Lite commit id: 00bcc9f

I (119493) [vendor_ie]: Mesh ID: 77
E (119513) [ESP_Mesh_Lite_Comm]: Bind error Address already in use
E (119513) [ESP_Mesh_Lite_Comm]: Bind error Address already in use
E (119513) [ESP_Mesh_Lite_Comm]: Bind error Address already in use
I (119523) [mesh-lite-espnow]: Start espnow task
E (119523) [ESP_Mesh_Lite_Comm]: Bind error Address already in use
I (119523) [ESP_Mesh_Lite_Comm]: msg action add success
W (119543) [vendor_ie]: [Unexpected restart]: the rtc data: temp_mesh_id:154, level:1, ssid:Hariharan, bssid 00:00:00:00:00:00
W (119553) [vendor_ie]: Try to connect the original parent node
I (119563) wifi:state: run -> init (0)
I (119563) wifi:pm stop, total sleep time: 51173906 us / 67149083 us

I (119573) wifi:<ba-del>idx:0, tid:0
I (119573) wifi:<ba-del>idx:1, tid:6
I (119573) wifi:new:<11,0>, old:<11,0>, ap:<11,2>, sta:<11,0>, prof:1
I (119593) [vendor_ie]: esp_mesh_lite_wifi_connect return ESP_OK
I (119603) wifi:new:<11,2>, old:<11,0>, ap:<11,2>, sta:<11,0>, prof:1
I (119963) wifi:state: init -> auth (b0)
I (119973) wifi:state: auth -> assoc (0)
I (120033) wifi:state: assoc -> run (10)
I (120063) wifi:connected with Hariharan, aid = 2, channel 11, BW20, bssid = d2:6f:b6:73:a5:87
I (120063) wifi:security: WPA2-PSK, phy: bgn, rssi: -13
I (120063) wifi:pm start, type: 1

I (120063) wifi:dp: 1, bi: 102400, li: 3, scale listen interval from 307200 us to 307200 us
I (120133) wifi:dp: 2, bi: 102400, li: 4, scale listen interval from 307200 us to 409600 us
I (120133) wifi:AP's beacon interval = 102400 us, DTIM period = 2
W (123473) mesh_mqtt: Memory in RAM before hb - 37804
W (123473) mesh_mqtt: Memory in RAM after hb - 37804 | length - 166
W (123473) mesh_mqtt: Device status - Active


▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ (128413) wifi:Error! Should use default active scan time parameter for WiFi scan when Bluetooth is enabled!!!!!!

More Information.

No response

harigt99 avatar Jun 27 '24 10:06 harigt99

I'm not sure what the purpose of deleting the esp-mesh-lite stack is, but if the purpose is to rebuild the MESH network topology, why not just reboot?

I think it will rebuild an appropriate MESH depending on the surrounding environment at the time of startup.

nopnop2002 avatar Aug 01 '25 06:08 nopnop2002