fix WiFi.config not being applied

fixes: https://github.com/espressif/arduino-esp32/issues/143
This commit is contained in:
me-no-dev 2017-01-24 01:08:48 +02:00
parent 3c7d0e9905
commit 6dfbdbca29

View File

@ -135,20 +135,20 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_
esp_wifi_set_config(WIFI_IF_STA, &conf); esp_wifi_set_config(WIFI_IF_STA, &conf);
} }
if(channel > 0 && channel <= 13) { if(channel > 0 && channel <= 13) {
esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE); esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
} }
if(!_useStaticIp) {
tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA);
}
if(connect) { if(connect) {
esp_wifi_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(); return status();
} }
@ -173,7 +173,10 @@ wl_status_t WiFiSTAClass::begin()
if(!_useStaticIp) { if(!_useStaticIp) {
tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA); tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA);
} else {
tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA);
} }
return status(); return status();
} }
@ -204,7 +207,7 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subne
info.netmask.addr = static_cast<uint32_t>(subnet); info.netmask.addr = static_cast<uint32_t>(subnet);
tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA); 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; _useStaticIp = true;
} else { } else {
return false; return false;