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: 8 additions & 1 deletion src/helpers/sensors/EnvironmentSensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
next_available_channel = TELEM_CHANNEL_SELF + 1;

if (requester_permissions & TELEM_PERM_LOCATION && gps_active) {
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude); // allow lat/lon via telemetry even if no GPS is detected
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
telemetry.addSwitch(TELEM_CHANNEL_SELF, gps_has_fix);
}

if (requester_permissions & TELEM_PERM_ENVIRONMENT) {
Expand Down Expand Up @@ -718,6 +719,9 @@ void EnvironmentSensorManager::loop() {
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
node_altitude = ((double)_location->getAltitude()) / 1000.0;
MESH_DEBUG_PRINTLN("lat %f lon %f alt %f", node_lat, node_lon, node_altitude);
gps_has_fix = true;
} else {
gps_has_fix = false;
}
#else
if (_location->isValid()) {
Expand All @@ -726,6 +730,9 @@ void EnvironmentSensorManager::loop() {
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
node_altitude = ((double)_location->getAltitude()) / 1000.0;
MESH_DEBUG_PRINTLN("lat %f lon %f alt %f", node_lat, node_lon, node_altitude);
gps_has_fix = true;
} else {
gps_has_fix = false;
}
#endif
}
Expand Down
1 change: 1 addition & 0 deletions src/helpers/sensors/EnvironmentSensorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class EnvironmentSensorManager : public SensorManager {

bool gps_detected = false;
bool gps_active = false;
bool gps_has_fix = false; // true only when _location->isValid() — reset on fix loss
uint32_t gps_update_interval_sec = 1; // Default 1 second

#if ENV_INCLUDE_GPS
Expand Down