[已解决] 求大神指导。esp32 怎么禁用DHCP和设置静态IP?
-
- Posts: 786
- Joined: Wed Nov 14, 2018 8:45 am
Re: 求大神指导。esp32 怎么禁用DHCP和设置静态IP?
你说的是 dhcp client 吧,可以这样做:
具体你得好好再看下 esp-netif 及相关 APIs 的说明:https://docs.espressif.com/projects/esp ... netif.html
Code: Select all
const esp_netif_ip_info_t ip_info = {
.ip = { .addr = ESP_IP4TOADDR( 192, 168, 3, 41) },
.gw = { .addr = ESP_IP4TOADDR( 192, 168, 3, 1) },
.netmask = { .addr = ESP_IP4TOADDR( 255, 255, 255, 0) },
};
esp_netif_t* netif = esp_netif_create_default_wifi_sta();
esp_netif_dhcpc_stop(netif);
esp_netif_set_ip_info(netif, &ip_info);
Re: 求大神指导。esp32 怎么禁用DHCP和设置静态IP?
目前 IDF 有静态 IP 设置的示例,https://github.com/espressif/esp-idf/tr ... /static_ip,可以参考示例代码。
Who is online
Users browsing this forum: No registered users and 161 guests