Added more clear RTC handling and quality logging (#3691)

* Also refresh timestamp for "timeonly" fixed position nodes

* Added more clear RTC quality handling

* Fix clock drift from Phone GPS / NTP too
This commit is contained in:
Ben Meadors
2024-04-21 14:40:47 -05:00
committed by GitHub
parent 0406be82d2
commit 39bbf0d352
4 changed files with 39 additions and 11 deletions

View File

@@ -71,14 +71,8 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
p.time);
if (p.time && channels.getByIndex(mp.channel).role == meshtastic_Channel_Role_PRIMARY) {
struct timeval tv;
uint32_t secs = p.time;
tv.tv_sec = secs;
tv.tv_usec = 0;
// Set from phone RTC Quality to RTCQualityNTP since it should be approximately so
perhapsSetRTC(isLocal ? RTCQualityNTP : RTCQualityFromNet, &tv);
trySetRtc(p, isLocal);
}
nodeDB->updatePosition(getFrom(&mp), p);
@@ -93,6 +87,16 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
return false; // Let others look at this message also if they want
}
void PositionModule::trySetRtc(meshtastic_Position p, bool isLocal)
{
struct timeval tv;
uint32_t secs = p.time;
tv.tv_sec = secs;
tv.tv_usec = 0;
perhapsSetRTC(isLocal ? RTCQualityNTP : RTCQualityFromNet, &tv);
}
meshtastic_MeshPacket *PositionModule::allocReply()
{
if (precision == 0) {