diff --git a/WifiControlSensor/WifiControlSensor.ino b/WifiControlSensor/WifiControlSensor.ino index ae99b9c..39c87ca 100644 --- a/WifiControlSensor/WifiControlSensor.ino +++ b/WifiControlSensor/WifiControlSensor.ino @@ -124,19 +124,24 @@ void WifiSetup(productConfig conf) { bssid[3] = strtoul(bssidStr.substring(9, 11).c_str(), NULL, 16); bssid[4] = strtoul(bssidStr.substring(12, 14).c_str(), NULL, 16); bssid[5] = strtoul(bssidStr.substring(15, 17).c_str(), NULL, 16); - SKETCH_DEBUG_PRINTF("Using BSSID: %x:%x:%x:%x:%x:%x\n", bssid[5], bssid[4], bssid[3], bssid[2], bssid[1], bssid[0]); + SKETCH_DEBUG_PRINTF("Using BSSID: %02x:%02x:%02x:%02x:%02x:%02x\n", bssid[5], bssid[4], bssid[3], bssid[2], bssid[1], bssid[0]); bssidConf = bssid; } + + // WA https://github.com/esp8266/Arduino/issues/2186 + WiFi.persistent(false); + WiFi.mode(WIFI_OFF); // this is a temporary line, to be removed after SDK update to 1.5.4 + WiFi.mode(WIFI_STA); WiFi.begin(conf.ssid, conf.password, conf.channel, bssidConf); while (WiFi.status() != WL_CONNECTED) { - delay(500); + delay(50); SKETCH_DEBUG_PRINT("."); if (reconfig == 1) { reconfig = 0; return; } - if (connectionTry == 10) { - SKETCH_DEBUG_PRINTLN("Cannot connect to wifi. Try withour BSSID and channel"); + if (connectionTry == 20) { + SKETCH_DEBUG_PRINTLN("Cannot connect to wifi. Try without BSSID and channel"); WiFi.begin(conf.ssid, conf.password); } connectionTry++;