From 4a1f36069773da31b2d75b4680775a1d44a63f02 Mon Sep 17 00:00:00 2001 From: Tim Kerby Date: Mon, 13 Jan 2020 17:14:09 +0000 Subject: [PATCH] Bug fixes - frame counter, link checking and battery charge status Fixed frame counter (was unsigned char, should have been uint_32) which caused TTN to ignore device after 255 frames and rollover when frame count checks enabled Turned off link checking when ADR not in use as it was forcing confirmed links Added display of battery charging status --- .gitignore | 3 +++ main/main.ino | 3 +++ main/screen.ino | 1 + main/ttn.ino | 3 ++- 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5dc1407 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ + +main/configuration.h +main/credentials.h diff --git a/main/main.ino b/main/main.ino index 544920c..b848b23 100644 --- a/main/main.ino +++ b/main/main.ino @@ -263,6 +263,9 @@ void setup() { ttn_join(); ttn_sf(LORAWAN_SF); ttn_adr(LORAWAN_ADR); + if(!LORAWAN_ADR){ + LMIC_setLinkCheckMode(0); // Link check problematic if not using ADR. Must be set after join + } } void loop() { diff --git a/main/screen.ino b/main/screen.ino index f6ab07b..5cd6422 100644 --- a/main/screen.ino +++ b/main/screen.ino @@ -115,6 +115,7 @@ void screen_loop() { if (axp.isVbusRemoveIRQ()) { baChStatus = "No Charging"; } + Serial.println(baChStatus); //Prints charging status to screen digitalWrite(2, !digitalRead(2)); axp.clearIRQ(); } diff --git a/main/ttn.ino b/main/ttn.ino index 0cc7e15..60b80f2 100644 --- a/main/ttn.ino +++ b/main/ttn.ino @@ -230,9 +230,10 @@ void ttn_sf(unsigned char sf) { void ttn_adr(bool enabled) { LMIC_setAdrMode(enabled); + LMIC_setLinkCheckMode(!enabled); } -void ttn_cnt(unsigned char num) { +void ttn_cnt(uint32_t num) { LMIC_setSeqnoUp(num); }