Fixed beacon timeout handling.

This commit is contained in:
nobody 2020-11-01 23:19:32 +01:00
parent 2c04d96435
commit f512cfffb6
2 changed files with 17 additions and 6 deletions

View file

@ -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

View file

@ -8,6 +8,7 @@
#include "settings.h"
#include "display.h"
#include <TimeLib.h>
#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;