ESP-Mesh-Lite 可以使用静态IP模式吗?

BDTD-WANYAO
Posts: 7
Joined: Mon Sep 26, 2022 7:13 am

ESP-Mesh-Lite 可以使用静态IP模式吗?

Postby BDTD-WANYAO » Tue Nov 28, 2023 8:08 am

在esp_bridge_create_station_netif函数中关闭DHCP,设置IP后,无法进行组网,只有一个节点可以连接到服务器上。如果想使用静态IP的方式连接WiFi应该怎样处理?谢谢!
还有在多节点同时上电连接路由器时,会出现无法组成一个整体网络的情况,会有多个节点直接连接路由器,这个情况应该怎样避免?

esp_netif_t* esp_bridge_create_station_netif(esp_netif_ip_info_t* ip_info, uint8_t mac[6], bool data_forwarding, bool enable_dhcps)
{
esp_netif_t* wifi_netif = NULL;
wifi_mode_t mode = WIFI_MODE_NULL;

if (data_forwarding || enable_dhcps) {
return wifi_netif;
}

esp_bridge_wifi_init();
wifi_netif = esp_netif_create_default_wifi_sta();


esp_netif_dhcpc_stop(wifi_netif);
esp_netif_ip_info_t ip_infos;
memset(&ip_infos, 0, sizeof(esp_netif_ip_info_t));
char static_ip_add[17] = {"192.168.3.149"};
char static_gw_add[17] = {"192.168.3.1"};
char static_netmask_add[17] = {"255.255.255.0"};


ip_infos.ip.addr = ipaddr_addr(static_ip_add);
ip_infos.gw.addr = ipaddr_addr(static_gw_add);
ip_infos.netmask.addr = ipaddr_addr(static_netmask_add);

esp_netif_set_ip_info(wifi_netif, &ip_infos);

esp_bridge_netif_list_add(wifi_netif, NULL);

esp_wifi_get_mode(&mode);
mode |= WIFI_MODE_STA;
ESP_ERROR_CHECK(esp_wifi_set_mode(mode));

wifi_sta_config_t router_config;
/* Get WiFi Station configuration */
esp_wifi_get_config(WIFI_IF_STA, (wifi_config_t*)&router_config);

/* Get Wi-Fi Station ssid success */
if (strlen((const char*)router_config.ssid)) {
ESP_LOGI(TAG, "Found ssid %s", (const char*)router_config.ssid);
ESP_LOGI(TAG, "Found password %s", (const char*)router_config.password);
}

/* Register our event handler for Wi-Fi, IP and Provisioning related events */
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &wifi_event_sta_disconnected_handler, NULL, NULL));
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &ip_event_sta_got_ip_handler, NULL, NULL));

return wifi_netif;
}

ESP_TianSW
Posts: 52
Joined: Wed Sep 23, 2020 12:19 pm

Re: ESP-Mesh-Lite 可以使用静态IP模式吗?

Postby ESP_TianSW » Tue Nov 28, 2023 8:56 am

只用根节点可以配置静态 ip,所有子节点的 ip 必须由其父节点动态分配。

无法避免,如果同时上电是会都先连接到路由器,不过后面会有融合机制将其融合为一个网络,具体请参考 https://github.com/espressif/esp-mesh-l ... 1%E7%BB%9C

BDTD-WANYAO
Posts: 7
Joined: Mon Sep 26, 2022 7:13 am

Re: ESP-Mesh-Lite 可以使用静态IP模式吗?

Postby BDTD-WANYAO » Thu Nov 30, 2023 1:50 am

使用10个ESP32模块进行组网,其中有5个成功连上了服务器,还有5个无法连接服务器,这5个自己组成了一个网络,没有融合进另一个网络。这个独立网络最上层和下一层的模块日志如下,请问这种情况是什么原因,怎么避免?这种情况偶尔出现,复位最上层模块后,10个模块融合成一个网络。

