Only allow phone to set time for fixed positions (#3403)

This commit is contained in:
Ben Meadors 2024-03-13 20:27:26 -05:00 committed by GitHub
parent 9d2fcbe1e1
commit 9c37e57e75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 4 deletions

View File

@ -133,8 +133,13 @@ class NodeDB
meshtastic_NodeInfoLite *getMeshNode(NodeNum n); meshtastic_NodeInfoLite *getMeshNode(NodeNum n);
size_t getNumMeshNodes() { return *numMeshNodes; } size_t getNumMeshNodes() { return *numMeshNodes; }
void setLocalPosition(meshtastic_Position position) void setLocalPosition(meshtastic_Position position, bool timeOnly = false)
{ {
if (timeOnly) {
LOG_DEBUG("Setting local position time only: time=%i\n", position.time);
localPosition.time = position.time;
return;
}
LOG_DEBUG("Setting local position: latitude=%i, longitude=%i, time=%i\n", position.latitude_i, position.longitude_i, LOG_DEBUG("Setting local position: latitude=%i, longitude=%i, time=%i\n", position.latitude_i, position.longitude_i,
position.time); position.time);
localPosition = position; localPosition = position;

View File

@ -59,10 +59,16 @@ bool PositionModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes
// to set fixed location, EUD-GPS location or just the time (see also issue #900) // to set fixed location, EUD-GPS location or just the time (see also issue #900)
bool isLocal = false; bool isLocal = false;
if (nodeDB.getNodeNum() == getFrom(&mp)) { if (nodeDB.getNodeNum() == getFrom(&mp)) {
LOG_DEBUG("Incoming update from MYSELF\n");
isLocal = true; isLocal = true;
if (config.position.fixed_position) {
LOG_DEBUG("Ignore incoming position update from myself except for time, because position.fixed_position is true\n");
nodeDB.setLocalPosition(p, true);
return false;
} else {
LOG_DEBUG("Incoming update from MYSELF\n");
nodeDB.setLocalPosition(p); nodeDB.setLocalPosition(p);
} }
}
// Log packet size and data fields // Log packet size and data fields
LOG_INFO("POSITION node=%08x l=%d latI=%d lonI=%d msl=%d hae=%d geo=%d pdop=%d hdop=%d vdop=%d siv=%d fxq=%d fxt=%d pts=%d " LOG_INFO("POSITION node=%08x l=%d latI=%d lonI=%d msl=%d hae=%d geo=%d pdop=%d hdop=%d vdop=%d siv=%d fxq=%d fxt=%d pts=%d "