From 845725a60f7559c0a0e9e5ebf4d5a2f1e34ed13f Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Fri, 23 Aug 2024 11:34:47 +0800 Subject: [PATCH 1/3] fix(wifi/mesh): clear the rootless state in mesh ie when changing from leaf to root Closes https://github.com/espressif/esp-idf/issues/14063 --- components/esp_wifi/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 8b791fef0a..b0bb937e26 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 8b791fef0adc3e87c14581f1faa11ee338e75f72 +Subproject commit b0bb937e26f0ceb8e43a6989b4a96c70b76bca1f From 117c85961aae8040c2b4022c9f9e3349f735fe60 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Thu, 18 Jul 2024 11:27:57 +0800 Subject: [PATCH 2/3] fix(wifi/mesh): fixed the dhcp offer send error issue when root restart multiple times Closes https://github.com/espressif/esp-idf/issues/13212 --- .../ip_internal_network/main/mesh_netif.c | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/examples/mesh/ip_internal_network/main/mesh_netif.c b/examples/mesh/ip_internal_network/main/mesh_netif.c index 7a2bd71dad..28d73cbfbb 100644 --- a/examples/mesh/ip_internal_network/main/mesh_netif.c +++ b/examples/mesh/ip_internal_network/main/mesh_netif.c @@ -66,7 +66,6 @@ static esp_err_t set_dhcps_dns(esp_netif_t *netif, uint32_t addr) dns.ip.u_addr.ip4.addr = addr; dns.ip.type = IPADDR_TYPE_V4; dhcps_offer_t dhcps_dns_value = OFFER_DNS; - ESP_ERROR_CHECK_WITHOUT_ABORT(esp_netif_dhcps_stop(netif)); ESP_ERROR_CHECK(esp_netif_dhcps_option(netif, ESP_NETIF_OP_SET, ESP_NETIF_DOMAIN_NAME_SERVER, &dhcps_dns_value, sizeof(dhcps_dns_value))); ESP_ERROR_CHECK(esp_netif_set_dns_info(netif, ESP_NETIF_DNS_MAIN, &dns)); ESP_ERROR_CHECK_WITHOUT_ABORT(esp_netif_dhcps_start(netif)); @@ -350,6 +349,20 @@ static esp_netif_t* create_mesh_link_ap(void) return netif; } +/** + * @brief Destroy esp-netif for AP interface over mesh + */ +static void destory_mesh_link_ap(void) +{ + if (netif_ap) { + ESP_ERROR_CHECK_WITHOUT_ABORT(esp_netif_dhcps_stop(netif_ap)); + esp_netif_action_disconnected(netif_ap, NULL, 0, NULL); + mesh_delete_if_driver(esp_netif_get_io_driver(netif_ap)); + esp_netif_destroy(netif_ap); + netif_ap = NULL; + } +} + /** * @brief Creates esp-netif for station interface over mesh * @@ -376,12 +389,7 @@ static esp_netif_t* create_mesh_link_sta(void) esp_err_t mesh_netif_start_root_ap(bool is_root, uint32_t addr) { if (is_root) { - if (netif_ap) { - esp_netif_action_disconnected(netif_ap, NULL, 0, NULL); - mesh_delete_if_driver(esp_netif_get_io_driver(netif_ap)); - esp_netif_destroy(netif_ap); - netif_ap = NULL; - } + destory_mesh_link_ap(); netif_ap = create_mesh_link_ap(); mesh_netif_driver_t driver = mesh_create_if_driver(true, true); if (driver == NULL) { @@ -445,13 +453,7 @@ esp_err_t mesh_netifs_start(bool is_root) esp_netif_attach(netif_sta, driver); start_mesh_link_sta(); // If we have a AP on NODE -> stop and remove it! - if (netif_ap) { - esp_netif_action_disconnected(netif_ap, NULL, 0, NULL); - mesh_delete_if_driver(esp_netif_get_io_driver(netif_ap)); - esp_netif_destroy(netif_ap); - netif_ap = NULL; - } - + destory_mesh_link_ap(); } return ESP_OK; } @@ -475,12 +477,7 @@ esp_err_t mesh_netifs_stop(void) netif_sta = NULL; } - if (netif_ap) { - esp_netif_action_disconnected(netif_ap, NULL, 0, NULL); - mesh_delete_if_driver(esp_netif_get_io_driver(netif_ap)); - esp_netif_destroy(netif_ap); - netif_ap = NULL; - } + destory_mesh_link_ap(); // reserve the default (STA gets ready to become root) mesh_netif_init_station(); start_wifi_link_sta(); From cf21dd6b8b2d442877de127a6cc24a5696827af3 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Thu, 18 Jul 2024 14:13:55 +0800 Subject: [PATCH 3/3] fix(wifi/mesh): update the mesh ip_internal_network example --- examples/mesh/ip_internal_network/main/Kconfig.projbuild | 6 ++++++ examples/mesh/ip_internal_network/main/mesh_main.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/examples/mesh/ip_internal_network/main/Kconfig.projbuild b/examples/mesh/ip_internal_network/main/Kconfig.projbuild index 28708ae787..89de1393e6 100644 --- a/examples/mesh/ip_internal_network/main/Kconfig.projbuild +++ b/examples/mesh/ip_internal_network/main/Kconfig.projbuild @@ -64,6 +64,12 @@ menu "Example Configuration" help The number of non-mesh stations allowed to connect in. + config MESH_IE_ENCRYPTED + bool "Mesh IE encrypted" + default y + help + The mesh IE is encrypted by default. + config MESH_MAX_LAYER int "Mesh Max Layer" range 1 25 diff --git a/examples/mesh/ip_internal_network/main/mesh_main.c b/examples/mesh/ip_internal_network/main/mesh_main.c index d2870fbf79..2165742094 100644 --- a/examples/mesh/ip_internal_network/main/mesh_main.c +++ b/examples/mesh/ip_internal_network/main/mesh_main.c @@ -405,7 +405,12 @@ void app_main(void) 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)); + /* set blocking time of esp_mesh_send() to 30s, to prevent the esp_mesh_send() from permanently for some reason */ + ESP_ERROR_CHECK(esp_mesh_send_block_time(30000)); mesh_cfg_t cfg = MESH_INIT_CONFIG_DEFAULT(); +#if !MESH_IE_ENCRYPTED + cfg.crypto_funcs = NULL; +#endif /* mesh ID */ memcpy((uint8_t *) &cfg.mesh_id, MESH_ID, 6); /* router */