Created
July 20, 2016 21:08
-
-
Save technobly/bb27555bc293a15bbbc9bde747f818c1 to your computer and use it in GitHub Desktop.
Manually enter and exit listening mode with the D0 pin
This file contains hidden or 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
// Configure a wifi network with a bogus name or password into the Photon | |
// Ground D0 to call WiFi.listen(true) while the connection attempt is ongoing | |
// Open, then Ground D0 again to call WiFi.listen(false) | |
/// | |
#include "application.h" | |
SYSTEM_THREAD(ENABLED); | |
SYSTEM_MODE(AUTOMATIC); | |
void reconnectAfterListen() { | |
Particle.connect(); | |
} | |
void setup() { | |
System.on(wifi_listen_end, reconnectAfterListen); | |
pinMode(D0, INPUT_PULLUP); | |
} | |
void loop() { | |
if(digitalRead(D0) == LOW) { | |
if (!WiFi.listening()) { | |
// Delay of ~20 seconds to enter listen mode if these 2 disconnect calls are missing | |
Particle.disconnect(); | |
WiFi.disconnect(); | |
// ------------------------- | |
WiFi.listen(true); | |
} | |
else { | |
WiFi.listen(false); | |
} | |
delay(50); | |
while (digitalRead(D0) == LOW) Particle.process(); | |
delay(50); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment