-
-
Save developit/380050b05ab2d4f45e84 to your computer and use it in GitHub Desktop.
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
/** Slay and pillage an unprotected network! ...oh, we can't do that? | |
* Ok, let's publish an event instead, to a backdrop of flashing lights | |
* and clashing of metal on metal. | |
*/ | |
void vanquishOpenNetwork() { | |
if (!openNetworkCount || !strongest.rssi) { | |
return; | |
} | |
// allow the system to control the LED so we can see cloud connection progress | |
RGB.control(false); | |
makeSound(); | |
String name = ssid(strongest); | |
WiFi.on(); | |
WiFi.setCredentials(name.c_str()); | |
makeSound(); | |
WiFi.connect(); | |
// wait for the DHCP to complete | |
if (waitForWifi(20000)) { | |
// start connecting to the cloud | |
Spark.connect(); | |
// wait for connection | |
if (waitForCloud(true, 30000)) { | |
// Feel the Wrath! | |
Spark.publish("vanquished", name); | |
makeSound(); | |
// flash the LED faster and faster | |
for (int i=0; i<50; i++) { | |
setLight(240); | |
int d = (60-i)*(60-i)/20; | |
delay(d); | |
soundfx(); | |
setLight(0); | |
delay(d); | |
} | |
// one less unsecured network! | |
openNetworkCount--; | |
seen.push_back(name); | |
strongest.rssi = 0; | |
Spark.disconnect(); | |
WiFi.disconnect(); | |
} | |
} | |
RGB.control(true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment