From a79d155bd658eff85036f0d7d29486faac0bf3cc Mon Sep 17 00:00:00 2001 From: matt Date: Tue, 7 Jan 2025 23:05:19 +0000 Subject: [PATCH] Added libgps fix to support api version >7 and lower. --- src/autoapp/Service/SensorService.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/autoapp/Service/SensorService.cpp b/src/autoapp/Service/SensorService.cpp index 7a47d6c..e4348a4 100644 --- a/src/autoapp/Service/SensorService.cpp +++ b/src/autoapp/Service/SensorService.cpp @@ -188,7 +188,11 @@ void SensorService::sendGPSLocationData() auto * locInd = indication.add_gps_location(); // epoch seconds - locInd->set_timestamp(this->gpsData_.fix.time.tv_sec); + #if GPSD_API_MAJOR_VERSION >= 7 + locInd->set_timestamp(this->gpsData_.fix.time.tv_sec); + #else + locInd->set_timestamp(this->gpsData_.fix.time); + #endif // degrees locInd->set_latitude(this->gpsData_.fix.latitude * 1e7); locInd->set_longitude(this->gpsData_.fix.longitude * 1e7); @@ -226,10 +230,19 @@ void SensorService::sensorPolling() this->previous = this->isNight; this->sendNightData(); } - + bool gpsDataAvailable = false; + #if GPSD_API_MAJOR_VERSION >= 7 + if (gps_read (&this->gpsData_, NULL, 0) != -1) { + gpsDataAvailable = true; + } + #else + if (gps_read (&this->gpsData_) != -1) { + gpsDataAvailable = true; + } + #endif if ((this->gpsEnabled_) && (gps_waiting(&this->gpsData_, 0)) && - (gps_read(&this->gpsData_, nullptr, 0) > 0) && + (gpsDataAvailable == true) && (this->gpsData_.fix.mode == MODE_2D || this->gpsData_.fix.mode == MODE_3D) && (this->gpsData_.set & TIME_SET) && (this->gpsData_.set & LATLON_SET))