From 74239d77f4e57c720de25c27c815386a50b1ca94 Mon Sep 17 00:00:00 2001 From: Oliver Seiler Date: Sun, 27 Sep 2020 17:35:27 +1300 Subject: [PATCH 1/7] Fix: issue #639, if no LORA time source available and GPS time in first call is invalid, then time will never get updated from GPS https://github.com/cyberman54/ESP32-Paxcounter/issues/639 --- src/timekeeper.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/timekeeper.cpp b/src/timekeeper.cpp index 6d8439ec..1c65d9a1 100644 --- a/src/timekeeper.cpp +++ b/src/timekeeper.cpp @@ -35,8 +35,10 @@ void calibrateTime(void) { timesync_request(); #endif - // (only!) if we lost time, we try to fallback to local time source RTS or GPS - if (timeSource == _unsynced) { + // if no LORA timesource is available, or if we lost time, then fallback to + // local time source RTS or GPS + if (((!TIME_SYNC_LORASERVER) && (!TIME_SYNC_LORAWAN)) || + (timeSource == _unsynced)) { // has RTC -> fallback to RTC time #ifdef HAS_RTC @@ -47,7 +49,10 @@ void calibrateTime(void) { // no RTC -> fallback to GPS time #if (HAS_GPS) t = get_gpstime(&t_msec); - timeSource = _gps; + if (t) { + // only set time source to GPS if GPS time was actually valid + timeSource = _gps; + } #endif if (t) From 53570d7ccfad2b73ae5a0b1be147729e1d95cc13 Mon Sep 17 00:00:00 2001 From: Oliver Seiler Date: Sun, 27 Sep 2020 18:19:02 +1300 Subject: [PATCH 2/7] Add sub band channel selection for AU915 Also see https://github.com/mcci-catena/arduino-lmic/commits/master/examples/ttn-abp/ttn-abp.ino --- src/loraconf_abp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/loraconf_abp.cpp b/src/loraconf_abp.cpp index 76de2f73..675b90fa 100644 --- a/src/loraconf_abp.cpp +++ b/src/loraconf_abp.cpp @@ -39,8 +39,8 @@ void setABPParameters() { // devices' ping slots. LMIC does not have an easy way to define set this // frequency and support for class B is spotty and untested, so this // frequency is not configured here. - #elif defined(CFG_us915) - // NA-US channels 0-71 are configured automatically + #elif defined(CFG_us915) || defined(CFG_au915) + // NA-US and AU channels 0-71 are configured automatically // but only one group of 8 should (a subband) should be active // TTN recommends the second sub band, 1 in a zero based count. // https://github.com/TheThingsNetwork/gateway-conf/blob/master/US-global_conf.json From 19710bae4b9a6b964bb77703fc4f7070a5e2e29f Mon Sep 17 00:00:00 2001 From: Oliver Seiler Date: Sun, 27 Sep 2020 20:39:02 +1300 Subject: [PATCH 3/7] Fixing issue #639 in a better way, that ensures TIME_SYNC_INTERVAL_RETRY is used over TIME_SYNC_INTERVAL when GPS time was invalid --- src/timekeeper.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/timekeeper.cpp b/src/timekeeper.cpp index 1c65d9a1..bc9e52b5 100644 --- a/src/timekeeper.cpp +++ b/src/timekeeper.cpp @@ -49,14 +49,10 @@ void calibrateTime(void) { // no RTC -> fallback to GPS time #if (HAS_GPS) t = get_gpstime(&t_msec); - if (t) { - // only set time source to GPS if GPS time was actually valid - timeSource = _gps; - } + timeSource = _gps; #endif - if (t) - setMyTime((uint32_t)t, t_msec, timeSource); // set time + setMyTime((uint32_t)t, t_msec, timeSource); // set time } // fallback From 5073c00f174630009a74eaaeba7e3d2ee6e57f8c Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 27 Sep 2020 18:00:28 +0200 Subject: [PATCH 4/7] sensor.cpp: comment for ENS count added --- src/sensor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sensor.cpp b/src/sensor.cpp index baebf9d1..3b5f9e2d 100644 --- a/src/sensor.cpp +++ b/src/sensor.cpp @@ -54,9 +54,10 @@ uint8_t *sensor_read(uint8_t sensor) { 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) - payload.addCount( cwa_report(), MAC_SNIFF_BLE_CWA); + payload.addCount(cwa_report(), MAC_SNIFF_BLE_CWA); #else buf[0] = length; buf[1] = 0x01; From 01f990d17f8429dd4c824fd62e145546c611ed6f Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 27 Sep 2020 18:03:12 +0200 Subject: [PATCH 5/7] fix issue#642 --- README.md | 4 ++-- src/senddata.cpp | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 0e09a505..2d18ce1e 100644 --- a/README.md +++ b/README.md @@ -282,8 +282,8 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering. **Port #1:** Paxcount data - byte 1-2: Number of unique devices, seen on Wifi - byte 3-4: Number of unique devices, seen on Bluetooth [ommited if BT disabled] + byte 1-2: Number of unique devices, seen on Wifi [00 00 if Wifi scan disabled] + byte 3-4: Number of unique devices, seen on Bluetooth [ommited if BT scan disabled] **Port #2:** Device status query result diff --git a/src/senddata.cpp b/src/senddata.cpp index 13b42927..a9ca74ea 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -56,12 +56,13 @@ void SendPayload(uint8_t port, sendprio_t prio) { // write data to sdcard, if present #if (HAS_SDCARD) - if ( port == COUNTERPORT ) { - sdcardWriteData(macs_wifi, macs_ble + if (port == COUNTERPORT) { + sdcardWriteData(macs_wifi, macs_ble #if (COUNT_ENS) - , cwa_report() -#endif - ); + , + cwa_report() +#endif + ); } #endif @@ -86,8 +87,7 @@ void sendData() { case COUNT_DATA: payload.reset(); #if !(PAYLOAD_OPENSENSEBOX) - if (cfg.wifiscan) - payload.addCount(macs_wifi, MAC_SNIFF_WIFI); + payload.addCount(macs_wifi, MAC_SNIFF_WIFI); if (cfg.blescan) payload.addCount(macs_ble, MAC_SNIFF_BLE); #endif @@ -102,8 +102,7 @@ void sendData() { } #endif #if (PAYLOAD_OPENSENSEBOX) - if (cfg.wifiscan) - payload.addCount(macs_wifi, MAC_SNIFF_WIFI); + payload.addCount(macs_wifi, MAC_SNIFF_WIFI); if (cfg.blescan) payload.addCount(macs_ble, MAC_SNIFF_BLE); #endif From 44b990be38f3b093de6f9a30ebed18e98171c921 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 27 Sep 2020 18:19:16 +0200 Subject: [PATCH 6/7] ttgobean.h removed display default on --- src/hal/ttgobeam.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hal/ttgobeam.h b/src/hal/ttgobeam.h index 7451a5b3..61547adc 100644 --- a/src/hal/ttgobeam.h +++ b/src/hal/ttgobeam.h @@ -33,7 +33,7 @@ //#define BME680_ADDR BME680_I2C_ADDR_PRIMARY // !! connect SDIO of BME680 to GND !! // display (if connected) -#define HAS_DISPLAY 1 +//#define HAS_DISPLAY 1 #define MY_DISPLAY_SDA SDA #define MY_DISPLAY_SCL SCL #define MY_DISPLAY_RST NOT_A_PIN From 14921ee266e1518c826bbfac608848016a6d93f8 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 27 Sep 2020 18:23:48 +0200 Subject: [PATCH 7/7] macsniff.cpp: reduce logging on level debug --- src/macsniff.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/macsniff.cpp b/src/macsniff.cpp index 4ba08575..90f29a79 100644 --- a/src/macsniff.cpp +++ b/src/macsniff.cpp @@ -116,7 +116,7 @@ uint16_t mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) { } // added // Log scan result - ESP_LOGD(TAG, + ESP_LOGV(TAG, "%s %s RSSI %ddBi -> salted MAC %s -> Hash %04X -> WiFi:%d " "BLTH:%d " #if (COUNT_ENS)