ESP-MESH [recv]invalid child

leGrandNono
Posts: 1
Joined: Sun Mar 15, 2020 2:49 pm

ESP-MESH [recv]invalid child

Postby leGrandNono » Sun Mar 15, 2020 2:53 pm

I'm trying to build a mesh-network with esp-mesh from Espressif on esp32.
First, I would like to send data from a child to the root of the network but the roots don't receive the data and logs are:

Code: Select all

I (12991) wifi: new:<7,1>, old:<7,1>, ap:<7,1>, sta:<7,0>, prof:7
I (13001) wifi: station: 3c:71:bf:0d:7e:18 join, AID=1, bgn, 40U
I (13031) mesh: 1185[recv]invalid child 3c:71:bf:0d:7e:18
I (13031) mesh: 1185[recv]invalid child 3c:71:bf:0d:7e:18
I (13051) mesh: 1185[recv]invalid child 3c:71:bf:0d:7e:18
I (13051) mesh: 1185[recv]invalid child 3c:71:bf:0d:7e:18
I (13051) mesh: 1674[XON]async, from child 3c:71:bf:0d:7e:18
I (13101) mesh: 1185[recv]invalid child 3c:71:bf:0d:7e:18
I (13101) mesh: 1185[recv]invalid child 3c:71:bf:0d:7e:18
I (13101) mesh: 1674[XON]async, from child 3c:71:bf:0d:7e:18
What does "invalid child" mean ?

here are the interesting snippets of code:

send data

Code: Select all

void send(){
    while(true){
        ESP_LOGI(MESH_TAG, "will send !");
        
        mesh_addr_t to;
        ip4_addr_t address;
        address.addr = ipaddr_addr("192.168.4.1");
        to.mip.ip4 = address;
        to.mip.port=5005;
        
        mesh_data_t mesh_data;
        uint8_t data[1];
        data[0] = 'a';
        mesh_data.data=data;
        mesh_data.size = 1;
        mesh_data.proto = MESH_PROTO_BIN;
        
        
        ESP_ERROR_CHECK(esp_mesh_send(NULL, &mesh_data, 0, NULL, 0));
        ESP_LOGI(MESH_TAG, "SENDED !");
    }
}
receive data

Code: Select all

void receive(){
    esp_err_t err;
    mesh_addr_t from;
    mesh_data_t data;
    int flag = 0;
    
    while(true){
        err = esp_mesh_recv(&from, &data, portMAX_DELAY, &flag, NULL, 0);
        if (err != ESP_OK || !data.size) {
            ESP_LOGE(MESH_TAG, "err:0x%x, size:%d", err, data.size);
            continue;
        }else{
            printf("DATA! %d:", data.data[0]);
        }
    }
}
part of event handler

Code: Select all

void mesh_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data){
    switch (event_id) {
        case MESH_EVENT_CHILD_CONNECTED: {
            ESP_LOGI(MESH_TAG,"child connected");
        }
        break;

        case MESH_EVENT_PARENT_CONNECTED: {
            mesh_event_connected_t *connected = (mesh_event_connected_t *)event_data;
            mesh_layer = connected->self_layer;
            ESP_LOGI(MESH_TAG,
                     "<MESH_EVENT_PARENT_CONNECTED>layer:%d",mesh_layer);
            if (esp_mesh_is_root()){
                ESP_LOGI(MESH_TAG, "is root");
                /*
                 * the node is the root and he has
                 * a child -> prepare to receive data
                 */
                receive();
                isRoot=true;
            }else{
                ESP_LOGI(MESH_TAG, "is child");
                /*
                 * the node is a child and he
                 * has a parent -> send data
                 */
                send();
                isChild=true;
            }
        }
        break;

spirosbond
Posts: 4
Joined: Thu Dec 24, 2020 11:06 pm

Re: ESP-MESH [recv]invalid child

Postby spirosbond » Sun Apr 25, 2021 12:20 pm

I have the same problem:

mesh: 1315[recv]invalid child

It pops up at the logs for every child multiple times and occurs after deep_sleep.
Any idea what might cause this?

Who is online

Users browsing this forum: No registered users and 408 guests