最上层:
[2023-11-30 09:30:28.184]# RECV ASCII>
[0;33mW (1170284) vendor_ie: Scanning in progress, please try again later[0m

[2023-11-30 09:30:30.252]# RECV ASCII>
W (1172328) wifi:Haven't to connect to a suitable AP now!
[0;32m (1172329) [local_control, 195]: System information, channel: 1, layer: 15, self mac: 10:97:bd:d2:82:a4, parent bssid: 00:00:00:00:00:00, parent rssi: -120, free heap: 194196[0m
[0;32m (1172338) [local_control, 200]: child node number: 0[0m
[0;32m (1172344) [local_control, 203]: Child mac: 10:97:bd:d2:d9:f8[0m

[2023-11-30 09:30:38.201]# RECV ASCII>
[0;33mW (1180284) vendor_ie: Scanning in progress, please try again later[0m

[2023-11-30 09:30:40.257]# RECV ASCII>
W (1182328) wifi:Haven't to connect to a suitable AP now!
[0;32m (1182329) [local_control, 195]: System information, channel: 1, layer: 15, self mac: 10:97:bd:d2:82:a4, parent bssid: 00:00:00:00:00:00, parent rssi: -120, free heap: 194196[0m
[0;32m (1182338) [local_control, 200]: child node number: 0[0m
[0;32m (1182344) [local_control, 203]: Child mac: 10:97:bd:d2:d9:f8[0m

[2023-11-30 09:30:48.189]# RECV ASCII>
[0;33mW (1190284) vendor_ie: Scanning in progress, please try again later[0m

[2023-11-30 09:30:50.246]# RECV ASCII>
W (1192328) wifi:Haven't to connect to a suitable AP now!
[0;32m (1192329) [local_control, 195]: System information, channel: 1, layer: 15, self mac: 10:97:bd:d2:82:a4, parent bssid: 00:00:00:00:00:00, parent rssi: -120, free heap: 194196[0m
[0;32m (1192338) [local_control, 200]: child node number: 0[0m
[0;32m (1192344) [local_control, 203]: Child mac: 10:97:bd:d2:d9:f8[0m

[2023-11-30 09:30:58.189]# RECV ASCII>
[0;33mW (1200284) vendor_ie: Scanning in progress, please try again later[0m

[2023-11-30 09:31:00.258]# RECV ASCII>
W (1202328) wifi:Haven't to connect to a suitable AP now!
[0;32m (1202329) [local_control, 195]: System information, channel: 1, layer: 15, self mac: 10:97:bd:d2:82:a4, parent bssid: 00:00:00:00:00:00, parent rssi: -120, free heap: 193696[0m
[0;32m (1202341) [local_control, 200]: child node number: 0[0m
[0;32m (1202344) [local_control, 203]: Child mac: 10:97:bd:d2:d9:f8[0m

[2023-11-30 09:31:04.182]# RECV ASCII>
[0;31mE (1206284) ESP_Mesh_Lite_Comm: Error occurred during sending: errno Not enough space[0m

[2023-11-30 09:31:08.185]# RECV ASCII>
[0;33mW (1210285) vendor_ie: Scanning in progress, please try again later[0m

[2023-11-30 09:31:10.248]# RECV ASCII>
W (1212328) wifi:Haven't to connect to a suitable AP now!


下一层:
[2023-11-30 09:30:28.244]# RECV ASCII>
[0;32m (1022157) [local_control, 195]: System information, channel: 1, layer: 0, self mac: 10:97:bd:d2:d9:f8, parent bssid: 10:97:bd:d2:82:a5, parent rssi: -6, free heap: 189940[0m
[0;32m (1022163) [local_control, 200]: child node number: 0[0m
[0;32m (1022169) [local_control, 203]: Child mac: 24:4c:ab:14:c1:a0[0m
[0;32m (1022175) [local_control, 203]: Child mac: 24:4c:ab:14:ce:dc[0m
[0;32m (1022181) [local_control, 203]: Child mac: 10:97:bd:d2:df:e0[0m

[2023-11-30 09:30:38.241]# RECV ASCII>
[0;32m (1032157) [local_control, 195]: System information, channel: 1, layer: 0, self mac: 10:97:bd:d2:d9:f8, parent bssid: 10:97:bd:d2:82:a5, parent rssi: -6, free heap: 189940[0m
[0;32m (1032163) [local_control, 200]: child node number: 0[0m
[0;32m (1032169) [local_control, 203]: Child mac: 24:4c:ab:14:c1:a0[0m
[0;32m (1032175) [local_control, 203]: Child mac: 24:4c:ab:14:ce:dc[0m
[0;32m (1032181) [local_control, 203]: Child mac: 10:97:bd:d2:df:e0[0m

[2023-11-30 09:30:44.073]# RECV ASCII>
[0;32m (1038033) [local_control, 127]: socket create[0m

[2023-11-30 09:30:48.249]# RECV ASCII>
[0;32m (1042157) [local_control, 195]: System information, channel: 1, layer: 0, self mac: 10:97:bd:d2:d9:f8, parent bssid: 10:97:bd:d2:82:a5, parent rssi: -6, free heap: 189940[0m
[0;32m (1042163) [local_control, 200]: child node number: 0[0m
[0;32m (1042169) [local_control, 203]: Child mac: 24:4c:ab:14:c1:a0[0m
[0;32m (1042175) [local_control, 203]: Child mac: 24:4c:ab:14:ce:dc[0m
[0;32m (1042181) [local_control, 203]: Child mac: 10:97:bd:d2:df:e0[0m

[2023-11-30 09:30:58.243]# RECV ASCII>
[0;32m (1052157) [local_control, 195]: System information, channel: 1, layer: 0, self mac: 10:97:bd:d2:d9:f8, parent bssid: 10:97:bd:d2:82:a5, parent rssi: -7, free heap: 189940[0m
[0;32m (1052163) [local_control, 200]: child node number: 0[0m
[0;32m (1052169) [local_control, 203]: Child mac: 24:4c:ab:14:c1:a0[0m
[0;32m (1052175) [local_control, 203]: Child mac: 24:4c:ab:14:ce:dc[0m
[0;32m (1052181) [local_control, 203]: Child mac: 10:97:bd:d2:df:e0[0m


再下一层日志:

[2023-11-30 09:46:50.249]# RECV ASCII>
[0;32m (2152325) [local_control, 195]: System information, channel: 1, layer: 15, self mac: 24:4c:ab:14:c1:a0, parent bssid: 10:97:bd:d2:d9:f9, parent rssi: -19, free heap: 196680[0m
[0;32m (2152331) [local_control, 200]: child node number: 0[0m

[2023-11-30 09:46:57.735]# RECV ASCII>
[0;32m (2159824) [local_control, 127]: socket create[0m

[2023-11-30 09:47:00.240]# RECV ASCII>
[0;32m (2162325) [local_control, 195]: System information, channel: 1, layer: 15, self mac: 24:4c:ab:14:c1:a0, parent bssid: 10:97:bd:d2:d9:f9, parent rssi: -19, free heap: 196400[0m
[0;32m (2162331) [local_control, 200]: child node number: 0[0m

[2023-11-30 09:47:10.248]# RECV ASCII>
[0;32m (2172325) [local_control, 195]: System information, channel: 1, layer: 15, self mac: 24:4c:ab:14:c1:a0, parent bssid: 10:97:bd:d2:d9:f9, parent rssi: -19, free heap: 196680[0m
[0;32m (2172331) [local_control, 200]: child node number: 0[0m

[2023-11-30 09:47:16.745]# RECV ASCII>
[0;32m (2178840) [local_control, 127]: socket create[0m

ESP_TianSW
Posts: 52
Joined: Wed Sep 23, 2020 12:19 pm

Re: ESP-Mesh-Lite 可以使用静态IP模式吗?

Postby ESP_TianSW » Thu Nov 30, 2023 3:42 am

您使用的是 github 上面最新的吗?您可以使用最新的试试。

BDTD-WANYAO
Posts: 7
Joined: Mon Sep 26, 2022 7:13 am

Re: ESP-Mesh-Lite 可以使用静态IP模式吗?

Postby BDTD-WANYAO » Fri Dec 01, 2023 2:30 am

用的是上周的版本。
请问如果我同时使用mesh-lite和BLE的GATTC、GATTS,可以稳定组网运行吗?我尝试使用MDF+GATTC+GATTS,组网效果很差,经常掉线和失联,不如只用WiFi-mesh稳定,您有什么好的建议吗?是我的程序和配置有问题吗?

ESP_TianSW
Posts: 52
Joined: Wed Sep 23, 2020 12:19 pm

Re: ESP-Mesh-Lite 可以使用静态IP模式吗?

Postby ESP_TianSW » Fri Dec 01, 2023 7:44 am

不管是 MDF 还是 mesh-lite,这种 wifi mesh 都是依靠 Station 和 Softap 组成的,再同时开启蓝牙的话,涉及到共存的问题,效果肯定不如单 Wi-Fi 效果好。

Who is online

Users browsing this forum: No registered users and 9 guests