From 6dfbdbca29dd4ea872c8fb37e3153d359c4ebb08 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 24 Jan 2017 01:08:48 +0200 Subject: [PATCH] fix WiFi.config not being applied fixes: https://github.com/espressif/arduino-esp32/issues/143 --- libraries/WiFi/src/WiFiSTA.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libraries/WiFi/src/WiFiSTA.cpp b/libraries/WiFi/src/WiFiSTA.cpp index f8b17ae8..60d7125d 100644 --- a/libraries/WiFi/src/WiFiSTA.cpp +++ b/libraries/WiFi/src/WiFiSTA.cpp @@ -135,20 +135,20 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_ esp_wifi_set_config(WIFI_IF_STA, &conf); } - - if(channel > 0 && channel <= 13) { esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE); } - if(!_useStaticIp) { - tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA); - } - if(connect) { esp_wifi_connect(); } + if(!_useStaticIp) { + tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA); + } else { + tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA); + } + return status(); } @@ -173,7 +173,10 @@ wl_status_t WiFiSTAClass::begin() if(!_useStaticIp) { tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA); + } else { + tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA); } + return status(); } @@ -204,7 +207,7 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subne info.netmask.addr = static_cast(subnet); tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA); - if(tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_STA, &info)) { + if(tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_STA, &info) == ESP_OK) { _useStaticIp = true; } else { return false;