Skip to content

Commit cf93109

Browse files
committed
✨ feat: add altitude support to environment sensor node telemetry
- Include actual node altitude in GPS telemetry instead of hardcoded 0.0f - Extract altitude data from both ublox_GNSS and serial GPS sources - Update debug logging to display altitude alongside lat/lon coordinates
1 parent 5344f04 commit cf93109

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/helpers/sensors/EnvironmentSensorManager.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
252252
next_available_channel = TELEM_CHANNEL_SELF + 1;
253253

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

258258
if (requester_permissions & TELEM_PERM_ENVIRONMENT) {
@@ -577,17 +577,23 @@ void EnvironmentSensorManager::loop() {
577577
node_lat = ((double)ublox_GNSS.getLatitude())/10000000.;
578578
node_lon = ((double)ublox_GNSS.getLongitude())/10000000.;
579579
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
580+
node_altitude = ((double)ublox_GNSS.getAltitude()) / 1000.0;
581+
MESH_DEBUG_PRINTLN("lat %f lon %f alt %f", node_lat, node_lon, node_altitude);
580582
}
581583
else if (serialGPSFlag && _location->isValid()) {
582584
node_lat = ((double)_location->getLatitude())/1000000.;
583585
node_lon = ((double)_location->getLongitude())/1000000.;
584586
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
587+
node_altitude = ((double)_location->getAltitude()) / 1000.0;
588+
MESH_DEBUG_PRINTLN("lat %f lon %f alt %f", node_lat, node_lon, node_altitude);
585589
}
586590
#else
587591
if (_location->isValid()) {
588592
node_lat = ((double)_location->getLatitude())/1000000.;
589593
node_lon = ((double)_location->getLongitude())/1000000.;
590594
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon);
595+
node_altitude = ((double)_location->getAltitude()) / 1000.0;
596+
MESH_DEBUG_PRINTLN("lat %f lon %f alt %f", node_lat, node_lon, node_altitude);
591597
}
592598
#endif
593599
}

0 commit comments

Comments
 (0)