remove unused ENS/CWA code

This commit is contained in:
cyberman54 2022-01-28 22:17:17 +01:00
parent efca209795
commit db60afe05d
18 changed files with 9 additions and 167 deletions

View File

@ -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:<br> 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"}]` This describes how to set up a mobile PaxCounter:<br> 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 <A HREF="https://linux-fuer-wi.blogspot.com/2020/10/suche-die-zahl-64879.html">gives an indication</A> 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 # 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: 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 **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 # 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 0x02 = RESERVED_DATA
0x04 = MEMS_DATA 0x04 = MEMS_DATA
0x08 = GPS_DATA 0x08 = GPS_DATA
0x10 = SENSOR_1_DATA (also ENS counter) 0x10 = SENSOR_1_DATA
0x20 = SENSOR_2_DATA 0x20 = SENSOR_2_DATA
0x40 = SENSOR_3_DATA 0x40 = SENSOR_3_DATA
0x80 = BATT_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 0 = disabled
1 = enabled [default] 1 = enabled [default]
0x18 set ENS counter on/off 0x18 reserved
0 = disabled [default] unused, does nothing
1 = enabled
0x19 set sleep cycle 0x19 set sleep cycle
@ -622,4 +612,4 @@ Thanks to
- [terrillmoore](https://github.com/mcci-catena) for maintaining the LMIC for arduino LoRaWAN stack - [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 - [sbamueller](https://github.com/sbamueller) for writing the tutorial in Make Magazine
- [Stefan](https://github.com/nerdyscout) for paxcounter opensensebox integration - [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

View File

@ -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 <map>
bool cwa_init(void);
void cwa_mac_add(uint16_t hashedmac);
void cwa_clear(void);
uint16_t cwa_report(void);
#endif

View File

@ -6,10 +6,6 @@
#include "qrcode.h" #include "qrcode.h"
#include "power.h" #include "power.h"
#if (COUNT_ENS)
#include "corona.h"
#endif
#if (HAS_DISPLAY) == 1 #if (HAS_DISPLAY) == 1
#include <OneBitDisplay.h> #include <OneBitDisplay.h>
#elif (HAS_DISPLAY) == 2 #elif (HAS_DISPLAY) == 2

View File

@ -71,7 +71,6 @@ typedef struct __attribute__((packed)) {
uint8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4) uint8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4)
uint8_t rgblum; // RGB Led luminosity (0..100%) uint8_t rgblum; // RGB Led luminosity (0..100%)
uint8_t payloadmask; // bitswitches for payload data uint8_t payloadmask; // bitswitches for payload data
uint8_t enscount; // 0=disabled 1= enabled
#ifdef HAS_BME680 #ifdef HAS_BME680
uint8_t uint8_t

View File

@ -18,7 +18,6 @@
#include "sensor.h" #include "sensor.h"
#include "lorawan.h" #include "lorawan.h"
#include "timekeeper.h" #include "timekeeper.h"
#include "corona.h"
#include "boot.h" #include "boot.h"
#include "libpax_helpers.h" #include "libpax_helpers.h"
#include "power.h" #include "power.h"

View File

@ -10,10 +10,6 @@
#include "display.h" #include "display.h"
#include "sdcard.h" #include "sdcard.h"
#if (COUNT_ENS)
#include "corona.h"
#endif
extern struct count_payload_t count_from_libpax; extern struct count_payload_t count_from_libpax;
void SendPayload(uint8_t port); void SendPayload(uint8_t port);

View File

@ -84,11 +84,6 @@ function Decoder(bytes, port) {
} }
} }
if (port === 10) {
// ENS count
return decode(bytes, [uint16], ['ens']);
}
} }

View File

@ -91,11 +91,6 @@ function decodeUplink(input) {
} }
} }
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.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 data.port = input.fPort; // comment out if you do not want to inlude the port

View File

@ -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) { if (data.hdop) {
data.hdop /= 100; data.hdop /= 100;
data.latitude /= 1000000; data.latitude /= 1000000;

View File

@ -57,7 +57,6 @@ static void defaultConfig(configData_t *myconfig) {
myconfig->wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4) myconfig->wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
myconfig->rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%) myconfig->rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%)
myconfig->payloadmask = PAYLOADMASK; // payloads as defined in default myconfig->payloadmask = PAYLOADMASK; // payloads as defined in default
myconfig->enscount = COUNT_ENS; // 0=disabled, 1=enabled
#ifdef HAS_BME680 #ifdef HAS_BME680
// initial BSEC state for BME680 sensor // initial BSEC state for BME680 sensor

