Removed Vendor filter for BLE Scan
This commit is contained in:
parent
ea62f49220
commit
c5d82fb1e0
@ -11,9 +11,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef VENDORFILTER
|
#ifdef VENDORFILTER
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "vendor_array.h"
|
#include "vendor_array.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Local logging tag
|
// Local logging tag
|
||||||
@ -27,8 +27,8 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
|
|||||||
|
|
||||||
char counter [11]; // uint32_t -> 4 byte -> 10 decimals + '0' terminator -> 11 chars
|
char counter [11]; // uint32_t -> 4 byte -> 10 decimals + '0' terminator -> 11 chars
|
||||||
char macbuf [21]; // uint64_t -> 8 byte -> 20 decimals + '0' terminator -> 21 chars
|
char macbuf [21]; // uint64_t -> 8 byte -> 20 decimals + '0' terminator -> 21 chars
|
||||||
char typebuff[8] ;
|
char typebuff[8] ;
|
||||||
bool added = false;
|
bool added = false;
|
||||||
uint32_t hashedmac, vendor2int;
|
uint32_t hashedmac, vendor2int;
|
||||||
uint64_t addr2int;
|
uint64_t addr2int;
|
||||||
std::pair<std::set<uint32_t>::iterator, bool> newmac;
|
std::pair<std::set<uint32_t>::iterator, bool> newmac;
|
||||||
@ -38,35 +38,36 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
|
|||||||
|
|
||||||
#ifdef VENDORFILTER
|
#ifdef VENDORFILTER
|
||||||
vendor2int = ( (uint32_t)paddr[2] ) | ( (uint32_t)paddr[1] << 8 ) | ( (uint32_t)paddr[0] << 16 );
|
vendor2int = ( (uint32_t)paddr[2] ) | ( (uint32_t)paddr[1] << 8 ) | ( (uint32_t)paddr[0] << 16 );
|
||||||
if ( std::find(vendors.begin(), vendors.end(), vendor2int) != vendors.end() ) {
|
// No vendor filter for BLE
|
||||||
|
if ( (sniff_type==MAC_SNIFF_BLE) || std::find(vendors.begin(), vendors.end(), vendor2int) != vendors.end() ) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//if (!(addr2int & WIFI_MAC_FILTER_MASK)) { // filter local and group MACs
|
//if (!(addr2int & WIFI_MAC_FILTER_MASK)) { // filter local and group MACs
|
||||||
|
|
||||||
// salt and hash MAC, and if new unique one, store hash in container and increment counter on display
|
// salt and hash MAC, and if new unique one, store hash in container and increment counter on display
|
||||||
addr2int <<= 8;
|
addr2int <<= 8;
|
||||||
addr2int += salt; // append salt value to MAC before hashing it
|
addr2int += salt; // append salt value to MAC before hashing it
|
||||||
itoa(addr2int, macbuf, 10); // convert 64 bit MAC to base 10 decimal string
|
itoa(addr2int, macbuf, 10); // convert 64 bit MAC to base 10 decimal string
|
||||||
hashedmac = rokkit(macbuf, 10); // hash MAC for privacy, use 10 chars to fit in uint32_t container
|
hashedmac = rokkit(macbuf, 10); // hash MAC for privacy, use 10 chars to fit in uint32_t container
|
||||||
|
|
||||||
if (sniff_type == MAC_SNIFF_WIFI ) {
|
if (sniff_type == MAC_SNIFF_WIFI ) {
|
||||||
newmac = wifis.insert(hashedmac); // store hashed MAC if new unique
|
newmac = wifis.insert(hashedmac); // store hashed MAC if new unique
|
||||||
strcpy(typebuff, "WiFi");
|
strcpy(typebuff, "WiFi");
|
||||||
} else if (sniff_type == MAC_SNIFF_BLE ) {
|
} else if (sniff_type == MAC_SNIFF_BLE ) {
|
||||||
newmac = bles.insert(hashedmac); // store hashed MAC if new unique
|
newmac = bles.insert(hashedmac); // store hashed MAC if new unique
|
||||||
strcpy(typebuff, "BLE ");
|
strcpy(typebuff, "BLE ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newmac.second) { // first time seen this WIFI/BLE MAC
|
if (newmac.second) { // first time seen this WIFI/BLE MAC
|
||||||
// Insert to glbal counter
|
// Insert to glbal counter
|
||||||
macs.insert(hashedmac);
|
macs.insert(hashedmac);
|
||||||
added = true;
|
added = true;
|
||||||
itoa(macs.size(), counter, 10); // base 10 decimal counter value
|
itoa(macs.size(), counter, 10); // base 10 decimal counter value
|
||||||
u8x8.draw2x2String(0, 0, counter);
|
u8x8.draw2x2String(0, 0, counter);
|
||||||
ESP_LOGI(TAG, "%s RSSI %04d -> Hash %010u -> #%04i", typebuff, rssi, hashedmac, macs.size());
|
ESP_LOGI(TAG, "%s RSSI %04d -> Hash %010u -> #%04i", typebuff, rssi, hashedmac, macs.size());
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGI(TAG, "%s RSSI %04d -> already seen", typebuff, rssi);
|
ESP_LOGI(TAG, "%s RSSI %04d -> already seen", typebuff, rssi);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VENDORFILTER
|
#ifdef VENDORFILTER
|
||||||
} else {
|
} else {
|
||||||
@ -75,7 +76,7 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// True if MAC (WiFi/BLE was new)
|
// True if MAC (WiFi/BLE was new)
|
||||||
return added;
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void BLECount() {
|
void BLECount() {
|
||||||
int blenum = 0; // Total device seen on this scan session
|
int blenum = 0; // Total device seen on this scan session
|
||||||
currentScanDevice = 0; // Set 0 seen device on this scan session
|
currentScanDevice = 0; // Set 0 seen device on this scan session
|
||||||
u8x8.clearLine(3);
|
u8x8.clearLine(3);
|
||||||
u8x8.drawString(0,3,"BLE Scan...");
|
u8x8.drawString(0,3,"BLE Scan...");
|
||||||
@ -103,7 +104,7 @@ void BLECount() {
|
|||||||
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
|
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
|
||||||
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
|
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
|
||||||
BLEScanResults foundDevices = pBLEScan->start(cfg.blescancycle);
|
BLEScanResults foundDevices = pBLEScan->start(cfg.blescancycle);
|
||||||
blenum=foundDevices.getCount();
|
blenum=foundDevices.getCount();
|
||||||
u8x8.clearLine(3);
|
u8x8.clearLine(3);
|
||||||
u8x8.setCursor(0,3);
|
u8x8.setCursor(0,3);
|
||||||
u8x8.printf("BLE#: %-5i %-3i",bles.size(), blenum);
|
u8x8.printf("BLE#: %-5i %-3i",bles.size(), blenum);
|
||||||
|
Loading…
Reference in New Issue
Block a user