2018-03-02 20:02:28 -05:00
|
|
|
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
|
2017-02-28 19:45:47 -05:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials provided
|
|
|
|
* with the distribution.
|
|
|
|
* * Neither the name of The Linux Foundation, nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
|
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
|
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
|
|
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
2018-05-17 14:35:32 -04:00
|
|
|
#define LOG_NDEBUG 0
|
2017-02-28 19:45:47 -05:00
|
|
|
#define LOG_TAG "LocSvc_GnssAdapter"
|
|
|
|
|
2017-07-03 09:00:31 -04:00
|
|
|
#include <inttypes.h>
|
2017-02-28 19:45:47 -05:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <cutils/properties.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <GnssAdapter.h>
|
|
|
|
#include <string>
|
|
|
|
#include <loc_log.h>
|
2017-03-24 20:39:20 -04:00
|
|
|
#include <loc_nmea.h>
|
2017-02-02 14:16:48 -05:00
|
|
|
#include <Agps.h>
|
2017-03-14 14:13:23 -04:00
|
|
|
#include <SystemStatus.h>
|
2017-02-28 19:45:47 -05:00
|
|
|
|
2016-12-23 00:12:44 -05:00
|
|
|
#include <vector>
|
|
|
|
|
2017-08-22 13:56:00 -04:00
|
|
|
#define RAD2DEG (180.0 / M_PI)
|
2018-01-29 04:02:06 -05:00
|
|
|
#define PROCESS_NAME_ENGINE_SERVICE "engine-service"
|
2017-08-22 13:56:00 -04:00
|
|
|
|
2017-02-28 19:45:47 -05:00
|
|
|
using namespace loc_core;
|
|
|
|
|
2017-08-29 05:49:40 -04:00
|
|
|
/* Method to fetch status cb from loc_net_iface library */
|
|
|
|
typedef AgpsCbInfo& (*LocAgpsGetAgpsCbInfo)(LocAgpsOpenResultCb openResultCb,
|
|
|
|
LocAgpsCloseResultCb closeResultCb, void* userDataPtr);
|
|
|
|
|
|
|
|
static void agpsOpenResultCb (bool isSuccess, AGpsExtType agpsType, const char* apn,
|
|
|
|
AGpsBearerType bearerType, void* userDataPtr);
|
|
|
|
static void agpsCloseResultCb (bool isSuccess, AGpsExtType agpsType, void* userDataPtr);
|
|
|
|
|
2017-02-28 19:45:47 -05:00
|
|
|
GnssAdapter::GnssAdapter() :
|
|
|
|
LocAdapterBase(0,
|
|
|
|
LocDualContext::getLocFgContext(NULL,
|
|
|
|
NULL,
|
|
|
|
LocDualContext::mLocationHalName,
|
2018-05-15 13:21:09 -04:00
|
|
|
false), true, nullptr),
|
2018-01-29 04:02:06 -05:00
|
|
|
mEngHubProxy(new EngineHubProxyBase()),
|
2018-06-07 15:03:55 -04:00
|
|
|
mLocPositionMode(),
|
2017-02-28 19:45:47 -05:00
|
|
|
mGnssSvIdUsedInPosition(),
|
|
|
|
mGnssSvIdUsedInPosAvail(false),
|
|
|
|
mControlCallbacks(),
|
|
|
|
mPowerVoteId(0),
|
2017-07-07 18:33:52 -04:00
|
|
|
mNmeaMask(0),
|
2018-05-20 09:59:46 -04:00
|
|
|
mGnssSvIdConfig(),
|
|
|
|
mGnssSvTypeConfig(),
|
|
|
|
mGnssSvTypeConfigCb(nullptr),
|
2017-02-02 14:16:48 -05:00
|
|
|
mNiData(),
|
2017-06-19 08:24:28 -04:00
|
|
|
mAgpsManager(),
|
2017-08-11 05:43:38 -04:00
|
|
|
mAgpsCbInfo(),
|
2018-04-08 14:05:14 -04:00
|
|
|
mOdcpiRequestCb(nullptr),
|
|
|
|
mOdcpiRequestActive(false),
|
|
|
|
mOdcpiInjectedPositionCount(0),
|
2017-08-21 21:41:23 -04:00
|
|
|
mSystemStatus(SystemStatus::getInstance(mMsgTask)),
|
2018-01-17 10:39:24 -05:00
|
|
|
mServerUrl(":"),
|
2017-08-11 08:06:10 -04:00
|
|
|
mXtraObserver(mSystemStatus->getOsObserver(), mMsgTask)
|
2017-02-28 19:45:47 -05:00
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: Constructor %p", __func__, this);
|
2018-06-07 15:03:55 -04:00
|
|
|
mLocPositionMode.mode = LOC_POSITION_MODE_INVALID;
|
2017-09-18 19:12:46 -04:00
|
|
|
|
2018-01-11 02:25:27 -05:00
|
|
|
pthread_condattr_t condAttr;
|
|
|
|
pthread_condattr_init(&condAttr);
|
|
|
|
pthread_condattr_setclock(&condAttr, CLOCK_MONOTONIC);
|
|
|
|
pthread_cond_init(&mNiData.session.tCond, &condAttr);
|
|
|
|
pthread_cond_init(&mNiData.sessionEs.tCond, &condAttr);
|
|
|
|
pthread_condattr_destroy(&condAttr);
|
|
|
|
|
2017-09-18 19:12:46 -04:00
|
|
|
/* Set ATL open/close callbacks */
|
|
|
|
AgpsAtlOpenStatusCb atlOpenStatusCb =
|
2018-01-22 19:04:50 -05:00
|
|
|
[this](int handle, int isSuccess, char* apn, uint32_t apnLen,
|
2018-05-17 14:35:32 -04:00
|
|
|
AGpsBearerType bearerType, AGpsExtType agpsType, LocApnTypeMask mask) {
|
2017-09-18 19:12:46 -04:00
|
|
|
|
|
|
|
mLocApi->atlOpenStatus(
|
2018-05-17 14:35:32 -04:00
|
|
|
handle, isSuccess, apn, apnLen, bearerType, agpsType, mask);
|
2017-09-18 19:12:46 -04:00
|
|
|
};
|
|
|
|
AgpsAtlCloseStatusCb atlCloseStatusCb =
|
|
|
|
[this](int handle, int isSuccess) {
|
|
|
|
|
|
|
|
mLocApi->atlCloseStatus(handle, isSuccess);
|
|
|
|
};
|
2018-03-13 13:11:02 -04:00
|
|
|
mAgpsManager.registerATLCallbacks(atlOpenStatusCb, atlCloseStatusCb);
|
2017-09-18 19:12:46 -04:00
|
|
|
|
2017-02-28 19:45:47 -05:00
|
|
|
readConfigCommand();
|
2017-08-29 05:49:40 -04:00
|
|
|
initDefaultAgpsCommand();
|
2018-01-29 04:02:06 -05:00
|
|
|
initEngHubProxyCommand();
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::setControlCallbacksCommand(LocationControlCallbacks& controlCallbacks)
|
|
|
|
{
|
|
|
|
struct MsgSetControlCallbacks : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
const LocationControlCallbacks mControlCallbacks;
|
|
|
|
inline MsgSetControlCallbacks(GnssAdapter& adapter,
|
|
|
|
LocationControlCallbacks& controlCallbacks) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mControlCallbacks(controlCallbacks) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter.setControlCallbacks(mControlCallbacks);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgSetControlCallbacks(*this, controlCallbacks));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-05-20 13:36:12 -04:00
|
|
|
GnssAdapter::convertOptions(LocPosMode& out, const TrackingOptions& trackingOptions)
|
2017-02-28 19:45:47 -05:00
|
|
|
{
|
2018-05-20 13:36:12 -04:00
|
|
|
switch (trackingOptions.mode) {
|
2017-02-28 19:45:47 -05:00
|
|
|
case GNSS_SUPL_MODE_MSB:
|
|
|
|
out.mode = LOC_POSITION_MODE_MS_BASED;
|
|
|
|
break;
|
|
|
|
case GNSS_SUPL_MODE_MSA:
|
|
|
|
out.mode = LOC_POSITION_MODE_MS_ASSISTED;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
out.mode = LOC_POSITION_MODE_STANDALONE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
out.share_position = true;
|
2018-05-20 13:36:12 -04:00
|
|
|
out.min_interval = trackingOptions.minInterval;
|
|
|
|
out.powerMode = trackingOptions.powerMode;
|
|
|
|
out.timeBetweenMeasurements = trackingOptions.tbm;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-01-10 00:58:17 -05:00
|
|
|
GnssAdapter::convertLocation(Location& out, const UlpLocation& ulpLocation,
|
2017-03-17 13:51:28 -04:00
|
|
|
const GpsLocationExtended& locationExtended,
|
2017-02-28 19:45:47 -05:00
|
|
|
const LocPosTechMask techMask)
|
|
|
|
{
|
2017-08-09 04:15:04 -04:00
|
|
|
memset(&out, 0, sizeof(Location));
|
2017-02-28 19:45:47 -05:00
|
|
|
out.size = sizeof(Location);
|
2018-01-10 00:58:17 -05:00
|
|
|
if (LOC_GPS_LOCATION_HAS_LAT_LONG & ulpLocation.gpsLocation.flags) {
|
2017-02-28 19:45:47 -05:00
|
|
|
out.flags |= LOCATION_HAS_LAT_LONG_BIT;
|
2018-01-10 00:58:17 -05:00
|
|
|
out.latitude = ulpLocation.gpsLocation.latitude;
|
|
|
|
out.longitude = ulpLocation.gpsLocation.longitude;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
2018-01-10 00:58:17 -05:00
|
|
|
if (LOC_GPS_LOCATION_HAS_ALTITUDE & ulpLocation.gpsLocation.flags) {
|
2017-02-28 19:45:47 -05:00
|
|
|
out.flags |= LOCATION_HAS_ALTITUDE_BIT;
|
2018-01-10 00:58:17 -05:00
|
|
|
out.altitude = ulpLocation.gpsLocation.altitude;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
2018-01-10 00:58:17 -05:00
|
|
|
if (LOC_GPS_LOCATION_HAS_SPEED & ulpLocation.gpsLocation.flags) {
|
2017-02-28 19:45:47 -05:00
|
|
|
out.flags |= LOCATION_HAS_SPEED_BIT;
|
2018-01-10 00:58:17 -05:00
|
|
|
out.speed = ulpLocation.gpsLocation.speed;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
2018-01-10 00:58:17 -05:00
|
|
|
if (LOC_GPS_LOCATION_HAS_BEARING & ulpLocation.gpsLocation.flags) {
|
2017-02-28 19:45:47 -05:00
|
|
|
out.flags |= LOCATION_HAS_BEARING_BIT;
|
2018-01-10 00:58:17 -05:00
|
|
|
out.bearing = ulpLocation.gpsLocation.bearing;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
2018-01-10 00:58:17 -05:00
|
|
|
if (LOC_GPS_LOCATION_HAS_ACCURACY & ulpLocation.gpsLocation.flags) {
|
2017-02-28 19:45:47 -05:00
|
|
|
out.flags |= LOCATION_HAS_ACCURACY_BIT;
|
2018-01-10 00:58:17 -05:00
|
|
|
out.accuracy = ulpLocation.gpsLocation.accuracy;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
2017-03-17 13:51:28 -04:00
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_VERT_UNC & locationExtended.flags) {
|
|
|
|
out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT;
|
|
|
|
out.verticalAccuracy = locationExtended.vert_unc;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_SPEED_UNC & locationExtended.flags) {
|
|
|
|
out.flags |= LOCATION_HAS_SPEED_ACCURACY_BIT;
|
|
|
|
out.speedAccuracy = locationExtended.speed_unc;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_BEARING_UNC & locationExtended.flags) {
|
|
|
|
out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT;
|
|
|
|
out.bearingAccuracy = locationExtended.bearing_unc;
|
|
|
|
}
|
2018-01-10 00:58:17 -05:00
|
|
|
out.timestamp = ulpLocation.gpsLocation.timestamp;
|
2017-02-28 19:45:47 -05:00
|
|
|
if (LOC_POS_TECH_MASK_SATELLITE & techMask) {
|
|
|
|
out.techMask |= LOCATION_TECHNOLOGY_GNSS_BIT;
|
|
|
|
}
|
|
|
|
if (LOC_POS_TECH_MASK_CELLID & techMask) {
|
|
|
|
out.techMask |= LOCATION_TECHNOLOGY_CELL_BIT;
|
|
|
|
}
|
|
|
|
if (LOC_POS_TECH_MASK_WIFI & techMask) {
|
|
|
|
out.techMask |= LOCATION_TECHNOLOGY_WIFI_BIT;
|
|
|
|
}
|
|
|
|
if (LOC_POS_TECH_MASK_SENSORS & techMask) {
|
|
|
|
out.techMask |= LOCATION_TECHNOLOGY_SENSORS_BIT;
|
|
|
|
}
|
2018-04-16 03:12:49 -04:00
|
|
|
|
|
|
|
if (LOC_GPS_LOCATION_HAS_SPOOF_MASK & ulpLocation.gpsLocation.flags) {
|
|
|
|
out.flags |= LOCATION_HAS_SPOOF_MASK;
|
|
|
|
out.spoofMask = ulpLocation.gpsLocation.spoof_mask;
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out,
|
|
|
|
const GpsLocationExtended& locationExtended)
|
|
|
|
{
|
|
|
|
out.size = sizeof(GnssLocationInfoNotification);
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_ALTITUDE_MEAN_SEA_LEVEL_BIT;
|
|
|
|
out.altitudeMeanSeaLevel = locationExtended.altitudeMeanSeaLevel;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_DOP & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_DOP_BIT;
|
|
|
|
out.pdop = locationExtended.pdop;
|
|
|
|
out.hdop = locationExtended.hdop;
|
|
|
|
out.vdop = locationExtended.vdop;
|
|
|
|
}
|
2018-01-10 00:58:17 -05:00
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_EXT_DOP & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_EXT_DOP_BIT;
|
|
|
|
out.gdop = locationExtended.extDOP.GDOP;
|
|
|
|
out.tdop = locationExtended.extDOP.TDOP;
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_MAG_DEV & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_MAGNETIC_DEVIATION_BIT;
|
|
|
|
out.magneticDeviation = locationExtended.magneticDeviation;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_HOR_RELIABILITY & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_HOR_RELIABILITY_BIT;
|
|
|
|
switch (locationExtended.horizontal_reliability) {
|
|
|
|
case LOC_RELIABILITY_VERY_LOW:
|
|
|
|
out.horReliability = LOCATION_RELIABILITY_VERY_LOW;
|
|
|
|
break;
|
|
|
|
case LOC_RELIABILITY_LOW:
|
|
|
|
out.horReliability = LOCATION_RELIABILITY_LOW;
|
|
|
|
break;
|
|
|
|
case LOC_RELIABILITY_MEDIUM:
|
|
|
|
out.horReliability = LOCATION_RELIABILITY_MEDIUM;
|
|
|
|
break;
|
|
|
|
case LOC_RELIABILITY_HIGH:
|
|
|
|
out.horReliability = LOCATION_RELIABILITY_HIGH;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
out.horReliability = LOCATION_RELIABILITY_NOT_SET;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_VERT_RELIABILITY & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_VER_RELIABILITY_BIT;
|
|
|
|
switch (locationExtended.vertical_reliability) {
|
|
|
|
case LOC_RELIABILITY_VERY_LOW:
|
|
|
|
out.verReliability = LOCATION_RELIABILITY_VERY_LOW;
|
|
|
|
break;
|
|
|
|
case LOC_RELIABILITY_LOW:
|
|
|
|
out.verReliability = LOCATION_RELIABILITY_LOW;
|
|
|
|
break;
|
|
|
|
case LOC_RELIABILITY_MEDIUM:
|
|
|
|
out.verReliability = LOCATION_RELIABILITY_MEDIUM;
|
|
|
|
break;
|
|
|
|
case LOC_RELIABILITY_HIGH:
|
|
|
|
out.verReliability = LOCATION_RELIABILITY_HIGH;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
out.verReliability = LOCATION_RELIABILITY_NOT_SET;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_MAJOR & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MAJOR_BIT;
|
|
|
|
out.horUncEllipseSemiMajor = locationExtended.horUncEllipseSemiMajor;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_MINOR & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MINOR_BIT;
|
|
|
|
out.horUncEllipseSemiMinor = locationExtended.horUncEllipseSemiMinor;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_AZIMUTH & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_AZIMUTH_BIT;
|
|
|
|
out.horUncEllipseOrientAzimuth = locationExtended.horUncEllipseOrientAzimuth;
|
|
|
|
}
|
2018-05-25 17:34:08 -04:00
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_NORTH_STD_DEV & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_NORTH_STD_DEV_BIT;
|
|
|
|
out.northVelocityStdDeviation = locationExtended.northStdDeviation;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_EAST_STD_DEV & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_EAST_STD_DEV_BIT;
|
|
|
|
out.eastVelocityStdDeviation = locationExtended.eastStdDeviation;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_NORTH_VEL & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_NORTH_VEL_BIT;
|
|
|
|
out.northVelocity = locationExtended.northVelocity;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_NORTH_VEL_UNC & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_NORTH_VEL_UNC_BIT;
|
|
|
|
out.northVelocityStdDeviation = locationExtended.northVelocityStdDeviation;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_EAST_VEL & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_EAST_VEL_BIT;
|
|
|
|
out.eastVelocity = locationExtended.eastVelocity;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_EAST_VEL_UNC & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_EAST_VEL_UNC_BIT;
|
|
|
|
out.eastVelocityStdDeviation = locationExtended.eastVelocityStdDeviation;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_UP_VEL & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_UP_VEL_BIT;
|
|
|
|
out.upVelocity = locationExtended.upVelocity;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_UP_VEL_UNC & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_UP_VEL_UNC_BIT;
|
|
|
|
out.upVelocityStdDeviation = locationExtended.upVelocityStdDeviation;
|
|
|
|
}
|
2018-01-10 00:58:17 -05:00
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_GNSS_SV_USED_DATA & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_GNSS_SV_USED_DATA_BIT;
|
|
|
|
out.svUsedInPosition.gpsSvUsedIdsMask =
|
|
|
|
locationExtended.gnss_sv_used_ids.gps_sv_used_ids_mask;
|
|
|
|
out.svUsedInPosition.gloSvUsedIdsMask =
|
|
|
|
locationExtended.gnss_sv_used_ids.glo_sv_used_ids_mask;
|
|
|
|
out.svUsedInPosition.galSvUsedIdsMask =
|
|
|
|
locationExtended.gnss_sv_used_ids.gal_sv_used_ids_mask;
|
|
|
|
out.svUsedInPosition.bdsSvUsedIdsMask =
|
|
|
|
locationExtended.gnss_sv_used_ids.bds_sv_used_ids_mask;
|
|
|
|
out.svUsedInPosition.qzssSvUsedIdsMask =
|
|
|
|
locationExtended.gnss_sv_used_ids.qzss_sv_used_ids_mask;
|
2018-05-25 17:34:08 -04:00
|
|
|
out.numOfMeasReceived = locationExtended.numOfMeasReceived;
|
|
|
|
|
|
|
|
for (int idx =0; idx < locationExtended.numOfMeasReceived; idx++) {
|
|
|
|
out.measUsageInfo[idx].gnssSignalType =
|
|
|
|
locationExtended.measUsageInfo[idx].gnssSignalType;
|
|
|
|
out.measUsageInfo[idx].gnssSvId =
|
|
|
|
locationExtended.measUsageInfo[idx].gnssSvId;
|
|
|
|
out.measUsageInfo[idx].gnssConstellation =
|
|
|
|
locationExtended.measUsageInfo[idx].gnssConstellation;
|
|
|
|
}
|
2018-01-10 00:58:17 -05:00
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_NAV_SOLUTION_MASK & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_NAV_SOLUTION_MASK_BIT;
|
|
|
|
out.navSolutionMask = locationExtended.navSolutionMask;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_POS_TECH_MASK & locationExtended.flags) {
|
|
|
|
out.flags |= GPS_LOCATION_EXTENDED_HAS_POS_TECH_MASK;
|
|
|
|
out.posTechMask = locationExtended.tech_mask;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_POS_DYNAMICS_DATA & locationExtended.flags) {
|
|
|
|
out.flags |= GPS_LOCATION_EXTENDED_HAS_POS_DYNAMICS_DATA;
|
|
|
|
if (locationExtended.bodyFrameData.bodyFrameDatamask &
|
|
|
|
LOCATION_NAV_DATA_HAS_LONG_ACCEL_BIT) {
|
|
|
|
out.bodyFrameData.bodyFrameDataMask |= LOCATION_NAV_DATA_HAS_LONG_ACCEL_BIT;
|
|
|
|
}
|
|
|
|
if (locationExtended.bodyFrameData.bodyFrameDatamask &
|
|
|
|
LOCATION_NAV_DATA_HAS_LAT_ACCEL_BIT) {
|
|
|
|
out.bodyFrameData.bodyFrameDataMask |= LOCATION_NAV_DATA_HAS_LAT_ACCEL_BIT;
|
|
|
|
}
|
|
|
|
if (locationExtended.bodyFrameData.bodyFrameDatamask &
|
|
|
|
LOCATION_NAV_DATA_HAS_VERT_ACCEL_BIT) {
|
|
|
|
out.bodyFrameData.bodyFrameDataMask |= LOCATION_NAV_DATA_HAS_VERT_ACCEL_BIT;
|
|
|
|
}
|
|
|
|
if (locationExtended.bodyFrameData.bodyFrameDatamask & LOCATION_NAV_DATA_HAS_YAW_RATE_BIT) {
|
|
|
|
out.bodyFrameData.bodyFrameDataMask |= LOCATION_NAV_DATA_HAS_YAW_RATE_BIT;
|
|
|
|
}
|
|
|
|
if (locationExtended.bodyFrameData.bodyFrameDatamask & LOCATION_NAV_DATA_HAS_PITCH_BIT) {
|
|
|
|
out.bodyFrameData.bodyFrameDataMask |= LOCATION_NAV_DATA_HAS_PITCH_BIT;
|
|
|
|
}
|
|
|
|
out.bodyFrameData.longAccel = locationExtended.bodyFrameData.longAccel;
|
|
|
|
out.bodyFrameData.latAccel = locationExtended.bodyFrameData.latAccel;
|
|
|
|
out.bodyFrameData.vertAccel = locationExtended.bodyFrameData.vertAccel;
|
|
|
|
out.bodyFrameData.yawRate = locationExtended.bodyFrameData.yawRate;
|
|
|
|
out.bodyFrameData.pitch = locationExtended.bodyFrameData.pitch;
|
|
|
|
}
|
2018-03-15 02:12:15 -04:00
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_GPS_TIME & locationExtended.flags) {
|
|
|
|
out.flags |= GPS_LOCATION_EXTENDED_HAS_GPS_TIME;
|
|
|
|
out.gnssSystemTime.gnssSystemTimeSrc = locationExtended.gnssSystemTime.gnssSystemTimeSrc;
|
|
|
|
out.gnssSystemTime.u = locationExtended.gnssSystemTime.u;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_NORTH_VEL & locationExtended.flags) {
|
|
|
|
out.flags |= GPS_LOCATION_EXTENDED_HAS_NORTH_VEL;
|
|
|
|
out.northVelocity = locationExtended.northVelocity;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_EAST_VEL & locationExtended.flags) {
|
|
|
|
out.flags |= GPS_LOCATION_EXTENDED_HAS_EAST_VEL;
|
|
|
|
out.eastVelocity = locationExtended.eastVelocity;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_UP_VEL & locationExtended.flags) {
|
|
|
|
out.flags |= GPS_LOCATION_EXTENDED_HAS_UP_VEL;
|
|
|
|
out.upVelocity = locationExtended.upVelocity;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_NORTH_VEL_UNC & locationExtended.flags) {
|
|
|
|
out.flags |= GPS_LOCATION_EXTENDED_HAS_NORTH_VEL_UNC;
|
|
|
|
out.northVelocityStdDeviation = locationExtended.northVelocityStdDeviation;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_EAST_VEL_UNC & locationExtended.flags) {
|
|
|
|
out.flags |= GPS_LOCATION_EXTENDED_HAS_EAST_VEL_UNC;
|
|
|
|
out.eastVelocityStdDeviation = locationExtended.eastVelocityStdDeviation;
|
|
|
|
}
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_UP_VEL_UNC & locationExtended.flags) {
|
|
|
|
out.flags |= GPS_LOCATION_EXTENDED_HAS_UP_VEL_UNC;
|
|
|
|
out.upVelocityStdDeviation = locationExtended.upVelocityStdDeviation;
|
|
|
|
}
|
2018-05-25 17:34:08 -04:00
|
|
|
|
|
|
|
// Validity of this structure is established from the timeSrc of the GnssSystemTime structure.
|
|
|
|
out.gnssSystemTime = locationExtended.gnssSystemTime;
|
|
|
|
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_LEAP_SECONDS & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_LEAP_SECONDS_BIT;
|
|
|
|
out.leapSeconds = locationExtended.leapSeconds;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GPS_LOCATION_EXTENDED_HAS_TIME_UNC & locationExtended.flags) {
|
|
|
|
out.flags |= GNSS_LOCATION_INFO_TIME_UNC_BIT;
|
|
|
|
out.timeUncMs = locationExtended.timeUncMs;
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
inline uint32_t
|
|
|
|
GnssAdapter::convertGpsLock(const GnssConfigGpsLock gpsLock)
|
|
|
|
{
|
|
|
|
switch (gpsLock) {
|
|
|
|
case GNSS_CONFIG_GPS_LOCK_MO:
|
|
|
|
return 1;
|
|
|
|
case GNSS_CONFIG_GPS_LOCK_NI:
|
|
|
|
return 2;
|
|
|
|
case GNSS_CONFIG_GPS_LOCK_MO_AND_NI:
|
|
|
|
return 3;
|
|
|
|
case GNSS_CONFIG_GPS_LOCK_NONE:
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline GnssConfigGpsLock
|
|
|
|
GnssAdapter::convertGpsLock(const uint32_t gpsLock)
|
|
|
|
{
|
|
|
|
switch (gpsLock) {
|
|
|
|
case 1:
|
|
|
|
return GNSS_CONFIG_GPS_LOCK_MO;
|
|
|
|
case 2:
|
|
|
|
return GNSS_CONFIG_GPS_LOCK_NI;
|
|
|
|
case 3:
|
|
|
|
return GNSS_CONFIG_GPS_LOCK_MO_AND_NI;
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
return GNSS_CONFIG_GPS_LOCK_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline uint32_t
|
|
|
|
GnssAdapter::convertSuplVersion(const GnssConfigSuplVersion suplVersion)
|
|
|
|
{
|
|
|
|
switch (suplVersion) {
|
|
|
|
case GNSS_CONFIG_SUPL_VERSION_2_0_0:
|
|
|
|
return 0x00020000;
|
|
|
|
case GNSS_CONFIG_SUPL_VERSION_2_0_2:
|
|
|
|
return 0x00020002;
|
|
|
|
case GNSS_CONFIG_SUPL_VERSION_1_0_0:
|
|
|
|
default:
|
|
|
|
return 0x00010000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline uint32_t
|
|
|
|
GnssAdapter::convertLppProfile(const GnssConfigLppProfile lppProfile)
|
|
|
|
{
|
|
|
|
switch (lppProfile) {
|
|
|
|
case GNSS_CONFIG_LPP_PROFILE_USER_PLANE:
|
|
|
|
return 1;
|
|
|
|
case GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE:
|
|
|
|
return 2;
|
|
|
|
case GNSS_CONFIG_LPP_PROFILE_USER_PLANE_AND_CONTROL_PLANE:
|
|
|
|
return 3;
|
|
|
|
case GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE:
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
GnssAdapter::convertLppeCp(const GnssConfigLppeControlPlaneMask lppeControlPlaneMask)
|
|
|
|
{
|
|
|
|
uint32_t mask = 0;
|
|
|
|
if (GNSS_CONFIG_LPPE_CONTROL_PLANE_DBH_BIT & lppeControlPlaneMask) {
|
|
|
|
mask |= (1<<0);
|
|
|
|
}
|
|
|
|
if (GNSS_CONFIG_LPPE_CONTROL_PLANE_WLAN_AP_MEASUREMENTS_BIT & lppeControlPlaneMask) {
|
|
|
|
mask |= (1<<1);
|
|
|
|
}
|
2017-08-12 16:09:36 -04:00
|
|
|
if (GNSS_CONFIG_LPPE_CONTROL_PLANE_SRN_AP_MEASUREMENTS_BIT & lppeControlPlaneMask) {
|
|
|
|
mask |= (1<<2);
|
|
|
|
}
|
|
|
|
if (GNSS_CONFIG_LPPE_CONTROL_PLANE_SENSOR_BARO_MEASUREMENTS_BIT & lppeControlPlaneMask) {
|
|
|
|
mask |= (1<<3);
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
GnssAdapter::convertLppeUp(const GnssConfigLppeUserPlaneMask lppeUserPlaneMask)
|
|
|
|
{
|
|
|
|
uint32_t mask = 0;
|
|
|
|
if (GNSS_CONFIG_LPPE_USER_PLANE_DBH_BIT & lppeUserPlaneMask) {
|
|
|
|
mask |= (1<<0);
|
|
|
|
}
|
|
|
|
if (GNSS_CONFIG_LPPE_USER_PLANE_WLAN_AP_MEASUREMENTS_BIT & lppeUserPlaneMask) {
|
|
|
|
mask |= (1<<1);
|
|
|
|
}
|
2017-08-12 16:09:36 -04:00
|
|
|
if (GNSS_CONFIG_LPPE_USER_PLANE_SRN_AP_MEASUREMENTS_BIT & lppeUserPlaneMask) {
|
|
|
|
mask |= (1<<2);
|
|
|
|
}
|
|
|
|
if (GNSS_CONFIG_LPPE_USER_PLANE_SENSOR_BARO_MEASUREMENTS_BIT & lppeUserPlaneMask) {
|
|
|
|
mask |= (1<<3);
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
GnssAdapter::convertAGloProt(const GnssConfigAGlonassPositionProtocolMask aGloPositionProtocolMask)
|
|
|
|
{
|
|
|
|
uint32_t mask = 0;
|
|
|
|
if (GNSS_CONFIG_RRC_CONTROL_PLANE_BIT & aGloPositionProtocolMask) {
|
|
|
|
mask |= (1<<0);
|
|
|
|
}
|
|
|
|
if (GNSS_CONFIG_RRLP_USER_PLANE_BIT & aGloPositionProtocolMask) {
|
|
|
|
mask |= (1<<1);
|
|
|
|
}
|
|
|
|
if (GNSS_CONFIG_LLP_USER_PLANE_BIT & aGloPositionProtocolMask) {
|
|
|
|
mask |= (1<<2);
|
|
|
|
}
|
|
|
|
if (GNSS_CONFIG_LLP_CONTROL_PLANE_BIT & aGloPositionProtocolMask) {
|
|
|
|
mask |= (1<<3);
|
|
|
|
}
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
GnssAdapter::convertEP4ES(const GnssConfigEmergencyPdnForEmergencySupl emergencyPdnForEmergencySupl)
|
|
|
|
{
|
|
|
|
switch (emergencyPdnForEmergencySupl) {
|
|
|
|
case GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_YES:
|
|
|
|
return 1;
|
|
|
|
case GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_NO:
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
GnssAdapter::convertSuplEs(const GnssConfigSuplEmergencyServices suplEmergencyServices)
|
|
|
|
{
|
|
|
|
switch (suplEmergencyServices) {
|
|
|
|
case GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_YES:
|
|
|
|
return 1;
|
|
|
|
case GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO:
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
GnssAdapter::convertSuplMode(const GnssConfigSuplModeMask suplModeMask)
|
|
|
|
{
|
|
|
|
uint32_t mask = 0;
|
2017-04-27 20:00:28 -04:00
|
|
|
if (GNSS_CONFIG_SUPL_MODE_MSB_BIT & suplModeMask) {
|
2017-02-28 19:45:47 -05:00
|
|
|
mask |= (1<<0);
|
|
|
|
}
|
2017-04-27 20:00:28 -04:00
|
|
|
if (GNSS_CONFIG_SUPL_MODE_MSA_BIT & suplModeMask) {
|
2017-02-28 19:45:47 -05:00
|
|
|
mask |= (1<<1);
|
|
|
|
}
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::readConfigCommand()
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: ", __func__);
|
|
|
|
|
|
|
|
struct MsgReadConfig : public LocMsg {
|
|
|
|
GnssAdapter* mAdapter;
|
|
|
|
ContextBase& mContext;
|
|
|
|
inline MsgReadConfig(GnssAdapter* adapter,
|
|
|
|
ContextBase& context) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mContext(context) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
// reads config into mContext->mGps_conf
|
|
|
|
mContext.readConfig();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (mContext != NULL) {
|
|
|
|
sendMsg(new MsgReadConfig(this, *mContext));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
void
|
2018-06-04 21:02:09 -04:00
|
|
|
GnssAdapter::setSuplHostServer(const char* server, int port, LocServerType type)
|
2017-09-18 05:11:35 -04:00
|
|
|
{
|
|
|
|
if (ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
|
|
|
|
char serverUrl[MAX_URL_LEN] = {};
|
2018-01-09 14:06:54 -05:00
|
|
|
int32_t length = -1;
|
2017-09-18 05:11:35 -04:00
|
|
|
const char noHost[] = "NONE";
|
2018-01-09 14:06:54 -05:00
|
|
|
|
|
|
|
if ((NULL == server) || (server[0] == 0) ||
|
2017-09-18 05:11:35 -04:00
|
|
|
(strncasecmp(noHost, server, sizeof(noHost)) == 0)) {
|
2018-02-07 01:39:33 -05:00
|
|
|
serverUrl[0] = '\0';
|
2018-01-09 14:06:54 -05:00
|
|
|
length = 0;
|
|
|
|
} else if (port > 0) {
|
2017-09-18 05:11:35 -04:00
|
|
|
length = snprintf(serverUrl, sizeof(serverUrl), "%s:%u", server, port);
|
2018-01-09 14:06:54 -05:00
|
|
|
}
|
2018-06-04 21:02:09 -04:00
|
|
|
if (LOC_AGPS_SUPL_SERVER != type && LOC_AGPS_MO_SUPL_SERVER != type) {
|
|
|
|
LOC_LOGe("Invalid type=%d", type);
|
|
|
|
} else {
|
|
|
|
string& url = (LOC_AGPS_SUPL_SERVER == type) ? getServerUrl() : getMoServerUrl();
|
|
|
|
if (length > 0 && strncasecmp(url.c_str(), serverUrl, sizeof(serverUrl)) != 0) {
|
|
|
|
url.assign(serverUrl);
|
|
|
|
LOC_LOGv("serverUrl=%s length=%d type=%d", serverUrl, length, type);
|
|
|
|
}
|
2017-09-18 05:11:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-28 19:45:47 -05:00
|
|
|
void
|
|
|
|
GnssAdapter::setConfigCommand()
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: ", __func__);
|
|
|
|
|
|
|
|
struct MsgSetConfig : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
LocApiBase& mApi;
|
2018-01-22 19:04:50 -05:00
|
|
|
inline MsgSetConfig(GnssAdapter& adapter, LocApiBase& api) :
|
2017-02-28 19:45:47 -05:00
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mApi(api) {}
|
|
|
|
inline virtual void proc() const {
|
2017-03-14 14:13:23 -04:00
|
|
|
|
|
|
|
// set nmea mask type
|
|
|
|
uint32_t mask = 0;
|
2017-02-28 19:45:47 -05:00
|
|
|
if (NMEA_PROVIDER_MP == ContextBase::mGps_conf.NMEA_PROVIDER) {
|
2017-07-07 18:33:52 -04:00
|
|
|
mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) {
|
2017-07-07 18:33:52 -04:00
|
|
|
mask |= LOC_NMEA_MASK_DEBUG_V02;
|
|
|
|
}
|
|
|
|
mAdapter.mNmeaMask= mask;
|
2017-03-14 14:13:23 -04:00
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
std::string oldServerUrl = mAdapter.getServerUrl();
|
2018-06-04 21:02:09 -04:00
|
|
|
std::string oldMoServerUrl = mAdapter.getMoServerUrl();
|
2018-01-22 19:04:50 -05:00
|
|
|
mAdapter.setSuplHostServer(ContextBase::mGps_conf.SUPL_HOST,
|
2018-06-04 21:02:09 -04:00
|
|
|
ContextBase::mGps_conf.SUPL_PORT,
|
|
|
|
LOC_AGPS_SUPL_SERVER);
|
|
|
|
mAdapter.setSuplHostServer(ContextBase::mGps_conf.MO_SUPL_HOST,
|
|
|
|
ContextBase::mGps_conf.MO_SUPL_PORT,
|
|
|
|
LOC_AGPS_MO_SUPL_SERVER);
|
2018-01-22 19:04:50 -05:00
|
|
|
|
|
|
|
// inject the configurations into modem
|
|
|
|
GnssAdapter& adapter = mAdapter;
|
|
|
|
loc_gps_cfg_s gpsConf = ContextBase::mGps_conf;
|
|
|
|
loc_sap_cfg_s_type sapConf = ContextBase::mSap_conf;
|
|
|
|
|
|
|
|
mApi.sendMsg(new LocApiMsg(
|
2018-06-04 21:02:09 -04:00
|
|
|
[&adapter, gpsConf, sapConf, oldServerUrl, oldMoServerUrl] () {
|
2018-01-22 19:04:50 -05:00
|
|
|
|
|
|
|
std::string serverUrl = adapter.getServerUrl();
|
2018-06-04 21:02:09 -04:00
|
|
|
std::string moServerUrl = adapter.getMoServerUrl();
|
2018-01-22 19:04:50 -05:00
|
|
|
int serverUrlLen = serverUrl.length();
|
2018-06-04 21:02:09 -04:00
|
|
|
int moServerUrlLen = moServerUrl.length();
|
2018-01-22 19:04:50 -05:00
|
|
|
|
|
|
|
if (gpsConf.AGPS_CONFIG_INJECT) {
|
|
|
|
adapter.mLocApi->setSUPLVersionSync(
|
|
|
|
adapter.mLocApi->convertSuplVersion(gpsConf.SUPL_VER));
|
|
|
|
adapter.mLocApi->setLPPConfigSync(
|
|
|
|
adapter.mLocApi->convertLppProfile(gpsConf.LPP_PROFILE));
|
|
|
|
adapter.mLocApi->setAGLONASSProtocolSync(
|
|
|
|
gpsConf.A_GLONASS_POS_PROTOCOL_SELECT);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((serverUrlLen !=0) && (oldServerUrl.compare(serverUrl) != 0)) {
|
|
|
|
LocationError locErr =
|
2018-06-04 21:02:09 -04:00
|
|
|
adapter.mLocApi->setServerSync(serverUrl.c_str(), serverUrlLen,
|
|
|
|
LOC_AGPS_SUPL_SERVER);
|
2018-01-22 19:04:50 -05:00
|
|
|
if (locErr != LOCATION_ERROR_SUCCESS) {
|
2018-06-04 21:02:09 -04:00
|
|
|
LOC_LOGe("Error while setting SUPL_HOST server:%s",
|
|
|
|
serverUrl.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((moServerUrlLen != 0) && (oldMoServerUrl.compare(moServerUrl) != 0)) {
|
|
|
|
LocationError locErr =
|
|
|
|
adapter.mLocApi->setServerSync(moServerUrl.c_str(),
|
|
|
|
moServerUrlLen,
|
|
|
|
LOC_AGPS_MO_SUPL_SERVER);
|
|
|
|
if (locErr != LOCATION_ERROR_SUCCESS) {
|
|
|
|
LOC_LOGe("Error while setting MO SUPL_HOST server:%s",
|
|
|
|
moServerUrl.c_str());
|
2018-01-22 19:04:50 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
adapter.mLocApi->setSensorControlConfigSync(sapConf.SENSOR_USAGE,
|
|
|
|
sapConf.SENSOR_PROVIDER);
|
|
|
|
adapter.mLocApi->setLPPeProtocolCpSync(
|
|
|
|
adapter.mLocApi->convertLppeCp(gpsConf.LPPE_CP_TECHNOLOGY));
|
|
|
|
adapter.mLocApi->setLPPeProtocolUpSync(
|
|
|
|
adapter.mLocApi->convertLppeUp(gpsConf.LPPE_UP_TECHNOLOGY));
|
|
|
|
|
|
|
|
// set nmea mask type
|
|
|
|
uint32_t mask = 0;
|
|
|
|
if (NMEA_PROVIDER_MP == gpsConf.NMEA_PROVIDER) {
|
|
|
|
mask |= LOC_NMEA_ALL_GENERAL_SUPPORTED_MASK;
|
|
|
|
}
|
|
|
|
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) {
|
|
|
|
mask |= LOC_NMEA_MASK_DEBUG_V02;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mask != 0) {
|
|
|
|
adapter.mLocApi->setNMEATypesSync(mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
adapter.mLocApi->setXtraVersionCheckSync(gpsConf.XTRA_VERSION_CHECK);
|
|
|
|
if (sapConf.GYRO_BIAS_RANDOM_WALK_VALID ||
|
|
|
|
sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
|
|
|
|
sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
|
|
|
|
sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID ||
|
|
|
|
sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) {
|
|
|
|
adapter.mLocApi->setSensorPropertiesSync(
|
|
|
|
sapConf.GYRO_BIAS_RANDOM_WALK_VALID,
|
|
|
|
sapConf.GYRO_BIAS_RANDOM_WALK,
|
|
|
|
sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
|
|
|
|
sapConf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY,
|
|
|
|
sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
|
|
|
|
sapConf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY,
|
|
|
|
sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
|
|
|
|
sapConf.RATE_RANDOM_WALK_SPECTRAL_DENSITY,
|
|
|
|
sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID,
|
|
|
|
sapConf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY);
|
|
|
|
}
|
|
|
|
adapter.mLocApi->setSensorPerfControlConfigSync(
|
|
|
|
sapConf.SENSOR_CONTROL_MODE,
|
|
|
|
sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH,
|
|
|
|
sapConf.SENSOR_ACCEL_BATCHES_PER_SEC,
|
|
|
|
sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH,
|
|
|
|
sapConf.SENSOR_GYRO_BATCHES_PER_SEC,
|
|
|
|
sapConf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH,
|
|
|
|
sapConf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH,
|
|
|
|
sapConf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH,
|
|
|
|
sapConf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH,
|
|
|
|
sapConf.SENSOR_ALGORITHM_CONFIG_MASK);
|
|
|
|
} ));
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgSetConfig(*this, *mLocApi));
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t*
|
|
|
|
GnssAdapter::gnssUpdateConfigCommand(GnssConfig config)
|
|
|
|
{
|
|
|
|
// count the number of bits set
|
|
|
|
GnssConfigFlagsMask flagsCopy = config.flags;
|
|
|
|
size_t count = 0;
|
|
|
|
while (flagsCopy > 0) {
|
|
|
|
if (flagsCopy & 1) {
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
flagsCopy >>= 1;
|
|
|
|
}
|
|
|
|
std::string idsString = "[";
|
|
|
|
uint32_t* ids = NULL;
|
|
|
|
if (count > 0) {
|
|
|
|
ids = new uint32_t[count];
|
2017-09-20 04:43:05 -04:00
|
|
|
if (ids == nullptr) {
|
|
|
|
LOC_LOGE("%s] new allocation failed, fatal error.", __func__);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
for (size_t i=0; i < count; ++i) {
|
|
|
|
ids[i] = generateSessionId();
|
|
|
|
IF_LOC_LOGD {
|
|
|
|
idsString += std::to_string(ids[i]) + " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
idsString += "]";
|
|
|
|
|
|
|
|
LOC_LOGD("%s]: ids %s flags 0x%X", __func__, idsString.c_str(), config.flags);
|
|
|
|
|
|
|
|
struct MsgGnssUpdateConfig : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
LocApiBase& mApi;
|
|
|
|
GnssConfig mConfig;
|
|
|
|
size_t mCount;
|
2018-01-22 19:04:50 -05:00
|
|
|
uint32_t* mIds;
|
2017-02-28 19:45:47 -05:00
|
|
|
inline MsgGnssUpdateConfig(GnssAdapter& adapter,
|
|
|
|
LocApiBase& api,
|
|
|
|
GnssConfig config,
|
|
|
|
uint32_t* ids,
|
|
|
|
size_t count) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mApi(api),
|
|
|
|
mConfig(config),
|
2018-01-22 19:04:50 -05:00
|
|
|
mCount(count),
|
|
|
|
mIds(ids) {}
|
2017-02-28 19:45:47 -05:00
|
|
|
inline virtual ~MsgGnssUpdateConfig()
|
|
|
|
{
|
2018-01-22 19:04:50 -05:00
|
|
|
delete [] mIds;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
|
2017-02-28 19:45:47 -05:00
|
|
|
inline virtual void proc() const {
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
GnssAdapter& adapter = mAdapter;
|
|
|
|
size_t countOfConfigs = mCount;
|
|
|
|
GnssConfig gnssConfigRequested = mConfig;
|
|
|
|
GnssConfig gnssConfigNeedEngineUpdate = mConfig;
|
|
|
|
std::string oldServerUrl = mAdapter.getServerUrl();
|
|
|
|
|
|
|
|
std::vector<uint32_t> sessionIds;
|
|
|
|
sessionIds.assign(mIds, mIds + mCount);
|
|
|
|
std::vector<LocationError> errs(mCount, LOCATION_ERROR_SUCCESS);
|
|
|
|
int index = 0;
|
2017-09-20 04:43:05 -04:00
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) {
|
|
|
|
index++;
|
|
|
|
uint32_t newGpsLock = mAdapter.convertGpsLock(gnssConfigRequested.gpsLock);
|
2017-02-28 19:45:47 -05:00
|
|
|
ContextBase::mGps_conf.GPS_LOCK = newGpsLock;
|
2018-05-15 13:21:09 -04:00
|
|
|
if (0 == ContextBase::mGps_conf.GPS_LOCK) {
|
|
|
|
ContextBase::mGps_conf.GPS_LOCK = 3;
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
if (0 != mAdapter.getPowerVoteId()) {
|
|
|
|
gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) {
|
|
|
|
index++;
|
|
|
|
uint32_t newSuplVersion =
|
|
|
|
mAdapter.convertSuplVersion(gnssConfigRequested.suplVersion);
|
2017-02-28 19:45:47 -05:00
|
|
|
if (newSuplVersion != ContextBase::mGps_conf.SUPL_VER &&
|
|
|
|
ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
|
|
|
|
ContextBase::mGps_conf.SUPL_VER = newSuplVersion;
|
|
|
|
} else {
|
2018-01-22 19:04:50 -05:00
|
|
|
gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
|
|
|
|
index++;
|
2017-02-28 19:45:47 -05:00
|
|
|
if (GNSS_ASSISTANCE_TYPE_SUPL == mConfig.assistanceServer.type) {
|
2018-01-22 19:04:50 -05:00
|
|
|
mAdapter.setSuplHostServer(mConfig.assistanceServer.hostName,
|
2018-06-04 21:02:09 -04:00
|
|
|
mConfig.assistanceServer.port,
|
|
|
|
LOC_AGPS_SUPL_SERVER);
|
|
|
|
} else {
|
2017-02-28 19:45:47 -05:00
|
|
|
LOC_LOGE("%s]: Not a valid gnss assistance type %u",
|
2018-01-22 19:04:50 -05:00
|
|
|
__func__, mConfig.assistanceServer.type);
|
|
|
|
errs.at(index) = LOCATION_ERROR_INVALID_PARAMETER;
|
|
|
|
gnssConfigNeedEngineUpdate.flags &=
|
|
|
|
~(GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
|
|
|
|
index++;
|
|
|
|
uint32_t newLppProfile = mAdapter.convertLppProfile(gnssConfigRequested.lppProfile);
|
2017-02-28 19:45:47 -05:00
|
|
|
if (newLppProfile != ContextBase::mGps_conf.LPP_PROFILE &&
|
|
|
|
ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
|
|
|
|
ContextBase::mGps_conf.LPP_PROFILE = newLppProfile;
|
|
|
|
} else {
|
2018-01-22 19:04:50 -05:00
|
|
|
gnssConfigNeedEngineUpdate.flags &= ~(GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
|
|
|
|
index++;
|
2017-02-28 19:45:47 -05:00
|
|
|
uint32_t newLppeControlPlaneMask =
|
2018-01-22 19:04:50 -05:00
|
|
|
mAdapter.convertLppeCp(gnssConfigRequested.lppeControlPlaneMask);
|
2017-02-28 19:45:47 -05:00
|
|
|
if (newLppeControlPlaneMask != ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY) {
|
|
|
|
ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY = newLppeControlPlaneMask;
|
|
|
|
} else {
|
2018-01-22 19:04:50 -05:00
|
|
|
gnssConfigNeedEngineUpdate.flags &=
|
|
|
|
~(GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) {
|
|
|
|
index++;
|
2017-02-28 19:45:47 -05:00
|
|
|
uint32_t newLppeUserPlaneMask =
|
2018-01-22 19:04:50 -05:00
|
|
|
mAdapter.convertLppeUp(gnssConfigRequested.lppeUserPlaneMask);
|
2017-02-28 19:45:47 -05:00
|
|
|
if (newLppeUserPlaneMask != ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY) {
|
|
|
|
ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY = newLppeUserPlaneMask;
|
|
|
|
} else {
|
2018-01-22 19:04:50 -05:00
|
|
|
gnssConfigNeedEngineUpdate.flags &=
|
|
|
|
~(GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
if (gnssConfigRequested.flags &
|
|
|
|
GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) {
|
|
|
|
index++;
|
2017-02-28 19:45:47 -05:00
|
|
|
uint32_t newAGloProtMask =
|
2018-01-22 19:04:50 -05:00
|
|
|
mAdapter.convertAGloProt(gnssConfigRequested.aGlonassPositionProtocolMask);
|
2017-02-28 19:45:47 -05:00
|
|
|
if (newAGloProtMask != ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT &&
|
|
|
|
ContextBase::mGps_conf.AGPS_CONFIG_INJECT) {
|
|
|
|
ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT = newAGloProtMask;
|
|
|
|
} else {
|
2018-01-22 19:04:50 -05:00
|
|
|
gnssConfigNeedEngineUpdate.flags &=
|
|
|
|
~(GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
}
|
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT) {
|
|
|
|
index++;
|
|
|
|
uint32_t newEP4ES = mAdapter.convertEP4ES(
|
|
|
|
gnssConfigRequested.emergencyPdnForEmergencySupl);
|
2017-02-28 19:45:47 -05:00
|
|
|
if (newEP4ES != ContextBase::mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL) {
|
|
|
|
ContextBase::mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = newEP4ES;
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
}
|
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT) {
|
|
|
|
index++;
|
|
|
|
uint32_t newSuplEs = mAdapter.convertSuplEs(
|
|
|
|
gnssConfigRequested.suplEmergencyServices);
|
2017-02-28 19:45:47 -05:00
|
|
|
if (newSuplEs != ContextBase::mGps_conf.SUPL_ES) {
|
|
|
|
ContextBase::mGps_conf.SUPL_ES = newSuplEs;
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
}
|
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_MODE_BIT) {
|
|
|
|
index++;
|
|
|
|
uint32_t newSuplMode = mAdapter.convertSuplMode(gnssConfigRequested.suplModeMask);
|
2017-02-28 19:45:47 -05:00
|
|
|
if (newSuplMode != ContextBase::mGps_conf.SUPL_MODE) {
|
|
|
|
ContextBase::mGps_conf.SUPL_MODE = newSuplMode;
|
2017-07-19 18:30:35 -04:00
|
|
|
mAdapter.broadcastCapabilities(mAdapter.getCapabilities());
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
LocApiCollectiveResponse *configCollectiveResponse = new LocApiCollectiveResponse(
|
|
|
|
*adapter.getContext(),
|
|
|
|
[&adapter, sessionIds, countOfConfigs] (std::vector<LocationError> errs) {
|
|
|
|
|
|
|
|
std::vector<uint32_t> ids(sessionIds);
|
|
|
|
adapter.reportResponse(countOfConfigs, errs.data(), ids.data());
|
|
|
|
});
|
|
|
|
|
|
|
|
mApi.sendMsg(new LocApiMsg(
|
|
|
|
[&adapter, gnssConfigRequested, gnssConfigNeedEngineUpdate,
|
|
|
|
countOfConfigs, configCollectiveResponse, errs, oldServerUrl] () {
|
|
|
|
|
|
|
|
size_t index = 0;
|
|
|
|
LocationError err = LOCATION_ERROR_SUCCESS;
|
|
|
|
std::vector<LocationError> errsList(errs);
|
|
|
|
|
|
|
|
std::string serverUrl = adapter.getServerUrl();
|
|
|
|
int serverUrlLen = serverUrl.length();
|
|
|
|
|
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) {
|
|
|
|
if (gnssConfigNeedEngineUpdate.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) {
|
|
|
|
err = adapter.mLocApi->setGpsLockSync(gnssConfigRequested.gpsLock);
|
|
|
|
if (index < countOfConfigs) {
|
|
|
|
errsList[index] = err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gnssConfigRequested.flags &
|
|
|
|
GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
|
|
|
|
index++;
|
|
|
|
if (gnssConfigNeedEngineUpdate.flags &
|
|
|
|
GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
|
|
|
|
if (gnssConfigNeedEngineUpdate.assistanceServer.type ==
|
|
|
|
GNSS_ASSISTANCE_TYPE_SUPL) {
|
|
|
|
if ((serverUrlLen != 0) && (oldServerUrl.compare(serverUrl) !=0)) {
|
|
|
|
err = adapter.mLocApi->setServerSync(
|
2018-06-04 21:02:09 -04:00
|
|
|
serverUrl.c_str(), serverUrlLen, LOC_AGPS_SUPL_SERVER);
|
2018-01-22 19:04:50 -05:00
|
|
|
errsList[index] = err;
|
|
|
|
}
|
|
|
|
} else if (gnssConfigNeedEngineUpdate.assistanceServer.type ==
|
|
|
|
GNSS_ASSISTANCE_TYPE_C2K) {
|
|
|
|
struct in_addr addr;
|
|
|
|
struct hostent* hp;
|
|
|
|
bool resolveAddrSuccess = true;
|
|
|
|
|
|
|
|
hp = gethostbyname(
|
|
|
|
gnssConfigNeedEngineUpdate.assistanceServer.hostName);
|
|
|
|
if (hp != NULL) { /* DNS OK */
|
|
|
|
memcpy(&addr, hp->h_addr_list[0], hp->h_length);
|
|
|
|
} else {
|
|
|
|
/* Try IP representation */
|
|
|
|
if (inet_aton(
|
|
|
|
gnssConfigNeedEngineUpdate.assistanceServer.hostName,
|
|
|
|
&addr) == 0) {
|
|
|
|
/* IP not valid */
|
|
|
|
LOC_LOGE("%s]: hostname '%s' cannot be resolved ",
|
|
|
|
__func__,
|
|
|
|
gnssConfigNeedEngineUpdate.assistanceServer.hostName);
|
|
|
|
errsList[index] = LOCATION_ERROR_INVALID_PARAMETER;
|
|
|
|
} else {
|
|
|
|
resolveAddrSuccess = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (resolveAddrSuccess) {
|
|
|
|
unsigned int ip = htonl(addr.s_addr);
|
|
|
|
err = adapter.mLocApi->setServerSync(ip,
|
|
|
|
gnssConfigNeedEngineUpdate.assistanceServer.port,
|
|
|
|
LOC_AGPS_CDMA_PDE_SERVER);
|
|
|
|
errsList[index] = err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) {
|
|
|
|
index++;
|
|
|
|
if (gnssConfigNeedEngineUpdate.flags &
|
|
|
|
GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) {
|
|
|
|
err = adapter.mLocApi->setSUPLVersionSync(gnssConfigRequested.suplVersion);
|
|
|
|
if (index < countOfConfigs) {
|
|
|
|
errsList[index] = err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
|
|
|
|
index++;
|
|
|
|
if (gnssConfigNeedEngineUpdate.flags &
|
|
|
|
GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
|
|
|
|
err = adapter.mLocApi->setLPPConfigSync(gnssConfigRequested.lppProfile);
|
|
|
|
if (index < countOfConfigs) {
|
|
|
|
errsList[index] = err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
|
|
|
|
index++;
|
|
|
|
if (gnssConfigNeedEngineUpdate.flags &
|
|
|
|
GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
|
|
|
|
err = adapter.mLocApi->setLPPeProtocolCpSync(
|
|
|
|
gnssConfigRequested.lppeControlPlaneMask);
|
|
|
|
if (index < countOfConfigs) {
|
|
|
|
errsList[index] = err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) {
|
|
|
|
index++;
|
|
|
|
if (gnssConfigNeedEngineUpdate.flags &
|
|
|
|
GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) {
|
|
|
|
err = adapter.mLocApi->setLPPeProtocolUpSync(
|
|
|
|
gnssConfigRequested.lppeUserPlaneMask);
|
|
|
|
if (index < countOfConfigs) {
|
|
|
|
errsList[index] = err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gnssConfigRequested.flags &
|
|
|
|
GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) {
|
|
|
|
index++;
|
|
|
|
if (gnssConfigNeedEngineUpdate.flags &
|
|
|
|
GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) {
|
|
|
|
err = adapter.mLocApi->setAGLONASSProtocolSync(
|
|
|
|
gnssConfigRequested.aGlonassPositionProtocolMask);
|
|
|
|
if (index < countOfConfigs) {
|
|
|
|
errsList[index] = err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-20 09:59:46 -04:00
|
|
|
if (gnssConfigRequested.flags & GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT) {
|
|
|
|
index++;
|
|
|
|
// Check if feature is supported
|
|
|
|
if (!ContextBase::isFeatureSupported(
|
|
|
|
LOC_SUPPORTED_FEATURE_CONSTELLATION_ENABLEMENT_V02)) {
|
|
|
|
LOC_LOGe("Feature constellation enablement not supported.");
|
|
|
|
err = LOCATION_ERROR_NOT_SUPPORTED;
|
|
|
|
} else {
|
|
|
|
// Send the SV ID Config to Modem
|
|
|
|
err = adapter.gnssSvIdConfigUpdateSync(gnssConfigRequested.blacklistedSvIds);
|
|
|
|
if (LOCATION_ERROR_SUCCESS != err) {
|
|
|
|
LOC_LOGe("Failed to send config to modem, err %d", err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (index < countOfConfigs) {
|
|
|
|
errsList[index] = err;
|
|
|
|
}
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
configCollectiveResponse->returnToSender(errsList);
|
|
|
|
}));
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (NULL != ids) {
|
|
|
|
sendMsg(new MsgGnssUpdateConfig(*this, *mLocApi, config, ids, count));
|
|
|
|
} else {
|
|
|
|
LOC_LOGE("%s]: No GNSS config items to update", __func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
|
|
|
}
|
|
|
|
|
2018-05-20 09:59:46 -04:00
|
|
|
void
|
|
|
|
GnssAdapter::gnssSvIdConfigUpdate(const std::vector<GnssSvIdSource>& blacklistedSvIds)
|
|
|
|
{
|
|
|
|
// Clear the existing config
|
|
|
|
memset(&mGnssSvIdConfig, 0, sizeof(GnssSvIdConfig));
|
|
|
|
|
|
|
|
// Convert the sv id lists to masks
|
|
|
|
convertToGnssSvIdConfig(blacklistedSvIds, mGnssSvIdConfig);
|
|
|
|
|
|
|
|
// Now send to Modem
|
|
|
|
gnssSvIdConfigUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::gnssSvIdConfigUpdate()
|
|
|
|
{
|
|
|
|
LOC_LOGd("blacklist bds 0x%" PRIx64 ", glo 0x%" PRIx64
|
|
|
|
", qzss 0x%" PRIx64 ", gal 0x%" PRIx64,
|
|
|
|
mGnssSvIdConfig.bdsBlacklistSvMask, mGnssSvIdConfig.gloBlacklistSvMask,
|
|
|
|
mGnssSvIdConfig.qzssBlacklistSvMask, mGnssSvIdConfig.galBlacklistSvMask);
|
|
|
|
|
|
|
|
// Now set required blacklisted SVs
|
|
|
|
mLocApi->setBlacklistSv(mGnssSvIdConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
LocationError
|
|
|
|
GnssAdapter::gnssSvIdConfigUpdateSync(const std::vector<GnssSvIdSource>& blacklistedSvIds)
|
|
|
|
{
|
|
|
|
// Clear the existing config
|
|
|
|
memset(&mGnssSvIdConfig, 0, sizeof(GnssSvIdConfig));
|
|
|
|
|
|
|
|
// Convert the sv id lists to masks
|
|
|
|
convertToGnssSvIdConfig(blacklistedSvIds, mGnssSvIdConfig);
|
|
|
|
|
|
|
|
// Now send to Modem
|
|
|
|
return gnssSvIdConfigUpdateSync();
|
|
|
|
}
|
|
|
|
|
|
|
|
LocationError
|
|
|
|
GnssAdapter::gnssSvIdConfigUpdateSync()
|
|
|
|
{
|
|
|
|
LOC_LOGd("blacklist bds 0x%" PRIx64 ", glo 0x%" PRIx64
|
|
|
|
", qzss 0x%" PRIx64 ", gal 0x%" PRIx64,
|
|
|
|
mGnssSvIdConfig.bdsBlacklistSvMask, mGnssSvIdConfig.gloBlacklistSvMask,
|
|
|
|
mGnssSvIdConfig.qzssBlacklistSvMask, mGnssSvIdConfig.galBlacklistSvMask);
|
|
|
|
|
|
|
|
// Now set required blacklisted SVs
|
|
|
|
return mLocApi->setBlacklistSvSync(mGnssSvIdConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t*
|
|
|
|
GnssAdapter::gnssGetConfigCommand(GnssConfigFlagsMask configMask) {
|
|
|
|
|
|
|
|
// count the number of bits set
|
|
|
|
GnssConfigFlagsMask flagsCopy = configMask;
|
|
|
|
size_t count = 0;
|
|
|
|
while (flagsCopy > 0) {
|
|
|
|
if (flagsCopy & 1) {
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
flagsCopy >>= 1;
|
|
|
|
}
|
|
|
|
std::string idsString = "[";
|
|
|
|
uint32_t* ids = NULL;
|
|
|
|
if (count > 0) {
|
|
|
|
ids = new uint32_t[count];
|
|
|
|
if (nullptr == ids) {
|
|
|
|
LOC_LOGe("new allocation failed, fatal error.");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
for (size_t i=0; i < count; ++i) {
|
|
|
|
ids[i] = generateSessionId();
|
|
|
|
IF_LOC_LOGD {
|
|
|
|
idsString += std::to_string(ids[i]) + " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
idsString += "]";
|
|
|
|
|
|
|
|
LOC_LOGd("ids %s flags 0x%X", idsString.c_str(), configMask);
|
|
|
|
|
|
|
|
struct MsgGnssGetConfig : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
LocApiBase& mApi;
|
|
|
|
GnssConfigFlagsMask mConfigMask;
|
|
|
|
uint32_t* mIds;
|
|
|
|
size_t mCount;
|
|
|
|
inline MsgGnssGetConfig(GnssAdapter& adapter,
|
|
|
|
LocApiBase& api,
|
|
|
|
GnssConfigFlagsMask configMask,
|
|
|
|
uint32_t* ids,
|
|
|
|
size_t count) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mApi(api),
|
|
|
|
mConfigMask(configMask),
|
|
|
|
mIds(ids),
|
|
|
|
mCount(count) {}
|
|
|
|
inline virtual ~MsgGnssGetConfig()
|
|
|
|
{
|
|
|
|
delete[] mIds;
|
|
|
|
}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
|
|
|
|
LocationError* errs = new LocationError[mCount];
|
|
|
|
LocationError err = LOCATION_ERROR_SUCCESS;
|
|
|
|
uint32_t index = 0;
|
|
|
|
|
|
|
|
if (nullptr == errs) {
|
|
|
|
LOC_LOGE("%s] new allocation failed, fatal error.", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mConfigMask & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) {
|
|
|
|
if (index < mCount) {
|
|
|
|
errs[index++] = LOCATION_ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mConfigMask & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) {
|
|
|
|
if (index < mCount) {
|
|
|
|
errs[index++] = LOCATION_ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mConfigMask & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
|
|
|
|
if (index < mCount) {
|
|
|
|
errs[index++] = LOCATION_ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mConfigMask & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
|
|
|
|
if (index < mCount) {
|
|
|
|
errs[index++] = LOCATION_ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mConfigMask & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
|
|
|
|
if (index < mCount) {
|
|
|
|
errs[index++] = LOCATION_ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mConfigMask & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) {
|
|
|
|
if (index < mCount) {
|
|
|
|
errs[index++] = LOCATION_ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mConfigMask & GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) {
|
|
|
|
if (index < mCount) {
|
|
|
|
errs[index++] = LOCATION_ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mConfigMask & GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT) {
|
|
|
|
if (index < mCount) {
|
|
|
|
errs[index++] = LOCATION_ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mConfigMask & GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT) {
|
|
|
|
if (index < mCount) {
|
|
|
|
errs[index++] = LOCATION_ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mConfigMask & GNSS_CONFIG_FLAGS_SUPL_MODE_BIT) {
|
|
|
|
err = LOCATION_ERROR_NOT_SUPPORTED;
|
|
|
|
if (index < mCount) {
|
|
|
|
errs[index++] = LOCATION_ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mConfigMask & GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT) {
|
|
|
|
// Check if feature is supported
|
|
|
|
if (!ContextBase::isFeatureSupported(
|
|
|
|
LOC_SUPPORTED_FEATURE_CONSTELLATION_ENABLEMENT_V02)) {
|
|
|
|
LOC_LOGe("Feature not supported.");
|
|
|
|
err = LOCATION_ERROR_NOT_SUPPORTED;
|
|
|
|
} else {
|
|
|
|
// Send request to Modem to fetch the config
|
|
|
|
mApi.getBlacklistSv();
|
|
|
|
err = LOCATION_ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
if (index < mCount) {
|
|
|
|
errs[index++] = err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mAdapter.reportResponse(index, errs, mIds);
|
|
|
|
delete[] errs;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (NULL != ids) {
|
|
|
|
sendMsg(new MsgGnssGetConfig(*this, *mLocApi, configMask, ids, count));
|
|
|
|
} else {
|
|
|
|
LOC_LOGe("No GNSS config items to Get");
|
|
|
|
}
|
|
|
|
|
|
|
|
return ids;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::convertToGnssSvIdConfig(
|
|
|
|
const std::vector<GnssSvIdSource>& blacklistedSvIds, GnssSvIdConfig& config)
|
|
|
|
{
|
|
|
|
config.size = sizeof(GnssSvIdConfig);
|
|
|
|
|
|
|
|
// Empty vector => Clear any previous blacklisted SVs
|
|
|
|
if (0 == blacklistedSvIds.size()) {
|
|
|
|
config.gloBlacklistSvMask = 0;
|
|
|
|
config.bdsBlacklistSvMask = 0;
|
|
|
|
config.qzssBlacklistSvMask = 0;
|
|
|
|
config.galBlacklistSvMask = 0;
|
|
|
|
} else {
|
|
|
|
// Parse the vector and convert SV IDs to mask values
|
|
|
|
for (GnssSvIdSource source : blacklistedSvIds) {
|
|
|
|
uint64_t* svMaskPtr = NULL;
|
|
|
|
GnssSvId initialSvId = 0;
|
|
|
|
switch(source.constellation) {
|
|
|
|
case GNSS_SV_TYPE_GLONASS:
|
|
|
|
svMaskPtr = &config.gloBlacklistSvMask;
|
|
|
|
initialSvId = GNSS_SV_CONFIG_GLO_INITIAL_SV_ID;
|
|
|
|
break;
|
|
|
|
case GNSS_SV_TYPE_BEIDOU:
|
|
|
|
svMaskPtr = &config.bdsBlacklistSvMask;
|
|
|
|
initialSvId = GNSS_SV_CONFIG_BDS_INITIAL_SV_ID;
|
|
|
|
break;
|
|
|
|
case GNSS_SV_TYPE_QZSS:
|
|
|
|
svMaskPtr = &config.qzssBlacklistSvMask;
|
|
|
|
initialSvId = GNSS_SV_CONFIG_QZSS_INITIAL_SV_ID;
|
|
|
|
break;
|
|
|
|
case GNSS_SV_TYPE_GALILEO:
|
|
|
|
svMaskPtr = &config.galBlacklistSvMask;
|
|
|
|
initialSvId = GNSS_SV_CONFIG_GAL_INITIAL_SV_ID;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL == svMaskPtr) {
|
|
|
|
LOC_LOGe("Invalid constellation %d", source.constellation);
|
|
|
|
} else {
|
|
|
|
// SV ID 0 = All SV IDs
|
|
|
|
if (0 == source.svId) {
|
|
|
|
*svMaskPtr = GNSS_SV_CONFIG_ALL_BITS_ENABLED_MASK;
|
|
|
|
} else if (source.svId < initialSvId || source.svId >= initialSvId + 64) {
|
|
|
|
LOC_LOGe("Invalid sv id %d for sv type %d",
|
|
|
|
source.svId, source.constellation);
|
|
|
|
} else {
|
|
|
|
*svMaskPtr |= (1 << (source.svId - initialSvId));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::convertFromGnssSvIdConfig(
|
|
|
|
const GnssSvIdConfig& svConfig, GnssConfig& config)
|
|
|
|
{
|
|
|
|
// Convert blacklisted SV mask values to vectors
|
|
|
|
if (svConfig.bdsBlacklistSvMask) {
|
|
|
|
convertGnssSvIdMaskToList(
|
|
|
|
svConfig.bdsBlacklistSvMask, config.blacklistedSvIds,
|
|
|
|
GNSS_SV_CONFIG_BDS_INITIAL_SV_ID, GNSS_SV_TYPE_BEIDOU);
|
|
|
|
config.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
|
|
|
|
}
|
|
|
|
if (svConfig.galBlacklistSvMask) {
|
|
|
|
convertGnssSvIdMaskToList(
|
|
|
|
svConfig.galBlacklistSvMask, config.blacklistedSvIds,
|
|
|
|
GNSS_SV_CONFIG_GAL_INITIAL_SV_ID, GNSS_SV_TYPE_GALILEO);
|
|
|
|
config.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
|
|
|
|
}
|
|
|
|
if (svConfig.gloBlacklistSvMask) {
|
|
|
|
convertGnssSvIdMaskToList(
|
|
|
|
svConfig.gloBlacklistSvMask, config.blacklistedSvIds,
|
|
|
|
GNSS_SV_CONFIG_GLO_INITIAL_SV_ID, GNSS_SV_TYPE_GLONASS);
|
|
|
|
config.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
|
|
|
|
}
|
|
|
|
if (svConfig.qzssBlacklistSvMask) {
|
|
|
|
convertGnssSvIdMaskToList(
|
|
|
|
svConfig.qzssBlacklistSvMask, config.blacklistedSvIds,
|
|
|
|
GNSS_SV_CONFIG_QZSS_INITIAL_SV_ID, GNSS_SV_TYPE_QZSS);
|
|
|
|
config.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::convertGnssSvIdMaskToList(
|
|
|
|
uint64_t svIdMask, std::vector<GnssSvIdSource>& svIds,
|
|
|
|
GnssSvId initialSvId, GnssSvType svType)
|
|
|
|
{
|
|
|
|
GnssSvIdSource source = {};
|
|
|
|
source.size = sizeof(GnssSvIdSource);
|
|
|
|
source.constellation = svType;
|
|
|
|
|
|
|
|
// SV ID 0 => All SV IDs in mask
|
|
|
|
if (GNSS_SV_CONFIG_ALL_BITS_ENABLED_MASK == svIdMask) {
|
|
|
|
source.svId = 0;
|
|
|
|
svIds.push_back(source);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert each bit in svIdMask to vector entry
|
|
|
|
uint32_t bitNumber = 0;
|
|
|
|
while (svIdMask > 0) {
|
|
|
|
if (svIdMask & 0x1) {
|
|
|
|
source.svId = bitNumber + initialSvId;
|
|
|
|
svIds.push_back(source);
|
|
|
|
}
|
|
|
|
bitNumber++;
|
|
|
|
svIdMask >>= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::reportGnssSvIdConfigEvent(const GnssSvIdConfig& config)
|
|
|
|
{
|
|
|
|
struct MsgReportGnssSvIdConfig : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
const GnssSvIdConfig mConfig;
|
|
|
|
inline MsgReportGnssSvIdConfig(GnssAdapter& adapter,
|
|
|
|
const GnssSvIdConfig& config) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mConfig(config) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter.reportGnssSvIdConfig(mConfig);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgReportGnssSvIdConfig(*this, config));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::reportGnssSvIdConfig(const GnssSvIdConfig& svIdConfig)
|
|
|
|
{
|
|
|
|
GnssConfig config = {};
|
|
|
|
config.size = sizeof(GnssConfig);
|
|
|
|
|
|
|
|
// Invoke control clients config callback
|
|
|
|
if (nullptr != mControlCallbacks.gnssConfigCb &&
|
|
|
|
svIdConfig.size == sizeof(GnssSvIdConfig)) {
|
|
|
|
convertFromGnssSvIdConfig(svIdConfig, config);
|
|
|
|
LOC_LOGd("blacklist bds 0x%" PRIx64 ", glo 0x%" PRIx64
|
|
|
|
", qzss 0x%" PRIx64 ", gal 0x%" PRIx64,
|
|
|
|
svIdConfig.bdsBlacklistSvMask, svIdConfig.gloBlacklistSvMask,
|
|
|
|
svIdConfig.qzssBlacklistSvMask, svIdConfig.galBlacklistSvMask);
|
|
|
|
mControlCallbacks.gnssConfigCb(config);
|
|
|
|
} else {
|
|
|
|
LOC_LOGe("Failed to report, size %d", (uint32_t)config.size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::gnssUpdateSvTypeConfigCommand(GnssSvTypeConfig config)
|
|
|
|
{
|
|
|
|
struct MsgGnssUpdateSvTypeConfig : public LocMsg {
|
|
|
|
GnssAdapter* mAdapter;
|
|
|
|
LocApiBase* mApi;
|
|
|
|
GnssSvTypeConfig mConfig;
|
|
|
|
inline MsgGnssUpdateSvTypeConfig(
|
|
|
|
GnssAdapter* adapter,
|
|
|
|
LocApiBase* api,
|
|
|
|
GnssSvTypeConfig& config) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mApi(api),
|
|
|
|
mConfig(config) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
|
|
|
|
// Check if feature is supported
|
|
|
|
if (!ContextBase::isFeatureSupported(
|
|
|
|
LOC_SUPPORTED_FEATURE_CONSTELLATION_ENABLEMENT_V02)) {
|
|
|
|
LOC_LOGe("Feature not supported.");
|
|
|
|
} else {
|
|
|
|
// Send update request to modem
|
|
|
|
mAdapter->gnssSvTypeConfigUpdate(mConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgGnssUpdateSvTypeConfig(this, mLocApi, config));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::gnssSvTypeConfigUpdate(const GnssSvTypeConfig& config)
|
|
|
|
{
|
|
|
|
gnssSetSvTypeConfig(config);
|
|
|
|
gnssSvTypeConfigUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::gnssSvTypeConfigUpdate()
|
|
|
|
{
|
|
|
|
LOC_LOGd("constellations blacklisted 0x%" PRIx64 ", enabled 0x%" PRIx64,
|
|
|
|
mGnssSvTypeConfig.blacklistedSvTypesMask, mGnssSvTypeConfig.enabledSvTypesMask);
|
|
|
|
|
|
|
|
if (mGnssSvTypeConfig.size == sizeof(mGnssSvTypeConfig)) {
|
|
|
|
GnssSvIdConfig blacklistConfig = {};
|
|
|
|
// Revert to previously blacklisted SVs for each enabled constellation
|
|
|
|
blacklistConfig = mGnssSvIdConfig;
|
|
|
|
// Blacklist all SVs for each disabled constellation
|
|
|
|
if (mGnssSvTypeConfig.blacklistedSvTypesMask) {
|
|
|
|
if (mGnssSvTypeConfig.blacklistedSvTypesMask & GNSS_SV_TYPES_MASK_GLO_BIT) {
|
|
|
|
blacklistConfig.gloBlacklistSvMask = GNSS_SV_CONFIG_ALL_BITS_ENABLED_MASK;
|
|
|
|
}
|
|
|
|
if (mGnssSvTypeConfig.blacklistedSvTypesMask & GNSS_SV_TYPES_MASK_BDS_BIT) {
|
|
|
|
blacklistConfig.bdsBlacklistSvMask = GNSS_SV_CONFIG_ALL_BITS_ENABLED_MASK;
|
|
|
|
}
|
|
|
|
if (mGnssSvTypeConfig.blacklistedSvTypesMask & GNSS_SV_TYPES_MASK_QZSS_BIT) {
|
|
|
|
blacklistConfig.qzssBlacklistSvMask = GNSS_SV_CONFIG_ALL_BITS_ENABLED_MASK;
|
|
|
|
}
|
|
|
|
if (mGnssSvTypeConfig.blacklistedSvTypesMask & GNSS_SV_TYPES_MASK_GAL_BIT) {
|
|
|
|
blacklistConfig.galBlacklistSvMask = GNSS_SV_CONFIG_ALL_BITS_ENABLED_MASK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send blacklist info
|
|
|
|
mLocApi->setBlacklistSv(blacklistConfig);
|
|
|
|
|
|
|
|
// Send only enabled constellation config
|
|
|
|
if (mGnssSvTypeConfig.enabledSvTypesMask) {
|
|
|
|
GnssSvTypeConfig svTypeConfig = {sizeof(GnssSvTypeConfig), 0, 0};
|
|
|
|
svTypeConfig.enabledSvTypesMask = mGnssSvTypeConfig.enabledSvTypesMask;
|
|
|
|
mLocApi->setConstellationControl(svTypeConfig);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
LOC_LOGE("Invalid GnssSvTypeConfig size");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::gnssGetSvTypeConfigCommand(GnssSvTypeConfigCallback callback)
|
|
|
|
{
|
|
|
|
struct MsgGnssGetSvTypeConfig : public LocMsg {
|
|
|
|
GnssAdapter* mAdapter;
|
|
|
|
LocApiBase* mApi;
|
|
|
|
GnssSvTypeConfigCallback mCallback;
|
|
|
|
inline MsgGnssGetSvTypeConfig(
|
|
|
|
GnssAdapter* adapter,
|
|
|
|
LocApiBase* api,
|
|
|
|
GnssSvTypeConfigCallback callback) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mApi(api),
|
|
|
|
mCallback(callback) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
|
|
|
|
if (!ContextBase::isFeatureSupported(
|
|
|
|
LOC_SUPPORTED_FEATURE_CONSTELLATION_ENABLEMENT_V02)) {
|
|
|
|
LOC_LOGe("Feature not supported.");
|
|
|
|
} else {
|
|
|
|
// Save the callback
|
|
|
|
mAdapter->gnssSetSvTypeConfigCallback(mCallback);
|
|
|
|
// Send GET request to modem
|
|
|
|
mApi->getConstellationControl();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgGnssGetSvTypeConfig(this, mLocApi, callback));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::gnssResetSvTypeConfigCommand()
|
|
|
|
{
|
|
|
|
struct MsgGnssResetSvTypeConfig : public LocMsg {
|
|
|
|
GnssAdapter* mAdapter;
|
|
|
|
LocApiBase* mApi;
|
|
|
|
inline MsgGnssResetSvTypeConfig(
|
|
|
|
GnssAdapter* adapter,
|
|
|
|
LocApiBase* api) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mApi(api) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
|
|
|
|
if (!ContextBase::isFeatureSupported(
|
|
|
|
LOC_SUPPORTED_FEATURE_CONSTELLATION_ENABLEMENT_V02)) {
|
|
|
|
LOC_LOGe("Feature not supported.");
|
|
|
|
} else {
|
|
|
|
// Reset constellation config
|
|
|
|
mAdapter->gnssSetSvTypeConfig({sizeof(GnssSvTypeConfig), 0, 0});
|
|
|
|
// Re-enforce SV blacklist config
|
|
|
|
mAdapter->gnssSvIdConfigUpdate();
|
|
|
|
// Send reset request to modem
|
|
|
|
mApi->resetConstellationControl();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgGnssResetSvTypeConfig(this, mLocApi));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& config)
|
|
|
|
{
|
|
|
|
struct MsgReportGnssSvTypeConfig : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
const GnssSvTypeConfig mConfig;
|
|
|
|
inline MsgReportGnssSvTypeConfig(GnssAdapter& adapter,
|
|
|
|
const GnssSvTypeConfig& config) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mConfig(config) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter.reportGnssSvTypeConfig(mConfig);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgReportGnssSvTypeConfig(*this, config));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::reportGnssSvTypeConfig(const GnssSvTypeConfig& config)
|
|
|
|
{
|
|
|
|
// Invoke Get SV Type Callback
|
|
|
|
if (NULL != mGnssSvTypeConfigCb &&
|
|
|
|
config.size == sizeof(GnssSvTypeConfig)) {
|
|
|
|
LOC_LOGd("constellations blacklisted 0x%" PRIx64 ", enabled 0x%" PRIx64,
|
|
|
|
config.blacklistedSvTypesMask, config.enabledSvTypesMask);
|
|
|
|
mGnssSvTypeConfigCb(config);
|
|
|
|
} else {
|
|
|
|
LOC_LOGe("Failed to report, size %d", (uint32_t)config.size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
void GnssAdapter::deleteAidingData(const GnssAidingData &data, uint32_t sessionId) {
|
|
|
|
mLocApi->deleteAidingData(data, new LocApiResponse(*getContext(),
|
|
|
|
[this, sessionId] (LocationError err) {
|
|
|
|
reportResponse(err, sessionId);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2017-02-28 19:45:47 -05:00
|
|
|
uint32_t
|
|
|
|
GnssAdapter::gnssDeleteAidingDataCommand(GnssAidingData& data)
|
|
|
|
{
|
|
|
|
uint32_t sessionId = generateSessionId();
|
2016-12-23 00:12:44 -05:00
|
|
|
LOC_LOGD("%s]: id %u", __func__, sessionId);
|
2017-02-28 19:45:47 -05:00
|
|
|
|
|
|
|
struct MsgDeleteAidingData : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
uint32_t mSessionId;
|
|
|
|
GnssAidingData mData;
|
|
|
|
inline MsgDeleteAidingData(GnssAdapter& adapter,
|
|
|
|
uint32_t sessionId,
|
|
|
|
GnssAidingData& data) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mSessionId(sessionId),
|
|
|
|
mData(data) {}
|
|
|
|
inline virtual void proc() const {
|
2018-01-22 19:04:50 -05:00
|
|
|
mAdapter.deleteAidingData(mData, mSessionId);
|
|
|
|
|
2017-08-11 05:43:38 -04:00
|
|
|
SystemStatus* s = mAdapter.getSystemStatus();
|
2017-08-09 21:40:51 -04:00
|
|
|
if ((nullptr != s) && (mData.deleteAll)) {
|
2017-12-21 07:03:40 -05:00
|
|
|
s->setDefaultGnssEngineStates();
|
2017-08-09 21:40:51 -04:00
|
|
|
}
|
2018-01-29 04:02:06 -05:00
|
|
|
mAdapter.mEngHubProxy->gnssDeleteAidingData(mData);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
sendMsg(new MsgDeleteAidingData(*this, sessionId, data));
|
2017-02-28 19:45:47 -05:00
|
|
|
return sessionId;
|
|
|
|
}
|
|
|
|
|
2017-08-21 20:46:44 -04:00
|
|
|
void
|
|
|
|
GnssAdapter::gnssUpdateXtraThrottleCommand(const bool enabled)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s] enabled:%d", __func__, enabled);
|
|
|
|
|
|
|
|
struct UpdateXtraThrottleMsg : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
const bool mEnabled;
|
|
|
|
inline UpdateXtraThrottleMsg(GnssAdapter& adapter, const bool enabled) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mEnabled(enabled) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter.mXtraObserver.updateXtraThrottle(mEnabled);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new UpdateXtraThrottleMsg(*this, enabled));
|
|
|
|
}
|
|
|
|
|
2017-02-28 19:45:47 -05:00
|
|
|
void
|
|
|
|
GnssAdapter::injectLocationCommand(double latitude, double longitude, float accuracy)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: latitude %8.4f longitude %8.4f accuracy %8.4f",
|
|
|
|
__func__, latitude, longitude, accuracy);
|
|
|
|
|
|
|
|
struct MsgInjectLocation : public LocMsg {
|
|
|
|
LocApiBase& mApi;
|
|
|
|
ContextBase& mContext;
|
|
|
|
double mLatitude;
|
|
|
|
double mLongitude;
|
|
|
|
float mAccuracy;
|
|
|
|
inline MsgInjectLocation(LocApiBase& api,
|
|
|
|
ContextBase& context,
|
|
|
|
double latitude,
|
|
|
|
double longitude,
|
|
|
|
float accuracy) :
|
|
|
|
LocMsg(),
|
|
|
|
mApi(api),
|
|
|
|
mContext(context),
|
|
|
|
mLatitude(latitude),
|
|
|
|
mLongitude(longitude),
|
|
|
|
mAccuracy(accuracy) {}
|
|
|
|
inline virtual void proc() const {
|
2018-06-07 15:03:55 -04:00
|
|
|
mApi.injectPosition(mLatitude, mLongitude, mAccuracy);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgInjectLocation(*mLocApi, *mContext, latitude, longitude, accuracy));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::injectTimeCommand(int64_t time, int64_t timeReference, int32_t uncertainty)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: time %lld timeReference %lld uncertainty %d",
|
2016-12-23 00:12:44 -05:00
|
|
|
__func__, (long long)time, (long long)timeReference, uncertainty);
|
2017-02-28 19:45:47 -05:00
|
|
|
|
|
|
|
struct MsgInjectTime : public LocMsg {
|
|
|
|
LocApiBase& mApi;
|
|
|
|
ContextBase& mContext;
|
|
|
|
int64_t mTime;
|
|
|
|
int64_t mTimeReference;
|
|
|
|
int32_t mUncertainty;
|
|
|
|
inline MsgInjectTime(LocApiBase& api,
|
|
|
|
ContextBase& context,
|
|
|
|
int64_t time,
|
|
|
|
int64_t timeReference,
|
|
|
|
int32_t uncertainty) :
|
|
|
|
LocMsg(),
|
|
|
|
mApi(api),
|
|
|
|
mContext(context),
|
|
|
|
mTime(time),
|
|
|
|
mTimeReference(timeReference),
|
|
|
|
mUncertainty(uncertainty) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mApi.setTime(mTime, mTimeReference, mUncertainty);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgInjectTime(*mLocApi, *mContext, time, timeReference, uncertainty));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::addClientCommand(LocationAPI* client, const LocationCallbacks& callbacks)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: client %p", __func__, client);
|
|
|
|
|
|
|
|
struct MsgAddClient : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
LocationAPI* mClient;
|
|
|
|
const LocationCallbacks mCallbacks;
|
|
|
|
inline MsgAddClient(GnssAdapter& adapter,
|
|
|
|
LocationAPI* client,
|
|
|
|
const LocationCallbacks& callbacks) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mClient(client),
|
|
|
|
mCallbacks(callbacks) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter.saveClient(mClient, mCallbacks);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgAddClient(*this, client, callbacks));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::removeClientCommand(LocationAPI* client)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: client %p", __func__, client);
|
|
|
|
|
|
|
|
struct MsgRemoveClient : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
LocationAPI* mClient;
|
|
|
|
inline MsgRemoveClient(GnssAdapter& adapter,
|
|
|
|
LocationAPI* client) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mClient(client) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter.stopClientSessions(mClient);
|
|
|
|
mAdapter.eraseClient(mClient);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgRemoveClient(*this, client));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::stopClientSessions(LocationAPI* client)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: client %p", __func__, client);
|
|
|
|
for (auto it = mTrackingSessions.begin(); it != mTrackingSessions.end();) {
|
|
|
|
if (client == it->first.client) {
|
2018-01-22 19:04:50 -05:00
|
|
|
stopTrackingMultiplex(it->first.client, it->first.id);
|
|
|
|
it = mTrackingSessions.erase(it);
|
|
|
|
continue;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
++it; // increment only when not erasing an iterator
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::updateClientsEventMask()
|
|
|
|
{
|
|
|
|
LOC_API_ADAPTER_EVENT_MASK_T mask = 0;
|
|
|
|
for (auto it=mClientData.begin(); it != mClientData.end(); ++it) {
|
2018-01-10 00:58:17 -05:00
|
|
|
if (it->second.trackingCb != nullptr || it->second.gnssLocationInfoCb != nullptr) {
|
2017-02-28 19:45:47 -05:00
|
|
|
mask |= LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT;
|
|
|
|
}
|
|
|
|
if (it->second.gnssNiCb != nullptr) {
|
|
|
|
mask |= LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST;
|
|
|
|
}
|
|
|
|
if (it->second.gnssSvCb != nullptr) {
|
|
|
|
mask |= LOC_API_ADAPTER_BIT_SATELLITE_REPORT;
|
|
|
|
}
|
2017-07-07 18:33:52 -04:00
|
|
|
if ((it->second.gnssNmeaCb != nullptr) && (mNmeaMask)) {
|
2017-02-28 19:45:47 -05:00
|
|
|
mask |= LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT;
|
|
|
|
}
|
|
|
|
if (it->second.gnssMeasurementsCb != nullptr) {
|
|
|
|
mask |= LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT;
|
|
|
|
}
|
|
|
|
}
|
2017-03-10 06:50:57 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
** For Automotive use cases we need to enable MEASUREMENT and POLY
|
2018-01-29 04:02:06 -05:00
|
|
|
** when QDR is enabled (e.g.: either enabled via conf file or
|
|
|
|
** engine hub is loaded successfully).
|
|
|
|
** Note: this need to be called from msg queue thread.
|
2017-03-10 06:50:57 -05:00
|
|
|
*/
|
2018-01-29 04:02:06 -05:00
|
|
|
if((1 == ContextBase::mGps_conf.EXTERNAL_DR_ENABLED) ||
|
|
|
|
(true == initEngHubProxy())) {
|
2017-03-10 06:50:57 -05:00
|
|
|
mask |= LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT;
|
|
|
|
mask |= LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT;
|
2018-03-30 20:10:59 -04:00
|
|
|
mask |= LOC_API_ADAPTER_BIT_PARSED_UNPROPAGATED_POSITION_REPORT;
|
2017-03-10 06:50:57 -05:00
|
|
|
|
2018-05-15 13:21:09 -04:00
|
|
|
LOC_LOGD("%s]: Auto usecase, Enable MEAS/POLY - mask 0x%" PRIx64 "", __func__, mask);
|
2017-03-10 06:50:57 -05:00
|
|
|
}
|
|
|
|
|
2017-09-18 19:12:46 -04:00
|
|
|
if (mAgpsCbInfo.statusV4Cb != NULL) {
|
|
|
|
mask |= LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST;
|
|
|
|
}
|
|
|
|
|
2018-04-08 14:05:14 -04:00
|
|
|
// Add ODCPI handling
|
|
|
|
if (nullptr != mOdcpiRequestCb) {
|
|
|
|
mask |= LOC_API_ADAPTER_BIT_REQUEST_WIFI;
|
|
|
|
}
|
|
|
|
|
2017-02-28 19:45:47 -05:00
|
|
|
updateEvtMask(mask, LOC_REGISTRATION_MASK_SET);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::handleEngineUpEvent()
|
|
|
|
{
|
2018-01-22 19:04:50 -05:00
|
|
|
LOC_LOGD("%s]: ", __func__);
|
|
|
|
|
|
|
|
struct MsgHandleEngineUpEvent : public LocMsg {
|
2017-02-28 19:45:47 -05:00
|
|
|
GnssAdapter& mAdapter;
|
2018-01-22 19:04:50 -05:00
|
|
|
inline MsgHandleEngineUpEvent(GnssAdapter& adapter) :
|
2017-02-28 19:45:47 -05:00
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter) {}
|
|
|
|
virtual void proc() const {
|
2018-01-22 19:04:50 -05:00
|
|
|
mAdapter.broadcastCapabilities(mAdapter.getCapabilities());
|
|
|
|
// restart sessions
|
2017-02-28 19:45:47 -05:00
|
|
|
mAdapter.restartSessions();
|
2018-05-20 09:59:46 -04:00
|
|
|
mAdapter.gnssSvIdConfigUpdate();
|
|
|
|
mAdapter.gnssSvTypeConfigUpdate();
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
readConfigCommand();
|
2017-02-28 19:45:47 -05:00
|
|
|
setConfigCommand();
|
2018-01-22 19:04:50 -05:00
|
|
|
sendMsg(new MsgHandleEngineUpEvent(*this));
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::restartSessions()
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: ", __func__);
|
|
|
|
|
|
|
|
if (mTrackingSessions.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get the LocationOptions that has the smallest interval, which should be the active one
|
2018-05-20 13:36:12 -04:00
|
|
|
TrackingOptions smallestIntervalOptions = {}; // size is zero until set for the first time
|
|
|
|
TrackingOptions highestPowerTrackingOptions = {};
|
2017-02-28 19:45:47 -05:00
|
|
|
for (auto it = mTrackingSessions.begin(); it != mTrackingSessions.end(); ++it) {
|
2018-05-20 13:36:12 -04:00
|
|
|
// size of zero means we havent set it yet
|
|
|
|
if (0 == smallestIntervalOptions.size ||
|
2017-02-28 19:45:47 -05:00
|
|
|
it->second.minInterval < smallestIntervalOptions.minInterval) {
|
|
|
|
smallestIntervalOptions = it->second;
|
|
|
|
}
|
2018-05-20 13:36:12 -04:00
|
|
|
GnssPowerMode powerMode = it->second.powerMode;
|
|
|
|
// Size of zero means we havent set it yet
|
|
|
|
if (0 == highestPowerTrackingOptions.size ||
|
|
|
|
(GNSS_POWER_MODE_INVALID != powerMode &&
|
|
|
|
powerMode < highestPowerTrackingOptions.powerMode)) {
|
|
|
|
highestPowerTrackingOptions = it->second;
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
2017-06-06 13:54:39 -04:00
|
|
|
LocPosMode locPosMode = {};
|
2018-05-20 13:36:12 -04:00
|
|
|
highestPowerTrackingOptions.setLocationOptions(smallestIntervalOptions);
|
|
|
|
convertOptions(locPosMode, highestPowerTrackingOptions);
|
2018-06-07 15:03:55 -04:00
|
|
|
mLocApi->startFix(locPosMode, nullptr);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::requestCapabilitiesCommand(LocationAPI* client)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: ", __func__);
|
|
|
|
|
|
|
|
struct MsgRequestCapabilities : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
LocationAPI* mClient;
|
|
|
|
inline MsgRequestCapabilities(GnssAdapter& adapter,
|
|
|
|
LocationAPI* client) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mClient(client) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
LocationCallbacks callbacks = mAdapter.getClientCallbacks(mClient);
|
|
|
|
if (callbacks.capabilitiesCb == nullptr) {
|
|
|
|
LOC_LOGE("%s]: capabilitiesCb is NULL", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
LocationCapabilitiesMask mask = mAdapter.getCapabilities();
|
|
|
|
callbacks.capabilitiesCb(mask);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
if (ContextBase::isEngineCapabilitiesKnown()) {
|
|
|
|
sendMsg(new MsgRequestCapabilities(*this, client));
|
|
|
|
}
|
2017-07-19 18:30:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
LocationCapabilitiesMask
|
|
|
|
GnssAdapter::getCapabilities()
|
|
|
|
{
|
|
|
|
LocationCapabilitiesMask mask = 0;
|
|
|
|
uint32_t carrierCapabilities = ContextBase::getCarrierCapabilities();
|
|
|
|
// time based tracking always supported
|
|
|
|
mask |= LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT;
|
|
|
|
// geofence always supported
|
|
|
|
mask |= LOCATION_CAPABILITIES_GEOFENCE_BIT;
|
|
|
|
if (carrierCapabilities & LOC_GPS_CAPABILITY_MSB) {
|
|
|
|
mask |= LOCATION_CAPABILITIES_GNSS_MSB_BIT;
|
|
|
|
}
|
|
|
|
if (LOC_GPS_CAPABILITY_MSA & carrierCapabilities) {
|
|
|
|
mask |= LOCATION_CAPABILITIES_GNSS_MSA_BIT;
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
if (ContextBase::isMessageSupported(LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_LOCATION_BATCHING)) {
|
2017-07-19 18:30:35 -04:00
|
|
|
mask |= LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT |
|
|
|
|
LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT;
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
if (ContextBase::isMessageSupported(LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_TRACKING)) {
|
2017-07-19 18:30:35 -04:00
|
|
|
mask |= LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT;
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
if (ContextBase::isMessageSupported(LOC_API_ADAPTER_MESSAGE_OUTDOOR_TRIP_BATCHING)) {
|
2017-07-19 18:30:35 -04:00
|
|
|
mask |= LOCATION_CAPABILITIES_OUTDOOR_TRIP_BATCHING_BIT;
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
if (ContextBase::gnssConstellationConfig()) {
|
2017-07-19 18:30:35 -04:00
|
|
|
mask |= LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT;
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_DEBUG_NMEA_V02)) {
|
2017-07-19 18:30:35 -04:00
|
|
|
mask |= LOCATION_CAPABILITIES_DEBUG_NMEA_BIT;
|
|
|
|
}
|
2018-06-04 19:55:56 -04:00
|
|
|
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_CONSTELLATION_ENABLEMENT_V02)) {
|
|
|
|
mask |= LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT;
|
|
|
|
}
|
|
|
|
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_AGPM_V02)) {
|
|
|
|
mask |= LOCATION_CAPABILITIES_AGPM_BIT;
|
|
|
|
}
|
2017-07-19 18:30:35 -04:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::broadcastCapabilities(LocationCapabilitiesMask mask)
|
|
|
|
{
|
2018-01-22 19:04:50 -05:00
|
|
|
for (auto clientData : mClientData) {
|
|
|
|
if (nullptr != clientData.second.capabilitiesCb) {
|
|
|
|
clientData.second.capabilitiesCb(mask);
|
2017-07-19 18:30:35 -04:00
|
|
|
}
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
LocationCallbacks
|
|
|
|
GnssAdapter::getClientCallbacks(LocationAPI* client)
|
|
|
|
{
|
|
|
|
LocationCallbacks callbacks = {};
|
|
|
|
auto it = mClientData.find(client);
|
|
|
|
if (it != mClientData.end()) {
|
|
|
|
callbacks = it->second;
|
|
|
|
}
|
|
|
|
return callbacks;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::saveClient(LocationAPI* client, const LocationCallbacks& callbacks)
|
|
|
|
{
|
|
|
|
mClientData[client] = callbacks;
|
|
|
|
updateClientsEventMask();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::eraseClient(LocationAPI* client)
|
|
|
|
{
|
|
|
|
auto it = mClientData.find(client);
|
|
|
|
if (it != mClientData.end()) {
|
|
|
|
mClientData.erase(it);
|
|
|
|
}
|
|
|
|
updateClientsEventMask();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GnssAdapter::hasTrackingCallback(LocationAPI* client)
|
|
|
|
{
|
|
|
|
auto it = mClientData.find(client);
|
2018-01-10 00:58:17 -05:00
|
|
|
return (it != mClientData.end() && (it->second.trackingCb || it->second.gnssLocationInfoCb));
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GnssAdapter::hasMeasurementsCallback(LocationAPI* client)
|
|
|
|
{
|
|
|
|
auto it = mClientData.find(client);
|
|
|
|
return (it != mClientData.end() && it->second.gnssMeasurementsCb);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GnssAdapter::isTrackingSession(LocationAPI* client, uint32_t sessionId)
|
|
|
|
{
|
|
|
|
LocationSessionKey key(client, sessionId);
|
|
|
|
return (mTrackingSessions.find(key) != mTrackingSessions.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::saveTrackingSession(LocationAPI* client, uint32_t sessionId,
|
2018-05-20 13:36:12 -04:00
|
|
|
const TrackingOptions& trackingOptions)
|
2017-02-28 19:45:47 -05:00
|
|
|
{
|
|
|
|
LocationSessionKey key(client, sessionId);
|
2018-05-20 13:36:12 -04:00
|
|
|
mTrackingSessions[key] = trackingOptions;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::eraseTrackingSession(LocationAPI* client, uint32_t sessionId)
|
|
|
|
{
|
|
|
|
LocationSessionKey key(client, sessionId);
|
2018-05-20 13:36:12 -04:00
|
|
|
auto itr = mTrackingSessions.find(key);
|
|
|
|
if (itr != mTrackingSessions.end()) {
|
|
|
|
mTrackingSessions.erase(itr);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-07 15:03:55 -04:00
|
|
|
bool GnssAdapter::setLocPositionMode(const LocPosMode& mode) {
|
|
|
|
if (!mLocPositionMode.equals(mode)) {
|
|
|
|
mLocPositionMode = mode;
|
2017-08-21 21:41:23 -04:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-28 19:45:47 -05:00
|
|
|
void
|
|
|
|
GnssAdapter::reportResponse(LocationAPI* client, LocationError err, uint32_t sessionId)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: client %p id %u err %u", __func__, client, sessionId, err);
|
|
|
|
|
|
|
|
auto it = mClientData.find(client);
|
2018-01-22 19:04:50 -05:00
|
|
|
if (it != mClientData.end() && it->second.responseCb != nullptr) {
|
2017-02-28 19:45:47 -05:00
|
|
|
it->second.responseCb(err, sessionId);
|
|
|
|
} else {
|
|
|
|
LOC_LOGW("%s]: client %p id %u not found in data", __func__, client, sessionId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::reportResponse(LocationError err, uint32_t sessionId)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: id %u err %u", __func__, sessionId, err);
|
|
|
|
|
|
|
|
if (mControlCallbacks.size > 0 && mControlCallbacks.responseCb != nullptr) {
|
|
|
|
mControlCallbacks.responseCb(err, sessionId);
|
|
|
|
} else {
|
|
|
|
LOC_LOGW("%s]: control client response callback not found", __func__);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::reportResponse(size_t count, LocationError* errs, uint32_t* ids)
|
|
|
|
{
|
|
|
|
IF_LOC_LOGD {
|
|
|
|
std::string idsString = "[";
|
|
|
|
std::string errsString = "[";
|
|
|
|
if (NULL != ids && NULL != errs) {
|
|
|
|
for (size_t i=0; i < count; ++i) {
|
|
|
|
idsString += std::to_string(ids[i]) + " ";
|
|
|
|
errsString += std::to_string(errs[i]) + " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
idsString += "]";
|
|
|
|
errsString += "]";
|
|
|
|
|
|
|
|
LOC_LOGD("%s]: ids %s errs %s",
|
|
|
|
__func__, idsString.c_str(), errsString.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mControlCallbacks.size > 0 && mControlCallbacks.collectiveResponseCb != nullptr) {
|
|
|
|
mControlCallbacks.collectiveResponseCb(count, errs, ids);
|
|
|
|
} else {
|
|
|
|
LOC_LOGW("%s]: control client callback not found", __func__);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
2018-05-20 13:36:12 -04:00
|
|
|
GnssAdapter::startTrackingCommand(LocationAPI* client, TrackingOptions& options)
|
2017-02-28 19:45:47 -05:00
|
|
|
{
|
|
|
|
uint32_t sessionId = generateSessionId();
|
2018-05-20 13:36:12 -04:00
|
|
|
LOC_LOGD("%s]: client %p id %u minInterval %u minDistance %u mode %u powermode %u tbm %u",
|
|
|
|
__func__, client, sessionId, options.minInterval, options.minDistance, options.mode,
|
|
|
|
options.powerMode, options.tbm);
|
2017-02-28 19:45:47 -05:00
|
|
|
|
|
|
|
struct MsgStartTracking : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
LocApiBase& mApi;
|
|
|
|
LocationAPI* mClient;
|
|
|
|
uint32_t mSessionId;
|
2018-05-20 13:36:12 -04:00
|
|
|
mutable TrackingOptions mTrackingOptions;
|
2017-02-28 19:45:47 -05:00
|
|
|
inline MsgStartTracking(GnssAdapter& adapter,
|
|
|
|
LocApiBase& api,
|
|
|
|
LocationAPI* client,
|
|
|
|
uint32_t sessionId,
|
2018-05-20 13:36:12 -04:00
|
|
|
TrackingOptions trackingOptions) :
|
2017-02-28 19:45:47 -05:00
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mApi(api),
|
|
|
|
mClient(client),
|
|
|
|
mSessionId(sessionId),
|
2018-05-20 13:36:12 -04:00
|
|
|
mTrackingOptions(trackingOptions) {}
|
2017-02-28 19:45:47 -05:00
|
|
|
inline virtual void proc() const {
|
|
|
|
LocationError err = LOCATION_ERROR_SUCCESS;
|
|
|
|
if (!mAdapter.hasTrackingCallback(mClient) &&
|
|
|
|
!mAdapter.hasMeasurementsCallback(mClient)) {
|
|
|
|
err = LOCATION_ERROR_CALLBACK_MISSING;
|
2018-05-20 13:36:12 -04:00
|
|
|
} else if (0 == mTrackingOptions.size) {
|
2017-02-28 19:45:47 -05:00
|
|
|
err = LOCATION_ERROR_INVALID_PARAMETER;
|
|
|
|
} else {
|
2018-05-20 13:36:12 -04:00
|
|
|
if (GNSS_POWER_MODE_INVALID != mTrackingOptions.powerMode &&
|
|
|
|
!ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_AGPM_V02)) {
|
|
|
|
LOC_LOGv("Ignoring power mode, feature not supported.");
|
|
|
|
mTrackingOptions.powerMode = GNSS_POWER_MODE_INVALID;
|
|
|
|
}
|
|
|
|
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_AGPM_V02) &&
|
|
|
|
GNSS_POWER_MODE_M4 == mTrackingOptions.powerMode &&
|
|
|
|
mTrackingOptions.tbm > TRACKING_TBM_THRESHOLD_MILLIS) {
|
|
|
|
LOC_LOGd("TBM (%d) > %d Falling back to M2 power mode",
|
|
|
|
mTrackingOptions.tbm, TRACKING_TBM_THRESHOLD_MILLIS);
|
|
|
|
mTrackingOptions.powerMode = GNSS_POWER_MODE_M2;
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
// Api doesn't support multiple clients for time based tracking, so mutiplex
|
2018-01-22 19:04:50 -05:00
|
|
|
bool reportToClientWithNoWait =
|
2018-05-20 13:36:12 -04:00
|
|
|
mAdapter.startTrackingMultiplex(mClient, mSessionId, mTrackingOptions);
|
|
|
|
mAdapter.saveTrackingSession(mClient, mSessionId, mTrackingOptions);
|
2018-01-22 19:04:50 -05:00
|
|
|
|
|
|
|
if (reportToClientWithNoWait) {
|
|
|
|
mAdapter.reportResponse(mClient, LOCATION_ERROR_SUCCESS, mSessionId);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgStartTracking(*this, *mLocApi, client, sessionId, options));
|
|
|
|
return sessionId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
bool
|
|
|
|
GnssAdapter::startTrackingMultiplex(LocationAPI* client, uint32_t sessionId,
|
2018-05-20 13:36:12 -04:00
|
|
|
const TrackingOptions& options)
|
2017-02-28 19:45:47 -05:00
|
|
|
{
|
2018-01-22 19:04:50 -05:00
|
|
|
bool reportToClientWithNoWait = true;
|
2017-02-28 19:45:47 -05:00
|
|
|
|
|
|
|
if (mTrackingSessions.empty()) {
|
2018-06-07 15:03:55 -04:00
|
|
|
startTracking(client, sessionId, options);
|
|
|
|
// need to wait for QMI callback
|
|
|
|
reportToClientWithNoWait = false;
|
2017-02-28 19:45:47 -05:00
|
|
|
} else {
|
2018-05-20 13:36:12 -04:00
|
|
|
// find the smallest interval and powerMode
|
|
|
|
TrackingOptions multiplexedOptions = {}; // size is 0 until set for the first time
|
|
|
|
GnssPowerMode multiplexedPowerMode = GNSS_POWER_MODE_INVALID;
|
2017-02-28 19:45:47 -05:00
|
|
|
for (auto it = mTrackingSessions.begin(); it != mTrackingSessions.end(); ++it) {
|
2018-05-20 13:36:12 -04:00
|
|
|
// if not set or there is a new smallest interval, then set the new interval
|
|
|
|
if (0 == multiplexedOptions.size ||
|
|
|
|
it->second.minInterval < multiplexedOptions.minInterval) {
|
|
|
|
multiplexedOptions = it->second;
|
|
|
|
}
|
|
|
|
// if session is not the one we are updating and either powerMode
|
|
|
|
// is not set or there is a new smallest powerMode, then set the new powerMode
|
|
|
|
if (GNSS_POWER_MODE_INVALID == multiplexedPowerMode ||
|
|
|
|
it->second.powerMode < multiplexedPowerMode) {
|
|
|
|
multiplexedPowerMode = it->second.powerMode;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
2018-05-20 13:36:12 -04:00
|
|
|
bool updateOptions = false;
|
|
|
|
// if session we are starting has smaller interval then next smallest
|
|
|
|
if (options.minInterval < multiplexedOptions.minInterval) {
|
|
|
|
multiplexedOptions.minInterval = options.minInterval;
|
|
|
|
updateOptions = true;
|
|
|
|
}
|
|
|
|
// if session we are starting has smaller powerMode then next smallest
|
|
|
|
if (options.powerMode < multiplexedPowerMode) {
|
|
|
|
multiplexedOptions.powerMode = options.powerMode;
|
|
|
|
updateOptions = true;
|
|
|
|
}
|
|
|
|
if (updateOptions) {
|
|
|
|
// restart time based tracking with the newly updated options
|
2018-06-07 15:03:55 -04:00
|
|
|
startTracking(client, sessionId, multiplexedOptions);
|
|
|
|
// need to wait for QMI callback
|
|
|
|
reportToClientWithNoWait = false;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
2018-06-07 15:03:55 -04:00
|
|
|
// else part: no QMI call is made, need to report back to client right away
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
return reportToClientWithNoWait;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
2018-06-07 15:03:55 -04:00
|
|
|
void
|
2018-01-22 19:04:50 -05:00
|
|
|
GnssAdapter::startTracking(LocationAPI* client, uint32_t sessionId,
|
2018-05-20 13:36:12 -04:00
|
|
|
const TrackingOptions& trackingOptions)
|
2017-02-28 19:45:47 -05:00
|
|
|
{
|
|
|
|
LocPosMode locPosMode = {};
|
2018-05-20 13:36:12 -04:00
|
|
|
convertOptions(locPosMode, trackingOptions);
|
2018-01-22 19:04:50 -05:00
|
|
|
|
2018-06-07 15:03:55 -04:00
|
|
|
// inform engine hub that GNSS session is about to start
|
|
|
|
mEngHubProxy->gnssSetFixMode(locPosMode);
|
|
|
|
mEngHubProxy->gnssStartFix();
|
2018-01-22 19:04:50 -05:00
|
|
|
|
2018-06-07 15:03:55 -04:00
|
|
|
mLocApi->startFix(locPosMode, new LocApiResponse(*getContext(),
|
|
|
|
[this, client, sessionId] (LocationError err) {
|
|
|
|
if (LOCATION_ERROR_SUCCESS != err) {
|
|
|
|
eraseTrackingSession(client, sessionId);
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
|
2018-06-07 15:03:55 -04:00
|
|
|
reportResponse(client, err, sessionId);
|
|
|
|
}
|
|
|
|
));
|
2018-01-22 19:04:50 -05:00
|
|
|
}
|
|
|
|
|
2018-06-07 15:03:55 -04:00
|
|
|
void
|
2018-01-22 19:04:50 -05:00
|
|
|
GnssAdapter::updateTracking(LocationAPI* client, uint32_t sessionId,
|
2018-05-20 13:36:12 -04:00
|
|
|
const TrackingOptions& updatedOptions, const TrackingOptions& oldOptions)
|
2018-01-22 19:04:50 -05:00
|
|
|
{
|
|
|
|
LocPosMode locPosMode = {};
|
|
|
|
convertOptions(locPosMode, updatedOptions);
|
|
|
|
|
2018-06-07 15:03:55 -04:00
|
|
|
// inform engine hub that GNSS session is about to start
|
|
|
|
mEngHubProxy->gnssSetFixMode(locPosMode);
|
|
|
|
mEngHubProxy->gnssStartFix();
|
2017-02-28 19:45:47 -05:00
|
|
|
|
2018-06-07 15:03:55 -04:00
|
|
|
mLocApi->startFix(locPosMode, new LocApiResponse(*getContext(),
|
|
|
|
[this, client, sessionId, oldOptions] (LocationError err) {
|
|
|
|
if (LOCATION_ERROR_SUCCESS != err) {
|
|
|
|
// restore the old LocationOptions
|
|
|
|
saveTrackingSession(client, sessionId, oldOptions);
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
|
2018-06-07 15:03:55 -04:00
|
|
|
reportResponse(client, err, sessionId);
|
|
|
|
}
|
|
|
|
));
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::setPositionModeCommand(LocPosMode& locPosMode)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: min_interval %u mode %u",
|
|
|
|
__func__, locPosMode.min_interval, locPosMode.mode);
|
|
|
|
|
|
|
|
struct MsgSetPositionMode : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
LocApiBase& mApi;
|
|
|
|
LocPosMode mLocPosMode;
|
|
|
|
inline MsgSetPositionMode(GnssAdapter& adapter,
|
|
|
|
LocApiBase& api,
|
|
|
|
LocPosMode& locPosMode) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mApi(api),
|
|
|
|
mLocPosMode(locPosMode) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
// saves the mode in adapter to be used when startTrackingCommand is called from ULP
|
2018-06-07 15:03:55 -04:00
|
|
|
if (mAdapter.setLocPositionMode(mLocPosMode)) {
|
2018-01-29 04:02:06 -05:00
|
|
|
mAdapter.mEngHubProxy->gnssSetFixMode(mLocPosMode);
|
2017-08-21 21:41:23 -04:00
|
|
|
mApi.setPositionMode(mLocPosMode);
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgSetPositionMode(*this, *mLocApi, locPosMode));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::updateTrackingOptionsCommand(LocationAPI* client, uint32_t id,
|
2018-05-20 13:36:12 -04:00
|
|
|
TrackingOptions& options)
|
2017-02-28 19:45:47 -05:00
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: client %p id %u minInterval %u mode %u",
|
|
|
|
__func__, client, id, options.minInterval, options.mode);
|
|
|
|
|
|
|
|
struct MsgUpdateTracking : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
LocApiBase& mApi;
|
|
|
|
LocationAPI* mClient;
|
|
|
|
uint32_t mSessionId;
|
2018-05-20 13:36:12 -04:00
|
|
|
mutable TrackingOptions mTrackingOptions;
|
2017-02-28 19:45:47 -05:00
|
|
|
inline MsgUpdateTracking(GnssAdapter& adapter,
|
|
|
|
LocApiBase& api,
|
|
|
|
LocationAPI* client,
|
|
|
|
uint32_t sessionId,
|
2018-05-20 13:36:12 -04:00
|
|
|
TrackingOptions trackingOptions) :
|
2017-02-28 19:45:47 -05:00
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mApi(api),
|
|
|
|
mClient(client),
|
|
|
|
mSessionId(sessionId),
|
2018-05-20 13:36:12 -04:00
|
|
|
mTrackingOptions(trackingOptions) {}
|
2017-02-28 19:45:47 -05:00
|
|
|
inline virtual void proc() const {
|
|
|
|
if (mAdapter.isTrackingSession(mClient, mSessionId)) {
|
|
|
|
LocationError err = LOCATION_ERROR_SUCCESS;
|
2018-05-20 13:36:12 -04:00
|
|
|
if (0 == mTrackingOptions.size) {
|
2017-02-28 19:45:47 -05:00
|
|
|
err = LOCATION_ERROR_INVALID_PARAMETER;
|
|
|
|
} else {
|
2018-05-20 13:36:12 -04:00
|
|
|
if (GNSS_POWER_MODE_INVALID != mTrackingOptions.powerMode &&
|
|
|
|
!ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_AGPM_V02)) {
|
|
|
|
LOC_LOGv("Ignoring power mode, feature not supported.");
|
|
|
|
mTrackingOptions.powerMode = GNSS_POWER_MODE_INVALID;
|
|
|
|
}
|
|
|
|
if (ContextBase::isFeatureSupported(LOC_SUPPORTED_FEATURE_AGPM_V02) &&
|
|
|
|
GNSS_POWER_MODE_M4 == mTrackingOptions.powerMode &&
|
|
|
|
mTrackingOptions.tbm > TRACKING_TBM_THRESHOLD_MILLIS) {
|
|
|
|
LOC_LOGd("TBM (%d) > %d Falling back to M2 power mode",
|
|
|
|
mTrackingOptions.tbm, TRACKING_TBM_THRESHOLD_MILLIS);
|
|
|
|
mTrackingOptions.powerMode = GNSS_POWER_MODE_M2;
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
// Api doesn't support multiple clients for time based tracking, so mutiplex
|
2018-01-22 19:04:50 -05:00
|
|
|
bool reportToClientWithNoWait =
|
2018-05-20 13:36:12 -04:00
|
|
|
mAdapter.updateTrackingMultiplex(mClient, mSessionId, mTrackingOptions);
|
|
|
|
mAdapter.saveTrackingSession(mClient, mSessionId, mTrackingOptions);
|
2018-01-22 19:04:50 -05:00
|
|
|
|
|
|
|
if (reportToClientWithNoWait) {
|
|
|
|
mAdapter.reportResponse(mClient, err, mSessionId);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// we do not reportResponse for the case where there is no existing tracking session
|
|
|
|
// for the client and id being used, since updateTrackingCommand can be sent to both
|
|
|
|
// GnssAdapter & FlpAdapter by LocationAPI and we want to avoid incorrect error response
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgUpdateTracking(*this, *mLocApi, client, id, options));
|
|
|
|
}
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
bool
|
2017-06-06 03:11:02 -04:00
|
|
|
GnssAdapter::updateTrackingMultiplex(LocationAPI* client, uint32_t id,
|
2018-05-20 13:36:12 -04:00
|
|
|
const TrackingOptions& trackingOptions)
|
2017-06-06 03:11:02 -04:00
|
|
|
{
|
2018-01-22 19:04:50 -05:00
|
|
|
bool reportToClientWithNoWait = true;
|
|
|
|
|
|
|
|
LocationSessionKey key(client, id);
|
|
|
|
// get the session we are updating
|
|
|
|
auto it = mTrackingSessions.find(key);
|
2017-06-06 03:11:02 -04:00
|
|
|
|
2018-05-20 13:36:12 -04:00
|
|
|
// cache the clients existing LocationOptions
|
|
|
|
TrackingOptions oldOptions = it->second;
|
|
|
|
|
|
|
|
// if session we are updating exists and the minInterval or powerMode has changed
|
|
|
|
if (it != mTrackingSessions.end() && (it->second.minInterval != trackingOptions.minInterval ||
|
|
|
|
it->second.powerMode != trackingOptions.powerMode)) {
|
|
|
|
// find the smallest interval and powerMode, other than the session we are updating
|
|
|
|
TrackingOptions multiplexedOptions = {}; // size is 0 until set for the first time
|
|
|
|
GnssPowerMode multiplexedPowerMode = GNSS_POWER_MODE_INVALID;
|
|
|
|
for (auto it2 = mTrackingSessions.begin(); it2 != mTrackingSessions.end(); ++it2) {
|
|
|
|
// if session is not the one we are updating and either interval
|
|
|
|
// is not set or there is a new smallest interval, then set the new interval
|
|
|
|
if (it2->first != key && (0 == multiplexedOptions.size ||
|
|
|
|
it2->second.minInterval < multiplexedOptions.minInterval)) {
|
|
|
|
multiplexedOptions = it2->second;
|
2017-06-06 03:11:02 -04:00
|
|
|
}
|
2018-05-20 13:36:12 -04:00
|
|
|
// if session is not the one we are updating and either powerMode
|
|
|
|
// is not set or there is a new smallest powerMode, then set the new powerMode
|
|
|
|
if (it2->first != key && (GNSS_POWER_MODE_INVALID == multiplexedPowerMode ||
|
|
|
|
it2->second.powerMode < multiplexedPowerMode)) {
|
|
|
|
multiplexedPowerMode = it2->second.powerMode;
|
2017-06-06 03:11:02 -04:00
|
|
|
}
|
2018-06-07 15:03:55 -04:00
|
|
|
// else part: no QMI call is made, need to report back to client right away
|
2017-06-06 03:11:02 -04:00
|
|
|
}
|
2018-05-20 13:36:12 -04:00
|
|
|
bool updateOptions = false;
|
|
|
|
// if session we are updating has smaller interval then next smallest
|
|
|
|
if (trackingOptions.minInterval < multiplexedOptions.minInterval) {
|
|
|
|
multiplexedOptions.minInterval = trackingOptions.minInterval;
|
|
|
|
updateOptions = true;
|
|
|
|
}
|
|
|
|
// if session we are updating has smaller powerMode then next smallest
|
|
|
|
if (trackingOptions.powerMode < multiplexedPowerMode) {
|
|
|
|
multiplexedOptions.powerMode = trackingOptions.powerMode;
|
|
|
|
updateOptions = true;
|
|
|
|
}
|
|
|
|
// if only one session exists, then tracking should be updated with it
|
|
|
|
if (1 == mTrackingSessions.size()) {
|
|
|
|
multiplexedOptions = trackingOptions;
|
|
|
|
updateOptions = true;
|
|
|
|
}
|
|
|
|
if (updateOptions) {
|
|
|
|
// restart time based tracking with the newly updated options
|
2018-06-07 15:03:55 -04:00
|
|
|
updateTracking(client, id, multiplexedOptions, oldOptions);
|
|
|
|
// need to wait for QMI callback
|
|
|
|
reportToClientWithNoWait = false;
|
2018-05-20 13:36:12 -04:00
|
|
|
}
|
2017-06-06 03:11:02 -04:00
|
|
|
}
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
return reportToClientWithNoWait;
|
2017-06-06 03:11:02 -04:00
|
|
|
}
|
|
|
|
|
2017-02-28 19:45:47 -05:00
|
|
|
void
|
|
|
|
GnssAdapter::stopTrackingCommand(LocationAPI* client, uint32_t id)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: client %p id %u", __func__, client, id);
|
|
|
|
|
|
|
|
struct MsgStopTracking : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
LocApiBase& mApi;
|
|
|
|
LocationAPI* mClient;
|
|
|
|
uint32_t mSessionId;
|
|
|
|
inline MsgStopTracking(GnssAdapter& adapter,
|
|
|
|
LocApiBase& api,
|
|
|
|
LocationAPI* client,
|
|
|
|
uint32_t sessionId) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mApi(api),
|
|
|
|
mClient(client),
|
|
|
|
mSessionId(sessionId) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
if (mAdapter.isTrackingSession(mClient, mSessionId)) {
|
|
|
|
// Api doesn't support multiple clients for time based tracking, so mutiplex
|
2018-01-22 19:04:50 -05:00
|
|
|
bool reportToClientWithNoWait =
|
|
|
|
mAdapter.stopTrackingMultiplex(mClient, mSessionId);
|
|
|
|
mAdapter.eraseTrackingSession(mClient, mSessionId);
|
|
|
|
|
|
|
|
if (reportToClientWithNoWait) {
|
|
|
|
mAdapter.reportResponse(mClient, LOCATION_ERROR_SUCCESS, mSessionId);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// we do not reportResponse for the case where there is no existing tracking session
|
|
|
|
// for the client and id being used, since stopTrackingCommand can be sent to both
|
|
|
|
// GnssAdapter & FlpAdapter by LocationAPI and we want to avoid incorrect error response
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgStopTracking(*this, *mLocApi, client, id));
|
|
|
|
}
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
bool
|
2017-02-28 19:45:47 -05:00
|
|
|
GnssAdapter::stopTrackingMultiplex(LocationAPI* client, uint32_t id)
|
|
|
|
{
|
2018-01-22 19:04:50 -05:00
|
|
|
bool reportToClientWithNoWait = true;
|
2017-02-28 19:45:47 -05:00
|
|
|
|
|
|
|
if (1 == mTrackingSessions.size()) {
|
2018-06-07 15:03:55 -04:00
|
|
|
stopTracking(client, id);
|
|
|
|
// need to wait for QMI callback
|
|
|
|
reportToClientWithNoWait = false;
|
2017-02-28 19:45:47 -05:00
|
|
|
} else {
|
|
|
|
LocationSessionKey key(client, id);
|
|
|
|
|
|
|
|
// get the session we are stopping
|
|
|
|
auto it = mTrackingSessions.find(key);
|
|
|
|
if (it != mTrackingSessions.end()) {
|
2018-05-20 13:36:12 -04:00
|
|
|
// find the smallest interval and powerMode, other than the session we are stopping
|
|
|
|
TrackingOptions multiplexedOptions = {}; // size is 0 until set for the first time
|
|
|
|
GnssPowerMode multiplexedPowerMode = GNSS_POWER_MODE_INVALID;
|
2017-02-28 19:45:47 -05:00
|
|
|
for (auto it2 = mTrackingSessions.begin(); it2 != mTrackingSessions.end(); ++it2) {
|
2018-05-20 13:36:12 -04:00
|
|
|
// if session is not the one we are stopping and either interval
|
|
|
|
// is not set or there is a new smallest interval, then set the new interval
|
|
|
|
if (it2->first != key && (0 == multiplexedOptions.size ||
|
|
|
|
it2->second.minInterval < multiplexedOptions.minInterval)) {
|
|
|
|
multiplexedOptions = it2->second;
|
|
|
|
}
|
|
|
|
// if session is not the one we are stopping and either powerMode
|
|
|
|
// is not set or there is a new smallest powerMode, then set the new powerMode
|
|
|
|
if (it2->first != key && (GNSS_POWER_MODE_INVALID == multiplexedPowerMode ||
|
|
|
|
it2->second.powerMode < multiplexedPowerMode)) {
|
|
|
|
multiplexedPowerMode = it2->second.powerMode;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
2018-05-20 13:36:12 -04:00
|
|
|
// if session we are stopping has smaller interval then next smallest or
|
|
|
|
// if session we are stopping has smaller powerMode then next smallest
|
|
|
|
if (it->second.minInterval < multiplexedOptions.minInterval ||
|
|
|
|
it->second.powerMode < multiplexedPowerMode) {
|
|
|
|
multiplexedOptions.powerMode = multiplexedPowerMode;
|
|
|
|
// restart time based tracking with the newly updated options
|
2018-06-07 15:03:55 -04:00
|
|
|
startTracking(client, id, multiplexedOptions);
|
|
|
|
// need to wait for QMI callback
|
|
|
|
reportToClientWithNoWait = false;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
2018-06-07 15:03:55 -04:00
|
|
|
// else part: no QMI call is made, need to report back to client right away
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
return reportToClientWithNoWait;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-06-07 15:03:55 -04:00
|
|
|
GnssAdapter::stopTracking(LocationAPI* client, uint32_t id)
|
2017-02-28 19:45:47 -05:00
|
|
|
{
|
2018-06-07 15:03:55 -04:00
|
|
|
// inform engine hub that GNSS session has stopped
|
|
|
|
mEngHubProxy->gnssStopFix();
|
2017-02-28 19:45:47 -05:00
|
|
|
|
2018-06-07 15:03:55 -04:00
|
|
|
mLocApi->stopFix(new LocApiResponse(*getContext(),
|
|
|
|
[this, client, id] (LocationError err) {
|
|
|
|
reportResponse(client, err, id);
|
|
|
|
}));
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GnssAdapter::hasNiNotifyCallback(LocationAPI* client)
|
|
|
|
{
|
|
|
|
auto it = mClientData.find(client);
|
|
|
|
return (it != mClientData.end() && it->second.gnssNiCb);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::gnssNiResponseCommand(LocationAPI* client,
|
|
|
|
uint32_t id,
|
|
|
|
GnssNiResponse response)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: client %p id %u response %u", __func__, client, id, response);
|
|
|
|
|
|
|
|
struct MsgGnssNiResponse : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
LocationAPI* mClient;
|
|
|
|
uint32_t mSessionId;
|
|
|
|
GnssNiResponse mResponse;
|
|
|
|
inline MsgGnssNiResponse(GnssAdapter& adapter,
|
|
|
|
LocationAPI* client,
|
|
|
|
uint32_t sessionId,
|
|
|
|
GnssNiResponse response) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mClient(client),
|
|
|
|
mSessionId(sessionId),
|
|
|
|
mResponse(response) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
NiData& niData = mAdapter.getNiData();
|
|
|
|
LocationError err = LOCATION_ERROR_SUCCESS;
|
|
|
|
if (!mAdapter.hasNiNotifyCallback(mClient)) {
|
|
|
|
err = LOCATION_ERROR_ID_UNKNOWN;
|
|
|
|
} else {
|
|
|
|
NiSession* pSession = NULL;
|
|
|
|
if (mSessionId == niData.sessionEs.reqID &&
|
|
|
|
NULL != niData.sessionEs.rawRequest) {
|
|
|
|
pSession = &niData.sessionEs;
|
|
|
|
// ignore any SUPL NI non-Es session if a SUPL NI ES is accepted
|
|
|
|
if (mResponse == GNSS_NI_RESPONSE_ACCEPT &&
|
|
|
|
NULL != niData.session.rawRequest) {
|
|
|
|
pthread_mutex_lock(&niData.session.tLock);
|
|
|
|
niData.session.resp = GNSS_NI_RESPONSE_IGNORE;
|
|
|
|
niData.session.respRecvd = true;
|
|
|
|
pthread_cond_signal(&niData.session.tCond);
|
|
|
|
pthread_mutex_unlock(&niData.session.tLock);
|
|
|
|
}
|
|
|
|
} else if (mSessionId == niData.session.reqID &&
|
|
|
|
NULL != niData.session.rawRequest) {
|
|
|
|
pSession = &niData.session;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pSession) {
|
|
|
|
LOC_LOGI("%s]: gnssNiResponseCommand: send user mResponse %u for id %u",
|
|
|
|
__func__, mResponse, mSessionId);
|
|
|
|
pthread_mutex_lock(&pSession->tLock);
|
|
|
|
pSession->resp = mResponse;
|
|
|
|
pSession->respRecvd = true;
|
|
|
|
pthread_cond_signal(&pSession->tCond);
|
|
|
|
pthread_mutex_unlock(&pSession->tLock);
|
|
|
|
} else {
|
|
|
|
err = LOCATION_ERROR_ID_UNKNOWN;
|
|
|
|
LOC_LOGE("%s]: gnssNiResponseCommand: id %u not an active session",
|
|
|
|
__func__, mSessionId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mAdapter.reportResponse(mClient, err, mSessionId);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgGnssNiResponse(*this, client, id, response));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::gnssNiResponseCommand(GnssNiResponse response, void* rawRequest)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: response %u", __func__, response);
|
|
|
|
|
|
|
|
struct MsgGnssNiResponse : public LocMsg {
|
2018-01-22 19:04:50 -05:00
|
|
|
GnssAdapter& mAdapter;
|
2017-02-28 19:45:47 -05:00
|
|
|
LocApiBase& mApi;
|
|
|
|
const GnssNiResponse mResponse;
|
|
|
|
const void* mPayload;
|
2018-01-22 19:04:50 -05:00
|
|
|
inline MsgGnssNiResponse(GnssAdapter& adapter,
|
|
|
|
LocApiBase& api,
|
2017-02-28 19:45:47 -05:00
|
|
|
const GnssNiResponse response,
|
|
|
|
const void* rawRequest) :
|
|
|
|
LocMsg(),
|
2018-01-22 19:04:50 -05:00
|
|
|
mAdapter(adapter),
|
2017-02-28 19:45:47 -05:00
|
|
|
mApi(api),
|
|
|
|
mResponse(response),
|
|
|
|
mPayload(rawRequest) {}
|
|
|
|
inline virtual ~MsgGnssNiResponse() {
|
|
|
|
}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mApi.informNiResponse(mResponse, mPayload);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
sendMsg(new MsgGnssNiResponse(*this, *mLocApi, response, rawRequest));
|
2017-02-28 19:45:47 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
GnssAdapter::enableCommand(LocationTechnologyType techType)
|
|
|
|
{
|
|
|
|
uint32_t sessionId = generateSessionId();
|
|
|
|
LOC_LOGD("%s]: id %u techType %u", __func__, sessionId, techType);
|
|
|
|
|
|
|
|
struct MsgEnableGnss : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
LocApiBase& mApi;
|
|
|
|
ContextBase& mContext;
|
|
|
|
uint32_t mSessionId;
|
|
|
|
LocationTechnologyType mTechType;
|
|
|
|
inline MsgEnableGnss(GnssAdapter& adapter,
|
|
|
|
LocApiBase& api,
|
|
|
|
ContextBase& context,
|
|
|
|
uint32_t sessionId,
|
|
|
|
LocationTechnologyType techType) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mApi(api),
|
|
|
|
mContext(context),
|
|
|
|
mSessionId(sessionId),
|
|
|
|
mTechType(techType) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
LocationError err = LOCATION_ERROR_SUCCESS;
|
|
|
|
uint32_t powerVoteId = mAdapter.getPowerVoteId();
|
|
|
|
if (mTechType != LOCATION_TECHNOLOGY_TYPE_GNSS) {
|
|
|
|
err = LOCATION_ERROR_INVALID_PARAMETER;
|
|
|
|
} else if (powerVoteId > 0) {
|
|
|
|
err = LOCATION_ERROR_ALREADY_STARTED;
|
|
|
|
} else {
|
|
|
|
mContext.modemPowerVote(true);
|
|
|
|
mAdapter.setPowerVoteId(mSessionId);
|
2018-01-22 19:04:50 -05:00
|
|
|
|
|
|
|
mApi.sendMsg(new LocApiMsg([&mApi = mApi] () {
|
|
|
|
mApi.setGpsLockSync(GNSS_CONFIG_GPS_LOCK_NONE);
|
|
|
|
}));
|
|
|
|
|
2017-07-04 15:09:06 -04:00
|
|
|
mAdapter.mXtraObserver.updateLockStatus(
|
|
|
|
mAdapter.convertGpsLock(GNSS_CONFIG_GPS_LOCK_NONE));
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
mAdapter.reportResponse(err, mSessionId);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (mContext != NULL) {
|
|
|
|
sendMsg(new MsgEnableGnss(*this, *mLocApi, *mContext, sessionId, techType));
|
|
|
|
} else {
|
|
|
|
LOC_LOGE("%s]: Context is NULL", __func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sessionId;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::disableCommand(uint32_t id)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: id %u", __func__, id);
|
|
|
|
|
|
|
|
struct MsgDisableGnss : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
LocApiBase& mApi;
|
|
|
|
ContextBase& mContext;
|
|
|
|
uint32_t mSessionId;
|
|
|
|
inline MsgDisableGnss(GnssAdapter& adapter,
|
|
|
|
LocApiBase& api,
|
|
|
|
ContextBase& context,
|
|
|
|
uint32_t sessionId) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mApi(api),
|
|
|
|
mContext(context),
|
|
|
|
mSessionId(sessionId) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
LocationError err = LOCATION_ERROR_SUCCESS;
|
|
|
|
uint32_t powerVoteId = mAdapter.getPowerVoteId();
|
|
|
|
if (powerVoteId != mSessionId) {
|
|
|
|
err = LOCATION_ERROR_ID_UNKNOWN;
|
|
|
|
} else {
|
|
|
|
mContext.modemPowerVote(false);
|
|
|
|
mAdapter.setPowerVoteId(0);
|
2018-01-22 19:04:50 -05:00
|
|
|
|
|
|
|
GnssConfigGpsLock gpsLock =
|
|
|
|
mAdapter.convertGpsLock(ContextBase::mGps_conf.GPS_LOCK);
|
|
|
|
mApi.sendMsg(new LocApiMsg([&mApi = mApi,gpsLock] () {
|
|
|
|
mApi.setGpsLockSync(gpsLock);
|
|
|
|
}));
|
2017-07-04 15:09:06 -04:00
|
|
|
mAdapter.mXtraObserver.updateLockStatus(
|
|
|
|
mAdapter.convertGpsLock(ContextBase::mGps_conf.GPS_LOCK));
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
mAdapter.reportResponse(err, mSessionId);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (mContext != NULL) {
|
|
|
|
sendMsg(new MsgDisableGnss(*this, *mLocApi, *mContext, id));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation,
|
|
|
|
const GpsLocationExtended& locationExtended,
|
|
|
|
enum loc_sess_status status,
|
|
|
|
LocPosTechMask techMask,
|
2018-03-30 20:10:59 -04:00
|
|
|
bool fromEngineHub)
|
2017-02-28 19:45:47 -05:00
|
|
|
{
|
2018-06-07 15:03:55 -04:00
|
|
|
// if this event is called from QMI LOC API, then send report to engine hub
|
|
|
|
// if sending is successful, we return as we will wait for final report from engine hub
|
|
|
|
// if the position is called from engine hub, then send it out directly
|
|
|
|
if (!fromEngineHub) {
|
2018-03-30 20:10:59 -04:00
|
|
|
// report QMI position (both propagated and unpropagated) to engine hub,
|
|
|
|
// and engine hub will be distributing it to the registered plugins
|
2018-01-29 04:02:06 -05:00
|
|
|
mEngHubProxy->gnssReportPosition(ulpLocation, locationExtended, status);
|
2018-03-30 20:10:59 -04:00
|
|
|
|
|
|
|
if (true == ulpLocation.unpropagatedPosition) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// engine hub is loaded, do not report qmi position to client as
|
|
|
|
// final position report should come from engine hub
|
|
|
|
if (true == initEngHubProxy()){
|
|
|
|
return;
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
2018-03-30 20:10:59 -04:00
|
|
|
// for all other cases:
|
2018-06-07 15:03:55 -04:00
|
|
|
// case 1: fix is from engine hub, queue the msg
|
|
|
|
// case 2: fix is not from engine hub, e.g. from QMI, and it is not an
|
2018-04-27 16:38:36 -04:00
|
|
|
// unpropagated position and engine hub is not loaded, queue the msg
|
2018-03-30 20:10:59 -04:00
|
|
|
// when message is queued, the position can be dispatched to requesting client
|
2017-02-28 19:45:47 -05:00
|
|
|
struct MsgReportPosition : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
const UlpLocation mUlpLocation;
|
|
|
|
const GpsLocationExtended mLocationExtended;
|
|
|
|
loc_sess_status mStatus;
|
|
|
|
LocPosTechMask mTechMask;
|
|
|
|
inline MsgReportPosition(GnssAdapter& adapter,
|
|
|
|
const UlpLocation& ulpLocation,
|
|
|
|
const GpsLocationExtended& locationExtended,
|
|
|
|
loc_sess_status status,
|
|
|
|
LocPosTechMask techMask) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mUlpLocation(ulpLocation),
|
|
|
|
mLocationExtended(locationExtended),
|
|
|
|
mStatus(status),
|
|
|
|
mTechMask(techMask) {}
|
|
|
|
inline virtual void proc() const {
|
2017-03-21 20:16:49 -04:00
|
|
|
// extract bug report info - this returns true if consumed by systemstatus
|
2017-08-11 05:43:38 -04:00
|
|
|
SystemStatus* s = mAdapter.getSystemStatus();
|
2018-05-03 14:41:51 -04:00
|
|
|
if ((nullptr != s) &&
|
|
|
|
((LOC_SESS_SUCCESS == mStatus) || (LOC_SESS_INTERMEDIATE == mStatus))){
|
2017-03-21 20:16:49 -04:00
|
|
|
s->eventPosition(mUlpLocation, mLocationExtended);
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
mAdapter.reportPosition(mUlpLocation, mLocationExtended, mStatus, mTechMask);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgReportPosition(*this, ulpLocation, locationExtended, status, techMask));
|
|
|
|
}
|
|
|
|
|
2017-09-04 23:59:34 -04:00
|
|
|
bool
|
|
|
|
GnssAdapter::needReport(const UlpLocation& ulpLocation,
|
|
|
|
enum loc_sess_status status,
|
|
|
|
LocPosTechMask techMask) {
|
|
|
|
bool reported = false;
|
|
|
|
if (LOC_SESS_SUCCESS == status) {
|
|
|
|
// this is a final fix
|
|
|
|
LocPosTechMask mask =
|
|
|
|
LOC_POS_TECH_MASK_SATELLITE | LOC_POS_TECH_MASK_SENSORS | LOC_POS_TECH_MASK_HYBRID;
|
|
|
|
// it is a Satellite fix or a sensor fix
|
|
|
|
reported = (mask & techMask);
|
|
|
|
} else if (LOC_SESS_INTERMEDIATE == status &&
|
|
|
|
LOC_SESS_INTERMEDIATE == ContextBase::mGps_conf.INTERMEDIATE_POS) {
|
|
|
|
// this is a intermediate fix and we accepte intermediate
|
|
|
|
|
|
|
|
// it is NOT the case that
|
|
|
|
// there is inaccuracy; and
|
|
|
|
// we care about inaccuracy; and
|
|
|
|
// the inaccuracy exceeds our tolerance
|
|
|
|
reported = !((ulpLocation.gpsLocation.flags & LOC_GPS_LOCATION_HAS_ACCURACY) &&
|
|
|
|
(ContextBase::mGps_conf.ACCURACY_THRES != 0) &&
|
|
|
|
(ulpLocation.gpsLocation.accuracy > ContextBase::mGps_conf.ACCURACY_THRES));
|
|
|
|
}
|
|
|
|
|
|
|
|
return reported;
|
|
|
|
}
|
|
|
|
|
2017-02-28 19:45:47 -05:00
|
|
|
void
|
|
|
|
GnssAdapter::reportPosition(const UlpLocation& ulpLocation,
|
|
|
|
const GpsLocationExtended& locationExtended,
|
|
|
|
enum loc_sess_status status,
|
|
|
|
LocPosTechMask techMask)
|
|
|
|
{
|
2017-09-04 23:59:34 -04:00
|
|
|
bool reported = needReport(ulpLocation, status, techMask);
|
|
|
|
if (reported) {
|
2017-02-28 19:45:47 -05:00
|
|
|
if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_GNSS_SV_USED_DATA) {
|
|
|
|
mGnssSvIdUsedInPosAvail = true;
|
|
|
|
mGnssSvIdUsedInPosition = locationExtended.gnss_sv_used_ids;
|
|
|
|
}
|
|
|
|
for (auto it=mClientData.begin(); it != mClientData.end(); ++it) {
|
|
|
|
if (nullptr != it->second.gnssLocationInfoCb) {
|
|
|
|
GnssLocationInfoNotification locationInfo = {};
|
|
|
|
convertLocationInfo(locationInfo, locationExtended);
|
2018-01-10 00:58:17 -05:00
|
|
|
convertLocation(locationInfo.location, ulpLocation, locationExtended, techMask);
|
2017-02-28 19:45:47 -05:00
|
|
|
it->second.gnssLocationInfoCb(locationInfo);
|
2018-01-10 00:58:17 -05:00
|
|
|
} else if (nullptr != it->second.trackingCb) {
|
|
|
|
Location location = {};
|
|
|
|
convertLocation(location, ulpLocation, locationExtended, techMask);
|
|
|
|
it->second.trackingCb(location);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NMEA_PROVIDER_AP == ContextBase::mGps_conf.NMEA_PROVIDER && !mTrackingSessions.empty()) {
|
2017-06-15 10:13:52 -04:00
|
|
|
/*Only BlankNMEA sentence needs to be processed and sent, if both lat, long is 0 &
|
|
|
|
horReliability is not set. */
|
|
|
|
bool blank_fix = ((0 == ulpLocation.gpsLocation.latitude) &&
|
|
|
|
(0 == ulpLocation.gpsLocation.longitude) &&
|
|
|
|
(LOC_RELIABILITY_NOT_SET == locationExtended.horizontal_reliability));
|
|
|
|
uint8_t generate_nmea = (reported && status != LOC_SESS_FAILURE && !blank_fix);
|
2016-12-23 00:12:44 -05:00
|
|
|
std::vector<std::string> nmeaArraystr;
|
|
|
|
loc_nmea_generate_pos(ulpLocation, locationExtended, generate_nmea, nmeaArraystr);
|
|
|
|
for (auto sentence : nmeaArraystr) {
|
|
|
|
reportNmea(sentence.c_str(), sentence.length());
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::reportSvEvent(const GnssSvNotification& svNotify,
|
2018-03-30 20:10:59 -04:00
|
|
|
bool fromEngineHub)
|
2017-02-28 19:45:47 -05:00
|
|
|
{
|
2018-06-07 15:03:55 -04:00
|
|
|
if (!fromEngineHub) {
|
2018-01-29 04:02:06 -05:00
|
|
|
mEngHubProxy->gnssReportSv(svNotify);
|
2018-03-30 20:10:59 -04:00
|
|
|
if (true == initEngHubProxy()){
|
|
|
|
return;
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
struct MsgReportSv : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
const GnssSvNotification mSvNotify;
|
|
|
|
inline MsgReportSv(GnssAdapter& adapter,
|
|
|
|
const GnssSvNotification& svNotify) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mSvNotify(svNotify) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter.reportSv((GnssSvNotification&)mSvNotify);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgReportSv(*this, svNotify));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::reportSv(GnssSvNotification& svNotify)
|
|
|
|
{
|
2017-07-03 07:52:28 -04:00
|
|
|
int numSv = svNotify.count;
|
|
|
|
int16_t gnssSvId = 0;
|
|
|
|
uint64_t svUsedIdMask = 0;
|
|
|
|
for (int i=0; i < numSv; i++) {
|
|
|
|
svUsedIdMask = 0;
|
|
|
|
gnssSvId = svNotify.gnssSvs[i].svId;
|
|
|
|
switch (svNotify.gnssSvs[i].type) {
|
|
|
|
case GNSS_SV_TYPE_GPS:
|
|
|
|
if (mGnssSvIdUsedInPosAvail) {
|
2016-12-20 07:16:40 -05:00
|
|
|
svUsedIdMask = mGnssSvIdUsedInPosition.gps_sv_used_ids_mask;
|
2017-07-03 07:52:28 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GNSS_SV_TYPE_GLONASS:
|
|
|
|
if (mGnssSvIdUsedInPosAvail) {
|
2016-12-20 07:16:40 -05:00
|
|
|
svUsedIdMask = mGnssSvIdUsedInPosition.glo_sv_used_ids_mask;
|
2017-07-03 07:52:28 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GNSS_SV_TYPE_BEIDOU:
|
|
|
|
if (mGnssSvIdUsedInPosAvail) {
|
2016-12-20 07:16:40 -05:00
|
|
|
svUsedIdMask = mGnssSvIdUsedInPosition.bds_sv_used_ids_mask;
|
2017-07-03 07:52:28 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GNSS_SV_TYPE_GALILEO:
|
|
|
|
if (mGnssSvIdUsedInPosAvail) {
|
2016-12-20 07:16:40 -05:00
|
|
|
svUsedIdMask = mGnssSvIdUsedInPosition.gal_sv_used_ids_mask;
|
2017-07-03 07:52:28 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GNSS_SV_TYPE_QZSS:
|
|
|
|
if (mGnssSvIdUsedInPosAvail) {
|
2017-05-05 07:59:09 -04:00
|
|
|
svUsedIdMask = mGnssSvIdUsedInPosition.qzss_sv_used_ids_mask;
|
2017-07-03 07:52:28 -04:00
|
|
|
}
|
|
|
|
// QZSS SV id's need to reported as it is to framework, since
|
|
|
|
// framework expects it as it is. See GnssStatus.java.
|
|
|
|
// SV id passed to here by LocApi is 1-based.
|
|
|
|
svNotify.gnssSvs[i].svId += (QZSS_SV_PRN_MIN - 1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
svUsedIdMask = 0;
|
|
|
|
break;
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
|
2017-07-03 07:52:28 -04:00
|
|
|
// If SV ID was used in previous position fix, then set USED_IN_FIX
|
|
|
|
// flag, else clear the USED_IN_FIX flag.
|
|
|
|
if (svUsedIdMask & (1 << (gnssSvId - 1))) {
|
|
|
|
svNotify.gnssSvs[i].gnssSvOptionsMask |= GNSS_SV_OPTIONS_USED_IN_FIX_BIT;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto it=mClientData.begin(); it != mClientData.end(); ++it) {
|
|
|
|
if (nullptr != it->second.gnssSvCb) {
|
|
|
|
it->second.gnssSvCb(svNotify);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NMEA_PROVIDER_AP == ContextBase::mGps_conf.NMEA_PROVIDER && !mTrackingSessions.empty()) {
|
2016-12-23 00:12:44 -05:00
|
|
|
std::vector<std::string> nmeaArraystr;
|
|
|
|
loc_nmea_generate_sv(svNotify, nmeaArraystr);
|
|
|
|
for (auto sentence : nmeaArraystr) {
|
|
|
|
reportNmea(sentence.c_str(), sentence.length());
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
mGnssSvIdUsedInPosAvail = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-06-07 15:03:55 -04:00
|
|
|
GnssAdapter::reportNmeaEvent(const char* nmea, size_t length)
|
2017-02-28 19:45:47 -05:00
|
|
|
{
|
2018-06-07 15:03:55 -04:00
|
|
|
if (!loc_nmea_is_debug(nmea, length)) {
|
2018-04-27 16:38:36 -04:00
|
|
|
return;
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
struct MsgReportNmea : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
const char* mNmea;
|
|
|
|
size_t mLength;
|
|
|
|
inline MsgReportNmea(GnssAdapter& adapter,
|
|
|
|
const char* nmea,
|
|
|
|
size_t length) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
2017-05-04 17:43:52 -04:00
|
|
|
mNmea(new char[length+1]),
|
2017-02-28 19:45:47 -05:00
|
|
|
mLength(length) {
|
2017-09-20 04:43:05 -04:00
|
|
|
if (mNmea == nullptr) {
|
|
|
|
LOC_LOGE("%s] new allocation failed, fatal error.", __func__);
|
|
|
|
return;
|
|
|
|
}
|
2017-05-04 17:43:52 -04:00
|
|
|
strlcpy((char*)mNmea, nmea, length+1);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
inline virtual ~MsgReportNmea()
|
|
|
|
{
|
|
|
|
delete[] mNmea;
|
|
|
|
}
|
|
|
|
inline virtual void proc() const {
|
2017-03-14 14:13:23 -04:00
|
|
|
// extract bug report info - this returns true if consumed by systemstatus
|
|
|
|
bool ret = false;
|
2017-08-11 05:43:38 -04:00
|
|
|
SystemStatus* s = mAdapter.getSystemStatus();
|
2017-03-14 14:13:23 -04:00
|
|
|
if (nullptr != s) {
|
|
|
|
ret = s->setNmeaString(mNmea, mLength);
|
|
|
|
}
|
|
|
|
if (false == ret) {
|
|
|
|
// forward NMEA message to upper layer
|
|
|
|
mAdapter.reportNmea(mNmea, mLength);
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgReportNmea(*this, nmea, length));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::reportNmea(const char* nmea, size_t length)
|
|
|
|
{
|
|
|
|
GnssNmeaNotification nmeaNotification = {};
|
|
|
|
nmeaNotification.size = sizeof(GnssNmeaNotification);
|
|
|
|
|
2018-01-11 02:25:27 -05:00
|
|
|
struct timeval tv;
|
|
|
|
gettimeofday(&tv, (struct timezone *) NULL);
|
|
|
|
int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000;
|
2017-02-28 19:45:47 -05:00
|
|
|
nmeaNotification.timestamp = now;
|
|
|
|
nmeaNotification.nmea = nmea;
|
|
|
|
nmeaNotification.length = length;
|
|
|
|
|
|
|
|
for (auto it=mClientData.begin(); it != mClientData.end(); ++it) {
|
|
|
|
if (nullptr != it->second.gnssNmeaCb) {
|
|
|
|
it->second.gnssNmeaCb(nmeaNotification);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GnssAdapter::requestNiNotifyEvent(const GnssNiNotification ¬ify, const void* data)
|
|
|
|
{
|
|
|
|
LOC_LOGI("%s]: notif_type: %d, timeout: %d, default_resp: %d"
|
|
|
|
"requestor_id: %s (encoding: %d) text: %s text (encoding: %d) extras: %s",
|
|
|
|
__func__, notify.type, notify.timeout, notify.timeoutResponse,
|
|
|
|
notify.requestor, notify.requestorEncoding,
|
|
|
|
notify.message, notify.messageEncoding, notify.extras);
|
|
|
|
|
|
|
|
struct MsgReportNiNotify : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
const GnssNiNotification mNotify;
|
|
|
|
const void* mData;
|
|
|
|
inline MsgReportNiNotify(GnssAdapter& adapter,
|
|
|
|
const GnssNiNotification& notify,
|
|
|
|
const void* data) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mNotify(notify),
|
|
|
|
mData(data) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter.requestNiNotify(mNotify, mData);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgReportNiNotify(*this, notify, data));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void* niThreadProc(void *args)
|
|
|
|
{
|
|
|
|
NiSession* pSession = (NiSession*)args;
|
|
|
|
int rc = 0; /* return code from pthread calls */
|
|
|
|
|
2017-12-05 03:59:41 -05:00
|
|
|
struct timespec present_time;
|
2017-02-28 19:45:47 -05:00
|
|
|
struct timespec expire_time;
|
|
|
|
|
|
|
|
pthread_mutex_lock(&pSession->tLock);
|
|
|
|
/* Calculate absolute expire time */
|
2017-12-05 03:59:41 -05:00
|
|
|
clock_gettime(CLOCK_MONOTONIC, &present_time);
|
2017-02-28 19:45:47 -05:00
|
|
|
expire_time.tv_sec = present_time.tv_sec + pSession->respTimeLeft;
|
2017-12-05 03:59:41 -05:00
|
|
|
expire_time.tv_nsec = present_time.tv_nsec;
|
2017-02-28 19:45:47 -05:00
|
|
|
LOC_LOGD("%s]: time out set for abs time %ld with delay %d sec",
|
|
|
|
__func__, (long)expire_time.tv_sec, pSession->respTimeLeft);
|
|
|
|
|
|
|
|
while (!pSession->respRecvd) {
|
|
|
|
rc = pthread_cond_timedwait(&pSession->tCond,
|
|
|
|
&pSession->tLock,
|
|
|
|
&expire_time);
|
|
|
|
if (rc == ETIMEDOUT) {
|
|
|
|
pSession->resp = GNSS_NI_RESPONSE_NO_RESPONSE;
|
|
|
|
LOC_LOGD("%s]: time out after valting for specified time. Ret Val %d",
|
|
|
|
__func__, rc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LOC_LOGD("%s]: Java layer has sent us a user response and return value from "
|
|
|
|
"pthread_cond_timedwait = %d pSession->resp is %u", __func__, rc, pSession->resp);
|
|
|
|
pSession->respRecvd = false; /* Reset the user response flag for the next session*/
|
|
|
|
|
|
|
|
// adding this check to support modem restart, in which case, we need the thread
|
|
|
|
// to exit without calling sending data. We made sure that rawRequest is NULL in
|
|
|
|
// loc_eng_ni_reset_on_engine_restart()
|
|
|
|
GnssAdapter* adapter = pSession->adapter;
|
|
|
|
GnssNiResponse resp;
|
|
|
|
void* rawRequest = NULL;
|
|
|
|
bool sendResponse = false;
|
|
|
|
|
|
|
|
if (NULL != pSession->rawRequest) {
|
|
|
|
if (pSession->resp != GNSS_NI_RESPONSE_IGNORE) {
|
|
|
|
resp = pSession->resp;
|
|
|
|
rawRequest = pSession->rawRequest;
|
|
|
|
sendResponse = true;
|
|
|
|
} else {
|
|
|
|
free(pSession->rawRequest);
|
|
|
|
}
|
|
|
|
pSession->rawRequest = NULL;
|
|
|
|
}
|
|
|
|
pthread_mutex_unlock(&pSession->tLock);
|
|
|
|
|
|
|
|
pSession->respTimeLeft = 0;
|
|
|
|
pSession->reqID = 0;
|
|
|
|
|
|
|
|
if (sendResponse) {
|
|
|
|
adapter->gnssNiResponseCommand(resp, rawRequest);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GnssAdapter::requestNiNotify(const GnssNiNotification& notify, const void* data)
|
|
|
|
{
|
|
|
|
NiSession* pSession = NULL;
|
|
|
|
gnssNiCallback gnssNiCb = nullptr;
|
|
|
|
|
|
|
|
for (auto it=mClientData.begin(); it != mClientData.end(); ++it) {
|
|
|
|
if (nullptr != it->second.gnssNiCb) {
|
|
|
|
gnssNiCb = it->second.gnssNiCb;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nullptr == gnssNiCb) {
|
|
|
|
EXIT_LOG(%s, "no clients with gnssNiCb.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (notify.type == GNSS_NI_TYPE_EMERGENCY_SUPL) {
|
|
|
|
if (NULL != mNiData.sessionEs.rawRequest) {
|
|
|
|
LOC_LOGI("%s]: supl es NI in progress, new supl es NI ignored, type: %d",
|
|
|
|
__func__, notify.type);
|
|
|
|
if (NULL != data) {
|
|
|
|
free((void*)data);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pSession = &mNiData.sessionEs;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (NULL != mNiData.session.rawRequest ||
|
|
|
|
NULL != mNiData.sessionEs.rawRequest) {
|
|
|
|
LOC_LOGI("%s]: supl NI in progress, new supl NI ignored, type: %d",
|
|
|
|
__func__, notify.type);
|
|
|
|
if (NULL != data) {
|
|
|
|
free((void*)data);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pSession = &mNiData.session;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pSession) {
|
|
|
|
/* Save request */
|
|
|
|
pSession->rawRequest = (void*)data;
|
|
|
|
pSession->reqID = ++mNiData.reqIDCounter;
|
|
|
|
pSession->adapter = this;
|
|
|
|
|
|
|
|
int sessionId = pSession->reqID;
|
|
|
|
|
|
|
|
/* For robustness, spawn a thread at this point to timeout to clear up the notification
|
|
|
|
* status, even though the OEM layer in java does not do so.
|
|
|
|
**/
|
|
|
|
pSession->respTimeLeft =
|
|
|
|
5 + (notify.timeout != 0 ? notify.timeout : LOC_NI_NO_RESPONSE_TIME);
|
|
|
|
|
|
|
|
int rc = 0;
|
|
|
|
rc = pthread_create(&pSession->thread, NULL, niThreadProc, pSession);
|
|
|
|
if (rc) {
|
|
|
|
LOC_LOGE("%s]: Loc NI thread is not created.", __func__);
|
|
|
|
}
|
|
|
|
rc = pthread_detach(pSession->thread);
|
|
|
|
if (rc) {
|
|
|
|
LOC_LOGE("%s]: Loc NI thread is not detached.", __func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nullptr != gnssNiCb) {
|
|
|
|
gnssNiCb(sessionId, notify);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-08-09 21:40:51 -04:00
|
|
|
GnssAdapter::reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurements,
|
|
|
|
int msInWeek)
|
2017-02-28 19:45:47 -05:00
|
|
|
{
|
2018-06-25 17:36:06 -04:00
|
|
|
LOC_LOGD("%s]: msInWeek=%d", __func__, msInWeek);
|
2017-02-28 19:45:47 -05:00
|
|
|
|
|
|
|
struct MsgReportGnssMeasurementData : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
2017-08-09 21:40:51 -04:00
|
|
|
GnssMeasurementsNotification mMeasurementsNotify;
|
2017-02-28 19:45:47 -05:00
|
|
|
inline MsgReportGnssMeasurementData(GnssAdapter& adapter,
|
2017-08-09 21:40:51 -04:00
|
|
|
const GnssMeasurementsNotification& measurements,
|
|
|
|
int msInWeek) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mMeasurementsNotify(measurements) {
|
|
|
|
if (-1 != msInWeek) {
|
2017-08-11 05:43:38 -04:00
|
|
|
mAdapter.getAgcInformation(mMeasurementsNotify, msInWeek);
|
2017-08-09 21:40:51 -04:00
|
|
|
}
|
|
|
|
}
|
2017-02-28 19:45:47 -05:00
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter.reportGnssMeasurementData(mMeasurementsNotify);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-08-09 21:40:51 -04:00
|
|
|
sendMsg(new MsgReportGnssMeasurementData(*this, measurements, msInWeek));
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-08-09 21:40:51 -04:00
|
|
|
GnssAdapter::reportGnssMeasurementData(const GnssMeasurementsNotification& measurements)
|
2017-02-28 19:45:47 -05:00
|
|
|
{
|
|
|
|
for (auto it=mClientData.begin(); it != mClientData.end(); ++it) {
|
|
|
|
if (nullptr != it->second.gnssMeasurementsCb) {
|
2017-08-09 21:40:51 -04:00
|
|
|
it->second.gnssMeasurementsCb(measurements);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: ", __func__);
|
2018-01-29 04:02:06 -05:00
|
|
|
mEngHubProxy->gnssReportSvMeasurement(svMeasurementSet);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GnssAdapter::reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: ", __func__);
|
2018-01-29 04:02:06 -05:00
|
|
|
mEngHubProxy->gnssReportSvPolynomial(svPolynomial);
|
2017-02-28 19:45:47 -05:00
|
|
|
}
|
|
|
|
|
2018-04-08 14:05:14 -04:00
|
|
|
bool
|
|
|
|
GnssAdapter::requestOdcpiEvent(OdcpiRequestInfo& request)
|
|
|
|
{
|
|
|
|
LOC_LOGd("ODCPI request: type %d, tbf %d, isEmergency %d", request.type,
|
|
|
|
request.tbfMillis, request.isEmergencyMode);
|
|
|
|
|
|
|
|
struct MsgRequestOdcpi : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
OdcpiRequestInfo mOdcpiRequest;
|
|
|
|
inline MsgRequestOdcpi(GnssAdapter& adapter, OdcpiRequestInfo& request) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mOdcpiRequest(request) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter.requestOdcpi(mOdcpiRequest);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgRequestOdcpi(*this, request));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::requestOdcpi(const OdcpiRequestInfo& request)
|
|
|
|
{
|
|
|
|
if (nullptr != mOdcpiRequestCb) {
|
|
|
|
mOdcpiInjectedPositionCount = 0;
|
|
|
|
if (ODCPI_REQUEST_TYPE_START == request.type) {
|
|
|
|
mOdcpiRequestCb(request);
|
|
|
|
mOdcpiRequestActive = true;
|
|
|
|
} else {
|
|
|
|
mOdcpiRequestActive = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
LOC_LOGe("ODCPI request not supported");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::initOdcpiCommand(const OdcpiRequestCallback& callback)
|
|
|
|
{
|
|
|
|
struct MsgInitOdcpi : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
OdcpiRequestCallback mOdcpiCb;
|
|
|
|
inline MsgInitOdcpi(GnssAdapter& adapter,
|
|
|
|
const OdcpiRequestCallback& callback) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mOdcpiCb(callback) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter.initOdcpi(mOdcpiCb);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgInitOdcpi(*this, callback));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::initOdcpi(const OdcpiRequestCallback& callback)
|
|
|
|
{
|
|
|
|
mOdcpiRequestCb = callback;
|
|
|
|
|
|
|
|
/* Register for WIFI request */
|
|
|
|
updateEvtMask(LOC_API_ADAPTER_BIT_REQUEST_WIFI,
|
|
|
|
LOC_REGISTRATION_MASK_ENABLED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::injectOdcpiCommand(const Location& location)
|
|
|
|
{
|
|
|
|
struct MsgInjectOdcpi : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
Location mLocation;
|
|
|
|
inline MsgInjectOdcpi(GnssAdapter& adapter, const Location& location) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter),
|
|
|
|
mLocation(location) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter.injectOdcpi(mLocation);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgInjectOdcpi(*this, location));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::injectOdcpi(const Location& location)
|
|
|
|
{
|
|
|
|
mLocApi->injectPosition(location, true);
|
|
|
|
if (mOdcpiRequestActive) {
|
|
|
|
mOdcpiInjectedPositionCount++;
|
|
|
|
if (mOdcpiInjectedPositionCount >=
|
|
|
|
ODCPI_INJECTED_POSITION_COUNT_PER_REQUEST) {
|
|
|
|
mOdcpiRequestActive = false;
|
|
|
|
mOdcpiInjectedPositionCount = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-29 05:49:40 -04:00
|
|
|
void GnssAdapter::initDefaultAgps() {
|
|
|
|
LOC_LOGD("%s]: ", __func__);
|
|
|
|
|
|
|
|
void *handle = nullptr;
|
|
|
|
if ((handle = dlopen("libloc_net_iface.so", RTLD_NOW)) == nullptr) {
|
2017-09-18 19:12:46 -04:00
|
|
|
LOC_LOGD("%s]: libloc_net_iface.so not found !", __func__);
|
2017-08-29 05:49:40 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LocAgpsGetAgpsCbInfo getAgpsCbInfo = (LocAgpsGetAgpsCbInfo)
|
|
|
|
dlsym(handle, "LocNetIfaceAgps_getAgpsCbInfo");
|
|
|
|
if (getAgpsCbInfo == nullptr) {
|
|
|
|
LOC_LOGE("%s]: Failed to get method LocNetIfaceAgps_getStatusCb", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
AgpsCbInfo& cbInfo = getAgpsCbInfo(agpsOpenResultCb, agpsCloseResultCb, this);
|
|
|
|
|
|
|
|
if (cbInfo.statusV4Cb == nullptr) {
|
|
|
|
LOC_LOGE("%s]: statusV4Cb is nullptr!", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-18 19:12:46 -04:00
|
|
|
initAgps(cbInfo);
|
2017-08-29 05:49:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::initDefaultAgpsCommand() {
|
|
|
|
LOC_LOGD("%s]: ", __func__);
|
|
|
|
|
|
|
|
struct MsgInitDefaultAgps : public LocMsg {
|
|
|
|
GnssAdapter& mAdapter;
|
|
|
|
inline MsgInitDefaultAgps(GnssAdapter& adapter) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter) {
|
|
|
|
}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter.initDefaultAgps();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgInitDefaultAgps(*this));
|
|
|
|
}
|
|
|
|
|
2017-02-02 14:16:48 -05:00
|
|
|
/* INIT LOC AGPS MANAGER */
|
|
|
|
|
2017-09-18 19:12:46 -04:00
|
|
|
void GnssAdapter::initAgps(const AgpsCbInfo& cbInfo) {
|
|
|
|
LOC_LOGD("%s]: mAgpsCbInfo.cbPriority - %d; cbInfo.cbPriority - %d",
|
|
|
|
__func__, mAgpsCbInfo.cbPriority, cbInfo.cbPriority)
|
2017-02-02 14:16:48 -05:00
|
|
|
|
2017-09-18 19:12:46 -04:00
|
|
|
if (!((ContextBase::mGps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSB) ||
|
|
|
|
(ContextBase::mGps_conf.CAPABILITIES & LOC_GPS_CAPABILITY_MSA))) {
|
|
|
|
return;
|
|
|
|
}
|
2017-02-02 14:16:48 -05:00
|
|
|
|
2017-09-18 19:12:46 -04:00
|
|
|
if (mAgpsCbInfo.cbPriority > cbInfo.cbPriority) {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
mAgpsCbInfo = cbInfo;
|
2017-02-02 14:16:48 -05:00
|
|
|
|
2017-09-18 19:12:46 -04:00
|
|
|
mAgpsManager.registerFrameworkStatusCallback((AgnssStatusIpV4Cb)cbInfo.statusV4Cb);
|
2017-02-02 14:16:48 -05:00
|
|
|
|
2017-09-18 19:12:46 -04:00
|
|
|
mAgpsManager.createAgpsStateMachines();
|
2017-02-02 14:16:48 -05:00
|
|
|
|
2017-09-18 19:12:46 -04:00
|
|
|
/* Register for AGPS event mask */
|
|
|
|
updateEvtMask(LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST,
|
|
|
|
LOC_REGISTRATION_MASK_ENABLED);
|
|
|
|
}
|
|
|
|
}
|
2017-02-02 14:16:48 -05:00
|
|
|
|
2017-09-18 19:12:46 -04:00
|
|
|
void GnssAdapter::initAgpsCommand(const AgpsCbInfo& cbInfo){
|
|
|
|
LOC_LOGI("GnssAdapter::initAgpsCommand");
|
2017-02-02 14:16:48 -05:00
|
|
|
|
|
|
|
/* Message to initialize AGPS module */
|
|
|
|
struct AgpsMsgInit: public LocMsg {
|
2017-10-09 14:42:11 -04:00
|
|
|
const AgpsCbInfo mCbInfo;
|
2017-04-28 19:26:40 -04:00
|
|
|
GnssAdapter& mAdapter;
|
2017-02-02 14:16:48 -05:00
|
|
|
|
2017-09-18 19:12:46 -04:00
|
|
|
inline AgpsMsgInit(const AgpsCbInfo& cbInfo,
|
2017-04-28 19:26:40 -04:00
|
|
|
GnssAdapter& adapter) :
|
2017-09-18 19:12:46 -04:00
|
|
|
LocMsg(), mCbInfo(cbInfo), mAdapter(adapter) {
|
2017-02-02 14:16:48 -05:00
|
|
|
LOC_LOGV("AgpsMsgInit");
|
|
|
|
}
|
|
|
|
|
|
|
|
inline virtual void proc() const {
|
|
|
|
LOC_LOGV("AgpsMsgInit::proc()");
|
2017-09-18 19:12:46 -04:00
|
|
|
mAdapter.initAgps(mCbInfo);
|
2017-02-02 14:16:48 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Send message to initialize AGPS Manager */
|
2017-09-18 19:12:46 -04:00
|
|
|
sendMsg(new AgpsMsgInit(cbInfo, *this));
|
2017-02-02 14:16:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* GnssAdapter::requestATL
|
|
|
|
* Method triggered in QMI thread as part of handling below message:
|
|
|
|
* eQMI_LOC_SERVER_REQUEST_OPEN_V02
|
|
|
|
* Triggers the AGPS state machine to setup AGPS call for below WWAN types:
|
|
|
|
* eQMI_LOC_WWAN_TYPE_INTERNET_V02
|
2018-03-13 13:11:02 -04:00
|
|
|
* eQMI_LOC_WWAN_TYPE_AGNSS_V02
|
2017-02-02 14:16:48 -05:00
|
|
|
* eQMI_LOC_WWAN_TYPE_AGNSS_EMERGENCY_V02 */
|
2018-03-13 13:11:02 -04:00
|
|
|
bool GnssAdapter::requestATL(int connHandle, LocAGpsType agpsType,
|
|
|
|
LocApnTypeMask apnTypeMask){
|
2017-02-02 14:16:48 -05:00
|
|
|
|
2018-03-13 13:11:02 -04:00
|
|
|
LOC_LOGI("GnssAdapter::requestATL handle=%d agpsType=0x%X apnTypeMask=0x%X",
|
|
|
|
connHandle, agpsType, apnTypeMask);
|
2017-02-02 14:16:48 -05:00
|
|
|
|
|
|
|
sendMsg( new AgpsMsgRequestATL(
|
2018-03-13 13:11:02 -04:00
|
|
|
&mAgpsManager, connHandle, (AGpsExtType)agpsType,
|
|
|
|
apnTypeMask));
|
2017-02-02 14:16:48 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* GnssAdapter::releaseATL
|
|
|
|
* Method triggered in QMI thread as part of handling below message:
|
|
|
|
* eQMI_LOC_SERVER_REQUEST_CLOSE_V02
|
|
|
|
* Triggers teardown of an existing AGPS call */
|
|
|
|
bool GnssAdapter::releaseATL(int connHandle){
|
|
|
|
|
|
|
|
LOC_LOGI("GnssAdapter::releaseATL");
|
|
|
|
|
|
|
|
/* Release SUPL/INTERNET/SUPL_ES ATL */
|
|
|
|
struct AgpsMsgReleaseATL: public LocMsg {
|
|
|
|
|
|
|
|
AgpsManager* mAgpsManager;
|
|
|
|
int mConnHandle;
|
|
|
|
|
|
|
|
inline AgpsMsgReleaseATL(AgpsManager* agpsManager, int connHandle) :
|
|
|
|
LocMsg(), mAgpsManager(agpsManager), mConnHandle(connHandle) {
|
|
|
|
|
|
|
|
LOC_LOGV("AgpsMsgReleaseATL");
|
|
|
|
}
|
|
|
|
|
|
|
|
inline virtual void proc() const {
|
|
|
|
|
|
|
|
LOC_LOGV("AgpsMsgReleaseATL::proc()");
|
|
|
|
mAgpsManager->releaseATL(mConnHandle);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg( new AgpsMsgReleaseATL(&mAgpsManager, connHandle));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::dataConnOpenCommand(
|
|
|
|
AGpsExtType agpsType,
|
2017-08-29 05:49:40 -04:00
|
|
|
const char* apnName, int apnLen, AGpsBearerType bearerType){
|
2017-02-02 14:16:48 -05:00
|
|
|
|
|
|
|
LOC_LOGI("GnssAdapter::frameworkDataConnOpen");
|
|
|
|
|
|
|
|
struct AgpsMsgAtlOpenSuccess: public LocMsg {
|
|
|
|
|
|
|
|
AgpsManager* mAgpsManager;
|
|
|
|
AGpsExtType mAgpsType;
|
|
|
|
char* mApnName;
|
|
|
|
int mApnLen;
|
2017-08-29 05:49:40 -04:00
|
|
|
AGpsBearerType mBearerType;
|
2017-02-02 14:16:48 -05:00
|
|
|
|
|
|
|
inline AgpsMsgAtlOpenSuccess(AgpsManager* agpsManager, AGpsExtType agpsType,
|
2017-08-29 05:49:40 -04:00
|
|
|
const char* apnName, int apnLen, AGpsBearerType bearerType) :
|
2017-02-02 14:16:48 -05:00
|
|
|
LocMsg(), mAgpsManager(agpsManager), mAgpsType(agpsType), mApnName(
|
2017-08-29 05:49:40 -04:00
|
|
|
new char[apnLen + 1]), mApnLen(apnLen), mBearerType(bearerType) {
|
2017-02-02 14:16:48 -05:00
|
|
|
|
|
|
|
LOC_LOGV("AgpsMsgAtlOpenSuccess");
|
2017-09-20 04:43:05 -04:00
|
|
|
if (mApnName == nullptr) {
|
|
|
|
LOC_LOGE("%s] new allocation failed, fatal error.", __func__);
|
|
|
|
return;
|
|
|
|
}
|
2017-02-02 14:16:48 -05:00
|
|
|
memcpy(mApnName, apnName, apnLen);
|
|
|
|
mApnName[apnLen] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ~AgpsMsgAtlOpenSuccess() {
|
|
|
|
delete[] mApnName;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline virtual void proc() const {
|
|
|
|
|
|
|
|
LOC_LOGV("AgpsMsgAtlOpenSuccess::proc()");
|
2017-08-29 05:49:40 -04:00
|
|
|
mAgpsManager->reportAtlOpenSuccess(mAgpsType, mApnName, mApnLen, mBearerType);
|
2017-02-02 14:16:48 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg( new AgpsMsgAtlOpenSuccess(
|
2017-08-29 05:49:40 -04:00
|
|
|
&mAgpsManager, agpsType, apnName, apnLen, bearerType));
|
2017-02-02 14:16:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::dataConnClosedCommand(AGpsExtType agpsType){
|
|
|
|
|
|
|
|
LOC_LOGI("GnssAdapter::frameworkDataConnClosed");
|
|
|
|
|
|
|
|
struct AgpsMsgAtlClosed: public LocMsg {
|
|
|
|
|
|
|
|
AgpsManager* mAgpsManager;
|
|
|
|
AGpsExtType mAgpsType;
|
|
|
|
|
|
|
|
inline AgpsMsgAtlClosed(AgpsManager* agpsManager, AGpsExtType agpsType) :
|
|
|
|
LocMsg(), mAgpsManager(agpsManager), mAgpsType(agpsType) {
|
|
|
|
|
|
|
|
LOC_LOGV("AgpsMsgAtlClosed");
|
|
|
|
}
|
|
|
|
|
|
|
|
inline virtual void proc() const {
|
|
|
|
|
|
|
|
LOC_LOGV("AgpsMsgAtlClosed::proc()");
|
|
|
|
mAgpsManager->reportAtlClosed(mAgpsType);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg( new AgpsMsgAtlClosed(&mAgpsManager, (AGpsExtType)agpsType));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GnssAdapter::dataConnFailedCommand(AGpsExtType agpsType){
|
|
|
|
|
|
|
|
LOC_LOGI("GnssAdapter::frameworkDataConnFailed");
|
|
|
|
|
|
|
|
struct AgpsMsgAtlOpenFailed: public LocMsg {
|
|
|
|
|
|
|
|
AgpsManager* mAgpsManager;
|
|
|
|
AGpsExtType mAgpsType;
|
|
|
|
|
|
|
|
inline AgpsMsgAtlOpenFailed(AgpsManager* agpsManager, AGpsExtType agpsType) :
|
|
|
|
LocMsg(), mAgpsManager(agpsManager), mAgpsType(agpsType) {
|
|
|
|
|
|
|
|
LOC_LOGV("AgpsMsgAtlOpenFailed");
|
|
|
|
}
|
|
|
|
|
|
|
|
inline virtual void proc() const {
|
|
|
|
|
|
|
|
LOC_LOGV("AgpsMsgAtlOpenFailed::proc()");
|
|
|
|
mAgpsManager->reportAtlOpenFailed(mAgpsType);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg( new AgpsMsgAtlOpenFailed(&mAgpsManager, (AGpsExtType)agpsType));
|
|
|
|
}
|
2017-03-21 20:16:49 -04:00
|
|
|
|
|
|
|
void GnssAdapter::convertSatelliteInfo(std::vector<GnssDebugSatelliteInfo>& out,
|
2017-04-27 16:46:09 -04:00
|
|
|
const GnssSvType& in_constellation,
|
|
|
|
const SystemStatusReports& in)
|
2017-03-21 20:16:49 -04:00
|
|
|
{
|
2017-04-27 16:46:09 -04:00
|
|
|
uint64_t sv_mask = 0ULL;
|
2017-03-21 20:16:49 -04:00
|
|
|
uint32_t svid_min = 0;
|
2017-04-27 16:46:09 -04:00
|
|
|
uint32_t svid_num = 0;
|
|
|
|
uint32_t svid_idx = 0;
|
2017-03-21 20:16:49 -04:00
|
|
|
|
2017-04-27 16:46:09 -04:00
|
|
|
uint64_t eph_health_good_mask = 0ULL;
|
|
|
|
uint64_t eph_health_bad_mask = 0ULL;
|
|
|
|
uint64_t server_perdiction_available_mask = 0ULL;
|
|
|
|
float server_perdiction_age = 0.0f;
|
|
|
|
|
|
|
|
// set constellationi based parameters
|
2017-03-21 20:16:49 -04:00
|
|
|
switch (in_constellation) {
|
|
|
|
case GNSS_SV_TYPE_GPS:
|
2017-05-18 14:00:17 -04:00
|
|
|
svid_min = GNSS_BUGREPORT_GPS_MIN;
|
2017-04-27 16:46:09 -04:00
|
|
|
svid_num = GPS_NUM;
|
|
|
|
svid_idx = 0;
|
|
|
|
if (!in.mSvHealth.empty()) {
|
|
|
|
eph_health_good_mask = in.mSvHealth.back().mGpsGoodMask;
|
|
|
|
eph_health_bad_mask = in.mSvHealth.back().mGpsBadMask;
|
|
|
|
}
|
|
|
|
if (!in.mXtra.empty()) {
|
|
|
|
server_perdiction_available_mask = in.mXtra.back().mGpsXtraValid;
|
|
|
|
server_perdiction_age = (float)(in.mXtra.back().mGpsXtraAge);
|
|
|
|
}
|
2017-03-21 20:16:49 -04:00
|
|
|
break;
|
|
|
|
case GNSS_SV_TYPE_GLONASS:
|
2017-05-18 14:00:17 -04:00
|
|
|
svid_min = GNSS_BUGREPORT_GLO_MIN;
|
2017-04-27 16:46:09 -04:00
|
|
|
svid_num = GLO_NUM;
|
|
|
|
svid_idx = GPS_NUM;
|
|
|
|
if (!in.mSvHealth.empty()) {
|
|
|
|
eph_health_good_mask = in.mSvHealth.back().mGloGoodMask;
|
|
|
|
eph_health_bad_mask = in.mSvHealth.back().mGloBadMask;
|
|
|
|
}
|
|
|
|
if (!in.mXtra.empty()) {
|
|
|
|
server_perdiction_available_mask = in.mXtra.back().mGloXtraValid;
|
|
|
|
server_perdiction_age = (float)(in.mXtra.back().mGloXtraAge);
|
|
|
|
}
|
2017-03-21 20:16:49 -04:00
|
|
|
break;
|
|
|
|
case GNSS_SV_TYPE_QZSS:
|
2017-05-18 14:00:17 -04:00
|
|
|
svid_min = GNSS_BUGREPORT_QZSS_MIN;
|
2017-04-27 16:46:09 -04:00
|
|
|
svid_num = QZSS_NUM;
|
2017-07-07 18:00:10 -04:00
|
|
|
svid_idx = GPS_NUM+GLO_NUM+BDS_NUM+GAL_NUM;
|
2017-04-27 16:46:09 -04:00
|
|
|
if (!in.mSvHealth.empty()) {
|
|
|
|
eph_health_good_mask = in.mSvHealth.back().mQzssGoodMask;
|
|
|
|
eph_health_bad_mask = in.mSvHealth.back().mQzssBadMask;
|
|
|
|
}
|
|
|
|
if (!in.mXtra.empty()) {
|
|
|
|
server_perdiction_available_mask = in.mXtra.back().mQzssXtraValid;
|
|
|
|
server_perdiction_age = (float)(in.mXtra.back().mQzssXtraAge);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GNSS_SV_TYPE_BEIDOU:
|
2017-05-18 14:00:17 -04:00
|
|
|
svid_min = GNSS_BUGREPORT_BDS_MIN;
|
2017-04-27 16:46:09 -04:00
|
|
|
svid_num = BDS_NUM;
|
2017-07-07 18:00:10 -04:00
|
|
|
svid_idx = GPS_NUM+GLO_NUM;
|
2017-04-27 16:46:09 -04:00
|
|
|
if (!in.mSvHealth.empty()) {
|
|
|
|
eph_health_good_mask = in.mSvHealth.back().mBdsGoodMask;
|
|
|
|
eph_health_bad_mask = in.mSvHealth.back().mBdsBadMask;
|
|
|
|
}
|
|
|
|
if (!in.mXtra.empty()) {
|
|
|
|
server_perdiction_available_mask = in.mXtra.back().mBdsXtraValid;
|
|
|
|
server_perdiction_age = (float)(in.mXtra.back().mBdsXtraAge);
|
|
|
|
}
|
2017-03-21 20:16:49 -04:00
|
|
|
break;
|
|
|
|
case GNSS_SV_TYPE_GALILEO:
|
2017-05-18 14:00:17 -04:00
|
|
|
svid_min = GNSS_BUGREPORT_GAL_MIN;
|
2017-04-27 16:46:09 -04:00
|
|
|
svid_num = GAL_NUM;
|
2017-07-07 18:00:10 -04:00
|
|
|
svid_idx = GPS_NUM+GLO_NUM+BDS_NUM;
|
2017-04-27 16:46:09 -04:00
|
|
|
if (!in.mSvHealth.empty()) {
|
|
|
|
eph_health_good_mask = in.mSvHealth.back().mGalGoodMask;
|
|
|
|
eph_health_bad_mask = in.mSvHealth.back().mGalBadMask;
|
|
|
|
}
|
|
|
|
if (!in.mXtra.empty()) {
|
|
|
|
server_perdiction_available_mask = in.mXtra.back().mGalXtraValid;
|
|
|
|
server_perdiction_age = (float)(in.mXtra.back().mGalXtraAge);
|
|
|
|
}
|
2017-03-21 20:16:49 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-27 16:46:09 -04:00
|
|
|
// extract each sv info from systemstatus report
|
2017-07-03 07:37:37 -04:00
|
|
|
for(uint32_t i=0; i<svid_num && (svid_idx+i)<SV_ALL_NUM; i++) {
|
2017-04-27 16:46:09 -04:00
|
|
|
|
|
|
|
GnssDebugSatelliteInfo s = {};
|
|
|
|
s.size = sizeof(s);
|
|
|
|
s.svid = i + svid_min;
|
|
|
|
s.constellation = in_constellation;
|
|
|
|
|
|
|
|
if (!in.mNavData.empty()) {
|
|
|
|
s.mEphemerisType = in.mNavData.back().mNav[svid_idx+i].mType;
|
|
|
|
s.mEphemerisSource = in.mNavData.back().mNav[svid_idx+i].mSource;
|
2017-03-21 20:16:49 -04:00
|
|
|
}
|
|
|
|
else {
|
2017-04-27 16:46:09 -04:00
|
|
|
s.mEphemerisType = GNSS_EPH_TYPE_UNKNOWN;
|
|
|
|
s.mEphemerisSource = GNSS_EPH_SOURCE_UNKNOWN;
|
2017-03-21 20:16:49 -04:00
|
|
|
}
|
|
|
|
|
2017-04-27 16:46:09 -04:00
|
|
|
sv_mask = 0x1ULL << i;
|
|
|
|
if (eph_health_good_mask & sv_mask) {
|
|
|
|
s.mEphemerisHealth = GNSS_EPH_HEALTH_GOOD;
|
|
|
|
}
|
|
|
|
else if (eph_health_bad_mask & sv_mask) {
|
|
|
|
s.mEphemerisHealth = GNSS_EPH_HEALTH_BAD;
|
2017-03-21 20:16:49 -04:00
|
|
|
}
|
2017-04-27 16:46:09 -04:00
|
|
|
else {
|
|
|
|
s.mEphemerisHealth = GNSS_EPH_HEALTH_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!in.mNavData.empty()) {
|
|
|
|
s.ephemerisAgeSeconds =
|
|
|
|
(float)(in.mNavData.back().mNav[svid_idx+i].mAgeSec);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
s.ephemerisAgeSeconds = 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (server_perdiction_available_mask & sv_mask) {
|
|
|
|
s.serverPredictionIsAvailable = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
s.serverPredictionIsAvailable = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
s.serverPredictionAgeSeconds = server_perdiction_age;
|
|
|
|
out.push_back(s);
|
2017-03-21 20:16:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GnssAdapter::getDebugReport(GnssDebugReport& r)
|
|
|
|
{
|
|
|
|
LOC_LOGD("%s]: ", __func__);
|
|
|
|
|
2017-08-11 05:43:38 -04:00
|
|
|
SystemStatus* systemstatus = getSystemStatus();
|
2017-03-21 20:16:49 -04:00
|
|
|
if (nullptr == systemstatus) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SystemStatusReports reports = {};
|
|
|
|
systemstatus->getReport(reports, true);
|
|
|
|
|
|
|
|
r.size = sizeof(r);
|
|
|
|
|
|
|
|
// location block
|
2017-04-27 16:46:09 -04:00
|
|
|
r.mLocation.size = sizeof(r.mLocation);
|
2017-06-06 13:04:43 -04:00
|
|
|
if(!reports.mLocation.empty() && reports.mLocation.back().mValid) {
|
2017-04-27 16:46:09 -04:00
|
|
|
r.mLocation.mValid = true;
|
|
|
|
r.mLocation.mLocation.latitude =
|
|
|
|
reports.mLocation.back().mLocation.gpsLocation.latitude;
|
|
|
|
r.mLocation.mLocation.longitude =
|
|
|
|
reports.mLocation.back().mLocation.gpsLocation.longitude;
|
|
|
|
r.mLocation.mLocation.altitude =
|
|
|
|
reports.mLocation.back().mLocation.gpsLocation.altitude;
|
|
|
|
r.mLocation.mLocation.speed =
|
|
|
|
(double)(reports.mLocation.back().mLocation.gpsLocation.speed);
|
|
|
|
r.mLocation.mLocation.bearing =
|
|
|
|
(double)(reports.mLocation.back().mLocation.gpsLocation.bearing);
|
|
|
|
r.mLocation.mLocation.accuracy =
|
|
|
|
(double)(reports.mLocation.back().mLocation.gpsLocation.accuracy);
|
|
|
|
|
|
|
|
r.mLocation.verticalAccuracyMeters =
|
|
|
|
reports.mLocation.back().mLocationEx.vert_unc;
|
|
|
|
r.mLocation.speedAccuracyMetersPerSecond =
|
|
|
|
reports.mLocation.back().mLocationEx.speed_unc;
|
|
|
|
r.mLocation.bearingAccuracyDegrees =
|
|
|
|
reports.mLocation.back().mLocationEx.bearing_unc;
|
|
|
|
|
2017-05-18 14:00:17 -04:00
|
|
|
r.mLocation.mUtcReported =
|
|
|
|
reports.mLocation.back().mUtcReported;
|
2017-03-21 20:16:49 -04:00
|
|
|
}
|
2017-06-06 13:04:43 -04:00
|
|
|
else if(!reports.mBestPosition.empty() && reports.mBestPosition.back().mValid) {
|
2017-04-27 16:46:09 -04:00
|
|
|
r.mLocation.mValid = true;
|
2017-08-22 13:56:00 -04:00
|
|
|
r.mLocation.mLocation.latitude =
|
|
|
|
(double)(reports.mBestPosition.back().mBestLat) * RAD2DEG;
|
2017-04-27 16:46:09 -04:00
|
|
|
r.mLocation.mLocation.longitude =
|
2017-08-22 13:56:00 -04:00
|
|
|
(double)(reports.mBestPosition.back().mBestLon) * RAD2DEG;
|
|
|
|
r.mLocation.mLocation.altitude = reports.mBestPosition.back().mBestAlt;
|
2018-01-08 03:21:29 -05:00
|
|
|
r.mLocation.mLocation.accuracy =
|
|
|
|
(double)(reports.mBestPosition.back().mBestHepe);
|
|
|
|
|
2017-08-22 13:56:00 -04:00
|
|
|
r.mLocation.mUtcReported = reports.mBestPosition.back().mUtcReported;
|
2017-04-27 16:46:09 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
r.mLocation.mValid = false;
|
2017-03-21 20:16:49 -04:00
|
|
|
}
|
|
|
|
|
2017-04-27 16:46:09 -04:00
|
|
|
if (r.mLocation.mValid) {
|
|
|
|
LOC_LOGV("getDebugReport - lat=%f lon=%f alt=%f speed=%f",
|
|
|
|
r.mLocation.mLocation.latitude,
|
|
|
|
r.mLocation.mLocation.longitude,
|
|
|
|
r.mLocation.mLocation.altitude,
|
|
|
|
r.mLocation.mLocation.speed);
|
2017-04-12 17:04:29 -04:00
|
|
|
}
|
2017-04-27 16:46:09 -04:00
|
|
|
|
|
|
|
// time block
|
|
|
|
r.mTime.size = sizeof(r.mTime);
|
2017-05-18 14:00:17 -04:00
|
|
|
if(!reports.mTimeAndClock.empty() && reports.mTimeAndClock.back().mTimeValid) {
|
2017-04-27 16:46:09 -04:00
|
|
|
r.mTime.mValid = true;
|
|
|
|
r.mTime.timeEstimate =
|
|
|
|
(((int64_t)(reports.mTimeAndClock.back().mGpsWeek)*7 +
|
2017-05-18 14:00:17 -04:00
|
|
|
GNSS_UTC_TIME_OFFSET)*24*60*60 -
|
2017-04-27 16:46:09 -04:00
|
|
|
(int64_t)(reports.mTimeAndClock.back().mLeapSeconds))*1000ULL +
|
|
|
|
(int64_t)(reports.mTimeAndClock.back().mGpsTowMs);
|
|
|
|
|
|
|
|
r.mTime.timeUncertaintyNs =
|
2017-12-12 19:58:55 -05:00
|
|
|
((float)(reports.mTimeAndClock.back().mTimeUnc) +
|
|
|
|
(float)(reports.mTimeAndClock.back().mLeapSecUnc))*1000.0f;
|
2017-04-27 16:46:09 -04:00
|
|
|
r.mTime.frequencyUncertaintyNsPerSec =
|
|
|
|
(float)(reports.mTimeAndClock.back().mClockFreqBiasUnc);
|
2017-07-03 09:00:31 -04:00
|
|
|
LOC_LOGV("getDebugReport - timeestimate=%" PRIu64 " unc=%f frequnc=%f",
|
2017-05-18 14:00:17 -04:00
|
|
|
r.mTime.timeEstimate,
|
|
|
|
r.mTime.timeUncertaintyNs, r.mTime.frequencyUncertaintyNsPerSec);
|
2017-04-27 16:46:09 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
r.mTime.mValid = false;
|
2017-03-21 20:16:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// satellite info block
|
|
|
|
convertSatelliteInfo(r.mSatelliteInfo, GNSS_SV_TYPE_GPS, reports);
|
|
|
|
convertSatelliteInfo(r.mSatelliteInfo, GNSS_SV_TYPE_GLONASS, reports);
|
|
|
|
convertSatelliteInfo(r.mSatelliteInfo, GNSS_SV_TYPE_QZSS, reports);
|
2017-04-27 16:46:09 -04:00
|
|
|
convertSatelliteInfo(r.mSatelliteInfo, GNSS_SV_TYPE_BEIDOU, reports);
|
2017-03-21 20:16:49 -04:00
|
|
|
convertSatelliteInfo(r.mSatelliteInfo, GNSS_SV_TYPE_GALILEO, reports);
|
2017-07-03 09:00:31 -04:00
|
|
|
LOC_LOGV("getDebugReport - satellite=%zu", r.mSatelliteInfo.size());
|
2017-03-21 20:16:49 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-08-09 21:40:51 -04:00
|
|
|
/* get AGC information from system status and fill it */
|
|
|
|
void
|
|
|
|
GnssAdapter::getAgcInformation(GnssMeasurementsNotification& measurements, int msInWeek)
|
|
|
|
{
|
2017-08-11 05:43:38 -04:00
|
|
|
SystemStatus* systemstatus = getSystemStatus();
|
2017-08-09 21:40:51 -04:00
|
|
|
|
|
|
|
if (nullptr != systemstatus) {
|
|
|
|
SystemStatusReports reports = {};
|
|
|
|
systemstatus->getReport(reports, true);
|
|
|
|
|
|
|
|
if ((!reports.mRfAndParams.empty()) && (!reports.mTimeAndClock.empty()) &&
|
|
|
|
(abs(msInWeek - (int)reports.mTimeAndClock.back().mGpsTowMs) < 2000)) {
|
|
|
|
|
|
|
|
for (size_t i = 0; i < measurements.count; i++) {
|
|
|
|
switch (measurements.measurements[i].svType) {
|
|
|
|
case GNSS_SV_TYPE_GPS:
|
2018-05-21 17:33:14 -04:00
|
|
|
case GNSS_SV_TYPE_QZSS:
|
2017-08-09 21:40:51 -04:00
|
|
|
measurements.measurements[i].agcLevelDb =
|
|
|
|
reports.mRfAndParams.back().mAgcGps;
|
|
|
|
measurements.measurements[i].flags |=
|
|
|
|
GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GNSS_SV_TYPE_GALILEO:
|
|
|
|
measurements.measurements[i].agcLevelDb =
|
|
|
|
reports.mRfAndParams.back().mAgcGal;
|
|
|
|
measurements.measurements[i].flags |=
|
|
|
|
GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GNSS_SV_TYPE_GLONASS:
|
|
|
|
measurements.measurements[i].agcLevelDb =
|
|
|
|
reports.mRfAndParams.back().mAgcGlo;
|
|
|
|
measurements.measurements[i].flags |=
|
|
|
|
GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GNSS_SV_TYPE_BEIDOU:
|
|
|
|
measurements.measurements[i].agcLevelDb =
|
|
|
|
reports.mRfAndParams.back().mAgcBds;
|
|
|
|
measurements.measurements[i].flags |=
|
|
|
|
GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GNSS_SV_TYPE_SBAS:
|
|
|
|
case GNSS_SV_TYPE_UNKNOWN:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-29 05:49:40 -04:00
|
|
|
/* Callbacks registered with loc_net_iface library */
|
|
|
|
static void agpsOpenResultCb (bool isSuccess, AGpsExtType agpsType, const char* apn,
|
|
|
|
AGpsBearerType bearerType, void* userDataPtr) {
|
|
|
|
LOC_LOGD("%s]: ", __func__);
|
|
|
|
if (userDataPtr == nullptr) {
|
|
|
|
LOC_LOGE("%s]: userDataPtr is nullptr.", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (apn == nullptr) {
|
|
|
|
LOC_LOGE("%s]: apn is nullptr.", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
GnssAdapter* adapter = (GnssAdapter*)userDataPtr;
|
|
|
|
if (isSuccess) {
|
|
|
|
adapter->dataConnOpenCommand(agpsType, apn, strlen(apn), bearerType);
|
|
|
|
} else {
|
|
|
|
adapter->dataConnFailedCommand(agpsType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void agpsCloseResultCb (bool isSuccess, AGpsExtType agpsType, void* userDataPtr) {
|
|
|
|
LOC_LOGD("%s]: ", __func__);
|
|
|
|
if (userDataPtr == nullptr) {
|
|
|
|
LOC_LOGE("%s]: userDataPtr is nullptr.", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
GnssAdapter* adapter = (GnssAdapter*)userDataPtr;
|
|
|
|
if (isSuccess) {
|
|
|
|
adapter->dataConnClosedCommand(agpsType);
|
|
|
|
} else {
|
|
|
|
adapter->dataConnFailedCommand(agpsType);
|
|
|
|
}
|
|
|
|
}
|
2018-01-29 04:02:06 -05:00
|
|
|
|
|
|
|
/* ==== Eng Hub Proxy ================================================================= */
|
|
|
|
/* ======== UTILITIES ================================================================= */
|
|
|
|
void
|
|
|
|
GnssAdapter::initEngHubProxyCommand() {
|
|
|
|
LOC_LOGD("%s]: ", __func__);
|
|
|
|
|
|
|
|
struct MsgInitEngHubProxy : public LocMsg {
|
|
|
|
GnssAdapter* mAdapter;
|
|
|
|
inline MsgInitEngHubProxy(GnssAdapter* adapter) :
|
|
|
|
LocMsg(),
|
|
|
|
mAdapter(adapter) {}
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mAdapter->initEngHubProxy();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sendMsg(new MsgInitEngHubProxy(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GnssAdapter::initEngHubProxy() {
|
|
|
|
static bool firstTime = true;
|
|
|
|
static bool engHubLoadSuccessful = false;
|
|
|
|
|
|
|
|
const char *error = nullptr;
|
|
|
|
unsigned int processListLength = 0;
|
|
|
|
loc_process_info_s_type* processInfoList = nullptr;
|
|
|
|
|
|
|
|
do {
|
|
|
|
// load eng hub only once
|
|
|
|
if (firstTime == false) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rc = loc_read_process_conf(LOC_PATH_IZAT_CONF, &processListLength,
|
|
|
|
&processInfoList);
|
|
|
|
if (rc != 0) {
|
|
|
|
LOC_LOGE("%s]: failed to parse conf file", __func__);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool pluginDaemonEnabled = false;
|
|
|
|
// go over the conf table to see whether any plugin daemon is enabled
|
|
|
|
for (unsigned int i = 0; i < processListLength; i++) {
|
|
|
|
if ((strncmp(processInfoList[i].name[0], PROCESS_NAME_ENGINE_SERVICE,
|
|
|
|
strlen(PROCESS_NAME_ENGINE_SERVICE)) == 0) &&
|
|
|
|
(processInfoList[i].proc_status == ENABLED)) {
|
|
|
|
pluginDaemonEnabled = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// no plugin daemon is enabled for this platform, no need to load eng hub .so
|
|
|
|
if (pluginDaemonEnabled == false) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// load the engine hub .so, if the .so is not present
|
|
|
|
// all EngHubProxyBase calls will turn into no-op.
|
|
|
|
void *handle = nullptr;
|
|
|
|
if ((handle = dlopen("libloc_eng_hub.so", RTLD_NOW)) == nullptr) {
|
|
|
|
if ((error = dlerror()) != nullptr) {
|
|
|
|
LOC_LOGE("%s]: libloc_eng_hub.so not found %s !", __func__, error);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// prepare the callback functions
|
|
|
|
// callback function for engine hub to report back position event
|
|
|
|
GnssAdapterReportPositionEventCb reportPositionEventCb =
|
|
|
|
[this](const UlpLocation& ulpLocation,
|
|
|
|
const GpsLocationExtended& locationExtended,
|
|
|
|
enum loc_sess_status status,
|
|
|
|
LocPosTechMask techMask,
|
2018-03-30 20:10:59 -04:00
|
|
|
bool fromEngineHub) {
|
2018-01-29 04:02:06 -05:00
|
|
|
// report from engine hub on behalf of PPE will be treated as fromUlp
|
2018-03-30 20:10:59 -04:00
|
|
|
reportPositionEvent(ulpLocation, locationExtended, status,
|
2018-06-07 15:03:55 -04:00
|
|
|
techMask, fromEngineHub);
|
2018-01-29 04:02:06 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// callback function for engine hub to report back sv event
|
|
|
|
GnssAdapterReportSvEventCb reportSvEventCb =
|
2018-06-07 15:03:55 -04:00
|
|
|
[this](const GnssSvNotification& svNotify, bool fromEngineHub) {
|
|
|
|
reportSvEvent(svNotify, fromEngineHub);
|
2018-01-29 04:02:06 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
getEngHubProxyFn* getter = (getEngHubProxyFn*) dlsym(handle, "getEngHubProxy");
|
|
|
|
if(getter != nullptr) {
|
2018-03-07 13:19:24 -05:00
|
|
|
EngineHubProxyBase* hubProxy = (*getter) (mMsgTask, mSystemStatus->getOsObserver(),
|
|
|
|
reportPositionEventCb,
|
2018-01-29 04:02:06 -05:00
|
|
|
reportSvEventCb);
|
|
|
|
if (hubProxy != nullptr) {
|
|
|
|
mEngHubProxy = hubProxy;
|
|
|
|
engHubLoadSuccessful = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
LOC_LOGD("%s]: entered, did not find function", __func__);
|
|
|
|
}
|
2018-06-07 15:03:55 -04:00
|
|
|
|
|
|
|
LOC_LOGD("%s]: first time initialization %d, returned %d",
|
|
|
|
__func__, firstTime, engHubLoadSuccessful);
|
|
|
|
|
2018-01-29 04:02:06 -05:00
|
|
|
} while (0);
|
|
|
|
|
|
|
|
if (processInfoList != nullptr) {
|
|
|
|
free (processInfoList);
|
|
|
|
processInfoList = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
firstTime = false;
|
|
|
|
return engHubLoadSuccessful;
|
|
|
|
}
|