From f512cfffb685db0324e493cb2137ec1625f2bd23 Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 1 Nov 2020 23:19:32 +0100 Subject: [PATCH 1/2] Fixed beacon timeout handling. --- platformio.ini | 3 +++ src/LoRa_APRS_Tracker.cpp | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index 3b4afe4..2e5fdc2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -19,6 +19,7 @@ lib_deps = APRS-Decoder-Lib 1655 AXP202X_Library + paulstoffregen/Time [env:ttgo-t-beam-v0_7] lib_deps = @@ -28,4 +29,6 @@ lib_deps = APRS-Decoder-Lib APRS-IS-Lib 1655 + paulstoffregen/Time + build_flags = -DARDUINO_T_Beam_V0_7 diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index c6b8960..b5456c5 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -8,6 +8,7 @@ #include "settings.h" #include "display.h" +#include #if !defined(ARDUINO_T_Beam_V0_7) void setup_axp(); @@ -22,6 +23,10 @@ String create_long_aprs(RawDegrees lng); void setup_lora(); +static time_t nowTimeStamp = -1; +static time_t nextUpdateTimeStamp = -1; +static bool send_update = true; + // cppcheck-suppress unusedFunction void setup() { @@ -60,23 +65,26 @@ void loop() gps.encode(c); } - static unsigned long next_update = -1; - static bool send_update = true; - bool gps_time_update = false; if(gps.time.isUpdated()) { gps_time_update = true; } - if(gps.time.isValid() && (next_update <= gps.time.minute() || next_update == -1)) + if(gps.time.isValid()) { - send_update = true; + setTime(gps.time.hour(),gps.time.minute(),gps.time.second(),gps.date.day(),gps.date.month(),gps.date.year()); + nowTimeStamp = now(); + + if (nextUpdateTimeStamp <= nowTimeStamp || nextUpdateTimeStamp == -1) + { + send_update = true; + } } if(send_update && gps.location.isValid() && gps.location.isUpdated()) { - next_update = (gps.time.minute() + BEACON_TIMEOUT) % 60; + nextUpdateTimeStamp = nowTimeStamp + (BEACON_TIMEOUT * 60); send_update = false; APRSMessage msg; From 00fe727f558cc193105398959a534c8ace853121 Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 1 Nov 2020 23:19:32 +0100 Subject: [PATCH 2/2] Fixed beacon timeout handling. --- platformio.ini | 1 + src/LoRa_APRS_Tracker.cpp | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index 6615af7..3675a0c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,6 +11,7 @@ lib_deps = sandeepmistry/LoRa @ 0.7.2 peterus/APRS-Decoder-Lib @ 0.0.5 mikalhart/TinyGPSPlus @ 1.0.2 + paulstoffregen/Time @ 1.6 check_tool = cppcheck check_flags = cppcheck: --suppress=*:*.pio\* --inline-suppr diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index a8b8975..6e4c570 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -6,6 +6,7 @@ #include "settings.h" #include "display.h" #include "pins.h" +#include #ifdef TTGO_T_Beam_V1_0 #include @@ -21,6 +22,10 @@ String create_long_aprs(RawDegrees lng); void setup_lora(); +static time_t nowTimeStamp = -1; +static time_t nextUpdateTimeStamp = -1; +static bool send_update = true; + // cppcheck-suppress unusedFunction void setup() { @@ -59,23 +64,26 @@ void loop() gps.encode(c); } - static unsigned long next_update = -1; - static bool send_update = true; - bool gps_time_update = false; if(gps.time.isUpdated()) { gps_time_update = true; } - if(gps.time.isValid() && (next_update <= gps.time.minute() || next_update == -1)) + if(gps.time.isValid()) { - send_update = true; + setTime(gps.time.hour(),gps.time.minute(),gps.time.second(),gps.date.day(),gps.date.month(),gps.date.year()); + nowTimeStamp = now(); + + if (nextUpdateTimeStamp <= nowTimeStamp || nextUpdateTimeStamp == -1) + { + send_update = true; + } } if(send_update && gps.location.isValid() && gps.location.isUpdated()) { - next_update = (gps.time.minute() + BEACON_TIMEOUT) % 60; + nextUpdateTimeStamp = nowTimeStamp + (BEACON_TIMEOUT * 60); send_update = false; APRSMessage msg;