Fixed beacon timeout handling.
This commit is contained in:
parent
2c04d96435
commit
f512cfffb6
|
@ -19,6 +19,7 @@ lib_deps =
|
||||||
APRS-Decoder-Lib
|
APRS-Decoder-Lib
|
||||||
1655
|
1655
|
||||||
AXP202X_Library
|
AXP202X_Library
|
||||||
|
paulstoffregen/Time
|
||||||
|
|
||||||
[env:ttgo-t-beam-v0_7]
|
[env:ttgo-t-beam-v0_7]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
|
@ -28,4 +29,6 @@ lib_deps =
|
||||||
APRS-Decoder-Lib
|
APRS-Decoder-Lib
|
||||||
APRS-IS-Lib
|
APRS-IS-Lib
|
||||||
1655
|
1655
|
||||||
|
paulstoffregen/Time
|
||||||
|
|
||||||
build_flags = -DARDUINO_T_Beam_V0_7
|
build_flags = -DARDUINO_T_Beam_V0_7
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
#include <TimeLib.h>
|
||||||
|
|
||||||
#if !defined(ARDUINO_T_Beam_V0_7)
|
#if !defined(ARDUINO_T_Beam_V0_7)
|
||||||
void setup_axp();
|
void setup_axp();
|
||||||
|
@ -22,6 +23,10 @@ String create_long_aprs(RawDegrees lng);
|
||||||
|
|
||||||
void setup_lora();
|
void setup_lora();
|
||||||
|
|
||||||
|
static time_t nowTimeStamp = -1;
|
||||||
|
static time_t nextUpdateTimeStamp = -1;
|
||||||
|
static bool send_update = true;
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
@ -60,23 +65,26 @@ void loop()
|
||||||
gps.encode(c);
|
gps.encode(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long next_update = -1;
|
|
||||||
static bool send_update = true;
|
|
||||||
|
|
||||||
bool gps_time_update = false;
|
bool gps_time_update = false;
|
||||||
if(gps.time.isUpdated())
|
if(gps.time.isUpdated())
|
||||||
{
|
{
|
||||||
gps_time_update = true;
|
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())
|
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;
|
send_update = false;
|
||||||
|
|
||||||
APRSMessage msg;
|
APRSMessage msg;
|
||||||
|
|
Loading…
Reference in a new issue