Using Wi-Fi with ESP-MDF

KaranRaj
Posts: 16
Joined: Wed Jan 16, 2019 5:43 am

Using Wi-Fi with ESP-MDF

Postby KaranRaj » Tue Mar 12, 2019 11:26 am

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 https://docs.espressif.com/projects/esp ... _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 https://docs.espressif.com/projects/esp ... 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.

Thanks,
Karan

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

ESP_LBB
Posts: 108
Joined: Fri May 18, 2018 3:41 am

Re: Using Wi-Fi with ESP-MDF

Postby ESP_LBB » 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()"?
Yes.
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, https://github.com/espressif/esp-mdf/tr ... 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 https://github.com/espressif/esp-mdf/tr ... ction_demo

KaranRaj
Posts: 16
Joined: Wed Jan 16, 2019 5:43 am

Re: Using Wi-Fi with ESP-MDF

Postby KaranRaj » Thu Mar 21, 2019 7:57 am

Hi ESP_LBB!

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?

ESP_yudong
Posts: 68
Joined: Wed May 16, 2018 12:31 pm

Re: Using Wi-Fi with ESP-MDF

Postby ESP_yudong » Fri Mar 22, 2019 8:41 am

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.

KaranRaj
Posts: 16
Joined: Wed Jan 16, 2019 5:43 am

Re: Using Wi-Fi with ESP-MDF

Postby KaranRaj » Thu May 28, 2020 12:14 pm

Hi @ESP_yudong,

So basically the mesh will not connect when the root is trying to connect to the router? For example, if the WiFi SSID and password I provided to the ESP32 is incorrect, then the mesh will never connect, because the root is always trying to connect to the incorrect WiFi?

Any suggestions on how I can tackle this problem?

Who is online

Users browsing this forum: No registered users and 5 guests