EasyManua.ls Logo

Espressif ESP32-S2 - Page 151

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
Therefore, application calls to Wi-Fi APIs should be placed in between calls of
esp_mesh_set_self_organized() which disable and enable self organized networking. The follow-
ing code snippet demonstrates how an application can safely call esp_wifi_scan_start() whilst using
ESP-WIFI-MESH.
//Disable self organized networking
esp_mesh_set_self_organized(0, 0);
//Stop any scans already in progress
esp_wifi_scan_stop();
//Manually start scan. Will automatically stop when run to completion
esp_wifi_scan_start();
//Process scan results
...
//Re-enable self organized networking if still connected
esp_mesh_set_self_organized(1, 0);
...
//Re-enable self organized networking if non-root and disconnected
esp_mesh_set_self_organized(1, 1);
...
//Re-enable self organized networking if root and disconnected
esp_mesh_set_self_organized(1, 0); //Don't select new parent
esp_mesh_connect(); //Manually reconnect to router
Application Examples ESP-IDF contains these ESP-WIFI-MESH example projects:
The Internal Communication Example demonstrates how to set up a ESP-WIFI-MESH network and have the root
node send a data packet to every node within the network.
The Manual Networking Example demonstrates how to use ESP-WIFI-MESH without the self-organizing features.
This example shows how to program a node to manually scan for a list of potential parent nodes and select a parent
node based on custom criteria.
API Reference
Header File
components/esp_wifi/include/esp_mesh.h
Functions
esp_err_t esp_mesh_init(void)
Mesh initialization.
Check whether Wi-Fi is started.
Initialize mesh global variables with default values.
Attention This API shall be called after Wi-Fi is started.
Return
ESP_OK
ESP_FAIL
esp_err_t esp_mesh_deinit(void)
Mesh de-initialization.
Espressif Systems 140
Submit Document Feedback
Release v4.4

Table of Contents