Skip to content

Commit 2e09b13

Browse files
committed
Fix node_altitude not being set in EnvironmentSensorManager
- Replace hardcoded 0.0f with node_altitude in addGPS call - Add node_altitude assignment from GPS data in all GPS parsing branches - Update debug messages to include altitude information
1 parent 8462393 commit 2e09b13

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/helpers/sensors/EnvironmentSensorManager.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
248248
next_available_channel = TELEM_CHANNEL_SELF + 1;
249249

250250
if (requester_permissions & TELEM_PERM_LOCATION && gps_active) {
251-
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, 0.0f); // allow lat/lon via telemetry even if no GPS is detected
251+
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude); // allow lat/lon via telemetry even if no GPS is detected
252252
}
253253

254254
if (requester_permissions & TELEM_PERM_ENVIRONMENT) {
@@ -572,18 +572,21 @@ void EnvironmentSensorManager::loop() {
572572
if (_location->isValid()) {
573573
node_lat = ((double)_location->getLatitude())/1000000.;
574574
node_lon = ((double)_location->getLongitude())/1000000.;
575-
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
575+
node_altitude = ((double)_location->getAltitude()) / 1000.0;
576+
MESH_DEBUG_PRINTLN("lat %f lon %f alt %f", node_lat, node_lon, node_altitude);
576577
}
577578
#else
578579
if(i2cGPSFlag){
579580
node_lat = ((double)ublox_GNSS.getLatitude())/10000000.;
580581
node_lon = ((double)ublox_GNSS.getLongitude())/10000000.;
581-
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
582+
node_altitude = ((double)ublox_GNSS.getAltitude()) / 1000.0;
583+
MESH_DEBUG_PRINTLN("lat %f lon %f alt %f", node_lat, node_lon, node_altitude);
582584
}
583585
else if (serialGPSFlag && _location->isValid()) {
584586
node_lat = ((double)_location->getLatitude())/1000000.;
585587
node_lon = ((double)_location->getLongitude())/1000000.;
586-
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
588+
node_altitude = ((double)_location->getAltitude()) / 1000.0;
589+
MESH_DEBUG_PRINTLN("lat %f lon %f alt %f", node_lat, node_lon, node_altitude);
587590
}
588591
//else
589592
//MESH_DEBUG_PRINTLN("No valid GPS data");

0 commit comments

Comments
 (0)