Page 1 of 1

Using Wi-Fi with ESP-MDF

Posted: Tue Mar 12, 2019 11:26 am
by KaranRaj
Hi All,

I recently started working with the ESP-MDF framework. I want to use the Wi-Fi with mesh. I went through the ESP-mesh documents ... _mesh.html which says:

"When self organized networking is enabled, the ESP-MESH stack will internally make calls to Wi-Fi driver APIs. Therefore, the application layer should not make any calls to Wi-Fi driver APIs whilst self organized networking is enabled as doing so would risk interfering with ESP-MESH."

Since this document falls in the ESP-Mesh section under ESP-IDF, I'm not sure if this is also applicable to the ESP-MDF framework. When I call the "wifi_sta_init()" API within the code, it crashes.

The page ... nce/mwifi/ says:
"If you want to call Wi-Fi API to connect/disconnect/scan, please pause Mwifi first."
Is this the answer to my question? If so, do I "pause Mwifi" with the "mwifi_stop()" API, and resume it with "mwifi_start()"?

Also, I noticed when I pass the ".router_ssid" and ".router_password" to the "mwifi_config_t" structure, my root node connects to the WiFi successfully. Are there any "mwifi" APIs rather than "wifi" APIs to communicate with the router?

Please guide me through how to use Wi-Fi within the ESP-MDF framework or even point me to the right example? That would be very helpful.

Sorry for the multiple questions :oops: . Since they were all related, I preferred to go on a single post.


PS: I earlier posted this question on the general discussion section. Later moved it here.

Re: Using Wi-Fi with ESP-MDF

Posted: Mon Mar 18, 2019 8:27 am
Hi KaranRaj,
If so, do I "pause Mwifi" with the "mwifi_stop()" API, and resume it with "mwifi_start()"?
Are there any "mwifi" APIs rather than "wifi" APIs to communicate with the router?
As for the communication between root and router, we can use all the same APIs as wifi, so we don't add another more layer. The "mwifi" APIs service for the internal communication inside the mesh network.

As you already went through the docs, we suggest that you can start with the demos, ... opment_kit you can start with the light demo, which can give you a general idea. Then if you want to create your own demo, you can try get familiar with the examples here ... ction_demo

Re: Using Wi-Fi with ESP-MDF

Posted: Thu Mar 21, 2019 7:57 am
by KaranRaj

Thanks for the reply.

Another issue I'm facing in the ESP-MDF "get-started" example is that if the router_ssid and router_password do not match with the actual router ssid and passwords of my router respectively, the mesh wont connect (node wont connect to the root node).

Code: Select all

mwifi_config_t config   = {
        .channel   = CONFIG_MESH_CHANNEL,
        .mesh_id   = CONFIG_MESH_ID,
        .mesh_type = CONFIG_DEVICE_TYPE,
        .router_ssid = "yyyyyyyy",
        .router_password = "xxxxxxxx",
I've also noticed that the "MDF_EVENT_MWIFI_PARENT_DISCONNECTED" event keeps triggering when this happens, hence in the log printing "Parent is disconnected on station interface".(not sure if this is related to my problem but I've noticed that the nodes connect to the root only when "Parent is connected on station interface" is displayed when the "MDF_EVENT_MWIFI_PARENT_CONNECTED" event is triggered. When exactly are these events triggered? Is this an abnormal behavior?

Re: Using Wi-Fi with ESP-MDF

Posted: Fri Mar 22, 2019 8:41 am
by ESP_yudong
This behavior has some changes during adding channel switch functions.
On the current IDF version, The device will not tell others it's root before it connected with router. So the other nodes will not connect to the root which is connecting to router.