From b2d6bb7dccd3fbb3dc547de83a0f5b3e846e8266 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 27 Mar 2021 23:25:11 +0100 Subject: [PATCH] libpax integration 3 (remove macfilter) --- README.md | 10 ++-------- include/globals.h | 1 - src/TTN/packed_decoder.js | 2 +- src/TTNv3/packed_decodeUplink.js | 2 +- src/configmanager.cpp | 1 - src/main.cpp | 4 ---- src/paxcounter_orig.conf | 1 - src/payload.cpp | 15 +++++++++------ src/rcommand.cpp | 30 ++++++++++++------------------ 9 files changed, 25 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 1af14989..89cafb89 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ Note: If you use this software you do this at your own risk. That means that you # Privacy disclosure -Paxcounter generates identifiers for sniffed MAC adresses and collects them temporary in the device's RAM for a configurable scan cycle time (default 60 seconds). After each scan cycle the collected identifiers are cleared. Identifiers are generated by salting and hashing MAC adresses. The random salt value changes after each scan cycle. Identifiers and MAC adresses are never transferred to the LoRaWAN network. No persistent storing of MAC adresses, identifiers or timestamps and no other kind of analytics than counting are implemented in this code. Wireless networks are not touched by this code, but MAC adresses from wireless devices as well within as not within wireless networks, regardless if encrypted or unencrypted, are sniffed and processed by this code. If the bluetooth option in the code is enabled, bluetooth MACs are scanned and processed by the included BLE stack, then hashed and counted by this code. +Paxcounter generates identifiers for sniffed Wifi or Bluetooth MAC adresses and and collects them temporary in the device's RAM for a configurable scan cycle time (default 60 seconds). After each scan cycle the collected identifiers are cleared. Identifiers are generated by using the last 2 bytes of universal MAC adresses. Personal MAC adresses remain untouched and are not evaluated. Identifiers and MAC adresses are never transferred to the LoRaWAN network. No persistent storing of MAC adresses, identifiers or timestamps and no other kind of analytics than counting are implemented in this code. Wireless networks are not touched by this code, but MAC adresses from wireless devices as well within as not within wireless networks, regardless if encrypted or unencrypted, are sniffed and processed by this code. # LED blink pattern @@ -221,7 +221,6 @@ This describes how to set up a mobile PaxCounter:
Follow all steps so far fo Bluetooth low energy service UUID 0xFD6F, used by Google/Apple COVID-19 Exposure Notification System, can be monitored and counted. By comparing with the total number of observed devices this gives an indication how many people staying in proximity are using Apps for tracing COVID-19 exposures, e.g. in Germany the "Corona Warn App". To achive best results with this funcion, use following settings in `paxcounter.conf`: #define COUNT_ENS 1 // enable ENS monitoring function - #define MACFILTER 0 // disable MAC filter #define BLECOUNTER 1 // enable bluetooth sniffing #define WIFICOUNTER 0 // disable wifi sniffing (improves BLE scan speed) #define HAS_SENSOR_1 1 // optional: transmit ENS counter data to server @@ -320,7 +319,7 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering. byte 13: Wifi antenna switch (0=internal, 1=external) [default 0] byte 14: count randomizated MACs only (0=disabled, 1=enabled) [default 1] byte 15: RGB LED luminosity (0..100 %) [default 30] - byte 16: Payload filter mask + byte 16: 0 (reserved) byte 17: Beacon proximity alarm mode (1=on, 0=off) [default 0] bytes 18-28: Software version (ASCII format, terminating with zero) @@ -460,11 +459,6 @@ Send for example `8386` as Downlink on Port 2 to get battery status and time/dat 0 ... 255 duration for scanning a bluetooth advertising channel in seconds/100 e.g. 8 -> each channel is scanned for 80 milliseconds [default] -0x0D (NOT YET IMPLEMENTED) set BLE and WIFI MAC filter mode - - 0 = disabled (use to count devices, not people) - 1 = enabled [default] - 0x0E set Bluetooth scanner 0 = disabled diff --git a/include/globals.h b/include/globals.h index cf8e0869..4c601a72 100644 --- a/include/globals.h +++ b/include/globals.h @@ -80,7 +80,6 @@ typedef struct __attribute__((packed)) { uint8_t blescan; // 0=disabled, 1=enabled uint8_t wifiscan; // 0=disabled, 1=enabled uint8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4) - uint8_t macfilter; // 0=disabled, 1=enabled uint8_t rgblum; // RGB Led luminosity (0..100%) uint8_t monitormode; // 0=disabled, 1=enabled uint8_t payloadmask; // bitswitches for payload data diff --git a/src/TTN/packed_decoder.js b/src/TTN/packed_decoder.js index fb66d832..09461db8 100644 --- a/src/TTN/packed_decoder.js +++ b/src/TTN/packed_decoder.js @@ -248,7 +248,7 @@ var bitmap1 = function (byte) { } var i = bytesToInt(byte); var bm = ('00000000' + Number(i).toString(2)).substr(-8).split('').map(Number).map(Boolean); - return ['adr', 'screensaver', 'screen', 'countermode', 'blescan', 'antenna', 'filter', 'alarm'] + return ['adr', 'screensaver', 'screen', 'countermode', 'blescan', 'antenna', 'reserved', 'alarm'] .reduce(function (obj, pos, index) { obj[pos] = +bm[index]; return obj; diff --git a/src/TTNv3/packed_decodeUplink.js b/src/TTNv3/packed_decodeUplink.js index ac4916c4..0b1c3627 100644 --- a/src/TTNv3/packed_decodeUplink.js +++ b/src/TTNv3/packed_decodeUplink.js @@ -263,7 +263,7 @@ var bitmap1 = function (byte) { } var i = bytesToInt(byte); var bm = ('00000000' + Number(i).toString(2)).substr(-8).split('').map(Number).map(Boolean); - return ['adr', 'screensaver', 'screen', 'countermode', 'blescan', 'antenna', 'filter', 'alarm'] + return ['adr', 'screensaver', 'screen', 'countermode', 'blescan', 'antenna', 'reserved', 'alarm'] .reduce(function (obj, pos, index) { obj[pos] = +bm[index]; return obj; diff --git a/src/configmanager.cpp b/src/configmanager.cpp index ceccfcdc..55c604dd 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -51,7 +51,6 @@ static void defaultConfig(configData_t *myconfig) { myconfig->blescan = BLECOUNTER; // 0=disabled, 1=enabled myconfig->wifiscan = WIFICOUNTER; // 0=disabled, 1=enabled myconfig->wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4) - myconfig->macfilter = MACFILTER; // 0=disabled, 1=enabled myconfig->rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%) myconfig->monitormode = 0; // 0=disabled, 1=enabled myconfig->payloadmask = PAYLOADMASK; // payloads as defined in default diff --git a/src/main.cpp b/src/main.cpp index afd41322..6f0ee4ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -399,10 +399,6 @@ void setup() { strcat_P(features, " SDS"); #endif -#if (MACFILTER) - strcat_P(features, " FILTER"); -#endif - // initialize matrix display #ifdef HAS_MATRIX_DISPLAY strcat_P(features, " LED_MATRIX"); diff --git a/src/paxcounter_orig.conf b/src/paxcounter_orig.conf index d35c3909..629ae30c 100644 --- a/src/paxcounter_orig.conf +++ b/src/paxcounter_orig.conf @@ -19,7 +19,6 @@ #define COUNTERMODE 0 // 0=cyclic, 1=cumulative, 2=cyclic confirmed // MAC sniffing parameters -#define MACFILTER 1 // set to 0 if you want to scan all devices, 1 to scan only devices with random MACs (aka smartphones) [default = 1] #define BLECOUNTER 1 // set to 0 if you do not want to install the BLE sniffer #define WIFICOUNTER 1 // set to 0 if you do not want to install the WIFI sniffer #define MAC_QUEUE_SIZE 50 // size of MAC processing buffer (number of MACs) [default = 50] diff --git a/src/payload.cpp b/src/payload.cpp index 6c943981..2e89b1f4 100644 --- a/src/payload.cpp +++ b/src/payload.cpp @@ -49,7 +49,7 @@ void PayloadConvert::addConfig(configData_t value) { buffer[cursor++] = value.blescantime; buffer[cursor++] = value.blescan; buffer[cursor++] = value.wifiant; - buffer[cursor++] = value.macfilter; + buffer[cursor++] = 0; // reserved buffer[cursor++] = value.rgblum; buffer[cursor++] = value.payloadmask; buffer[cursor++] = value.monitormode; @@ -58,7 +58,8 @@ void PayloadConvert::addConfig(configData_t value) { } void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float cputemp, - uint32_t mem, uint8_t reset0, uint32_t restarts) { + uint32_t mem, uint8_t reset0, + uint32_t restarts) { buffer[cursor++] = highByte(voltage); buffer[cursor++] = lowByte(voltage); @@ -181,14 +182,15 @@ void PayloadConvert::addConfig(configData_t value) { writeUint8(value.rgblum); writeBitmap(value.adrmode ? true : false, value.screensaver ? true : false, value.screenon ? true : false, value.countermode ? true : false, - value.blescan ? true : false, value.wifiant ? true : false, - value.macfilter ? true : false, value.monitormode ? true : false); + value.blescan ? true : false, value.wifiant ? true : false, 0, + value.monitormode ? true : false); writeUint8(value.payloadmask); writeVersion(value.version); } void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float cputemp, - uint32_t mem, uint8_t reset0, uint32_t restarts) { + uint32_t mem, uint8_t reset0, + uint32_t restarts) { writeUint16(voltage); writeUptime(uptime); writeUint8((byte)cputemp); @@ -400,7 +402,8 @@ void PayloadConvert::addConfig(configData_t value) { } void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float celsius, - uint32_t mem, uint8_t reset0, uint32_t restarts) { + uint32_t mem, uint8_t reset0, + uint32_t restarts) { uint16_t temp = celsius * 10; uint16_t volt = voltage / 10; #if (defined BAT_MEASURE_ADC || defined HAS_PMU) diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 1eb8efae..12c83ce9 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -287,12 +287,6 @@ void set_wifiant(uint8_t val[]) { #endif } -void set_macfilter(uint8_t val[]) { - ESP_LOGI(TAG, "Remote command: set macfilter mode to %s", - val[0] ? "on" : "off"); - cfg.macfilter = val[0] ? 1 : 0; -} - void set_rgblum(uint8_t val[]) { // Avoid wrong parameters cfg.rgblum = (val[0] <= 100) ? (uint8_t)val[0] : RGBLUMINOSITY; @@ -422,18 +416,18 @@ static const cmd_t table[] = { {0x07, set_loraadr, 1}, {0x08, set_screensaver, 1}, {0x09, set_reset, 1}, {0x0a, set_sendcycle, 1}, {0x0b, set_wifichancycle, 1}, {0x0c, set_blescantime, 1}, - {0x0d, set_macfilter, 1}, {0x0e, set_blescan, 1}, - {0x0f, set_wifiant, 1}, {0x10, set_rgblum, 1}, - {0x11, set_monitor, 1}, {0x12, set_beacon, 7}, - {0x13, set_sensor, 2}, {0x14, set_payloadmask, 1}, - {0x15, set_bme, 1}, {0x16, set_batt, 1}, - {0x17, set_wifiscan, 1}, {0x18, set_enscount, 1}, - {0x19, set_sleepcycle, 2}, {0x20, set_loadconfig, 0}, - {0x21, set_saveconfig, 0}, {0x80, get_config, 0}, - {0x81, get_status, 0}, {0x83, get_batt, 0}, - {0x84, get_gps, 0}, {0x85, get_bme, 0}, - {0x86, get_time, 0}, {0x87, set_timesync, 0}, - {0x88, set_time, 4}, {0x99, set_flush, 0}}; + {0x0e, set_blescan, 1}, {0x0f, set_wifiant, 1}, + {0x10, set_rgblum, 1}, {0x11, set_monitor, 1}, + {0x12, set_beacon, 7}, {0x13, set_sensor, 2}, + {0x14, set_payloadmask, 1}, {0x15, set_bme, 1}, + {0x16, set_batt, 1}, {0x17, set_wifiscan, 1}, + {0x18, set_enscount, 1}, {0x19, set_sleepcycle, 2}, + {0x20, set_loadconfig, 0}, {0x21, set_saveconfig, 0}, + {0x80, get_config, 0}, {0x81, get_status, 0}, + {0x83, get_batt, 0}, {0x84, get_gps, 0}, + {0x85, get_bme, 0}, {0x86, get_time, 0}, + {0x87, set_timesync, 0}, {0x88, set_time, 4}, + {0x99, set_flush, 0}}; static const uint8_t cmdtablesize = sizeof(table) / sizeof(table[0]); // number of commands in command table