Skip to content

Instantly share code, notes, and snippets.

@kasperkamperman
Created July 3, 2016 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasperkamperman/8252f2a634ae7def5559e4c7b924c07f to your computer and use it in GitHub Desktop.
Save kasperkamperman/8252f2a634ae7def5559e4c7b924c07f to your computer and use it in GitHub Desktop.
Test with Photon and WiFi commands.
/*
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