Skip to content

Instantly share code, notes, and snippets.

@zsup
Last active Mar 17, 2019
Embed
What would you like to do?
A snippet of firmware for WarSting, a wardriving sword for Hobbits
/**
* 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