Espressif ESP32-S2 Programming Manual page 148

Table of Contents

Advertisement

Chapter 2. API Reference
Writing an ESP-WIFI-MESH Application
and Wi-Fi, The following code snippet demonstrates the necessary prerequisite steps before ESP-WIFI-MESH itself
can be initialized.
tcpip_adapter_init();
/*
* for mesh
* stop DHCP server on softAP interface by default
* stop DHCP client on station interface by default
*/
ESP_ERROR_CHECK(tcpip_adapter_dhcps_stop(TCPIP_ADAPTER_IF_AP));
ESP_ERROR_CHECK(tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA));
/*
event initialization */
ESP_ERROR_CHECK(esp_event_loop_create_default());
/*
Wi-Fi initialization */
wifi_init_config_t config
ESP_ERROR_CHECK(esp_wifi_init(&config));
/*
register IP events handler */
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &ip_
event_handler, NULL));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_FLASH));
ESP_ERROR_CHECK(esp_wifi_start());
After initializing LwIP and Wi-Fi, the process of getting an ESP-WIFI-MESH network up and running can be
summarized into the following three steps:
1.
Initialize Mesh
2.
Configuring an ESP-WIFI-MESH Network
3.
Start Mesh
Initialize Mesh
The following code snippet demonstrates how to initialize ESP-WIFI-MESH
/*
mesh initialization */
ESP_ERROR_CHECK(esp_mesh_init());
/*
register mesh events handler */
ESP_ERROR_CHECK(esp_event_handler_register(MESH_EVENT, ESP_EVENT_ANY_ID, &mesh_
event_handler, NULL));
Configuring
an
esp_mesh_set_config()
ture contains the following parameters used to configure ESP-WIFI-MESH:
Parameter
Channel
Mesh ID
Router
Mesh AP
Crypto Functions
The following code snippet demonstrates how to configure ESP-WIFI-MESH.
/* Enable the Mesh IE encryption by default */
mesh_cfg_t cfg
=
MESH_INIT_CONFIG_DEFAULT();
/* mesh ID */
memcpy((uint8_t
*) &cfg.mesh_id, MESH_ID, 6);
/* channel (must match the router's channel) */
Espressif Systems
The prerequisites for starting ESP-WIFI-MESH is to initialize LwIP
=
WIFI_INIT_CONFIG_DEFAULT();
ESP-WIFI-MESH
Network
which receives its arguments using the
Description
Range from 1 to 14
ID of ESP-WIFI-MESH Network, see
Router Configuration, see
Mesh AP Configuration, see
Crypto Functions for Mesh IE, see mesh_crypto_funcs_t
Submit Document Feedback
ESP-WIFI-MESH
mesh_cfg_t
mesh_router_t
mesh_ap_cfg_t
137
is
configured
structure.
The struc-
mesh_addr_t
(continues on next page)
Release v4.4
via

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents

Save PDF