Function esp_idf_sys::esp_mesh_send

source ·
pub unsafe extern "C" fn esp_mesh_send(
    to: *const mesh_addr_t,
    data: *const mesh_data_t,
    flag: c_int,
    opt: *const mesh_opt_t,
    opt_count: c_int,
) -> esp_err_t
Expand description

@brief Send a packet over the mesh network - Send a packet to any device in the mesh network. - Send a packet to external IP network.

@attention This API is not reentrant.

@param[in] to the address of the final destination of the packet - If the packet is to the root, set this parameter to NULL. - 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. @param[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). @param[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. Thus data outgoing
          to external IP network via socket is just from reading esp_mesh_recv_toDS() which avoids unnecessary memory copy.

@param[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. @param[in] opt_count option count - Currently, this API only takes one option, so opt_count is only supported to be 1.

@return

  • ESP_OK
  • ESP_FAIL
  • ESP_ERR_MESH_ARGUMENT
  • ESP_ERR_MESH_NOT_START
  • ESP_ERR_MESH_DISCONNECTED
  • ESP_ERR_MESH_OPT_UNKNOWN
  • ESP_ERR_MESH_EXCEED_MTU
  • ESP_ERR_MESH_NO_MEMORY
  • ESP_ERR_MESH_TIMEOUT
  • ESP_ERR_MESH_QUEUE_FULL
  • ESP_ERR_MESH_NO_ROUTE_FOUND
  • ESP_ERR_MESH_DISCARD