From bb227b525b582c7efb23e7d5977af958252bdd64 Mon Sep 17 00:00:00 2001 From: nerdyscout Date: Thu, 21 Nov 2019 17:04:55 +0000 Subject: [PATCH 1/5] additional decoder for short latLon on port4 --- src/TTN/packed_decoder.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/TTN/packed_decoder.js b/src/TTN/packed_decoder.js index bf2c3b39..0624d885 100644 --- a/src/TTN/packed_decoder.js +++ b/src/TTN/packed_decoder.js @@ -50,7 +50,11 @@ function Decoder(bytes, port) { if (port === 4) { // gps data - return decode(bytes, [latLng, latLng, uint8, hdop, altitude], ['latitude', 'longitude', 'sats', 'hdop', 'altitude']); + if (bytes.length === 8) { + return decode(bytes, [latLng, latLng], ['latitude', 'longitude']); + } else { + return decode(bytes, [latLng, latLng, uint8, hdop, altitude], ['latitude', 'longitude', 'sats', 'hdop', 'altitude']); + } } if (port === 5) { From 4d12aa7cecfa78b9eef0d0be741b84fc321f2035 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 27 Oct 2019 16:13:33 +0100 Subject: [PATCH 2/5] bugfix reset runmode logic --- src/reset.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/reset.cpp b/src/reset.cpp index 0fa965d3..94f6626d 100644 --- a/src/reset.cpp +++ b/src/reset.cpp @@ -34,8 +34,15 @@ void do_after_reset(int reason) { RTC_runmode = RUNMODE_POWERCYCLE; break; + case SW_CPU_RESET: // 0x0c Software reset CPU + // keep previous runmode (could be RUNMODE_UPDATE) + break; + case DEEPSLEEP_RESET: // 0x05 Deep Sleep reset digital core RTC_runmode = RUNMODE_WAKEUP; +#if (HAS_LORA) + // to be done: restore LoRaWAN channel configuration and datarate here +#endif break; case SW_RESET: // 0x03 Software reset digital core @@ -46,11 +53,11 @@ void do_after_reset(int reason) { case RTCWDT_SYS_RESET: // 0x09 RTC Watch dog Reset digital core case INTRUSION_RESET: // 0x0a Instrusion tested to reset CPU case TGWDT_CPU_RESET: // 0x0b Time Group reset CPU - case SW_CPU_RESET: // 0x0c Software reset CPU case RTCWDT_CPU_RESET: // 0x0d RTC Watch dog Reset CPU case EXT_CPU_RESET: // 0x0e for APP CPU, reseted by PRO CPU case RTCWDT_RTC_RESET: // 0x10 RTC Watch dog reset digital core and rtc mode default: + RTC_runmode = RUNMODE_POWERCYCLE; break; } @@ -66,6 +73,9 @@ void enter_deepsleep(const int wakeup_sec, const gpio_num_t wakeup_gpio) { #if (HAS_LORA) if (os_queryTimeCriticalJobs(ms2osticks(10000))) return; + + // to be done: save LoRaWAN channel configuration here + #endif // set up power domains From b5c5e3ce47681511c87f177b8a8fffb1c3d4f8af Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 27 Oct 2019 17:33:23 +0100 Subject: [PATCH 3/5] ota.cpp bugfix led define --- src/ota.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ota.cpp b/src/ota.cpp index d78a6453..087b92e7 100644 --- a/src/ota.cpp +++ b/src/ota.cpp @@ -246,7 +246,7 @@ int do_ota_update() { goto retry; } -#ifdef HAS_LED +#if (HAS_LED != NOT_A_PIN) #ifndef LED_ACTIVE_LOW if (!Update.begin(contentLength, U_FLASH, HAS_LED, HIGH)) { #else From 28d9def1d49da6041d340b0370b2eaa5565160eb Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Fri, 8 Nov 2019 23:05:28 +0100 Subject: [PATCH 4/5] disable LMIC onEvent() --- src/lmic_config.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lmic_config.h b/src/lmic_config.h index fb3a5816..dc55260a 100644 --- a/src/lmic_config.h +++ b/src/lmic_config.h @@ -21,7 +21,10 @@ #define LMIC_USE_INTERRUPTS 1 // time sync via LoRaWAN network, note: not supported by TTNv2 -// #define LMIC_ENABLE_DeviceTimeReq 1 +//#define LMIC_ENABLE_DeviceTimeReq 1 + +// use callback event handlers, not onEvent() reference +#define LMIC_ENABLE_onEvent 0 // This tells LMIC to make the receive windows bigger, in case your clock is // faster or slower. This causes the transceiver to be earlier switched on, From 2252d65375e548ff2070d46e96cffc4fcf0a526e Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Fri, 8 Nov 2019 23:06:31 +0100 Subject: [PATCH 5/5] TTN settings for join --- src/lorawan.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lorawan.cpp b/src/lorawan.cpp index 8b787580..ff8ecfe7 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -89,9 +89,7 @@ void lora_setupForNetwork(bool preJoin) { // other regions, this will need to be changed. LMIC_selectSubBand(1); #elif CFG_LMIC_EU_like - // setting for TheThingsNetwork - // TTN uses SF9, not SF12, for RX2 window - LMIC.dn2Dr = EU868_DR_SF9; + // settings for TheThingsNetwork // Enable link check validation LMIC_setLinkCheckMode(true); #endif