MESH Broadcast Message

rshumate
Posts: 1
Joined: Thu Aug 23, 2018 9:01 pm

MESH Broadcast Message

Postby rshumate » Thu Aug 23, 2018 9:29 pm

Board: Sparkfun ESP32 Thing
Branch: master
Network Configuration: 4 Layers - 1 Device per Layer - 4 Devices Total (root <--> dev1 <-->dev2 <-->dev3)

I am currently evaluating the ESP32's Mesh network and have come across an unexpected behavior in the Mesh. I am using the Broadcast MAC Address as the to parameter for sending data on the network. Typically all four devices will receive the broadcasted message from each device. However, occasionally it appears that lower layer devices will quit receiving broadcast messages from the root or higher layer devices. I am running a modified version of the internal_communication example that broadcasts a message from each device every 5 seconds with the device's MAC address and an incremented value.

If anyone attempts to recreate the issue, it is easily seen by bringing all four devices online. If they do not exhibit the issue to start with, reboot the layer 3 device and once the layer 3 device has reconnected, my results are showing that the layer 3 and 4 devices no longer receive broadcast messages from layer 1 or layer 2.

Is using the Broadcast MAC a valid way to send a Broadcast Message over the mesh?

Additional Variable Definitions

Code: Select all

static const mesh_addr_t broadcast_group_id = {.addr = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}};
typedef struct {
    uint8_t nodeId[6];
    uint32_t val;
} mesh_data_node_t;


Modified TX Function

Code: Select all

void esp_mesh_p2p_tx_main(void *arg)
{
    int i;
    esp_err_t err;
    int send_count = 0;
    mesh_addr_t route_table[CONFIG_MESH_ROUTE_TABLE_SIZE];
    int route_table_size = 0;
    mesh_data_t data;
    mesh_data_node_t node;
    data.data = &node;
    data.size = sizeof(node);
    data.proto = MESH_PROTO_BIN;
#ifdef MESH_P2P_TOS_OFF
    data.tos = MESH_TOS_DEF;
#endif /* MESH_P2P_TOS_OFF */

    ESP_ERROR_CHECK(esp_efuse_mac_get_default(node.nodeId));

    is_running = true;
    while (is_running) {

        if (esp_mesh_is_root()) {
            ESP_LOGI(MESH_TAG, "I AM ROOT");
        }

        node.val++;
        // ESP_LOGI(MESH_TAG, "Sending Group Message - %d", node.val);
        err = esp_mesh_send(&broadcast_group_id, &data, MESH_DATA_P2P, NULL, 0);
        if (err) {
            ESP_LOGE(MESH_TAG, "Error Sending Messsage to Group... %d", err);
        }

        esp_mesh_get_routing_table((mesh_addr_t *) &route_table,
                                   CONFIG_MESH_ROUTE_TABLE_SIZE * 6, &route_table_size);
        for (i = 0; i < route_table_size; i++) {
            ESP_LOGW(MESH_TAG,
                "[ROUTE-TABLE][L:%d][rtableSize:%d]parent:"MACSTR" Node:"MACSTR"",
                mesh_layer,
                esp_mesh_get_routing_table_size(),
                MAC2STR(mesh_parent_addr.addr),
                MAC2STR(route_table[i].addr)
            );
        }

        vTaskDelay(5 * 1000 / portTICK_RATE_MS);
    }
    vTaskDelete(NULL);
}


Modified RX Function

Code: Select all

void esp_mesh_p2p_rx_main(void *arg)
{
    int recv_count = 0;
    esp_err_t err;
    mesh_addr_t from;
    int send_count = 0;
    mesh_data_t data;
    mesh_data_node_t *node;
    int flag = 0;
    data.data = rx_buf;
    data.size = RX_SIZE;

    is_running = true;
    while (is_running) {
        data.size = RX_SIZE;
        err = esp_mesh_recv(&from, &data, portMAX_DELAY, &flag, NULL, 0);
        if (err != ESP_OK) {
            ESP_LOGE(MESH_TAG, "err:0x%x, size:%d", err, data.size);
            continue;
        }

        node = (mesh_data_node_t *) data.data;

        ESP_LOGI(MESH_TAG, "Got Message from: "MACSTR" - %d", MAC2STR(node->nodeId), node->val);

    }
    vTaskDelete(NULL);
}

ESP_Alvin
Posts: 12
Joined: Thu May 17, 2018 2:26 am

Re: MESH Broadcast Message

Postby ESP_Alvin » Fri Aug 24, 2018 1:52 am

Since this is a post regarding Mesh, move the post to ESP-MDF.

Who is online

Users browsing this forum: No registered users and 2 guests