From ca6c4b06e1a3bd2ebfc9bac587741532f97ab043 Mon Sep 17 00:00:00 2001 From: craigerl Date: Wed, 2 Dec 2020 07:38:25 -0800 Subject: [PATCH] Check for ntp clock shift when scheduling next beacon. Otherwise direwolf continuously transmits all beacons until it's caught up with the new system clock, which could be days. --- src/beacon.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/beacon.c b/src/beacon.c index 3fea714..78d2190 100644 --- a/src/beacon.c +++ b/src/beacon.c @@ -614,6 +614,14 @@ static void * beacon_thread (void *arg) /* i.e. Don't take relative to now in case there was some delay. */ bp->next += bp->every; + + /* craigerl: if next beacon is scheduled in the past, then set next beacon relative to now (happens when NTP pushes clock AHEAD) */ + /* fixme: if NTP sets clock BACK an hour, this thread will sleep for that hour */ + if ( bp->next < now ) { + bp->next = now + bp->every; + dw_printf("\nSystem clock appears to have jumped forward. Beacon schedule updated.\n\n"); + } + } } /* if time to send it */