|
|
@@ -212,16 +212,16 @@ void mesh_event_handler(void *arg, esp_event_base_t event_base,
|
|
|
break;
|
|
|
case MESH_EVENT_ROUTING_TABLE_ADD: {
|
|
|
mesh_event_routing_table_change_t *routing_table = (mesh_event_routing_table_change_t *)event_data;
|
|
|
- ESP_LOGW(MESH_TAG, "<MESH_EVENT_ROUTING_TABLE_ADD>add %d, new:%d",
|
|
|
+ ESP_LOGW(MESH_TAG, "<MESH_EVENT_ROUTING_TABLE_ADD>add %d, new:%d, layer:%d",
|
|
|
routing_table->rt_size_change,
|
|
|
- routing_table->rt_size_new);
|
|
|
+ routing_table->rt_size_new, mesh_layer);
|
|
|
}
|
|
|
break;
|
|
|
case MESH_EVENT_ROUTING_TABLE_REMOVE: {
|
|
|
mesh_event_routing_table_change_t *routing_table = (mesh_event_routing_table_change_t *)event_data;
|
|
|
- ESP_LOGW(MESH_TAG, "<MESH_EVENT_ROUTING_TABLE_REMOVE>remove %d, new:%d",
|
|
|
+ ESP_LOGW(MESH_TAG, "<MESH_EVENT_ROUTING_TABLE_REMOVE>remove %d, new:%d, layer:%d",
|
|
|
routing_table->rt_size_change,
|
|
|
- routing_table->rt_size_new);
|
|
|
+ routing_table->rt_size_new, mesh_layer);
|
|
|
}
|
|
|
break;
|
|
|
case MESH_EVENT_NO_PARENT_FOUND: {
|
|
|
@@ -391,6 +391,9 @@ void app_main(void)
|
|
|
/* mesh initialization */
|
|
|
ESP_ERROR_CHECK(esp_mesh_init());
|
|
|
ESP_ERROR_CHECK(esp_event_handler_register(MESH_EVENT, ESP_EVENT_ANY_ID, &mesh_event_handler, NULL));
|
|
|
+ /* set mesh topology */
|
|
|
+ ESP_ERROR_CHECK(esp_mesh_set_topology(CONFIG_MESH_TOPOLOGY));
|
|
|
+ /* set mesh max layer according to the topology */
|
|
|
ESP_ERROR_CHECK(esp_mesh_set_max_layer(CONFIG_MESH_MAX_LAYER));
|
|
|
ESP_ERROR_CHECK(esp_mesh_set_vote_percentage(1));
|
|
|
ESP_ERROR_CHECK(esp_mesh_set_ap_assoc_expire(10));
|
|
|
@@ -411,6 +414,7 @@ void app_main(void)
|
|
|
ESP_ERROR_CHECK(esp_mesh_set_config(&cfg));
|
|
|
/* mesh start */
|
|
|
ESP_ERROR_CHECK(esp_mesh_start());
|
|
|
- ESP_LOGI(MESH_TAG, "mesh starts successfully, heap:%d, %s\n", esp_get_free_heap_size(),
|
|
|
- esp_mesh_is_root_fixed() ? "root fixed" : "root not fixed");
|
|
|
+ ESP_LOGI(MESH_TAG, "mesh starts successfully, heap:%d, %s<%d>%s\n", esp_get_free_heap_size(),
|
|
|
+ esp_mesh_is_root_fixed() ? "root fixed" : "root not fixed",
|
|
|
+ esp_mesh_get_topology(), esp_mesh_get_topology() ? "(chain)":"(tree)");
|
|
|
}
|