View File

@ -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<uint16_t, unsigned long> 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 &notifier : 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

View File

@ -268,11 +268,6 @@ void dp_drawPage(bool nextpage) {
else else
dp_printf("WIFI:off"); dp_printf("WIFI:off");
if (cfg.blescan) 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 else
dp_printf(" BLTH:off"); dp_printf(" BLTH:off");
@ -284,11 +279,6 @@ void dp_drawPage(bool nextpage) {
#elif ((!WIFICOUNTER) && (BLECOUNTER)) #elif ((!WIFICOUNTER) && (BLECOUNTER))
if (cfg.blescan) if (cfg.blescan)
dp_printf("BLTH:%-5d", count_from_libpax.ble_count); 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 #else
dp_printf("Sniffer disabled"); dp_printf("Sniffer disabled");

View File

@ -91,11 +91,6 @@ function decodeUplink(input) {
} }
} }
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.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 data.port = input.fPort; // comment out if you do not want to inlude the port

View File

@ -337,15 +337,9 @@ void setup() {
// initialize sensors // initialize sensors
#if (HAS_SENSORS) #if (HAS_SENSORS)
#if (HAS_SENSOR_1) #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)"); strcat_P(features, " SENS(1)");
sensor_init(); sensor_init();
#endif #endif
#endif
#if (HAS_SENSOR_2) #if (HAS_SENSOR_2)
strcat_P(features, " SENS(2)"); strcat_P(features, " SENS(2)");
sensor_init(); sensor_init();

View File

@ -27,10 +27,6 @@
#define BLESCANWINDOW 80 // [milliseconds] scan window, see below, 3 .. 10240, default 80ms #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 #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 /* Note: guide for setting bluetooth parameters
* *
* |< Scan Window > |< Scan Window > | ... |< Scan Window > | * |< Scan Window > |< Scan Window > | ... |< Scan Window > |

View File

@ -397,15 +397,6 @@ void set_flush(uint8_t val[]) {
// used to open receive window on LoRaWAN class a nodes // 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[]) { void set_loadconfig(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: load config from NVRAM"); ESP_LOGI(TAG, "Remote command: load config from NVRAM");
loadConfig(); loadConfig();
@ -430,7 +421,7 @@ static const cmd_t table[] = {
{0x10, set_rgblum, 1}, {0x13, set_sensor, 2}, {0x10, set_rgblum, 1}, {0x13, set_sensor, 2},
{0x14, set_payloadmask, 1}, {0x15, set_bme, 1}, {0x14, set_payloadmask, 1}, {0x15, set_bme, 1},
{0x16, set_batt, 1}, {0x17, set_wifiscan, 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}, {0x20, set_loadconfig, 0}, {0x21, set_saveconfig, 0},
{0x80, get_config, 0}, {0x81, get_status, 0}, {0x80, get_config, 0}, {0x81, get_status, 0},
{0x83, get_batt, 0}, {0x84, get_gps, 0}, {0x83, get_batt, 0}, {0x84, get_gps, 0},

View File

@ -159,10 +159,6 @@ void sendData() {
payload.reset(); payload.reset();
payload.addSensor(sensor_read(1)); payload.addSensor(sensor_read(1));
SendPayload(SENSOR1PORT); SendPayload(SENSOR1PORT);
#if (COUNT_ENS)
if (cfg.countermode != 1)
cwa_clear();
#endif
break; break;
#endif #endif
#if (HAS_SENSOR_2) #if (HAS_SENSOR_2)

View File

@ -2,12 +2,6 @@
#include "globals.h" #include "globals.h"
#include "sensor.h" #include "sensor.h"
#if (COUNT_ENS)
#include "payload.h"
#include "corona.h"
extern PayloadConvert payload;
#endif
// Local logging tag // Local logging tag
static const char TAG[] = __FILE__; static const char TAG[] = __FILE__;
@ -53,16 +47,10 @@ uint8_t *sensor_read(uint8_t sensor) {
case 1: case 1:
// insert user specific sensor data frames here // 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[0] = length;
buf[1] = 0x01; buf[1] = 0x01;
buf[2] = 0x02; buf[2] = 0x02;
buf[3] = 0x03; buf[3] = 0x03;
#endif
break; break;
case 2: case 2: