Page 1 of 1

Example of WiFi Mesh for external MQTT communications

Posted: Sat Aug 10, 2024 2:43 am
by MichaelS
Hi

I am looking for an operational IDF example of WiFi Mesh which can be used with MQTT for external communications to a broker. I am using IDF ver 5.3

Looking at the Mesh examples on provided in Vscode I selected ip_internal_network.

I configured built and ran it and it and worked but found it not to be robust.

It doesn't support provisioning which I put to one side but the biggest 2 issues are:
  • If I start the application while my WIFI access point is powered off, and then power it up, it never establishes WiFi communications
  • If I start the application with my WIFI access point operation and have everything working, and then I power off my access point, it eventually crashes and halts without any useful information
I went to https://github.com/espressif/esp-idf/tr ... mples/mesh and found there had been changes within the last 3 weeks so I refreshed my files. With the latest updates problem 1 above still remains, while problem 2 seems to have been dealt with. It no longer crashes and halts but it takes a while to recover after the WIFI App is back up and running. MQTT reports broker online / offline a couple of times and then settles down and the system become stable.

I am hoping for a more mature example app if there is one. Please advise.

If not, I am looking for solutions to solve some problems like, events to detect when the WIFI access point connection is lost from my Root Node, also when coms are restored.
I have found on disconnect I get event:
  1. mesh_main: <MESH_EVENT_PARENT_DISCONNECTED>reason:201
But on re connection I don't get any events. The MQTT code continues to try to reconnect to the broker and it suddenly is successful again is the only warning I get.

Is it possible to restart WIFI Mesh? I am thinking on startup, if I dont get:
  1. mesh_main: <MESH_EVENT_PARENT_CONNECTED>layer:0-->1, parent:5c:e9:31:9a:5d:1a<ROOT>, ID:77:77:77:77:77:76
and only get:
  1. mesh_main: <MESH_EVENT_PARENT_DISCONNECTED>reason:200
  2. mesh_main: <MESH_EVENT_PARENT_DISCONNECTED>reason:201
  3. mesh_main: <MESH_EVENT_PARENT_DISCONNECTED>reason:211
I could set a timer for say 2 minute and then restart the WIFI Mesh. Can you please advise if this sounds the best option and if so, what functions I need to call to do this.

eg call esp_mesh_stop(void) and esp_mesh_start() or do I ALSO need to call esp_mesh_deinit() and esp_mesh_init()? Are any delays required?

I feel like this should work but it feels like a bit of a hack?

Lastly back to provisioning, I have SoftAP provisioning working with the ESP Provisioning app for WIFI (not WIFI Mesh). Does this apply to WIFI Mesh for connection to the Wifi Access Point?

Can it also be used for Station SoftAP for sub node connections using Mesh AP Password?

Thanks for your help!

Re: Example of WiFi Mesh for external MQTT communications

Posted: Sat Aug 10, 2024 1:52 pm
by aliarifat794
You can add some lines to restart and reinitialize the mesh.