diff --git a/README.md b/README.md index e8ad0b69..a61d400a 100644 --- a/README.md +++ b/README.md @@ -216,15 +216,6 @@ Paxcounter can be used to sync a wall clock which has a DCF77 or IF482 time tele This describes how to set up a mobile PaxCounter:
Follow all steps so far for preparing the device, selecting the packed payload format. In `paxcounter.conf` set PAYLOAD_OPENSENSEBOX to 1. Register a new sensebox on https://opensensemap.org/. In the sensor configuration select "TheThingsNetwork" and set decoding profile to "LoRa serialization". Enter your TTN Application and Device ID. Setup decoding option using `[{"decoder":"latLng"},{"decoder":"uint16",sensor_id":"yoursensorid"}]` -# Covid-19 Exposure Notification System beacon detection (currently NOT working with v3.0.x, use v2.4.x for this feature) - -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 BLECOUNTER 1 // enable bluetooth sniffing - #define WIFICOUNTER 0 // disable wifi sniffing (improves BLE scan speed) - #define HAS_SENSOR_1 1 // optional, in board's hal file: transmit ENS counter data to server - # SD-card Data can be stored on an SD-card if one is availabe. Simply choose the file in src/hal and add the following lines to your hal-file: @@ -384,7 +375,7 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering. **Ports #10, #11, #12:** User sensor data - Format is specified by user in function `sensor_read(uint8_t sensor)`, see `src/sensor.cpp`. Port #10 is also used for ENS counter (2 bytes = 16 bit), if ENS is compiled AND ENS data transfer is enabled + Format is specified by user in function `sensor_read(uint8_t sensor)`, see `src/sensor.cpp`. # Remote control @@ -504,7 +495,7 @@ Send for example `83` `86` as Downlink on Port 2 to get battery status and time/ 0x02 = RESERVED_DATA 0x04 = MEMS_DATA 0x08 = GPS_DATA - 0x10 = SENSOR_1_DATA (also ENS counter) + 0x10 = SENSOR_1_DATA 0x20 = SENSOR_2_DATA 0x40 = SENSOR_3_DATA 0x80 = BATT_DATA @@ -525,10 +516,9 @@ Send for example `83` `86` as Downlink on Port 2 to get battery status and time/ 0 = disabled 1 = enabled [default] -0x18 set ENS counter on/off +0x18 reserved - 0 = disabled [default] - 1 = enabled + unused, does nothing 0x19 set sleep cycle @@ -622,4 +612,4 @@ Thanks to - [terrillmoore](https://github.com/mcci-catena) for maintaining the LMIC for arduino LoRaWAN stack - [sbamueller](https://github.com/sbamueller) for writing the tutorial in Make Magazine - [Stefan](https://github.com/nerdyscout) for paxcounter opensensebox integration -- [August Quint](https://github.com/AugustQu) for adding SD card data logger, SDS011 and ENS support +- [August Quint](https://github.com/AugustQu) for adding SD card data logger and SDS011 support diff --git a/include/corona.h b/include/corona.h deleted file mode 100644 index 9af0d314..00000000 --- a/include/corona.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _CORONA_h -#define _CORONA_H - -// inspired by https://github.com/kmetz/BLEExposureNotificationBeeper -// (c) by Kaspar Metz -// modified for use in the Paxcounter by AQ - -#include "globals.h" -#include - -bool cwa_init(void); -void cwa_mac_add(uint16_t hashedmac); -void cwa_clear(void); -uint16_t cwa_report(void); - -#endif diff --git a/include/display.h b/include/display.h index 2b00aa44..62cdf363 100644 --- a/include/display.h +++ b/include/display.h @@ -6,10 +6,6 @@ #include "qrcode.h" #include "power.h" -#if (COUNT_ENS) -#include "corona.h" -#endif - #if (HAS_DISPLAY) == 1 #include #elif (HAS_DISPLAY) == 2 diff --git a/include/globals.h b/include/globals.h index fb2e773e..9b141b09 100644 --- a/include/globals.h +++ b/include/globals.h @@ -71,7 +71,6 @@ typedef struct __attribute__((packed)) { uint8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4) uint8_t rgblum; // RGB Led luminosity (0..100%) uint8_t payloadmask; // bitswitches for payload data - uint8_t enscount; // 0=disabled 1= enabled #ifdef HAS_BME680 uint8_t diff --git a/include/main.h b/include/main.h index a0772b03..6fa72b11 100644 --- a/include/main.h +++ b/include/main.h @@ -18,7 +18,6 @@ #include "sensor.h" #include "lorawan.h" #include "timekeeper.h" -#include "corona.h" #include "boot.h" #include "libpax_helpers.h" #include "power.h" diff --git a/include/senddata.h b/include/senddata.h index 4ae83018..6c44dfa7 100644 --- a/include/senddata.h +++ b/include/senddata.h @@ -10,10 +10,6 @@ #include "display.h" #include "sdcard.h" -#if (COUNT_ENS) -#include "corona.h" -#endif - extern struct count_payload_t count_from_libpax; void SendPayload(uint8_t port); diff --git a/src/TTN/packed_decoder.js b/src/TTN/packed_decoder.js index f338e6df..7230fb46 100644 --- a/src/TTN/packed_decoder.js +++ b/src/TTN/packed_decoder.js @@ -84,11 +84,6 @@ function Decoder(bytes, port) { } } - if (port === 10) { - // ENS count - return decode(bytes, [uint16], ['ens']); - } - } diff --git a/src/TTNv3/packed_decodeUplink.js b/src/TTNv3/packed_decodeUplink.js index a010f3dc..94c1ec8b 100644 --- a/src/TTNv3/packed_decodeUplink.js +++ b/src/TTNv3/packed_decodeUplink.js @@ -90,11 +90,6 @@ function decodeUplink(input) { data = decode(input.bytes, [uint32, uint8], ['time', 'timestatus']); } } - - if (input.fPort === 10) { - // ENS count - data = decode(input.bytes, [uint16], ['ens']); - } data.bytes = input.bytes; // comment out if you do not want to include the original payload data.port = input.fPort; // comment out if you do not want to inlude the port diff --git a/src/TTNv3/plain_decodeUplink.js b/src/TTNv3/plain_decodeUplink.js index d19feb48..0b1b8c23 100644 --- a/src/TTNv3/plain_decodeUplink.js +++ b/src/TTNv3/plain_decodeUplink.js @@ -84,13 +84,6 @@ function decodeUplink(input) { } } - if (input.fPort === 10) { - var i = 0; - if (input.bytes.length >= 2) { - data.ens = (input.bytes[i++] << 8) | input.bytes[i++]; - } - } - if (data.hdop) { data.hdop /= 100; data.latitude /= 1000000; diff --git a/src/configmanager.cpp b/src/configmanager.cpp index 7de8d127..256c9f2d 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -57,7 +57,6 @@ static void defaultConfig(configData_t *myconfig) { myconfig->wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4) myconfig->rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%) myconfig->payloadmask = PAYLOADMASK; // payloads as defined in default - myconfig->enscount = COUNT_ENS; // 0=disabled, 1=enabled #ifdef HAS_BME680 // initial BSEC state for BME680 sensor diff --git a/src/corona.cpp b/src/corona.cpp deleted file mode 100644 index bd20fb17..00000000 --- a/src/corona.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// routines for counting the number of devices which advertise Exposure -// Notification Service e.g. "Corona Warn App" in Germany - -// copied from https://github.com/kmetz/BLEExposureNotificationBeeper -// (c) by Kaspar Metz -// modified for use in the Paxcounter by AQ - -#if (COUNT_ENS) && !(BLECOUNTER) -#warning ENS-Counter needs Bluetooth, but Bluetooth compile option is disabled -#endif - -#if (COUNT_ENS) - -// Local logging tag -static const char TAG[] = __FILE__; - -#define BT_BD_ADDR_HEX(addr) \ - addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] - -#include "corona.h" - -// When to forget old senders ** currently not used ** -#define FORGET_AFTER_MINUTES 2 - -// array of timestamps for seen notifiers: hash -> timestamp[ms] -static std::map cwaSeenNotifiers; - -// Remove notifiers last seen over FORGET_AFTER_MINUTES ago. -void cwa_clear() { -#ifdef VERBOSE - ESP_LOGV(TAG, "CWA: forget old notifier: %d", cwaSeenNotifiers.size()); - for (auto const ¬ifier : cwaSeenNotifiers) { - ESP_LOGD(TAG, "CWA forget <%04X>", notifier.first); - // } - } -#endif - // clear everything, otherwise we would count the same device again, as in the - // next cycle it likely will advertise with a different hash-value - cwaSeenNotifiers.clear(); -} - -// return the total number of devices seen advertising ENS -uint16_t cwa_report(void) { return cwaSeenNotifiers.size(); } - -bool cwa_init(void) { - ESP_LOGD(TAG, "init BLE-scanner for ENS"); - return true; -} - -void cwa_mac_add(uint16_t hashedmac) { - cwaSeenNotifiers[hashedmac] = millis(); // hash last seen at .... -} - -#endif diff --git a/src/display.cpp b/src/display.cpp index fdf70904..10722fa3 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -268,12 +268,7 @@ void dp_drawPage(bool nextpage) { else dp_printf("WIFI:off"); if (cfg.blescan) -#if (COUNT_ENS) - if (cfg.enscount) - dp_printf(" CWA:%-5d", cwa_report()); - else -#endif - dp_printf("BLTH:%-5d", count_from_libpax.ble_count); + dp_printf("BLTH:%-5d", count_from_libpax.ble_count); else dp_printf(" BLTH:off"); #elif ((WIFICOUNTER) && (!BLECOUNTER)) @@ -284,12 +279,7 @@ void dp_drawPage(bool nextpage) { #elif ((!WIFICOUNTER) && (BLECOUNTER)) if (cfg.blescan) dp_printf("BLTH:%-5d", count_from_libpax.ble_count); -#if (COUNT_ENS) - if (cfg.enscount) - dp_printf("(CWA:%d)", cwa_report()); - else -#endif - dp_printf("BLTH:off"); + dp_printf("BLTH:off"); #else dp_printf("Sniffer disabled"); #endif diff --git a/src/lorawan-devices-repo/vendor/opensource/esp32-paxcounter-packed.js b/src/lorawan-devices-repo/vendor/opensource/esp32-paxcounter-packed.js index d82e56e9..b9fc15a1 100644 --- a/src/lorawan-devices-repo/vendor/opensource/esp32-paxcounter-packed.js +++ b/src/lorawan-devices-repo/vendor/opensource/esp32-paxcounter-packed.js @@ -90,12 +90,7 @@ function decodeUplink(input) { data = decode(input.bytes, [uint32, uint8], ['time', 'timestatus']); } } - - if (input.fPort === 10) { - // ENS count - data = decode(input.bytes, [uint16], ['ens']); - } - + data.bytes = input.bytes; // comment out if you do not want to include the original payload data.port = input.fPort; // comment out if you do not want to inlude the port diff --git a/src/main.cpp b/src/main.cpp index 82398073..4bc007ab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -337,15 +337,9 @@ void setup() { // initialize sensors #if (HAS_SENSORS) #if (HAS_SENSOR_1) -#if (COUNT_ENS) - ESP_LOGI(TAG, "init CWA-counter"); - if (cwa_init()) - strcat_P(features, " CWA"); -#else strcat_P(features, " SENS(1)"); sensor_init(); #endif -#endif #if (HAS_SENSOR_2) strcat_P(features, " SENS(2)"); sensor_init(); diff --git a/src/paxcounter_orig.conf b/src/paxcounter_orig.conf index 0fe927b9..a96a8c53 100644 --- a/src/paxcounter_orig.conf +++ b/src/paxcounter_orig.conf @@ -27,10 +27,6 @@ #define BLESCANWINDOW 80 // [milliseconds] scan window, see below, 3 .. 10240, default 80ms #define BLESCANINTERVAL 80 // [illiseconds] scan interval, see below, 3 .. 10240, default 80ms = 100% duty cycle -// Corona Exposure Notification Service(ENS) counter -#define COUNT_ENS 0 // count found number of devices which advertise Exposure Notification Service - // set to 1 if you want to enable this function [default=0] - /* Note: guide for setting bluetooth parameters * * |< Scan Window > |< Scan Window > | ... |< Scan Window > | diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 08c7618d..ecaadca7 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -397,15 +397,6 @@ void set_flush(uint8_t val[]) { // used to open receive window on LoRaWAN class a nodes }; -void set_enscount(uint8_t val[]) { - ESP_LOGI(TAG, "Remote command: set ENS_COUNT to %s", val[0] ? "on" : "off"); - cfg.enscount = val[0] ? 1 : 0; - if (val[0]) - cfg.payloadmask |= (uint8_t)SENSOR1_DATA; - else - cfg.payloadmask &= (uint8_t)~SENSOR1_DATA; -} - void set_loadconfig(uint8_t val[]) { ESP_LOGI(TAG, "Remote command: load config from NVRAM"); loadConfig(); @@ -430,7 +421,7 @@ static const cmd_t table[] = { {0x10, set_rgblum, 1}, {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}, + {0x18, set_flush, 0}, {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}, diff --git a/src/senddata.cpp b/src/senddata.cpp index bc9ee702..9b7a5e57 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -159,10 +159,6 @@ void sendData() { payload.reset(); payload.addSensor(sensor_read(1)); SendPayload(SENSOR1PORT); -#if (COUNT_ENS) - if (cfg.countermode != 1) - cwa_clear(); -#endif break; #endif #if (HAS_SENSOR_2) diff --git a/src/sensor.cpp b/src/sensor.cpp index 21f212f5..2d077175 100644 --- a/src/sensor.cpp +++ b/src/sensor.cpp @@ -2,12 +2,6 @@ #include "globals.h" #include "sensor.h" -#if (COUNT_ENS) -#include "payload.h" -#include "corona.h" -extern PayloadConvert payload; -#endif - // Local logging tag static const char TAG[] = __FILE__; @@ -53,16 +47,10 @@ uint8_t *sensor_read(uint8_t sensor) { case 1: // insert user specific sensor data frames here - // note: Sensor1 fields are used for ENS count, if ENS detection enabled -#if (COUNT_ENS) - if (cfg.enscount) - payload.addCount(cwa_report(), MAC_SNIFF_BLE_ENS); -#else buf[0] = length; buf[1] = 0x01; buf[2] = 0x02; buf[3] = 0x03; -#endif break; case 2: