Chapter 2. API Reference
– If the packet is to an external IP network, set this parameter to the IPv4:PORT combination.
This packet will be delivered to the root firstly, then the root will forward this packet to the final
IP server address.
• [in] data: pointer to a sending mesh packet
– Field size should not exceed MESH_MPS. Note that the size of one mesh packet should not
exceed MESH_MTU.
– Field proto should be set to data protocol in use (default is MESH_PROTO_BIN for binary).
– Field tos should be set to transmission tos (type of service) in use (default is MESH_TOS_P2P
for point-to-point reliable).
• [in] flag: bitmap for data sent
– Speed up the route search
* If the packet is to the root and "to"parameter is NULL, set this parameter to 0.
* If the packet is to an internal device, MESH_DATA_P2P should be set.
* If the packet is to the root ("to"parameter isn't NULL) or to external IP network,
MESH_DATA_TODS should be set.
* If the packet is from the root to an internal device, MESH_DATA_FROMDS should be set.
– Specify whether this API is block or non-block, block by default
* If needs non-blocking, MESH_DATA_NONBLOCK should be set. Otherwise, may use
esp_mesh_send_block_time() to specify a blocking time.
– In the situation of the root change, MESH_DATA_DROP identifies this packet can be dropped
by the new root for upstream data to external IP network, we try our best to avoid data loss caused
by the root change, but there is a risk that the new root is running out of memory because most of
memory is occupied by the pending data which isn' t read out in time by esp_mesh_recv_toDS().
Generally, we suggest esp_mesh_recv_toDS() is called after a connection with IP network
is created.
esp_mesh_recv_toDS() which avoids unnecessary memory copy.
• [in] opt: options
– In case of sending a packet to a certain group, MESH_OPT_SEND_GROUP is a good choice.
In this option, the value field should be set to the target receiver addresses in this group.
– Root sends a packet to an internal device, this packet is from external IP network in case the
receiver device responds this packet, MESH_OPT_RECV_DS_ADDR is required to attach the
target DS address.
• [in] opt_count: option count
– Currently, this API only takes one option, so opt_count is only supported to be 1.
esp_err_t
esp_mesh_send_block_time(uint32_t time_ms)
Set blocking time of esp_mesh_send()
Attention This API shall be called before mesh is started.
Return
• ESP_OK
Parameters
• [in] time_ms: blocking time of esp_mesh_send(), unit:ms
esp_err_t esp_mesh_recv(mesh_addr_t
Receive a packet targeted to self over the mesh network.
flag could be MESH_DATA_FROMDS or MESH_DATA_TODS.
Attention Mesh RX queue should be checked regularly to avoid running out of memory.
• Use esp_mesh_get_rx_pending() to check the number of packets available in the queue waiting to
be received by applications.
Return
• ESP_OK
• ESP_ERR_MESH_ARGUMENT
• ESP_ERR_MESH_NOT_START
• ESP_ERR_MESH_TIMEOUT
• ESP_ERR_MESH_DISCARD
Parameters
• [out] from: the address of the original source of the packet
Espressif Systems
Thus data outgoing to external IP network via socket is just from reading
*from,
mesh_data_t
opt[], int opt_count)
142
Submit Document Feedback
*data, int timeout_ms, int *flag,
mesh_opt_t
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?