Merge pull request #3 from raufaser/master
Fixed beacon timeout handling. Thanks for the pull request!
This commit is contained in:
commit
919fdd3a7e
|
@ -11,6 +11,7 @@ lib_deps =
|
||||||
sandeepmistry/LoRa @ 0.7.2
|
sandeepmistry/LoRa @ 0.7.2
|
||||||
peterus/APRS-Decoder-Lib @ 0.0.5
|
peterus/APRS-Decoder-Lib @ 0.0.5
|
||||||
mikalhart/TinyGPSPlus @ 1.0.2
|
mikalhart/TinyGPSPlus @ 1.0.2
|
||||||
|
paulstoffregen/Time @ 1.6
|
||||||
check_tool = cppcheck
|
check_tool = cppcheck
|
||||||
check_flags =
|
check_flags =
|
||||||
cppcheck: --suppress=*:*.pio\* --inline-suppr
|
cppcheck: --suppress=*:*.pio\* --inline-suppr
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "pins.h"
|
#include "pins.h"
|
||||||
|
#include <TimeLib.h>
|
||||||
|
|
||||||
#ifdef TTGO_T_Beam_V1_0
|
#ifdef TTGO_T_Beam_V1_0
|
||||||
#include <axp20x.h>
|
#include <axp20x.h>
|
||||||
|
@ -21,6 +22,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()
|
||||||
{
|
{
|
||||||
|
@ -59,23 +64,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