Last active
March 17, 2019 17:44
-
-
Save zsup/bfa7726adf375f4a744f to your computer and use it in GitHub Desktop.
A snippet of firmware for WarSting, a wardriving sword for Hobbits
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
/** | |
* 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; | |
RGB.control(false); // allow the system to control the LED so we can see cloud connection progress | |
makeSound(); | |
String name = ssid(strongest); | |
WiFi.on(); | |
WiFi.setCredentials(name.c_str()); | |
makeSound(); | |
WiFi.connect(); | |
if (waitForWifi(20000)) { // wait for the DHCP to complete | |
Spark.connect(); // start connecting to the cloud | |
if (waitForCloud(true, 30000)) // wait for connection | |
{ | |
Spark.publish("vanquished",name); // Feel the Wrath! | |
makeSound(); | |
for (int i=0; i<50; i++) { // flash the LED faster and faster | |
setLight(240); | |
int d = (60-i)*(60-i)/20; | |
delay(d); | |
soundfx(); | |
setLight(0); | |
delay(d); | |
} | |
openNetworkCount--; // one less unsecured network! | |
seen.push_back(name); // remember that we've dealt with this one | |
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