From cf3ff56bc578a6f73a51a0a69c4f3d013a4aa0e3 Mon Sep 17 00:00:00 2001 From: Padmal Date: Tue, 22 Nov 2016 18:11:42 +0530 Subject: [PATCH 1/2] Disconnect only if the ESP has connected before I've tried scanning function in ESP many times with many ESPs and every time they stop functioning and crashed. So I checked line by line and found out that this disconnect upon no connection is the one causing it. So I added the control block and now they're working fine! --- libraries/ESP8266WiFi/examples/WiFiScan/WiFiScan.ino | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/ESP8266WiFi/examples/WiFiScan/WiFiScan.ino b/libraries/ESP8266WiFi/examples/WiFiScan/WiFiScan.ino index 3e6ff7363b..675dc7bb0a 100644 --- a/libraries/ESP8266WiFi/examples/WiFiScan/WiFiScan.ino +++ b/libraries/ESP8266WiFi/examples/WiFiScan/WiFiScan.ino @@ -10,7 +10,12 @@ void setup() { // Set WiFi to station mode and disconnect from an AP if it was previously connected WiFi.mode(WIFI_STA); - WiFi.disconnect(); + // Check if there is any connections made previously. If there is any, disconnect + // This throws "Exception 3" and prints a huge stack on Serial monitor and stops scanning + // if we try to disconnect when the ESP has not connected to any + if (WiFi.status() == WL_CONNECTED) { + WiFi.disconnect(); + } delay(100); Serial.println("Setup done"); From 5e64ed411c48c1cdc2cd872d50ff7dc751619ba1 Mon Sep 17 00:00:00 2001 From: Develo Date: Tue, 29 Oct 2019 17:10:04 -0300 Subject: [PATCH 2/2] Update WiFiScan.ino --- libraries/ESP8266WiFi/examples/WiFiScan/WiFiScan.ino | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/ESP8266WiFi/examples/WiFiScan/WiFiScan.ino b/libraries/ESP8266WiFi/examples/WiFiScan/WiFiScan.ino index 6748787293..e5e26b189d 100644 --- a/libraries/ESP8266WiFi/examples/WiFiScan/WiFiScan.ino +++ b/libraries/ESP8266WiFi/examples/WiFiScan/WiFiScan.ino @@ -10,9 +10,8 @@ void setup() { // Set WiFi to station mode and disconnect from an AP if it was previously connected WiFi.mode(WIFI_STA); + // Check if there is any connections made previously. If there is any, disconnect - // This throws "Exception 3" and prints a huge stack on Serial monitor and stops scanning - // if we try to disconnect when the ESP has not connected to any if (WiFi.status() == WL_CONNECTED) { WiFi.disconnect(); }