This commit is contained in:
Oliver Brandmueller 2018-04-08 19:42:55 +02:00
commit bd60d53746
4 changed files with 39 additions and 22 deletions

View File

@ -118,10 +118,15 @@ void do_send(osjob_t* j){
mydata[0] = (data & 0xff00) >> 8; mydata[0] = (data & 0xff00) >> 8;
mydata[1] = data & 0xff; mydata[1] = data & 0xff;
#ifdef BLECOUNTER
// Sum of unique BLE MACs seen // Sum of unique BLE MACs seen
data = (uint16_t) bles.size(); data = (uint16_t) bles.size();
mydata[2] = (data & 0xff00) >> 8; mydata[2] = (data & 0xff00) >> 8;
mydata[3] = data & 0xff; mydata[3] = data & 0xff;
#else
mydata[2] = 0;
mydata[3] = 0;
#endif
// Total BLE+WIFI unique MACs seen // Total BLE+WIFI unique MACs seen
// TBD ? // TBD ?

View File

@ -60,10 +60,13 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
if (sniff_type == MAC_SNIFF_WIFI ) { if (sniff_type == MAC_SNIFF_WIFI ) {
rgb_set_color(COLOR_GREEN); rgb_set_color(COLOR_GREEN);
wifis.insert(hashedmac); // add hashed MAC to wifi container if new unique wifis.insert(hashedmac); // add hashed MAC to wifi container if new unique
} else if (sniff_type == MAC_SNIFF_BLE ) { }
#ifdef BLECOUNTER
else if (sniff_type == MAC_SNIFF_BLE ) {
rgb_set_color(COLOR_MAGENTA); rgb_set_color(COLOR_MAGENTA);
bles.insert(hashedmac); // add hashed MAC to BLE container if new unique bles.insert(hashedmac); // add hashed MAC to BLE container if new unique
} }
#endif
// Not sure user will have time to see the LED // Not sure user will have time to see the LED
// TBD do light off further in the code // TBD do light off further in the code
rgb_set_color(COLOR_NONE); rgb_set_color(COLOR_NONE);
@ -72,7 +75,12 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
ESP_LOGI(TAG, "%s RSSI %ddBi -> MAC %s -> Hash %04X -> WiFi:%d BLE:%d %s", ESP_LOGI(TAG, "%s RSSI %ddBi -> MAC %s -> Hash %04X -> WiFi:%d BLE:%d %s",
sniff_type==MAC_SNIFF_WIFI ? "WiFi":"BLE ", sniff_type==MAC_SNIFF_WIFI ? "WiFi":"BLE ",
rssi, buff, hashedmac, rssi, buff, hashedmac,
(int) wifis.size(), (int) bles.size(), (int) wifis.size(),
#ifdef BLECOUNTER
(int) bles.size(),
#else
0,
#endif
added ? "New" : "Already seen"); added ? "New" : "Already seen");
#ifdef VENDORFILTER #ifdef VENDORFILTER
@ -96,7 +104,7 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
/* to be done here: /* to be done here:
#ifdef VENDORFILTER #ifdef VENDORFILTER
filter BLE devices using their advertisements to get second filter additional to vendor OUI filter BLE devices using their advertisements to get filter alternative to vendor OUI
if vendorfiltering is on, we ... if vendorfiltering is on, we ...
- want to count: mobile phones and tablets - want to count: mobile phones and tablets
- don't want to count: beacons, peripherals (earphones, headsets, printers), cars and machines - don't want to count: beacons, peripherals (earphones, headsets, printers), cars and machines
@ -105,11 +113,9 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
http://www.libelium.com/products/meshlium/smartphone-detection/ http://www.libelium.com/products/meshlium/smartphone-detection/
http://dev.ti.com/tirex/content/simplelink_academy_cc2640r2sdk_1_12_01_16/modules/ble_scan_adv_basic/ble_scan_adv_basic.html https://www.question-defense.com/2013/01/12/bluetooth-cod-bluetooth-class-of-deviceclass-of-service-explained
http://microchipdeveloper.com/wireless:ble-link-layer-packet-types https://www.bluetooth.com/specifications/assigned-numbers/baseband
http://microchipdeveloper.com/wireless:ble-link-layer-address
"The Class of Device (CoD) in case of Bluetooth which allows us to differentiate the type of "The Class of Device (CoD) in case of Bluetooth which allows us to differentiate the type of
device (smartphone, handsfree, computer, LAN/network AP). With this parameter we can device (smartphone, handsfree, computer, LAN/network AP). With this parameter we can

View File

@ -218,7 +218,7 @@ void lorawan_loop(void * pvParameters) {
#ifdef BLECOUNTER #ifdef BLECOUNTER
void BLECount(void); void BLECount(void);
#else #else
btStop(); bool btstop = btStop();
#endif #endif
void set_onboard_led(int st){ void set_onboard_led(int st){
@ -272,24 +272,27 @@ void sniffer_loop(void * pvParameters) {
ESP_LOGI(TAG, "Wifi set channel %d", channel); ESP_LOGI(TAG, "Wifi set channel %d", channel);
snprintf(buff, sizeof(buff), "PAX:%d", (int) macs.size()); // convert 16-bit MAC counter to decimal counter value snprintf(buff, sizeof(buff), "PAX:%d", (int) macs.size()); // convert 16-bit MAC counter to decimal counter value
u8x8.draw2x2String(0, 0, buff); // display number on unique macs total Wifi + BLE u8x8.draw2x2String(0, 0, buff); // display number on unique macs total
u8x8.setCursor(0,3);
// We just state out of BLE scanning #ifdef BLECOUNTER
if (currentScanDevice) { // We just state out of BLE scanning
u8x8.printf("BLE: %-4d %-4d", (int) bles.size(), currentScanDevice); u8x8.setCursor(0,3);
} else { if (currentScanDevice) {
u8x8.printf("BLE: %-4d", (int) bles.size()); u8x8.printf("BLE: %-4d %-4d", (int) bles.size(), currentScanDevice);
} } else {
u8x8.printf("BLE: %-4d", (int) bles.size());
}
#endif
u8x8.setCursor(0,4); u8x8.setCursor(0,4);
u8x8.printf("WIFI: %-4d", (int) wifis.size()); u8x8.printf("WIFI: %-4d", (int) wifis.size());
u8x8.setCursor(11,4); u8x8.setCursor(11,4);
u8x8.printf("ch:%02i", channel); u8x8.printf("ch:%02i", channel);
u8x8.setCursor(0,5); u8x8.setCursor(0,5);
u8x8.printf(!cfg.rssilimit ? "RLIM: off" : "RLIM: %-3d", cfg.rssilimit); u8x8.printf(!cfg.rssilimit ? "RLIM: off" : "RLIM: %-3d", cfg.rssilimit);
//u8x8.printf(" ch:%02i", channel);
// duration of one wifi scan loop reached? then send data and begin new scan cycle // duration of one wifi scan loop reached? then send data and begin new scan cycle
if( nloop >= ( (100 / cfg.wifichancycle) * (cfg.wifiscancycle * 2)) +1 ) { if ( nloop >= ( (100 / cfg.wifichancycle) * (cfg.wifiscancycle * 2)) +1 ) {
u8x8.setPowerSave(!cfg.screenon); // set display on if enabled u8x8.setPowerSave(!cfg.screenon); // set display on if enabled
nloop=0; channel=0; // reset wifi scan + channel loop counter nloop=0; channel=0; // reset wifi scan + channel loop counter
do_send(&sendjob); // Prepare and execute LoRaWAN data upload do_send(&sendjob); // Prepare and execute LoRaWAN data upload
@ -301,7 +304,7 @@ void sniffer_loop(void * pvParameters) {
macs.clear(); // clear all macs container macs.clear(); // clear all macs container
wifis.clear(); // clear Wifi macs couner wifis.clear(); // clear Wifi macs couner
#ifdef BLECOUNTER #ifdef BLECOUNTER
bles.clear(); // clear BLE macs counter bles.clear(); // clear BLE macs counter
#endif #endif
salt_reset(); // get new salt for salting hashes salt_reset(); // get new salt for salting hashes
u8x8.clearLine(0); // clear Display counter u8x8.clearLine(0); // clear Display counter
@ -336,8 +339,9 @@ void sniffer_loop(void * pvParameters) {
else { else {
#ifdef BLECOUNTER #ifdef BLECOUNTER
if (nloop % (WIFI_CHANNEL_MAX * cfg.blescancycle) == 0 ) // once after cfg.blescancycle Wifi scans, do a BLE scan if (nloop % (WIFI_CHANNEL_MAX * cfg.blescancycle) == 0 ) // once after cfg.blescancycle Wifi scans, do a BLE scan
if (cfg.blescan) // execute BLE count if BLE function is enabled if (cfg.blescan) { // execute BLE count if BLE function is enabled
BLECount(); BLECount(); // start BLE scan, this is a blocking call
}
#endif #endif
} // end of channel rotation loop } // end of channel rotation loop
} // end of infinite wifi scan loop } // end of infinite wifi scan loop

View File

@ -68,7 +68,9 @@ void set_reset(int val) {
ESP_LOGI(TAG, "Remote command: reset MAC counter"); ESP_LOGI(TAG, "Remote command: reset MAC counter");
macs.clear(); // clear all macs container macs.clear(); // clear all macs container
wifis.clear(); // clear Wifi macs container wifis.clear(); // clear Wifi macs container
bles.clear(); // clear BLE macs container #ifdef BLECOUNTER
bles.clear(); // clear BLE macs container
#endif
salt_reset(); // get new 16bit salt salt_reset(); // get new 16bit salt
u8x8.clearLine(0); u8x8.clearLine(1); // clear Display counter u8x8.clearLine(0); u8x8.clearLine(1); // clear Display counter
u8x8.clearLine(5); u8x8.clearLine(5);