kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'mesh/feature_chain_topology' into 'master'
Mesh/feature chain topology Closes WIFI-1726 See merge request espressif/esp-idf!7215pull/4926/head
commit
a30557ca31
|
@ -252,6 +252,14 @@ typedef enum {
|
|||
MESH_REASON_PARENT_UNENCRYPTED, /**< connect to an unencrypted parent/router */
|
||||
} mesh_disconnect_reason_t;
|
||||
|
||||
/**
|
||||
* @brief Mesh topology
|
||||
*/
|
||||
typedef enum {
|
||||
MESH_TOPO_TREE, /**< tree topology */
|
||||
MESH_TOPO_CHAIN, /**< chain topology */
|
||||
} esp_mesh_topology_t;
|
||||
|
||||
/*******************************************************
|
||||
* Structures
|
||||
*******************************************************/
|
||||
|
@ -1454,6 +1462,28 @@ esp_err_t esp_mesh_get_router_bssid(uint8_t *router_bssid);
|
|||
*/
|
||||
int64_t esp_mesh_get_tsf_time(void);
|
||||
|
||||
/**
|
||||
* @brief Set mesh topology. The default value is MESH_TOPO_TREE
|
||||
* - MESH_TOPO_CHAIN supports up to 1000 layers
|
||||
*
|
||||
* @attention This API shall be called before mesh is started
|
||||
*
|
||||
* @param[in] topo MESH_TOPO_TREE or MESH_TOPO_CHAIN
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_MESH_ERR_ARGUMENT
|
||||
* - ESP_ERR_MESH_NOT_ALLOWED
|
||||
*/
|
||||
esp_err_t esp_mesh_set_topology(esp_mesh_topology_t topo);
|
||||
|
||||
/**
|
||||
* @brief Get mesh topology
|
||||
*
|
||||
* @return MESH_TOPO_TREE or MESH_TOPO_CHAIN
|
||||
*/
|
||||
esp_mesh_topology_t esp_mesh_get_topology(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 0dd62e0f12d3c78f8274ffd0f42f90c39a9bbb7c
|
||||
Subproject commit 662585ad48bbcad01b757fab63ba9adbb0020f57
|
|
@ -1,5 +1,32 @@
|
|||
menu "Example Configuration"
|
||||
|
||||
choice
|
||||
bool "Mesh Topology"
|
||||
default MESH_TOPO_TREE
|
||||
help
|
||||
Mesh Network Topology.
|
||||
|
||||
config MESH_TOPO_TREE
|
||||
bool "MESH_TOPO_TREE"
|
||||
config MESH_TOPO_CHAIN
|
||||
bool "MESH_TOPO_CHAIN"
|
||||
endchoice
|
||||
|
||||
config MESH_TOPOLOGY
|
||||
int
|
||||
default 0 if MESH_TOPO_TREE
|
||||
default 1 if MESH_TOPO_CHAIN
|
||||
help
|
||||
Mesh Network Topology.
|
||||
|
||||
config MESH_MAX_LAYER
|
||||
int "Mesh Max Layer"
|
||||
range 1 25 if MESH_TOPO_TREE
|
||||
range 1 1000 if MESH_TOPO_CHAIN
|
||||
default 6
|
||||
help
|
||||
Max layer allowed in mesh network.
|
||||
|
||||
config MESH_CHANNEL
|
||||
int "channel"
|
||||
range 0 14
|
||||
|
@ -57,13 +84,6 @@ menu "Example Configuration"
|
|||
help
|
||||
The number of stations allowed to connect in.
|
||||
|
||||
config MESH_MAX_LAYER
|
||||
int "Mesh Max Layer"
|
||||
range 1 25
|
||||
default 6
|
||||
help
|
||||
Max layer allowed in mesh network.
|
||||
|
||||
config MESH_ROUTE_TABLE_SIZE
|
||||
int "Mesh Routing Table Size"
|
||||
range 1 300
|
||||
|
|
|
@ -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)");
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue