bug in esp_mesh_send sending to ROOT
Posted: Sat Feb 09, 2019 2:44 pm
Hi all,
I am having some trouble with esp_mesh_send. The following code runs on 2 x ESP32s and seems to work fine if the node is ROOT but if it is not ROOT I get the following errors
This is the function that sends the mesh data
and this is the calling code
This seems like a bug to me but anyone have any ideas?
thanks
Lee.
I am having some trouble with esp_mesh_send. The following code runs on 2 x ESP32s and seems to work fine if the node is ROOT but if it is not ROOT I get the following errors
Code: Select all
[0;32mI (1065587) HomeIoT: DoStuff: leaf node[0m
[0;32mI (1065587) HomeIoT: DoStuff: About to send message [Hello from HomeIOT] size [19] layer[2] numb nodes[1][0m
[0;32mI (1065587) mesh_node: MeshNodeSendData: message size [19] message [Hello from HomeIOT][0m
[0;32mI (1065597) mesh_node: Destination is NULL so off to ROOT[0m
[0;31mE (1065597) mesh_node: MeshNodeSendData: Failed to send Mesh data Error[16392 = ESP_ERR_MESH_ARGUMENT] - message size [19] parent [ 3c:71:bf:96:e6:41 ] [0m
[0;31mE (1065617) HomeIoT: DoStuff: Failed to send Mesh data to ROOT Error[16392 = ESP_ERR_MESH_ARGUMENT] - Message [Hello from HomeIOT][0m
Code: Select all
esp_err_t mesh_node_send_data(mesh_addr_t *dest_addr, mesh_data_t *data)
{
esp_err_t err = ESP_OK;
char *sMessage = (char*)data->data;
ESP_LOGI(MESH_TAG,"MeshNodeSendData: message size [%d] message [%s]", data->size, sMessage );
err = esp_mesh_send(dest_addr, data, MESH_DATA_P2P, NULL, 0);
if (mesh_parent_addr.addr == NULL)
{
ESP_LOGE(MESH_TAG, "MeshNodeSendData: parent address is NULL");
return ESP_FAIL;
}
if (err != ESP_OK)
ESP_LOGE(MESH_TAG,"MeshNodeSendData: Failed to send Mesh data Error[%d = %s] - message size [%d] parent [ "MACSTR" ] ", err, esp_err_to_name(err), data->size, MAC2STR(mesh_parent_addr.addr) );
else
ESP_LOGI(MESH_TAG,"MeshNodeSendData: Sent Mesh message - message size [%d] parent ["MACSTR"] ", data->size, MAC2STR(mesh_parent_addr.addr) );
return err;
}
Code: Select all
void DoStuff()
{
char sMessage[40] = "";
esp_err_t err;
mesh_addr_t routeTable[100];
int nRouteTableSize = 0;
int nLayer = 0;
bool bIsRoot = false;
sprintf(sMessage, "Hello from HomeIOT");
mesh_data_t data;
data.data = (void*) sMessage;
data.size = strlen((char*) data.data)+1;
data.proto = MESH_PROTO_BIN;
data.tos = MESH_TOS_DEF;
while (1)
{
bIsRoot = esp_mesh_is_root();
if (bIsRoot)
ESP_LOGI(HOMEIOT_TAG, "DoStuff: I AM ROOT");
else
ESP_LOGI(HOMEIOT_TAG, "DoStuff: leaf node");
// Only gives table of this node and those below
err = esp_mesh_get_routing_table( (mesh_addr_t*) &routeTable, 100*6, &nRouteTableSize);
nLayer = esp_mesh_get_layer();
ESP_LOGI(HOMEIOT_TAG, "DoStuff: About to send message [%s] size [%d] layer[%d] numb nodes[%d]", (char*) data.data, data.size, nLayer, nRouteTableSize);
err = mesh_node_send_data( NULL , &data);
if (err !=ESP_OK)
ESP_LOGE(HOMEIOT_TAG, "DoStuff: Failed to send Mesh data to ROOT Error[%d = %s] - Message [%s]", err ,esp_err_to_name(err), (char *) data.data);
vTaskDelay(5 * 1000 / portTICK_RATE_MS);
}
}
thanks
Lee.