mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-20 09:43:03 +00:00
Compare commits
1 Commits
master
...
first-posi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5938ef525e |
@@ -276,6 +276,10 @@ bool MeshService::trySendPosition(NodeNum dest, bool wantReplies)
|
||||
if (nodeDB->hasValidPosition(node)) {
|
||||
#if HAS_GPS && !MESHTASTIC_EXCLUDE_GPS
|
||||
if (positionModule) {
|
||||
if (!config.position.fixed_position && !nodeDB->hasLocalPositionSinceBoot()) {
|
||||
LOG_DEBUG("Skip position ping; no fresh position since boot");
|
||||
return false;
|
||||
}
|
||||
LOG_INFO("Send position ping to 0x%x, wantReplies=%d, channel=%d", dest, wantReplies, node->channel);
|
||||
positionModule->sendOurPosition(dest, wantReplies, node->channel);
|
||||
return true;
|
||||
|
||||
@@ -1043,6 +1043,7 @@ void NodeDB::clearLocalPosition()
|
||||
node->position.altitude = 0;
|
||||
node->position.time = 0;
|
||||
setLocalPosition(meshtastic_Position_init_default);
|
||||
localPositionUpdatedSinceBoot = false;
|
||||
}
|
||||
|
||||
void NodeDB::cleanupMeshDB()
|
||||
|
||||
@@ -279,9 +279,13 @@ class NodeDB
|
||||
LOG_DEBUG("Set local position: lat=%i lon=%i time=%u timestamp=%u", position.latitude_i, position.longitude_i,
|
||||
position.time, position.timestamp);
|
||||
localPosition = position;
|
||||
if (position.latitude_i != 0 || position.longitude_i != 0) {
|
||||
localPositionUpdatedSinceBoot = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool hasValidPosition(const meshtastic_NodeInfoLite *n);
|
||||
bool hasLocalPositionSinceBoot() const { return localPositionUpdatedSinceBoot; }
|
||||
|
||||
#if !defined(MESHTASTIC_EXCLUDE_PKI)
|
||||
bool checkLowEntropyPublicKey(const meshtastic_Config_SecurityConfig_public_key_t &keyToTest);
|
||||
@@ -301,6 +305,7 @@ class NodeDB
|
||||
|
||||
private:
|
||||
bool duplicateWarned = false;
|
||||
bool localPositionUpdatedSinceBoot = false;
|
||||
uint32_t lastNodeDbSave = 0; // when we last saved our db to flash
|
||||
uint32_t lastBackupAttempt = 0; // when we last tried a backup automatically or manually
|
||||
uint32_t lastSort = 0; // When last sorted the nodeDB
|
||||
|
||||
@@ -349,6 +349,11 @@ void PositionModule::sendOurPosition()
|
||||
|
||||
void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies, uint8_t channel)
|
||||
{
|
||||
if (!config.position.fixed_position && !nodeDB->hasLocalPositionSinceBoot()) {
|
||||
LOG_DEBUG("Skip position send; no fresh position since boot");
|
||||
return;
|
||||
}
|
||||
|
||||
// cancel any not yet sent (now stale) position packets
|
||||
if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal)
|
||||
service->cancelSending(prevPacketId);
|
||||
@@ -420,8 +425,12 @@ int32_t PositionModule::runOnce()
|
||||
return RUNONCE_INTERVAL;
|
||||
}
|
||||
|
||||
bool waitingForFreshPosition = (lastGpsSend == 0) && !config.position.fixed_position && !nodeDB->hasLocalPositionSinceBoot();
|
||||
|
||||
if (lastGpsSend == 0 || msSinceLastSend >= intervalMs) {
|
||||
if (nodeDB->hasValidPosition(node)) {
|
||||
if (waitingForFreshPosition) {
|
||||
LOG_DEBUG("Skip initial position send; no fresh position since boot");
|
||||
} else if (nodeDB->hasValidPosition(node)) {
|
||||
lastGpsSend = now;
|
||||
|
||||
lastGpsLatitude = node->position.latitude_i;
|
||||
|
||||
Reference in New Issue
Block a user