Clean up GPS code and add some flags per #1740

This commit is contained in:
Thomas Göttgens
2022-10-03 20:30:11 +02:00
parent 482c0766af
commit cf124d97b8
3 changed files with 29 additions and 23 deletions

View File

@@ -58,6 +58,8 @@ MeshPacket *PositionModule::allocReply()
NodeInfo *node = service.refreshMyNodeInfo(); // should guarantee there is now a position
assert(node->has_position);
node->position.seq_number++;
// configuration of POSITION packet
// consider making this a function argument?
uint32_t pos_flags = config.position.position_flags;
@@ -97,6 +99,12 @@ MeshPacket *PositionModule::allocReply()
if (pos_flags & Config_PositionConfig_PositionFlags_SEQ_NO)
p.seq_number = node->position.seq_number;
if (pos_flags & Config_PositionConfig_PositionFlags_HEADING)
p.ground_track = node->position.ground_track;
if (pos_flags & Config_PositionConfig_PositionFlags_SPEED)
p.ground_speed = node->position.ground_speed;
// Strip out any time information before sending packets to other nodes - to keep the wire size small (and because other
// nodes shouldn't trust it anyways) Note: we allow a device with a local GPS to include the time, so that gpsless
// devices can get time.