Hello flok99 and other Wiglers!
This is excellent! I'm quite interested in this project,as I've been playing with the ESP8266 for a couple of years now,and more recently the ESP32 also. These little things are great! I started on a similar ESP8266 Wardriving project a while ago,but ran into a couple of bumps while trying to figure out the code,and never got around to finishing it. (that 'daily life' thing getting in the way.) I'm not much of a coder,I'm more of a hardware guy,so my code is probably horrible,though I can usually,kinda,mostly,figure it out,and make it work.Maybe.
Anyways,after some tinkering with your code,and looking at .CSV files from the Wigle app over the last couple of days,I think I've managed to get the ESP to automatically format the files on the SD card in a 'Wigle-like' .CSV format.
Here's what I've done:
I added a Wigle-like .CSV file header (Copied from your "process-wigle.py" Python code),when the file is first made on the SD card,something like this:
Code: Select all
fh = SD.open(fname, FILE_WRITE);
fh.println("WigleWifi-1.4,appRelease=2.27,model=SM-G960Z,release=8.9.0,device=starlte,display=R16NW.G960FXXU1ARC5,board=universal9810,brand=apple"); // Write File header,for a Wigle-like .CSV structure.
fh.println("MAC,SSID,AuthMode,FirstSeen,Channel,RSSI,CurrentLatitude,CurrentLongitude,AltitudeMeters,AccuracyMeters,Type");
I also re-ordered some of the data to fit,like so:
Code: Select all
fh.print(WiFi.BSSIDstr(i));
fh.print(',');
fh.print(WiFi.SSID(i));
fh.print(",");
printEncryptionType(WiFi.encryptionType(i)); // Reformatted to a Wigle-like .CSV structure.
fh.print(",");
fh.print(year);
fh.print('-');
fh.print(month);
fh.print('-');
fh.print(day);
fh.print(" ");
fh.printf("%02d:%02d:%02d.%02d", hour, minute, second, centisec);
fh.print(",");
fh.print(WiFi.channel(i));
fh.print(",");
fh.print(WiFi.RSSI(i));
fh.print(",");
fh.print(lat, 6);
fh.print(",");
fh.print(lng, 6);
fh.print(",");
fh.print(alt);
fh.print(",");
fh.print(hdop);
fh.print(",");
fh.println("WIFI");
And I copied a bit of code from an Arduino example(the "ScanNetworks" sketch),to do the encryption type 'detection',and add it to the file (note the "printEncryptionType" bit,above..it leads to here) I put this at the very bottom of the sketch:
Code: Select all
void printEncryptionType(int thisType) {
switch (thisType) {
case ENC_TYPE_WEP:
//Serial.println(" WEP ");
fh.print("[WEP][ESS]");
break;
case ENC_TYPE_TKIP:
//Serial.println(" WPA ");
fh.print("[WPA-PSK-TKIP][ESS]");
break;
case ENC_TYPE_CCMP:
//Serial.println(" WPA2 ");
fh.print("[WPA2-PSK-CCMP][ESS]");
break;
case ENC_TYPE_NONE:
// Serial.println(" None ");
fh.print("[None]");
break;
case ENC_TYPE_AUTO:
//Serial.println(" Auto ");
fh.print("[Auto]");
break;
}
}
(EDIT: The code got kind of mangled,but hopefully you can still make sense of it.)
Possible tweaks/questions;
1: In the file header part,I'm not sure what would be a better alternative to just copying a random make/model of phone,app version,etc. Perhaps it doesn't matter much? Maybe we could make a new category for "IoT"/ESP/"other" devices? I don't know. I mean,this isn't even a phone,and certainly isn't running the Wigle app. Maybe just 'zero it out' somehow,or leave it blank?
2: The encryption detection/logging bit is kind of basic,and funky,currently. I plan on trying to have that make more sense,and be more like a .CSV from the Wigle app. I just kind of copied some semi-sensible stuff into there,for now,to test if it even remotely works...and it seems it does! The site accepted,and processed some test files I uploaded,and it appears I even found a couple new networks while I was testing/tinkering with it! I also got good looking .KML's back from Wigle. I got so excited I decided to make this post.
I love this stuff!
Maybe the excellent Wigle devs can share any thoughts they have on the above points? Does kinda wonky data in those fields (File header,and encryption types) matter much? Any suggestions to make it better/more accurate/whatever? There may be some hardware limitations here,as I'm not sure the ESP8266 supports/can distinguish all of the various encryption types. Maybe just the basic WEP/WPA/WPA2/None/Auto are enough?
Other than some random stability issues that may be attributed to the poor connections in my breadboard,this seems to be working fairly well so far for me. Still a bit crashy though. I'm using a 'bare' ESP8266 -07 module w/external 9dBi whip antenna,SD card breakout,and a uBlox NEO-7 GPS module. It catches about 40-50 networks per scan,at my location.
In an attempt to resolve the random stability issue(s) I'm having,I made some hardware changes also. I moved the SD card SS pin to GPIO 16 instead of 15,to avoid conflict with GPIO 15 (D8,on the WeMos) because the ESP8266 is picky about that pin,since it is used for boot-mode selection. I also removed the status/lock LED bits,since it is also picky about GPIO 0 and GPIO 2 (D3 and D4 on WeMos),since these are also related to boot-modes. (plus, I didn't want it to be too 'blinky'.) I also moved the start/stop button to GPIO 2. I've got pull-up resistors on GPIO 0 and 2,along with the buttons,and pull-down on GPIO 15. I also pared down the serial output,thinking that may help some. It's much better than when I first started,but still crashes at random sometimes. Maybe I just need to move it off the breadboard,and actually solder the connections.
I'm not 100% sure how the WeMos modules are setup,with regards to pull-up/pull-down on the pins,etc. I've never used them. I'll have to order a couple,and tinker with them.Maybe that will be more stable for me.
I'd love to get this down to roughly the size of a matchbox,using an ESP8266 -12 module,and power it directly from a small lithium cell of some sort. A tiny wardriving setup!
Even more fun might be doing something similar with the ESP32,since it also includes Bluetooth capability.
Big thanks to flok99 for releasing the code,so I could find it and tinker with it.
I'm having fun playing with this. I'd love to hear any thoughts/comments/questions/feedback the community has.
Cheers!