PR #653 merged and added some corrections

This commit is contained in:
Klaus K Wilting 2020-10-05 13:56:41 +02:00
parent ae80ac7f7f
commit 092842a4c0
9 changed files with 47 additions and 68 deletions

View File

@ -11,7 +11,7 @@
#include "sds011read.h"
#include "sdcard.h"
extern Ticker housekeeper;
extern Ticker cyclicTimer;
void setCyclicIRQ(void);
void doHousekeeping(void);

View File

@ -82,11 +82,11 @@ typedef struct __attribute__((packed)) {
uint8_t monitormode; // 0=disabled, 1=enabled
uint8_t runmode; // 0=normal, 1=update
uint8_t payloadmask; // bitswitches for payload data
uint8_t enscount; // 0=disabled 1= enabled
#ifdef HAS_BME680
uint8_t bsecstate[BSEC_MAX_STATE_BLOB_SIZE + 1]; // BSEC state for BME680 sensor
uint8_t
bsecstate[BSEC_MAX_STATE_BLOB_SIZE + 1]; // BSEC state for BME680 sensor
#endif
} configData_t;

View File

@ -168,12 +168,13 @@ IRAM_ATTR void gap_callback_handler(esp_gap_ble_cb_event_t event,
mac_add((uint8_t *)p->scan_rst.bda, p->scan_rst.rssi, MAC_SNIFF_BLE);
if (cfg.enscount){
// check for ens signature
#if (COUNT_ENS)
if (cfg.enscount) {
// check for ens signature
if (NULL != strstr((const char *)p->scan_rst.ble_adv, ensMagicBytes))
cwa_mac_add(hashedmac);
cwa_mac_add(hashedmac);
}
#endif
/* to be improved in vendorfilter if:
// you can search for elements in the payload using the

View File

@ -49,12 +49,11 @@ static void defaultConfig(configData_t *myconfig) {
myconfig->blescan = 1; // 0=disabled, 1=enabled
myconfig->wifiscan = 1; // 0=disabled, 1=enabled
myconfig->wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
myconfig->vendorfilter = VENDORFILTER; // 0=disabled, 1=enabled
myconfig->rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%)
myconfig->monitormode = 0; // 0=disabled, 1=enabled
myconfig->payloadmask = PAYLOADMASK; // all payload switched on
myconfig->enscount =0; // 0= disabled, 1 = enabled
myconfig->vendorfilter = VENDORFILTER; // 0=disabled, 1=enabled
myconfig->rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%)
myconfig->monitormode = 0; // 0=disabled, 1=enabled
myconfig->payloadmask = PAYLOADMASK; // all payload switched on
myconfig->enscount = 0; // 0=disabled, 1=enabled
#ifdef HAS_BME680
// initial BSEC state for BME680 sensor

View File

@ -7,7 +7,7 @@
// Local logging tag
static const char TAG[] = __FILE__;
Ticker housekeeper;
Ticker cyclicTimer;
#if (HAS_SDS011)
extern boolean isSDS011Active;
@ -150,7 +150,7 @@ uint32_t getFreeRAM() {
void reset_counters() {
#if ((WIFICOUNTER) || (BLECOUNTER))
macs.clear(); // clear all macs container
macs.clear(); // clear all macs container
macs_wifi = 0;
macs_ble = 0;
#ifdef HAS_DISPLAY

View File

@ -1,6 +1,6 @@
// clang-format off
// upload_speed 921600
// board esp32dev
// board ttgo-lora32-v21new
#ifndef _TTGOV21NEW_H
#define _TTGOV21NEW_H

View File

@ -486,7 +486,7 @@ void setup() {
// cyclic function interrupts
sendTimer.attach(cfg.sendcycle * 2, setSendIRQ);
housekeeper.attach(HOMECYCLE, setCyclicIRQ);
cyclicTimer.attach(HOMECYCLE, setCyclicIRQ);
#if (TIME_SYNC_INTERVAL)

View File

@ -340,54 +340,35 @@ void set_flush(uint8_t val[]) {
};
void set_enscount(uint8_t val[]) {
ESP_LOGI(TAG, "Remote command: set ENS_COUNT to %s",
val[0] ? "on" : "off");
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 |= SENSOR1_DATA;
else
cfg.payloadmask &= ~SENSOR1_DATA;
if (val[0])
cfg.payloadmask |= SENSOR1_DATA;
else
cfg.payloadmask &= ~SENSOR1_DATA;
}
// assign previously defined functions to set of numeric remote commands
// format: opcode, function, #bytes params,
// flag (true = do make settings persistent / false = don't)
//
static const cmd_t table[] = {
{0x01, set_rssi, 1, true},
{0x02, set_countmode, 1, true},
{0x03, set_gps, 1, true},
{0x04, set_display, 1, true},
{0x05, set_loradr, 1, true},
{0x06, set_lorapower, 1, true},
{0x07, set_loraadr, 1, true},
{0x08, set_screensaver, 1, true},
{0x09, set_reset, 1, false},
{0x0a, set_sendcycle, 1, true},
{0x0b, set_wifichancycle, 1, true},
{0x0c, set_blescantime, 1, true},
{0x0d, set_vendorfilter, 1, false},
{0x0e, set_blescan, 1, true},
{0x0f, set_wifiant, 1, true},
{0x10, set_rgblum, 1, true},
{0x11, set_monitor, 1, true},
{0x12, set_beacon, 7, false},
{0x13, set_sensor, 2, true},
{0x14, set_payloadmask, 1, true},
{0x15, set_bme, 1, true},
{0x16, set_batt, 1, true},
{0x17, set_wifiscan, 1, true},
{0x18, set_enscount, 1, true},
{0x80, get_config, 0, false},
{0x81, get_status, 0, false},
{0x83, get_batt, 0, false},
{0x84, get_gps, 0, false},
{0x85, get_bme, 0, false},
{0x86, get_time, 0, false},
{0x87, set_time, 0, false},
{0x99, set_flush, 0, false}};
// assign previously defined functions to set of numeric remote commands
// format: opcode, function, #bytes params,
// flag (true = do make settings persistent / false = don't)
//
static const cmd_t table[] = {
{0x01, set_rssi, 1, true}, {0x02, set_countmode, 1, true},
{0x03, set_gps, 1, true}, {0x04, set_display, 1, true},
{0x05, set_loradr, 1, true}, {0x06, set_lorapower, 1, true},
{0x07, set_loraadr, 1, true}, {0x08, set_screensaver, 1, true},
{0x09, set_reset, 1, false}, {0x0a, set_sendcycle, 1, true},
{0x0b, set_wifichancycle, 1, true}, {0x0c, set_blescantime, 1, true},
{0x0d, set_vendorfilter, 1, false}, {0x0e, set_blescan, 1, true},
{0x0f, set_wifiant, 1, true}, {0x10, set_rgblum, 1, true},
{0x11, set_monitor, 1, true}, {0x12, set_beacon, 7, false},
{0x13, set_sensor, 2, true}, {0x14, set_payloadmask, 1, true},
{0x15, set_bme, 1, true}, {0x16, set_batt, 1, true},
{0x17, set_wifiscan, 1, true}, {0x18, set_enscount, 1, true},
{0x80, get_config, 0, false}, {0x81, get_status, 0, false},
{0x83, get_batt, 0, false}, {0x84, get_gps, 0, false},
{0x85, get_bme, 0, false}, {0x86, get_time, 0, false},
{0x87, set_time, 0, false}, {0x99, set_flush, 0, false}};
static const uint8_t cmdtablesize =
sizeof(table) / sizeof(table[0]); // number of commands in command table

View File

@ -56,16 +56,14 @@ uint8_t *sensor_read(uint8_t sensor) {
// 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_CWA);
#if (COUNT_ENS)
if (cfg.enscount)
payload.addCount(cwa_report(), MAC_SNIFF_BLE_CWA);
#else
if(!cfg.enscount)
buf[0] = length;
buf[1] = 0x01;
buf[2] = 0x02;
buf[3] = 0x03;
#endif
break;
case 2: