Created
August 21, 2015 23:38
-
-
Save anthonywebb/fe2b5958c6d42f07d6aa to your computer and use it in GitHub Desktop.
WiFi.listen() issues
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
STARTUP(WiFi.selectAntenna(ANT_EXTERNAL)); | |
// we will handle wifi manually | |
SYSTEM_MODE(SEMI_AUTOMATIC); | |
void setup() { | |
Serial.begin(9600); // open serial over USB | |
delay(3000); | |
Serial.println("connecting to wifi"); | |
WiFi.connect(); | |
if(!WiFi.ready()){ | |
Serial.println("no wifi, going into listen mode"); | |
WiFi.listen(); | |
// only listen for a while | |
unsigned int stopTryingToListen = millis() + 180000; | |
while(millis() < stopTryingToListen){ | |
// waiting for some credentials | |
} | |
// did not get any new creds reset the device | |
Serial.println("did not get any new creds, reset the device"); | |
System.reset(); | |
} else { | |
Serial.println("wifi is ready to go"); | |
} | |
Spark.connect(); | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there! Looking over this script I'm unsure how this could ever have worked. Here's some things that I see:
There is a bug in 0.4.4 that the first call to connect fails. So as a workaround try duplicating WiFi.connect();