From 34faea610012fa2455680be8398d901f88f27158 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sun, 3 Jan 2021 20:11:26 +0800 Subject: [PATCH] fix #622 - we might not have a local position yet early in the boot --- src/plugins/PositionPlugin.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/PositionPlugin.cpp b/src/plugins/PositionPlugin.cpp index b0ce8e21..e0c77895 100644 --- a/src/plugins/PositionPlugin.cpp +++ b/src/plugins/PositionPlugin.cpp @@ -31,10 +31,16 @@ MeshPacket *PositionPlugin::allocReply() { NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum()); assert(node); - assert(node->has_position); + + // We might not have a position yet for our local node, in that case, at least try to send the time + if(!node->has_position) { + memset(&node->position, 0, sizeof(node->position)); + node->has_position = true; + } + + Position &position = node->position; // Update our local node info with our position (even if we don't decide to update anyone else) - auto position = node->position; position.time = getValidTime(RTCQualityGPS); // This nodedb timestamp might be stale, so update it if our clock is valid. return allocDataProtobuf(position);