mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-21 10:12:50 +00:00
Coalesce duplicated method GetTimeSinceMeshPacket (#4968)
GetTimeSinceMeshPacket was duplicated in PowerTelemetry and EnvironmentalTelemetry, albeit one had a cooler name than the other. As we add HealthTelemetry, to avoid creating a third instance of this method, let's move it somewhere that makese sense. Adds a new method GetTimeSinceMeshPacket to MeshService and updates EnvironmentTelemetry and PowerTelemetry to use it.
This commit is contained in:
@@ -406,4 +406,16 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
|
||||
bool MeshService::isToPhoneQueueEmpty()
|
||||
{
|
||||
return toPhoneQueue.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t MeshService::GetTimeSinceMeshPacket(const meshtastic_MeshPacket *mp)
|
||||
{
|
||||
uint32_t now = getTime();
|
||||
|
||||
uint32_t last_seen = mp->rx_time;
|
||||
int delta = (int)(now - last_seen);
|
||||
if (delta < 0) // our clock must be slightly off still - not set from GPS yet
|
||||
delta = 0;
|
||||
|
||||
return delta;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user