The software setup is split into two parts.
- Software running on the Raspberry Pi
- Scripts running on a server in my home.
For the Raspberry Pi, I'm using Kismet to detect wireless networks. Kismet does all the heavy lifting and combines the GPS data along with the Wireless Networks it detects and spits out a nice log file. The Kismet package includes scripts to convert the .kismet logs into other file formats that can be loaded into other tools or uploaded to Wigle.net for instance.
The relay circuitry is only half of what is required to safely shutdown the Pi, you also need some software running on the Pi to detect the GPIO pin changes and run a script to shutdown the Pi. Again, there is a lot of info and instruction out there on how to do this, I used a slightly modifed version of this script to detect the GPIO pin getting pulled low. I added some code that resets the network interface on the Pi so that it will attempt to connect to the network defined in my file and then run a bash script that will upload the Kismet logs to my server.
#restart networking os.system('sudo /etc/init.d/networking restart') time.sleep(2) os.system('sudo wpa_supplicant -c /etc/wpa_supplicant.conf -i wlan0') #10 seconds for authentication time.sleep(10) #upload logs subprocess.call("/home/pi/bin/kismetupload.sh", shell=True) #shutdown os.system('sudo shutdown now')
The Kismet Upload bash script essentially checks that the network you are connected to is the one you want it to be, then it uses rsync to upload the logfiles to your server, removing the source files after they have been uploaded. This process is dependent on you setting up SSH access with SSH Keys between your Pi and your Server.
The server also has Kismet installed on it so it can do the heavy-lifting of converting the kismet logs into different types for different uses. There are a few different built in scripts that Kismet comes with for conversion, but I'm mainly using the kismetdb_to_wigglecsv and kismetdb_to_kml script so I can upload logs to wigle.net. I have a cronjob that runs once a day to run my kismet log conversion script. In my case, this script also moves the converted logs to a separate computer although this is may be unnecessary if you try to replicate this setup yourself.
#cronjob to convert and upload logs everyday at 1 AM 0 1 * * * /home/user/bin/kismet_log_convert_and_backup.sh
The end result is a daily tar.gz file that can be directly uploaded to Wigle.net without me having to do anything. Exactly what I wanted.