Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/GPSStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class GPSStatus : public Status

bool hasLock = false; // default to false, until we complete our first read
bool isConnected = false; // Do we have a GPS we are talking to
bool hasTime = false; // GPS has decoded a valid time this acquisition, even without a position fix

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Expected: every custom GPSStatus copy implementation propagates hasTime.
rg -n -C 12 \
  'GPSStatus\s*\(const\s+GPSStatus\s*&|GPSStatus::GPSStatus\s*\(|GPSStatus::operator\s*=|hasTime' \
  src -g '*.cpp' -g '*.h' -g '*.hpp'

Repository: meshtastic/firmware

Length of output: 6173


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- matching GPSStatus custom copy symbols across tracked files ---\n'
rg -n -C 16 \
  'GPSStatus\s*\(\s*const\s+GPSStatus\s*&|::GPSStatus\s*\([^{\w]*const\s+.*\)|::operator\s*=\s*\(|operator\s*=\s*\(\s*const\s+GPSStatus|hasTime' \
  . -g '*.cpp' -g '*.h' -g '*.hpp' | sed -n '1,220p'

printf '\n--- all GPSStatus operator symbols ---\n'
rg -n 'GPSStatus::operator\s*=|GPSStatus\s*::\s*::operator\s*=' . -g '*.cpp' -g '*.h' -g '*.hpp' || true

Repository: meshtastic/firmware

Length of output: 248


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- matching GPSStatus custom copy symbols across tracked files ---'
rg -n -C 16 \
  'GPSStatus[[:space:]]*\([[:space:]]*const[[:space:]]+GPSStatus[[:space:]]*&|::GPSStatus[[:space:]]*\(.*const[[:space:]]+.*\)|::operator[[:space:]]*=[[:space:]]*\(|operator[[:space:]]*=[[:space:]]*([^(]*|[^(0-9a-zA-Z_])*\([[:space:]]*const[[:space:]]+GPSStatus|hasTime' \
  . -g '*.cpp' -g '*.h' -g '*.hpp' | sed -n '1,220p'

printf '%s\n' ''
printf '%s\n' '--- all GPSStatus operator symbols ---'
rg -n 'GPSStatus::operator[[:space:]]*=|GPSStatus[[:space:]]*::[[:space:]]*operator[[:space:]]*=' . -g '*.cpp' -g '*.h' -g '*.hpp' || true

Repository: meshtastic/firmware

Length of output: 7221


Link the declared GPSStatus copy operations.

src/GPSStatus.h declares the copy constructor and copy assignment operator but the definitions are missing, so this no longer builds. Add the definitions or remove the declarations if the default copy operators are sufficient.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/GPSStatus.h` at line 20, Resolve the missing copy operations declared in
GPSStatus by either defining its copy constructor and copy assignment operator
or removing those declarations when compiler-generated copying is sufficient.
Keep the class copyable and ensure all existing GPSStatus fields, including
hasTime, are copied correctly.


bool isPowerSaving = false; // Are we in power saving state

Expand All @@ -29,11 +30,12 @@ class GPSStatus : public Status
GPSStatus() { statusType = STATUS_TYPE_GPS; }

// preferred method
GPSStatus(bool hasLock, bool isConnected, bool isPowerSaving, const meshtastic_Position &pos) : Status()
GPSStatus(bool hasLock, bool isConnected, bool isPowerSaving, const meshtastic_Position &pos, bool hasTime = false) : Status()
{
this->hasLock = hasLock;
this->isConnected = isConnected;
this->isPowerSaving = isPowerSaving;
this->hasTime = hasTime;

// all-in-one struct copy
this->p = pos;
Expand All @@ -50,6 +52,8 @@ class GPSStatus : public Status

bool getIsPowerSaving() const { return isPowerSaving; }

bool getHasTime() const { return hasTime; }

int32_t getLatitude() const
{
if (config.position.fixed_position) {
Expand Down Expand Up @@ -91,7 +95,7 @@ class GPSStatus : public Status
#ifdef GPS_DEBUG
LOG_DEBUG("GPSStatus.match() new pos@%x to old pos@%x", newStatus->p.timestamp, p.timestamp);
#endif
return (newStatus->hasLock != hasLock || newStatus->isConnected != isConnected ||
return (newStatus->hasLock != hasLock || newStatus->isConnected != isConnected || newStatus->hasTime != hasTime ||
newStatus->isPowerSaving != isPowerSaving || newStatus->p.latitude_i != p.latitude_i ||
newStatus->p.longitude_i != p.longitude_i || newStatus->p.altitude != p.altitude ||
newStatus->p.altitude_hae != p.altitude_hae || newStatus->p.PDOP != p.PDOP ||
Expand All @@ -112,6 +116,7 @@ class GPSStatus : public Status
initialized = true;
hasLock = newStatus->hasLock;
isConnected = newStatus->isConnected;
hasTime = newStatus->hasTime;

p = newStatus->p;

Expand Down
9 changes: 7 additions & 2 deletions src/gps/GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ void GPS::publishUpdate()
LOG_DEBUG("Publish pos@%x:2, hasVal=%d, Sats=%d, GPSlock=%d", p.timestamp, hasValidLocation, p.sats_in_view, hasLock());

// Notify any status instances that are observing us
const meshtastic::GPSStatus status = meshtastic::GPSStatus(hasValidLocation, isConnected(), isPowerSaving(), p);
const meshtastic::GPSStatus status = meshtastic::GPSStatus(hasValidLocation, isConnected(), isPowerSaving(), p, gotTime);
newStatus.notifyObservers(&status);
if (config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED) {
positionModule->handleNewPosition();
Expand Down Expand Up @@ -1502,7 +1502,7 @@ int32_t GPS::runOnce()
// gps_update_interval is faster than the position broadcast interval so there's a
// fresh position ready when the device wants to broadcast one on the mesh.
//
// 1. Got a time for the first time --> set the time, don't publish.
// 1. Got a time for the first time --> set the time, publish so the UI can show the time-only state.
// 2. Got a lock for the first time
// --> If gps_update_interval is <= 10s --> publishUpdate
// --> Otherwise, hold for MIN(gps_update_interval - GPS_UPDATE_ALWAYS_ON_THRESHOLD_MS, 20s)
Expand Down Expand Up @@ -1536,6 +1536,11 @@ int32_t GPS::runOnce()
// 1. Got a time for the first time this cycle
if (!gotTime && lookForTime()) { // Note: we count on this && short-circuiting and not resetting the RTC time
gotTime = true;
// Publish immediately (rather than via the block below, which would clear fixHoldEnds) so the
// time-only state reaches the UI without waiting for a location. Safe without a valid location:
// PositionModule::handleNewPosition ignores invalid positions.
shouldPublish = true;
publishUpdate();
}

// 2. Got a lock for the first time, or 3. Got a lock after turning back on
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/draw/UIRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ void UIRenderer::drawGpsCoordinates(OLEDDisplay *display, int16_t x, int16_t y,
}
} else if (!gps->getHasLock() && !config.position.fixed_position) {
if (strcmp(mode, "line1") == 0) {
strcpy(displayLine, "No GPS Lock");
strcpy(displayLine, gps->getHasTime() ? "GPS Time Only" : "No GPS Lock");
display->drawString(x, y, displayLine);
}
} else {
Expand Down
Loading