From ecb94ab243b815c8ec82686de53be9a1bdf66be5 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 9 Jan 2021 15:32:11 +0100 Subject: [PATCH 1/6] small patch display mask last row --- src/display.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index 3b7bb01b..b8f4c9cc 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -345,10 +345,10 @@ void dp_drawPage(time_t t, bool nextpage) { #if (HAS_LORA) // LMiC event display - dp_printf("%-16s", lmic_event_msg); + dp_printf("%-16s ", lmic_event_msg); // LORA datarate, display inverse if ADR disabled dp_setFont(MY_FONT_SMALL, !cfg.adrmode); - dp_printf(" %-4s", getSfName(updr2rps(LMIC.datarate))); + dp_printf("%-4s", getSfName(updr2rps(LMIC.datarate))); dp_setFont(MY_FONT_SMALL, 0); dp_println(); #endif // HAS_LORA From 241a19148b6fad0b2a9793d44903fbe00b8c2d2b Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 9 Jan 2021 23:52:08 +0100 Subject: [PATCH 2/6] fix bitshift in payload + configmask --- include/globals.h | 32 ++++++++++++++++---------------- src/TTN/packed_decoder.js | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/globals.h b/include/globals.h index c8755412..1818b976 100644 --- a/include/globals.h +++ b/include/globals.h @@ -22,24 +22,24 @@ #define _bitl(b) (1UL << (b)) // bits in payloadmask for filtering payload data -#define COUNT_DATA _bit(1) -#define ALARM_DATA _bit(2) -#define MEMS_DATA _bit(3) -#define GPS_DATA _bit(4) -#define SENSOR1_DATA _bit(5) -#define SENSOR2_DATA _bit(6) -#define SENSOR3_DATA _bit(7) -#define BATT_DATA _bit(8) +#define COUNT_DATA _bit(0) +#define ALARM_DATA _bit(1) +#define MEMS_DATA _bit(2) +#define GPS_DATA _bit(3) +#define SENSOR1_DATA _bit(4) +#define SENSOR2_DATA _bit(5) +#define SENSOR3_DATA _bit(6) +#define BATT_DATA _bit(7) // bits in configmask for device runmode control -#define GPS_MODE _bit(1) -#define ALARM_MODE _bit(2) -#define BEACON_MODE _bit(3) -#define UPDATE_MODE _bit(4) -#define FILTER_MODE _bit(5) -#define ANTENNA_MODE _bit(6) -#define BLE_MODE _bit(7) -#define SCREEN_MODE _bit(8) +#define GPS_MODE _bit(0) +#define ALARM_MODE _bit(1) +#define BEACON_MODE _bit(2) +#define UPDATE_MODE _bit(3) +#define FILTER_MODE _bit(4) +#define ANTENNA_MODE _bit(5) +#define BLE_MODE _bit(6) +#define SCREEN_MODE _bit(7) // length of display buffer for lmic event messages #define LMIC_EVENTMSG_LEN 17 diff --git a/src/TTN/packed_decoder.js b/src/TTN/packed_decoder.js index ee61706e..e8666a02 100644 --- a/src/TTN/packed_decoder.js +++ b/src/TTN/packed_decoder.js @@ -262,7 +262,7 @@ var bitmap2 = function (byte) { } var i = bytesToInt(byte); var bm = ('00000000' + Number(i).toString(2)).substr(-8).split('').map(Number).map(Boolean); - return ['battery', 'sensor3', 'sensor2', 'sensor1', 'counter', 'bme', 'alarm', 'gps'] + return ['battery', 'sensor3', 'sensor2', 'sensor1', 'gps', 'bme', 'alarm', 'counter'] .reduce(function (obj, pos, index) { obj[pos] = +bm[index]; return obj; From 69a62166656e34b9deece50a4367413644377231 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 9 Jan 2021 23:52:29 +0100 Subject: [PATCH 3/6] fix bitshift in irq mask --- include/irqhandler.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/irqhandler.h b/include/irqhandler.h index 9e52ccbf..5d40c63c 100644 --- a/include/irqhandler.h +++ b/include/irqhandler.h @@ -1,16 +1,16 @@ #ifndef _IRQHANDLER_H #define _IRQHANDLER_H -#define DISPLAY_IRQ _bitl(1) -#define BUTTON_IRQ _bitl(2) -#define SENDCYCLE_IRQ _bitl(3) -#define CYCLIC_IRQ _bitl(4) -#define TIMESYNC_IRQ _bitl(5) -#define MASK_IRQ _bitl(6) -#define UNMASK_IRQ _bitl(7) -#define BME_IRQ _bitl(8) -#define MATRIX_DISPLAY_IRQ _bitl(9) -#define PMU_IRQ _bitl(10) +#define DISPLAY_IRQ _bitl(0) +#define BUTTON_IRQ _bitl(1) +#define SENDCYCLE_IRQ _bitl(2) +#define CYCLIC_IRQ _bitl(3) +#define TIMESYNC_IRQ _bitl(4) +#define MASK_IRQ _bitl(5) +#define UNMASK_IRQ _bitl(6) +#define BME_IRQ _bitl(7) +#define MATRIX_DISPLAY_IRQ _bitl(8) +#define PMU_IRQ _bitl(9) #include "globals.h" #include "button.h" From 144b59fb575f94be6545d75e8be39f06a36b986f Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sun, 10 Jan 2021 00:34:31 +0100 Subject: [PATCH 4/6] remove unneeded defines from globals.h --- include/globals.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/include/globals.h b/include/globals.h index 1818b976..adddd3ab 100644 --- a/include/globals.h +++ b/include/globals.h @@ -31,16 +31,6 @@ #define SENSOR3_DATA _bit(6) #define BATT_DATA _bit(7) -// bits in configmask for device runmode control -#define GPS_MODE _bit(0) -#define ALARM_MODE _bit(1) -#define BEACON_MODE _bit(2) -#define UPDATE_MODE _bit(3) -#define FILTER_MODE _bit(4) -#define ANTENNA_MODE _bit(5) -#define BLE_MODE _bit(6) -#define SCREEN_MODE _bit(7) - // length of display buffer for lmic event messages #define LMIC_EVENTMSG_LEN 17 From 66d9ef0f4d7d9b793c5534f8979c8de8d78b8f56 Mon Sep 17 00:00:00 2001 From: HouzuoGuo Date: Sun, 10 Jan 2021 11:48:00 +0200 Subject: [PATCH 5/6] Enrich the debug-level log message with reading of timestamp at program compilation as well as GPS time reading when the board time fails to sync with GPS. This helps user to debug time synchronisation failure stemmed from a mismatch of developer's time zone and board's time zone. --- src/gpsread.cpp | 4 ++-- src/timekeeper.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gpsread.cpp b/src/gpsread.cpp index a29d9c9f..a38a175d 100644 --- a/src/gpsread.cpp +++ b/src/gpsread.cpp @@ -119,8 +119,8 @@ time_t get_gpstime(uint16_t *msec) { tm.Year = CalendarYrToTm(atoi(gpsyear.value())); // year offset from 1970 t = makeTime(tm); - // ESP_LOGD(TAG, "GPS time/date = %2d:%2d:%2d / %2d.%2d.%2d", tm.Hour, - // tm.Minute, tm.Second, tm.Day, tm.Month, tm.Year + 1970); + ESP_LOGD(TAG, "GPS time/date = %2d:%2d:%2d / %2d.%2d.%2d", tm.Hour, + tm.Minute, tm.Second, tm.Day, tm.Month, tm.Year + 1970); // add protocol delay with millisecond precision t += delay_ms / 1000 - 1; // whole seconds diff --git a/src/timekeeper.cpp b/src/timekeeper.cpp index e4c08a89..f49adc7c 100644 --- a/src/timekeeper.cpp +++ b/src/timekeeper.cpp @@ -109,8 +109,9 @@ void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec, _seconds(), timeSetSymbols[mytimesource]); } else { timesyncer.attach(TIME_SYNC_INTERVAL_RETRY * 60, setTimeSyncIRQ); - ESP_LOGD(TAG, "[%0.3f] Timesync failed, invalid time fetched | source: %c", - _seconds(), timeSetSymbols[mytimesource]); + time_t unix_sec_at_compilation = compiledUTC(); + ESP_LOGD(TAG, "[%0.3f] Failed to synchronise time from source %c | unix sec obtained from source: %d | unix sec at program compilation: %d", + _seconds(), timeSetSymbols[mytimesource], time_to_set, unix_sec_at_compilation); } } From 555cf4138080faeaa8f708249a20245ce67a7360 Mon Sep 17 00:00:00 2001 From: HouzuoGuo Date: Sun, 10 Jan 2021 13:36:54 +0200 Subject: [PATCH 6/6] Increase release version from 2.1.1 to 2.2.0. This is necessary after having changed the payload type definition bits recently. By increasing the release number, the setup function will erase memorised and non-compatible enabled payload bits. --- platformio_orig.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio_orig.ini b/platformio_orig.ini index a6cf1ac7..a39cc315 100644 --- a/platformio_orig.ini +++ b/platformio_orig.ini @@ -47,7 +47,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I [common] ; for release_version use max. 10 chars total, use any decimal format like "a.b.c" -release_version = 2.1.1 +release_version = 2.2.0 ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose debug_level = 3 @@ -135,4 +135,4 @@ upload_protocol = esptool [env:dev] upload_protocol = esptool build_type = debug -platform = https://github.com/platformio/platform-espressif32.git#develop \ No newline at end of file +platform = https://github.com/platformio/platform-espressif32.git#develop