-
-
Save kasperkamperman/8252f2a634ae7def5559e4c7b924c07f to your computer and use it in GitHub Desktop.
Test with Photon and WiFi commands.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
I'm testing what happens if a WiFi network is not found while I've put | |
in the correct creditials, but the network is offline (use case: router temporary unplugged). | |
Why does WiFi.hasCredentials pause for about 21 seconds? What is going on | |
in the background? | |
This only happens when WiFi.connect() is called before | |
(which doesn't influence the WiFi.connecting() flag directly it seems). | |
Serial monitor output: | |
start | |
WiFi.connecting() : 0 | |
WiFi.ready() : 0 | |
WiFi.hasCredentials() : | |
<here it will "pause" for about 21 seconds> | |
1 | |
duration : 21634 | |
WiFi.connecting() : 1 | |
WiFi.ready() : 0 | |
WiFi.hasCredentials() : | |
*/ | |
#include "application.h" | |
SYSTEM_THREAD(ENABLED); | |
//SYSTEM_MODE(SEMI_AUTOMATIC); | |
SYSTEM_MODE(MANUAL); | |
void wifiManager(); | |
long duration = 0; | |
long startTime = 0; | |
void setup() { | |
delay(5000); | |
Serial.begin(57600); | |
Serial.println("start"); | |
} | |
void loop() { | |
wifiManager(); | |
} | |
/* | |
*/ | |
void wifiManager() { | |
WiFi.connect(); | |
Serial.print("WiFi.connecting() : "); | |
Serial.println(WiFi.connecting()); | |
Serial.print("WiFi.ready() : "); | |
Serial.println(WiFi.ready()); | |
startTime = millis(); | |
Serial.print("WiFi.hasCredentials() : "); | |
Serial.println(WiFi.hasCredentials()); | |
duration = millis() - startTime; | |
Serial.print("duration : "); | |
Serial.println(duration); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment