Chapter 2. API Reference
• [out] data: pointer to the received mesh packet
– Field proto is the data protocol in use. Should follow it to parse the received data.
– Field tos is the transmission tos (type of service) in use.
• [in]
timeout_ms: wait time if a packet isn't immediately available (0:no wait, port-
MAX_DELAY:wait forever)
• [out] flag: bitmap for data received
– MESH_DATA_FROMDS represents data from external IP network
– MESH_DATA_TODS represents data directed upward within the mesh network
Parameters
• [out] opt: options desired to receive
– MESH_OPT_RECV_DS_ADDR attaches the DS address
• [in] opt_count: option count desired to receive
– Currently, this API only takes one option, so opt_count is only supported to be 1.
esp_err_t esp_mesh_recv_toDS(mesh_addr_t
Receive a packet targeted to external IP network.
• Root uses this API to receive packets destined to external IP network
• Root forwards the received packets to the final destination via socket.
• If no socket connection is ready to send out the received packets and this esp_mesh_recv_toDS() hasn'
t been called by applications, packets from the whole mesh network will be pending in toDS queue.
Use esp_mesh_get_rx_pending() to check the number of packets available in the queue waiting to be received
by applications in case of running out of memory in the root.
Using esp_mesh_set_xon_qsize() users may configure the RX queue size, default:32. If this size is too large,
and esp_mesh_recv_toDS() isn't called in time, there is a risk that a great deal of memory is occupied by the
pending packets. If this size is too small, it will impact the efficiency on upstream. How to decide this value
depends on the specific application scenarios.
flag could be MESH_DATA_TODS.
Attention This API is only called by the root.
Return
• ESP_OK
• ESP_ERR_MESH_ARGUMENT
• ESP_ERR_MESH_NOT_START
• ESP_ERR_MESH_TIMEOUT
• ESP_ERR_MESH_DISCARD
• ESP_ERR_MESH_RECV_RELEASE
Parameters
• [out] from: the address of the original source of the packet
• [out] to: the address contains remote IP address and port (IPv4:PORT)
• [out] data: pointer to the received packet
– Contain the protocol and applications should follow it to parse the data.
• [in]
timeout_ms: wait time if a packet isn't immediately available (0:no wait, port-
MAX_DELAY:wait forever)
• [out] flag: bitmap for data received
– MESH_DATA_TODS represents the received data target to external IP network. Root shall
forward this data to external IP network via the association with router.
Parameters
• [out] opt: options desired to receive
• [in] opt_count: option count desired to receive
esp_err_t
esp_mesh_set_config(const
Set mesh stack configuration.
• Use MESH_INIT_CONFIG_DEFAULT() to initialize the default values, mesh IE is encrypted by de-
fault.
• Mesh network is established on a fixed channel (1-14).
• Mesh event callback is mandatory.
Espressif Systems
*from,
mesh_addr_t
out_ms, int *flag,
mesh_opt_t
mesh_cfg_t
*config)
143
Submit Document Feedback
*to,
mesh_data_t
*data, int time-
opt[], int opt_count)
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?