Browse Source
Merge pull request #304 from jquatier/altitude-telemetry
Add altitude to GPS telemetry
pull/306/head
ripplebiz
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with
16 additions and
5 deletions
-
src/helpers/SensorManager.h
-
src/helpers/sensors/LocationProvider.h
-
src/helpers/sensors/MicroNMEALocationProvider.h
-
variants/heltec_tracker/target.cpp
-
variants/lilygo_tbeam_supreme_SX1262/target.cpp
-
variants/t1000-e/target.cpp
-
variants/t114/target.cpp
|
|
|
@ -11,8 +11,9 @@ |
|
|
|
class SensorManager { |
|
|
|
public: |
|
|
|
double node_lat, node_lon; // modify these, if you want to affect Advert location
|
|
|
|
double node_altitude; // altitude in meters
|
|
|
|
|
|
|
|
SensorManager() { node_lat = 0; node_lon = 0; } |
|
|
|
SensorManager() { node_lat = 0; node_lon = 0; node_altitude = 0; } |
|
|
|
virtual bool begin() { return false; } |
|
|
|
virtual bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) { return false; } |
|
|
|
virtual void loop() { } |
|
|
|
|
|
|
|
@ -8,6 +8,7 @@ class LocationProvider { |
|
|
|
public: |
|
|
|
virtual long getLatitude() = 0; |
|
|
|
virtual long getLongitude() = 0; |
|
|
|
virtual long getAltitude() = 0; |
|
|
|
virtual bool isValid() = 0; |
|
|
|
virtual long getTimestamp() = 0; |
|
|
|
virtual void reset(); |
|
|
|
|
|
|
|
@ -61,6 +61,11 @@ public : |
|
|
|
|
|
|
|
long getLatitude() override { return nmea.getLatitude(); } |
|
|
|
long getLongitude() override { return nmea.getLongitude(); } |
|
|
|
long getAltitude() override { |
|
|
|
long alt = 0; |
|
|
|
nmea.getAltitude(alt); |
|
|
|
return alt; |
|
|
|
} |
|
|
|
bool isValid() override { return nmea.isValid(); } |
|
|
|
|
|
|
|
long getTimestamp() override { |
|
|
|
|
|
|
|
@ -103,7 +103,7 @@ bool HWTSensorManager::begin() { |
|
|
|
|
|
|
|
bool HWTSensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) { |
|
|
|
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
|
|
|
|
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, 0.0f); |
|
|
|
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
@ -117,6 +117,7 @@ void HWTSensorManager::loop() { |
|
|
|
if (gps_active && _location->isValid()) { |
|
|
|
node_lat = ((double)_location->getLatitude())/1000000.; |
|
|
|
node_lon = ((double)_location->getLongitude())/1000000.; |
|
|
|
node_altitude = ((double)_location->getAltitude()) / 1000.0; |
|
|
|
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon); |
|
|
|
} |
|
|
|
next_gps_update = millis() + 1000; |
|
|
|
|
|
|
|
@ -287,7 +287,7 @@ bool TbeamSupSensorManager::begin() { |
|
|
|
|
|
|
|
bool TbeamSupSensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) { |
|
|
|
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
|
|
|
|
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, 0.0f); |
|
|
|
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
@ -301,6 +301,7 @@ void TbeamSupSensorManager::loop() { |
|
|
|
if (_nmea->isValid()) { |
|
|
|
node_lat = ((double)_nmea->getLatitude())/1000000.; |
|
|
|
node_lon = ((double)_nmea->getLongitude())/1000000.; |
|
|
|
node_altitude = ((double)_nmea->getAltitude()) / 1000.0; |
|
|
|
//Serial.printf("lat %f lon %f\r\n", _lat, _lon);
|
|
|
|
} |
|
|
|
next_gps_update = millis() + 1000; |
|
|
|
|
|
|
|
@ -154,7 +154,7 @@ bool T1000SensorManager::begin() { |
|
|
|
|
|
|
|
bool T1000SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) { |
|
|
|
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
|
|
|
|
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, 0.0f); |
|
|
|
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
@ -168,6 +168,7 @@ void T1000SensorManager::loop() { |
|
|
|
if (_nmea->isValid()) { |
|
|
|
node_lat = ((double)_nmea->getLatitude())/1000000.; |
|
|
|
node_lon = ((double)_nmea->getLongitude())/1000000.; |
|
|
|
node_altitude = ((double)_nmea->getAltitude()) / 1000.0; |
|
|
|
//Serial.printf("lat %f lon %f\r\n", _lat, _lon);
|
|
|
|
} |
|
|
|
next_gps_update = millis() + 1000; |
|
|
|
|
|
|
|
@ -111,7 +111,7 @@ bool T114SensorManager::begin() { |
|
|
|
|
|
|
|
bool T114SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) { |
|
|
|
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
|
|
|
|
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, 0.0f); |
|
|
|
telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
@ -125,6 +125,7 @@ void T114SensorManager::loop() { |
|
|
|
if (_location->isValid()) { |
|
|
|
node_lat = ((double)_location->getLatitude())/1000000.; |
|
|
|
node_lon = ((double)_location->getLongitude())/1000000.; |
|
|
|
node_altitude = ((double)_location->getAltitude()) / 1000.0; |
|
|
|
MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon); |
|
|
|
} |
|
|
|
next_gps_update = millis() + 1000; |
|
|
|
|