reduced mac and ble counter to 16bit
This commit is contained in:
parent
527f47d558
commit
cf2a620e8a
@ -27,6 +27,6 @@ void BLECount() {
|
|||||||
u8x8.clearLine(3);
|
u8x8.clearLine(3);
|
||||||
u8x8.setCursor(0,3);
|
u8x8.setCursor(0,3);
|
||||||
blenum=foundDevices.getCount();
|
blenum=foundDevices.getCount();
|
||||||
u8x8.printf("BLE#: %4i",blenum);
|
u8x8.printf("BLE#: %5i",blenum);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -32,9 +32,10 @@ extern configData_t cfg;
|
|||||||
extern uint8_t mydata[];
|
extern uint8_t mydata[];
|
||||||
extern uint64_t uptimecounter;
|
extern uint64_t uptimecounter;
|
||||||
extern osjob_t sendjob;
|
extern osjob_t sendjob;
|
||||||
extern int macnum, blenum, countermode, screensaver, adrmode, lorasf, txpower, rlim, salt;
|
extern uint16_t macnum, blenum;
|
||||||
|
extern int countermode, screensaver, adrmode, lorasf, txpower, rlim, salt;
|
||||||
extern bool joinstate;
|
extern bool joinstate;
|
||||||
extern std::set<uint32_t> macs;
|
extern std::set<uint16_t> macs;
|
||||||
|
|
||||||
#ifdef HAS_DISPLAY
|
#ifdef HAS_DISPLAY
|
||||||
extern HAS_DISPLAY u8x8;
|
extern HAS_DISPLAY u8x8;
|
||||||
|
@ -79,10 +79,10 @@ void printKeys(void) {
|
|||||||
#endif // VERBOSE
|
#endif // VERBOSE
|
||||||
|
|
||||||
void do_send(osjob_t* j){
|
void do_send(osjob_t* j){
|
||||||
mydata[0] = (macnum & 0x0000ff00) >> 8;
|
mydata[0] = (macnum & 0xff00) >> 8;
|
||||||
mydata[1] = macnum & 0x000000ff;
|
mydata[1] = macnum & 0x00ff;
|
||||||
mydata[2] = (blenum & 0x0000ff00) >> 8;
|
mydata[2] = (blenum & 0xff00) >> 8;
|
||||||
mydata[3] = blenum & 0x000000ff;
|
mydata[3] = blenum & 0x00ff;
|
||||||
|
|
||||||
// Check if there is not a current TX/RX job running
|
// Check if there is not a current TX/RX job running
|
||||||
if (LMIC.opmode & OP_TXRXPEND) {
|
if (LMIC.opmode & OP_TXRXPEND) {
|
||||||
|
@ -42,11 +42,12 @@ configData_t cfg; // struct holds current device configuration
|
|||||||
osjob_t sendjob, initjob; // LMIC
|
osjob_t sendjob, initjob; // LMIC
|
||||||
|
|
||||||
// Initialize global variables
|
// Initialize global variables
|
||||||
int macnum = 0, blenum = 0, salt;
|
uint16_t macnum = 0, blenum = 0;
|
||||||
|
int salt;
|
||||||
uint64_t uptimecounter = 0;
|
uint64_t uptimecounter = 0;
|
||||||
bool joinstate = false;
|
bool joinstate = false;
|
||||||
|
|
||||||
std::set<uint32_t> macs; // associative container holds filtered MAC adresses
|
std::set<uint16_t> macs; // associative container holds filtered MAC adresses
|
||||||
|
|
||||||
// this variable will be changed in the ISR, and read in main loop
|
// this variable will be changed in the ISR, and read in main loop
|
||||||
static volatile bool ButtonTriggered = false;
|
static volatile bool ButtonTriggered = false;
|
||||||
@ -211,7 +212,7 @@ void wifi_sniffer_loop(void * pvParameters) {
|
|||||||
|
|
||||||
// Prepare and execute LoRaWAN data upload
|
// Prepare and execute LoRaWAN data upload
|
||||||
u8x8.setCursor(0,4);
|
u8x8.setCursor(0,4);
|
||||||
u8x8.printf("MAC#: %4i", macnum);
|
u8x8.printf("MAC#: %i", macnum);
|
||||||
do_send(&sendjob); // send payload
|
do_send(&sendjob); // send payload
|
||||||
vTaskDelay(500/portTICK_PERIOD_MS);
|
vTaskDelay(500/portTICK_PERIOD_MS);
|
||||||
yield();
|
yield();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// program version
|
// program version
|
||||||
#define PROGVERSION "1.2.61" // use max 10 chars here!
|
#define PROGVERSION "1.2.62" // use max 10 chars here!
|
||||||
#define PROGNAME "PAXCNT"
|
#define PROGNAME "PAXCNT"
|
||||||
|
|
||||||
// Verbose enables serial output
|
// Verbose enables serial output
|
||||||
|
@ -59,11 +59,12 @@ void wifi_sniffer_packet_handler(void* buff, wifi_promiscuous_pkt_type_t type) {
|
|||||||
const wifi_promiscuous_pkt_t *ppkt = (wifi_promiscuous_pkt_t *)buff;
|
const wifi_promiscuous_pkt_t *ppkt = (wifi_promiscuous_pkt_t *)buff;
|
||||||
const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)ppkt->payload;
|
const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)ppkt->payload;
|
||||||
const wifi_ieee80211_mac_hdr_t *hdr = &ipkt->hdr;
|
const wifi_ieee80211_mac_hdr_t *hdr = &ipkt->hdr;
|
||||||
char counter [11]; // uint32_t -> 4 byte -> 10 decimals + '0' terminator -> 11 chars
|
char counter [6]; // uint16_t -> 2 byte -> 5 decimals + '0' terminator -> 6 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
|
||||||
uint32_t hashedmac, vendor2int;
|
|
||||||
uint64_t addr2int;
|
uint64_t addr2int;
|
||||||
std::pair<std::set<uint32_t>::iterator, bool> newmac;
|
uint32_t vendor2int;
|
||||||
|
uint16_t hashedmac;
|
||||||
|
std::pair<std::set<uint16_t>::iterator, bool> newmac;
|
||||||
|
|
||||||
if (( cfg.rssilimit == 0 ) || (ppkt->rx_ctrl.rssi > cfg.rssilimit )) { // rssi is negative value
|
if (( cfg.rssilimit == 0 ) || (ppkt->rx_ctrl.rssi > cfg.rssilimit )) { // rssi is negative value
|
||||||
addr2int = ( (uint64_t)hdr->addr2[0] ) | ( (uint64_t)hdr->addr2[1] << 8 ) | ( (uint64_t)hdr->addr2[2] << 16 ) | \
|
addr2int = ( (uint64_t)hdr->addr2[0] ) | ( (uint64_t)hdr->addr2[1] << 8 ) | ( (uint64_t)hdr->addr2[2] << 16 ) | \
|
||||||
@ -78,16 +79,16 @@ void wifi_sniffer_packet_handler(void* buff, wifi_promiscuous_pkt_type_t type) {
|
|||||||
//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; // left shift out msb of vendor oui
|
||||||
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, 5); // hash MAC for privacy, use 5 chars to fit in uint16_t container
|
||||||
newmac = macs.insert(hashedmac); // store hashed MAC if new unique
|
newmac = macs.insert(hashedmac); // store hashed MAC if new unique
|
||||||
if (newmac.second) { // first time seen MAC
|
if (newmac.second) { // first time seen MAC
|
||||||
macnum++; // increment MAC counter
|
macnum++; // increment MAC counter
|
||||||
itoa(macnum, counter, 10); // base 10 decimal counter value
|
itoa(macnum, counter, 10); // base 10 decimal counter value
|
||||||
u8x8.draw2x2String(0, 0, counter);
|
u8x8.draw2x2String(0, 0, counter);
|
||||||
ESP_LOGI(TAG, "RSSI %04d -> Hash %010u -> #%04i", ppkt->rx_ctrl.rssi, hashedmac, macnum);
|
ESP_LOGI(TAG, "RSSI %04d -> Hash %05u -> #%05i", ppkt->rx_ctrl.rssi, hashedmac, macnum);
|
||||||
}
|
}
|
||||||
else // already seen MAC
|
else // already seen MAC
|
||||||
ESP_LOGI(TAG, "RSSI %04d -> already seen", ppkt->rx_ctrl.rssi);
|
ESP_LOGI(TAG, "RSSI %04d -> already seen", ppkt->rx_ctrl.rssi);
|
||||||
|
Loading…
Reference in New Issue
Block a user