clean up position broadcasts, send them even if we don't have gps lock

This commit is contained in:
Kevin Hester
2021-02-14 11:57:48 +08:00
parent 52ec4d511c
commit a872231f8a
3 changed files with 31 additions and 19 deletions

View File

@@ -60,3 +60,22 @@ void PositionPlugin::sendOurPosition(NodeNum dest, bool wantReplies)
service.sendToMesh(p);
}
int32_t PositionPlugin::runOnce(){
// We limit our GPS broadcasts to a max rate
uint32_t now = millis();
if (lastGpsSend == 0 || now - lastGpsSend >= getPref_position_broadcast_secs() * 1000) {
lastGpsSend = now;
// If we changed channels, ask everyone else for their latest info
bool requestReplies = currentGeneration != radioGeneration;
currentGeneration = radioGeneration;
DEBUG_MSG("Sending position to mesh (wantReplies=%d)\n", requestReplies);
sendOurPosition(NODENUM_BROADCAST, requestReplies);
}
return 5000; // to save power only wake for our callback occasionally
}