esp_mesh_recv_toDS() function
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. @attention This API is only called by the root. flag could be MESH_DATA_TODS.
Arguments
from
the address of the original source of the packet
to
the address contains remote IP address and port (IPv4:PORT)
data
pointer to the received packet - Contain the protocol and applications should follow it to parse the data.
timeout_ms
wait time if a packet isn't immediately available (0:no wait, portMAX_DELAY:wait forever)
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.
opt
options desired to receive
opt_count
option count desired to receive
Return value
- ESP_OK - ESP_ERR_MESH_ARGUMENT - ESP_ERR_MESH_NOT_START - ESP_ERR_MESH_TIMEOUT - ESP_ERR_MESH_DISCARD - ESP_ERR_MESH_RECV_RELEASE