Commit 02567536 authored by Max Weffers's avatar Max Weffers Committed by prady

sdm660-common: Downgrade GPS HAL to LA.UM.8.2.r1-05100-sdm660.0

This reverts commit 31e787be.

Change-Id: I64691f2defe79aa317248bf9daf77b2530b9fc59
parent 4ac3ae2c
/*
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
......@@ -28,7 +28,6 @@
#include "Gnss.h"
#include <LocationUtil.h>
#include "battery_listener.h"
#include "loc_misc_utils.h"
typedef const GnssInterface* (getLocationInterface)();
......@@ -103,14 +102,25 @@ GnssAPIClient* Gnss::getApi() {
const GnssInterface* Gnss::getGnssInterface() {
static bool getGnssInterfaceFailed = false;
if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
void * libHandle = nullptr;
getLocationInterface* getter = (getLocationInterface*)
dlGetSymFromLib(libHandle, "libgnss.so", "getGnssInterface");
LOC_LOGD("%s]: loading libgnss.so::getGnssInterface ...", __func__);
getLocationInterface* getter = NULL;
const char *error = NULL;
dlerror();
void *handle = dlopen("libgnss.so", RTLD_NOW);
if (NULL == handle || (error = dlerror()) != NULL) {
LOC_LOGW("dlopen for libgnss.so failed, error = %s", error);
} else {
getter = (getLocationInterface*)dlsym(handle, "getGnssInterface");
if ((error = dlerror()) != NULL) {
LOC_LOGW("dlsym for libgnss.so::getGnssInterface failed, error = %s", error);
getter = NULL;
}
}
if (nullptr == getter) {
if (NULL == getter) {
getGnssInterfaceFailed = true;
} else {
mGnssInterface = (GnssInterface*)(*getter)();
mGnssInterface = (const GnssInterface*)(*getter)();
}
}
return mGnssInterface;
......@@ -254,7 +264,14 @@ Return<bool> Gnss::injectLocation(double latitudeDegrees,
Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
int32_t uncertaintyMs) {
return true;
ENTRY_LOG_CALLFLOW();
const GnssInterface* gnssInterface = getGnssInterface();
if (nullptr != gnssInterface) {
gnssInterface->injectTime(timeMs, timeReferenceMs, uncertaintyMs);
return true;
} else {
return false;
}
}
Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) {
......
......@@ -540,7 +540,7 @@ static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvSta
}
for (size_t i = 0; i < out.numSvs; i++) {
IGnssCallback::GnssSvInfo& info = out.gnssSvList[i];
convertGnssSvid(in.gnssSvs[i], info.svid);
info.svid = in.gnssSvs[i].svId;
convertGnssConstellationType(in.gnssSvs[i].type, info.constellation);
info.cN0Dbhz = in.gnssSvs[i].cN0Dbhz;
info.elevationDegrees = in.gnssSvs[i].elevation;
......
......@@ -147,64 +147,6 @@ void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out)
}
}
void convertGnssSvid(GnssSv& in, int16_t& out)
{
switch(in.type){
case GNSS_SV_TYPE_GPS:
out = in.svId;
break;
case GNSS_SV_TYPE_SBAS:
out = in.svId;
break;
case GNSS_SV_TYPE_GLONASS:
out = in.svId - GLO_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_QZSS:
out = in.svId;
break;
case GNSS_SV_TYPE_BEIDOU:
out = in.svId - BDS_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_GALILEO:
out = in.svId - GAL_SV_PRN_MIN + 1;
break;
default:
out = in.svId;
break;
}
}
void convertGnssSvid(GnssMeasurementsData& in, int16_t& out)
{
switch (in.svType) {
case GNSS_SV_TYPE_GPS:
out = in.svId;
break;
case GNSS_SV_TYPE_SBAS:
out = in.svId;
break;
case GNSS_SV_TYPE_GLONASS:
if (in.svId != 255) { // OSN is known
out = in.svId - GLO_SV_PRN_MIN + 1;
} else { // OSN is not known, report FCN
out = in.gloFrequency + 92;
}
break;
case GNSS_SV_TYPE_QZSS:
out = in.svId;
break;
case GNSS_SV_TYPE_BEIDOU:
out = in.svId - BDS_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_GALILEO:
out = in.svId - GAL_SV_PRN_MIN + 1;
break;
default:
out = in.svId;
break;
}
}
void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out)
{
switch(in) {
......
......@@ -43,8 +43,6 @@ namespace implementation {
void convertGnssLocation(Location& in, V1_0::GnssLocation& out);
void convertGnssLocation(const V1_0::GnssLocation& in, Location& out);
void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out);
void convertGnssSvid(GnssSv& in, int16_t& out);
void convertGnssSvid(GnssMeasurementsData& in, int16_t& out);
void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out);
void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out);
void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out);
......
......@@ -163,7 +163,7 @@ static void convertGnssMeasurement(GnssMeasurementsData& in,
out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE_UNCERTAINTY;
if (in.flags & GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT)
out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_AUTOMATIC_GAIN_CONTROL;
convertGnssSvid(in, out.svid);
out.svid = in.svId;
convertGnssConstellationType(in.svType, out.constellation);
out.timeOffsetNs = in.timeOffsetNs;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT)
......
/*
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
......@@ -29,7 +29,6 @@
#include <LocationUtil.h>
#include "battery_listener.h"
#include "loc_misc_utils.h"
typedef const GnssInterface* (getLocationInterface)();
......@@ -144,14 +143,25 @@ GnssAPIClient* Gnss::getApi() {
const GnssInterface* Gnss::getGnssInterface() {
static bool getGnssInterfaceFailed = false;
if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
void * libHandle = nullptr;
getLocationInterface* getter = (getLocationInterface*)
dlGetSymFromLib(libHandle, "libgnss.so", "getGnssInterface");
LOC_LOGD("%s]: loading libgnss.so::getGnssInterface ...", __func__);
getLocationInterface* getter = NULL;
const char *error = NULL;
dlerror();
void *handle = dlopen("libgnss.so", RTLD_NOW);
if (NULL == handle || (error = dlerror()) != NULL) {
LOC_LOGW("dlopen for libgnss.so failed, error = %s", error);
} else {
getter = (getLocationInterface*)dlsym(handle, "getGnssInterface");
if ((error = dlerror()) != NULL) {
LOC_LOGW("dlsym for libgnss.so::getGnssInterface failed, error = %s", error);
getter = NULL;
}
}
if (nullptr == getter) {
if (NULL == getter) {
getGnssInterfaceFailed = true;
} else {
mGnssInterface = (GnssInterface*)(*getter)();
mGnssInterface = (const GnssInterface*)(*getter)();
}
}
return mGnssInterface;
......@@ -295,7 +305,14 @@ Return<bool> Gnss::injectLocation(double latitudeDegrees,
Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
int32_t uncertaintyMs) {
return true;
ENTRY_LOG_CALLFLOW();
const GnssInterface* gnssInterface = getGnssInterface();
if (nullptr != gnssInterface) {
gnssInterface->injectTime(timeMs, timeReferenceMs, uncertaintyMs);
return true;
} else {
return false;
}
}
Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) {
......
......@@ -540,7 +540,7 @@ static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvSta
}
for (size_t i = 0; i < out.numSvs; i++) {
IGnssCallback::GnssSvInfo& info = out.gnssSvList[i];
convertGnssSvid(in.gnssSvs[i], info.svid);
info.svid = in.gnssSvs[i].svId;
convertGnssConstellationType(in.gnssSvs[i].type, info.constellation);
info.cN0Dbhz = in.gnssSvs[i].cN0Dbhz;
info.elevationDegrees = in.gnssSvs[i].elevation;
......
......@@ -147,64 +147,6 @@ void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out)
}
}
void convertGnssSvid(GnssSv& in, int16_t& out)
{
switch(in.type){
case GNSS_SV_TYPE_GPS:
out = in.svId;
break;
case GNSS_SV_TYPE_SBAS:
out = in.svId;
break;
case GNSS_SV_TYPE_GLONASS:
out = in.svId - GLO_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_QZSS:
out = in.svId;
break;
case GNSS_SV_TYPE_BEIDOU:
out = in.svId - BDS_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_GALILEO:
out = in.svId - GAL_SV_PRN_MIN + 1;
break;
default:
out = in.svId;
break;
}
}
void convertGnssSvid(GnssMeasurementsData& in, int16_t& out)
{
switch (in.svType) {
case GNSS_SV_TYPE_GPS:
out = in.svId;
break;
case GNSS_SV_TYPE_SBAS:
out = in.svId;
break;
case GNSS_SV_TYPE_GLONASS:
if (in.svId != 255) { // OSN is known
out = in.svId - GLO_SV_PRN_MIN + 1;
} else { // OSN is not known, report FCN
out = in.gloFrequency + 92;
}
break;
case GNSS_SV_TYPE_QZSS:
out = in.svId;
break;
case GNSS_SV_TYPE_BEIDOU:
out = in.svId - BDS_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_GALILEO:
out = in.svId - GAL_SV_PRN_MIN + 1;
break;
default:
out = in.svId;
break;
}
}
void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out)
{
switch(in) {
......
......@@ -43,8 +43,6 @@ namespace implementation {
void convertGnssLocation(Location& in, V1_0::GnssLocation& out);
void convertGnssLocation(const V1_0::GnssLocation& in, Location& out);
void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out);
void convertGnssSvid(GnssSv& in, int16_t& out);
void convertGnssSvid(GnssMeasurementsData& in, int16_t& out);
void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out);
void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out);
void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out);
......
......@@ -197,7 +197,7 @@ static void convertGnssMeasurement(GnssMeasurementsData& in,
out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE_UNCERTAINTY;
if (in.flags & GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT)
out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_AUTOMATIC_GAIN_CONTROL;
convertGnssSvid(in, out.svid);
out.svid = in.svId;
convertGnssConstellationType(in.svType, out.constellation);
out.timeOffsetNs = in.timeOffsetNs;
if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT)
......
/*
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
......@@ -28,7 +28,6 @@
#include "Gnss.h"
#include "LocationUtil.h"
#include "battery_listener.h"
#include "loc_misc_utils.h"
typedef const GnssInterface* (getLocationInterface)();
......@@ -146,16 +145,26 @@ GnssAPIClient* Gnss::getApi() {
const GnssInterface* Gnss::getGnssInterface() {
static bool getGnssInterfaceFailed = false;
if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
void * libHandle = nullptr;
getLocationInterface* getter = (getLocationInterface*)
dlGetSymFromLib(libHandle, "libgnss.so", "getGnssInterface");
LOC_LOGD("%s]: loading libgnss.so::getGnssInterface ...", __func__);
getLocationInterface* getter = NULL;
const char *error = NULL;
dlerror();
void *handle = dlopen("libgnss.so", RTLD_NOW);
if (NULL == handle || (error = dlerror()) != NULL) {
LOC_LOGW("dlopen for libgnss.so failed, error = %s", error);
} else {
getter = (getLocationInterface*)dlsym(handle, "getGnssInterface");
if ((error = dlerror()) != NULL) {
LOC_LOGW("dlsym for libgnss.so::getGnssInterface failed, error = %s", error);
getter = NULL;
}
}
if (nullptr == getter) {
if (NULL == getter) {
getGnssInterfaceFailed = true;
} else {
mGnssInterface = (GnssInterface*)(*getter)();
mGnssInterface = (const GnssInterface*)(*getter)();
}
}
return mGnssInterface;
......@@ -321,7 +330,14 @@ Return<bool> Gnss::injectLocation(double latitudeDegrees,
Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
int32_t uncertaintyMs) {
return true;
ENTRY_LOG_CALLFLOW();
const GnssInterface* gnssInterface = getGnssInterface();
if (nullptr != gnssInterface) {
gnssInterface->injectTime(timeMs, timeReferenceMs, uncertaintyMs);
return true;
} else {
return false;
}
}
Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags) {
......@@ -369,41 +385,31 @@ Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() {
Return<sp<V1_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration() {
ENTRY_LOG_CALLFLOW();
if (mGnssConfig == nullptr) {
mGnssConfig = new GnssConfiguration(this);
}
mGnssConfig = new GnssConfiguration(this);
return mGnssConfig;
}
Return<sp<V1_0::IGnssGeofencing>> Gnss::getExtensionGnssGeofencing() {
ENTRY_LOG_CALLFLOW();
if (mGnssGeofencingIface == nullptr) {
mGnssGeofencingIface = new GnssGeofencing();
}
mGnssGeofencingIface = new GnssGeofencing();
return mGnssGeofencingIface;
}
Return<sp<V1_0::IGnssBatching>> Gnss::getExtensionGnssBatching() {
ENTRY_LOG_CALLFLOW();
if (mGnssBatching == nullptr) {
mGnssBatching = new GnssBatching();
}
mGnssBatching = new GnssBatching();
return mGnssBatching;
}
Return<sp<V1_0::IGnssDebug>> Gnss::getExtensionGnssDebug() {
ENTRY_LOG_CALLFLOW();
if (mGnssDebug == nullptr) {
mGnssDebug = new GnssDebug(this);
}
mGnssDebug = new GnssDebug(this);
return mGnssDebug;
}
Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() {
ENTRY_LOG_CALLFLOW();
if (mGnssRil == nullptr) {
mGnssRil = new AGnssRil(this);
}
mGnssRil = new AGnssRil(this);
return mGnssRil;
}
......@@ -590,23 +596,17 @@ Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
Return<sp<V2_0::IAGnss>> Gnss::getExtensionAGnss_2_0() {
ENTRY_LOG_CALLFLOW();
if (mAGnssIface_2_0 == nullptr) {
mAGnssIface_2_0 = new AGnss(this);
}
mAGnssIface_2_0 = new AGnss(this);
return mAGnssIface_2_0;
}
Return<sp<V2_0::IAGnssRil>> Gnss::getExtensionAGnssRil_2_0() {
if (mGnssRil == nullptr) {
mGnssRil = new AGnssRil(this);
}
mGnssRil = new AGnssRil(this);
return mGnssRil;
}
Return<sp<V2_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_2_0() {
ENTRY_LOG_CALLFLOW();
if (mGnssConfig == nullptr) {
mGnssConfig = new GnssConfiguration(this);
}
mGnssConfig = new GnssConfiguration(this);
return mGnssConfig;
}
Return<sp<V2_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_0() {
......@@ -646,17 +646,13 @@ Return<bool> Gnss::injectBestLocation_2_0(const V2_0::GnssLocation& gnssLocation
Return<sp<V2_0::IGnssDebug>> Gnss::getExtensionGnssDebug_2_0() {
ENTRY_LOG_CALLFLOW();
if (mGnssDebug == nullptr) {
mGnssDebug = new GnssDebug(this);
}
mGnssDebug = new GnssDebug(this);
return mGnssDebug;
}
Return<sp<V2_0::IGnssBatching>> Gnss::getExtensionGnssBatching_2_0() {
ENTRY_LOG_CALLFLOW();
if (mGnssBatching == nullptr) {
mGnssBatching = new GnssBatching();
}
mGnssBatching = new GnssBatching();
return mGnssBatching;
}
......
......@@ -29,7 +29,6 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<hal format="hidl">
<name>android.hardware.gnss</name>
<transport>hwbinder</transport>
<fqname>@1.0::IGnss/gnss_vendor</fqname>
<fqname>@1.1::IGnss/default</fqname>
<fqname>@2.0::IGnss/default</fqname>
</hal>
......
......@@ -678,7 +678,7 @@ static void convertGnssSvStatus(GnssSvNotification& in, V1_0::IGnssCallback::Gns
out.numSvs = static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT);
}
for (size_t i = 0; i < out.numSvs; i++) {
convertGnssSvid(in.gnssSvs[i], out.gnssSvList[i].svid);
out.gnssSvList[i].svid = in.gnssSvs[i].svId;
convertGnssConstellationType(in.gnssSvs[i].type, out.gnssSvList[i].constellation);
out.gnssSvList[i].cN0Dbhz = in.gnssSvs[i].cN0Dbhz;
out.gnssSvList[i].elevationDegrees = in.gnssSvs[i].elevation;
......@@ -701,7 +701,7 @@ static void convertGnssSvStatus(GnssSvNotification& in,
{
out.resize(in.count);
for (size_t i = 0; i < in.count; i++) {
convertGnssSvid(in.gnssSvs[i], out[i].v1_0.svid);
out[i].v1_0.svid = in.gnssSvs[i].svId;
out[i].v1_0.cN0Dbhz = in.gnssSvs[i].cN0Dbhz;
out[i].v1_0.elevationDegrees = in.gnssSvs[i].elevation;
out[i].v1_0.azimuthDegrees = in.gnssSvs[i].azimuth;
......
......@@ -30,7 +30,6 @@
#include <LocationUtil.h>
#include <log_util.h>
#include <inttypes.h>
#include <gps_extended_c.h>
namespace android {
namespace hardware {
......@@ -82,16 +81,21 @@ void convertGnssLocation(Location& in, V1_0::GnssLocation& out)
out.timestamp = static_cast<V1_0::GnssUtcTime>(in.timestamp);
}
bool getCurrentTime(struct timespec& currentTime, int64_t& sinceBootTimeNanos)
void convertGnssLocation(Location& in, V2_0::GnssLocation& out)
{
memset(&out, 0, sizeof(V2_0::GnssLocation));
convertGnssLocation(in, out.v1_0);
struct timespec sinceBootTime;
struct timespec currentTime;
struct timespec sinceBootTimeTest;
int64_t sinceBootTimeNanos = 0;
bool clockGetTimeSuccess = false;
const uint32_t MAX_TIME_DELTA_VALUE_NANOS = 10000;
const uint32_t MAX_GET_TIME_COUNT = 20;
/* Attempt to get CLOCK_REALTIME and CLOCK_BOOTIME in succession without an interruption
or context switch (for up to MAX_GET_TIME_COUNT times) to avoid errors in the calculation */
for (uint32_t i = 0; i < MAX_GET_TIME_COUNT; i++) {
or context switch (for up to MAX_GET_TIME_COUNT times) to avoid errors in the calculation */
for (uint32_t i=0; i < MAX_GET_TIME_COUNT; i++) {
if (clock_gettime(CLOCK_BOOTTIME, &sinceBootTime) != 0) {
break;
};
......@@ -101,34 +105,24 @@ bool getCurrentTime(struct timespec& currentTime, int64_t& sinceBootTimeNanos)
if (clock_gettime(CLOCK_BOOTTIME, &sinceBootTimeTest) != 0) {
break;
};
sinceBootTimeNanos = sinceBootTime.tv_sec * 1000000000 + sinceBootTime.tv_nsec;
sinceBootTimeNanos = sinceBootTime.tv_sec*1000000000 + sinceBootTime.tv_nsec;
int64_t sinceBootTimeTestNanos =
sinceBootTimeTest.tv_sec * 1000000000 + sinceBootTimeTest.tv_nsec;
sinceBootTimeTest.tv_sec*1000000000 + sinceBootTimeTest.tv_nsec;
int64_t sinceBootTimeDeltaNanos = sinceBootTimeTestNanos - sinceBootTimeNanos;
/* sinceBootTime and sinceBootTimeTest should have a close value if there was no
interruption or context switch between clock_gettime for CLOCK_BOOTIME and
clock_gettime for CLOCK_REALTIME */
interruption or context switch between clock_gettime for CLOCK_BOOTIME and
clock_gettime for CLOCK_REALTIME */
if (sinceBootTimeDeltaNanos < MAX_TIME_DELTA_VALUE_NANOS) {
clockGetTimeSuccess = true;
break;
} else {
LOC_LOGd("Delta:%" PRIi64 "ns time too large, retry number #%u...",
sinceBootTimeDeltaNanos, i + 1);
LOC_LOGD("%s]: Delta:%" PRIi64 "ns time too large, retry number #%u...",
__FUNCTION__, sinceBootTimeDeltaNanos, i+1);
}
}
return clockGetTimeSuccess;
}
void convertGnssLocation(Location& in, V2_0::GnssLocation& out)
{
memset(&out, 0, sizeof(V2_0::GnssLocation));
convertGnssLocation(in, out.v1_0);
struct timespec currentTime;
int64_t sinceBootTimeNanos;
if (getCurrentTime(currentTime, sinceBootTimeNanos)) {
if (clockGetTimeSuccess) {
int64_t currentTimeNanos = currentTime.tv_sec*1000000000 + currentTime.tv_nsec;
int64_t locationTimeNanos = in.timestamp*1000000;
LOC_LOGD("%s]: sinceBootTimeNanos:%" PRIi64 " currentTimeNanos:%" PRIi64 ""
......@@ -137,23 +131,19 @@ void convertGnssLocation(Location& in, V2_0::GnssLocation& out)
if (currentTimeNanos >= locationTimeNanos) {
int64_t ageTimeNanos = currentTimeNanos - locationTimeNanos;
LOC_LOGD("%s]: ageTimeNanos:%" PRIi64 ")", __FUNCTION__, ageTimeNanos);
// the max trusted propagation time 30s for ageTimeNanos to avoid user setting
//wrong time, it will affect elapsedRealtimeNanos
if (ageTimeNanos >= 0 && ageTimeNanos <= 30000000000) {
if (ageTimeNanos >= 0 && ageTimeNanos <= sinceBootTimeNanos) {
out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIMESTAMP_NS;
out.elapsedRealtime.timestampNs = sinceBootTimeNanos - ageTimeNanos;
out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS;
// time uncertainty is the max value between abs(AP_UTC - MP_UTC) and 100ms, to
//verify if user change the sys time
out.elapsedRealtime.timeUncertaintyNs =
std::max((int64_t)abs(currentTimeNanos - locationTimeNanos),
(int64_t)100000000);
// time uncertainty is 1 ms since it is calculated from utc time that is in ms
out.elapsedRealtime.timeUncertaintyNs = 1000000;
LOC_LOGD("%s]: timestampNs:%" PRIi64 ")",
__FUNCTION__, out.elapsedRealtime.timestampNs);
}
}
} else {
LOC_LOGe("Failed to calculate elapsedRealtimeNanos timestamp");
LOC_LOGE("%s]: Failed to calculate elapsedRealtimeNanos timestamp after %u tries",
__FUNCTION__, MAX_GET_TIME_COUNT);
}
}
......@@ -262,64 +252,6 @@ void convertGnssConstellationType(GnssSvType& in, V2_0::GnssConstellationType& o
}
}
void convertGnssSvid(GnssSv& in, int16_t& out)
{
switch (in.type) {
case GNSS_SV_TYPE_GPS:
out = in.svId;
break;
case GNSS_SV_TYPE_SBAS:
out = in.svId;
break;
case GNSS_SV_TYPE_GLONASS:
out = in.svId - GLO_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_QZSS:
out = in.svId;
break;
case GNSS_SV_TYPE_BEIDOU:
out = in.svId - BDS_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_GALILEO:
out = in.svId - GAL_SV_PRN_MIN + 1;
break;
default:
out = in.svId;
break;
}
}
void convertGnssSvid(GnssMeasurementsData& in, int16_t& out)
{
switch (in.svType) {
case GNSS_SV_TYPE_GPS:
out = in.svId;
break;
case GNSS_SV_TYPE_SBAS:
out = in.svId;
break;
case GNSS_SV_TYPE_GLONASS:
if (in.svId != 255) { // OSN is known
out = in.svId - GLO_SV_PRN_MIN + 1;
} else { // OSN is not known, report FCN
out = in.gloFrequency + 92;
}
break;
case GNSS_SV_TYPE_QZSS:
out = in.svId;
break;
case GNSS_SV_TYPE_BEIDOU:
out = in.svId - BDS_SV_PRN_MIN + 1;
break;
case GNSS_SV_TYPE_GALILEO:
out = in.svId - GAL_SV_PRN_MIN + 1;
break;
default:
out = in.svId;
break;
}
}
void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out)
{
switch(in) {
......
......@@ -46,12 +46,9 @@ void convertGnssLocation(const V1_0::GnssLocation& in, Location& out);
void convertGnssLocation(const V2_0::GnssLocation& in, Location& out);
void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out);
void convertGnssConstellationType(GnssSvType& in, V2_0::GnssConstellationType& out);
void convertGnssSvid(GnssSv& in, int16_t& out);
void convertGnssSvid(GnssMeasurementsData& in, int16_t& out);
void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out);
void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out);
void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out);
bool getCurrentTime(struct timespec& currentTime, int64_t& sinceBootTimeNanos);
} // namespace implementation
} // namespace V2_0
......
......@@ -32,7 +32,6 @@
#include <log_util.h>
#include <loc_cfg.h>