2018-03-13 13:11:02 -04:00
|
|
|
/* Copyright (c) 2011-2014, 2016-2018 The Linux Foundation. All rights reserved.
|
2013-08-07 21:40:27 -04: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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef LOC_API_BASE_H
|
|
|
|
#define LOC_API_BASE_H
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <gps_extended.h>
|
2017-02-28 19:45:47 -05:00
|
|
|
#include <LocationAPI.h>
|
2013-08-07 21:40:27 -04:00
|
|
|
#include <MsgTask.h>
|
2016-09-12 20:20:55 -04:00
|
|
|
#include <log_util.h>
|
2013-10-23 14:28:51 -04:00
|
|
|
|
2013-08-07 21:40:27 -04:00
|
|
|
namespace loc_core {
|
2018-01-22 19:04:50 -05:00
|
|
|
|
2014-02-24 14:13:57 -05:00
|
|
|
class ContextBase;
|
2018-01-22 19:04:50 -05:00
|
|
|
struct LocApiResponse;
|
2013-08-07 21:40:27 -04:00
|
|
|
|
|
|
|
int hexcode(char *hexstring, int string_size,
|
|
|
|
const char *data, int data_size);
|
|
|
|
int decodeAddress(char *addr_string, int string_size,
|
|
|
|
const char *data, int data_size);
|
|
|
|
|
|
|
|
#define MAX_ADAPTERS 10
|
2016-05-10 15:07:28 -04:00
|
|
|
#define MAX_FEATURE_LENGTH 100
|
2013-08-07 21:40:27 -04:00
|
|
|
|
|
|
|
#define TO_ALL_ADAPTERS(adapters, call) \
|
|
|
|
for (int i = 0; i < MAX_ADAPTERS && NULL != (adapters)[i]; i++) { \
|
|
|
|
call; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TO_1ST_HANDLING_ADAPTER(adapters, call) \
|
|
|
|
for (int i = 0; i <MAX_ADAPTERS && NULL != (adapters)[i] && !(call); i++);
|
|
|
|
|
2014-06-26 14:08:12 -04:00
|
|
|
enum xtra_version_check {
|
|
|
|
DISABLED,
|
|
|
|
AUTO,
|
|
|
|
XTRA2,
|
|
|
|
XTRA3
|
|
|
|
};
|
|
|
|
|
2013-08-07 21:40:27 -04:00
|
|
|
class LocAdapterBase;
|
|
|
|
struct LocSsrMsg;
|
2013-10-23 14:28:51 -04:00
|
|
|
struct LocOpenMsg;
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t accumulatedDistance;
|
|
|
|
uint32_t numOfBatchedPositions;
|
|
|
|
} LocApiBatchData;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint32_t hwId;
|
|
|
|
} LocApiGeofenceData;
|
|
|
|
|
|
|
|
struct LocApiMsg: LocMsg {
|
|
|
|
private:
|
|
|
|
std::function<void ()> mProcImpl;
|
|
|
|
inline virtual void proc() const {
|
|
|
|
mProcImpl();
|
|
|
|
}
|
|
|
|
public:
|
|
|
|
inline LocApiMsg(std::function<void ()> procImpl ) :
|
|
|
|
mProcImpl(procImpl) {}
|
|
|
|
};
|
|
|
|
|
2013-10-23 14:28:51 -04:00
|
|
|
class LocApiProxyBase {
|
|
|
|
public:
|
|
|
|
inline LocApiProxyBase() {}
|
|
|
|
inline virtual ~LocApiProxyBase() {}
|
|
|
|
inline virtual void* getSibling2() { return NULL; }
|
|
|
|
};
|
2013-08-07 21:40:27 -04:00
|
|
|
|
|
|
|
class LocApiBase {
|
|
|
|
friend struct LocSsrMsg;
|
2013-10-23 14:28:51 -04:00
|
|
|
//LocOpenMsg calls open() which makes it necessary to declare
|
|
|
|
//it as a friend
|
|
|
|
friend struct LocOpenMsg;
|
2018-01-22 19:04:50 -05:00
|
|
|
friend struct LocCloseMsg;
|
2013-08-07 21:40:27 -04:00
|
|
|
friend class ContextBase;
|
2018-01-22 19:04:50 -05:00
|
|
|
static MsgTask* mMsgTask;
|
2013-08-07 21:40:27 -04:00
|
|
|
LocAdapterBase* mLocAdapters[MAX_ADAPTERS];
|
2018-01-22 19:04:50 -05:00
|
|
|
|
2013-08-07 21:40:27 -04:00
|
|
|
|
2013-07-20 17:16:32 -04:00
|
|
|
protected:
|
2018-01-22 19:04:50 -05:00
|
|
|
ContextBase *mContext;
|
2013-08-07 21:40:27 -04:00
|
|
|
virtual enum loc_api_adapter_err
|
|
|
|
open(LOC_API_ADAPTER_EVENT_MASK_T mask);
|
|
|
|
virtual enum loc_api_adapter_err
|
|
|
|
close();
|
|
|
|
LOC_API_ADAPTER_EVENT_MASK_T getEvtMask();
|
|
|
|
LOC_API_ADAPTER_EVENT_MASK_T mMask;
|
2018-01-22 19:04:50 -05:00
|
|
|
LocApiBase(LOC_API_ADAPTER_EVENT_MASK_T excludedMask,
|
2014-02-24 14:13:57 -05:00
|
|
|
ContextBase* context = NULL);
|
2013-08-07 21:40:27 -04:00
|
|
|
inline virtual ~LocApiBase() { close(); }
|
|
|
|
bool isInSession();
|
2013-10-23 14:28:51 -04:00
|
|
|
const LOC_API_ADAPTER_EVENT_MASK_T mExcludedMask;
|
2013-08-07 21:40:27 -04:00
|
|
|
|
|
|
|
public:
|
2014-02-26 19:24:10 -05:00
|
|
|
inline void sendMsg(const LocMsg* msg) const {
|
|
|
|
mMsgTask->sendMsg(msg);
|
|
|
|
}
|
2013-08-07 21:40:27 -04:00
|
|
|
void addAdapter(LocAdapterBase* adapter);
|
|
|
|
void removeAdapter(LocAdapterBase* adapter);
|
|
|
|
|
|
|
|
// upward calls
|
|
|
|
void handleEngineUpEvent();
|
|
|
|
void handleEngineDownEvent();
|
2017-02-28 19:45:47 -05:00
|
|
|
void reportPosition(UlpLocation& location,
|
|
|
|
GpsLocationExtended& locationExtended,
|
2013-08-07 21:40:27 -04:00
|
|
|
enum loc_sess_status status,
|
|
|
|
LocPosTechMask loc_technology_mask =
|
|
|
|
LOC_POS_TECH_MASK_DEFAULT);
|
2017-02-28 19:45:47 -05:00
|
|
|
void reportSv(GnssSvNotification& svNotify);
|
2015-01-16 01:24:40 -05:00
|
|
|
void reportSvMeasurement(GnssSvMeasurementSet &svMeasurementSet);
|
|
|
|
void reportSvPolynomial(GnssSvPolynomial &svPolynomial);
|
2016-10-18 22:58:29 -04:00
|
|
|
void reportStatus(LocGpsStatusValue status);
|
2013-08-07 21:40:27 -04:00
|
|
|
void reportNmea(const char* nmea, int length);
|
|
|
|
void reportXtraServer(const char* url1, const char* url2,
|
|
|
|
const char* url3, const int maxlength);
|
|
|
|
void requestXtraData();
|
|
|
|
void requestTime();
|
|
|
|
void requestLocation();
|
2018-03-13 13:11:02 -04:00
|
|
|
void requestATL(int connHandle, LocAGpsType agps_type, LocApnTypeMask apn_type_mask);
|
2013-08-07 21:40:27 -04:00
|
|
|
void releaseATL(int connHandle);
|
2017-02-28 19:45:47 -05:00
|
|
|
void requestNiNotify(GnssNiNotification ¬ify, const void* data);
|
2017-08-09 21:40:51 -04:00
|
|
|
void reportGnssMeasurementData(GnssMeasurementsNotification& measurements, int msInWeek);
|
2016-10-18 22:58:29 -04:00
|
|
|
void reportWwanZppFix(LocGpsLocation &zppLoc);
|
2018-01-22 19:04:50 -05:00
|
|
|
void reportZppBestAvailableFix(LocGpsLocation &zppLoc, GpsLocationExtended &location_extended,
|
|
|
|
LocPosTechMask tech_mask);
|
2018-05-20 09:59:46 -04:00
|
|
|
void reportGnssSvIdConfig(const GnssSvIdConfig& config);
|
|
|
|
void reportGnssSvTypeConfig(const GnssSvTypeConfig& config);
|
2018-04-08 14:05:14 -04:00
|
|
|
void requestOdcpi(OdcpiRequestInfo& request);
|
2013-08-07 21:40:27 -04:00
|
|
|
|
|
|
|
// downward calls
|
|
|
|
// All below functions are to be defined by adapter specific modules:
|
|
|
|
// RPC, QMI, etc. The default implementation is empty.
|
2013-09-13 21:38:26 -04:00
|
|
|
|
|
|
|
virtual void* getSibling();
|
2013-10-23 14:28:51 -04:00
|
|
|
virtual LocApiProxyBase* getLocApiProxy();
|
2018-01-22 19:04:50 -05:00
|
|
|
virtual void startFix(const LocPosMode& fixCriteria, LocApiResponse* adapterResponse);
|
|
|
|
virtual void
|
|
|
|
stopFix(LocApiResponse* adapterResponse);
|
|
|
|
virtual void
|
|
|
|
deleteAidingData(const GnssAidingData& data, LocApiResponse* adapterResponse);
|
|
|
|
|
|
|
|
virtual void
|
2013-08-07 21:40:27 -04:00
|
|
|
injectPosition(double latitude, double longitude, float accuracy);
|
2018-04-08 14:05:14 -04:00
|
|
|
virtual void
|
|
|
|
injectPosition(const Location& location, bool onDemandCpi);
|
2018-01-22 19:04:50 -05:00
|
|
|
virtual void
|
2016-10-18 22:58:29 -04:00
|
|
|
setTime(LocGpsUtcTime time, int64_t timeReference, int uncertainty);
|
2018-01-22 19:04:50 -05:00
|
|
|
|
|
|
|
// // TODO:: called from izatapipds
|
2013-08-07 21:40:27 -04:00
|
|
|
virtual enum loc_api_adapter_err
|
|
|
|
setXtraData(char* data, int length);
|
2018-01-22 19:04:50 -05:00
|
|
|
|
|
|
|
virtual void
|
|
|
|
atlOpenStatus(int handle, int is_succ, char* apn, uint32_t apnLen,
|
2018-03-13 13:11:02 -04:00
|
|
|
AGpsBearerType bear, LocAGpsType agpsType,
|
|
|
|
LocApnTypeMask mask);
|
2018-01-22 19:04:50 -05:00
|
|
|
virtual void
|
2013-08-07 21:40:27 -04:00
|
|
|
atlCloseStatus(int handle, int is_succ);
|
2018-01-22 19:04:50 -05:00
|
|
|
virtual void
|
2013-08-07 21:40:27 -04:00
|
|
|
setPositionMode(const LocPosMode& posMode);
|
2017-02-28 19:45:47 -05:00
|
|
|
virtual LocationError
|
2018-01-22 19:04:50 -05:00
|
|
|
setServerSync(const char* url, int len);
|
2017-02-28 19:45:47 -05:00
|
|
|
virtual LocationError
|
2018-01-22 19:04:50 -05:00
|
|
|
setServerSync(unsigned int ip, int port,
|
2013-08-07 21:40:27 -04:00
|
|
|
LocServerType type);
|
2018-01-22 19:04:50 -05:00
|
|
|
virtual void
|
2017-02-28 19:45:47 -05:00
|
|
|
informNiResponse(GnssNiResponse userResponse, const void* passThroughData);
|
2018-01-22 19:04:50 -05:00
|
|
|
virtual LocationError setSUPLVersionSync(GnssConfigSuplVersion version);
|
2016-04-28 08:53:17 -04:00
|
|
|
virtual enum loc_api_adapter_err
|
2018-01-22 19:04:50 -05:00
|
|
|
setNMEATypesSync(uint32_t typesMask);
|
|
|
|
virtual LocationError setLPPConfigSync(GnssConfigLppProfile profile);
|
2013-08-07 21:40:27 -04:00
|
|
|
virtual enum loc_api_adapter_err
|
2018-01-22 19:04:50 -05:00
|
|
|
setSensorControlConfigSync(int sensorUsage, int sensorProvider);
|
2013-08-07 21:40:27 -04:00
|
|
|
virtual enum loc_api_adapter_err
|
2018-01-22 19:04:50 -05:00
|
|
|
setSensorPropertiesSync(bool gyroBiasVarianceRandomWalk_valid,
|
2013-08-07 21:40:27 -04:00
|
|
|
float gyroBiasVarianceRandomWalk,
|
|
|
|
bool accelBiasVarianceRandomWalk_valid,
|
|
|
|
float accelBiasVarianceRandomWalk,
|
|
|
|
bool angleBiasVarianceRandomWalk_valid,
|
|
|
|
float angleBiasVarianceRandomWalk,
|
|
|
|
bool rateBiasVarianceRandomWalk_valid,
|
|
|
|
float rateBiasVarianceRandomWalk,
|
|
|
|
bool velocityBiasVarianceRandomWalk_valid,
|
|
|
|
float velocityBiasVarianceRandomWalk);
|
|
|
|
virtual enum loc_api_adapter_err
|
2018-01-22 19:04:50 -05:00
|
|
|
setSensorPerfControlConfigSync(int controlMode,
|
2013-08-07 21:40:27 -04:00
|
|
|
int accelSamplesPerBatch,
|
|
|
|
int accelBatchesPerSec,
|
|
|
|
int gyroSamplesPerBatch,
|
|
|
|
int gyroBatchesPerSec,
|
|
|
|
int accelSamplesPerBatchHigh,
|
|
|
|
int accelBatchesPerSecHigh,
|
|
|
|
int gyroSamplesPerBatchHigh,
|
|
|
|
int gyroBatchesPerSecHigh,
|
|
|
|
int algorithmConfig);
|
2017-02-28 19:45:47 -05:00
|
|
|
virtual LocationError
|
2018-01-22 19:04:50 -05:00
|
|
|
setAGLONASSProtocolSync(GnssConfigAGlonassPositionProtocolMask aGlonassProtocol);
|
|
|
|
virtual LocationError setLPPeProtocolCpSync(GnssConfigLppeControlPlaneMask lppeCP);
|
|
|
|
virtual LocationError setLPPeProtocolUpSync(GnssConfigLppeUserPlaneMask lppeUP);
|
|
|
|
virtual GnssConfigSuplVersion convertSuplVersion(const uint32_t suplVersion);
|
|
|
|
virtual GnssConfigLppProfile convertLppProfile(const uint32_t lppProfile);
|
|
|
|
virtual GnssConfigLppeControlPlaneMask convertLppeCp(const uint32_t lppeControlPlaneMask);
|
|
|
|
virtual GnssConfigLppeUserPlaneMask convertLppeUp(const uint32_t lppeUserPlaneMask);
|
|
|
|
|
2018-06-04 16:16:59 -04:00
|
|
|
virtual void getWwanZppFix();
|
|
|
|
virtual void getBestAvailableZppFix();
|
2016-10-18 22:58:29 -04:00
|
|
|
virtual void installAGpsCert(const LocDerEncodedCertificate* pData,
|
2013-11-01 18:58:07 -04:00
|
|
|
size_t length,
|
|
|
|
uint32_t slotBitMask);
|
2016-03-14 06:00:09 -04:00
|
|
|
inline virtual void setInSession(bool inSession) {
|
|
|
|
|
|
|
|
(void)inSession;
|
|
|
|
}
|
2018-01-22 19:04:50 -05:00
|
|
|
|
2017-02-28 19:45:47 -05:00
|
|
|
|
2014-09-01 22:07:58 -04:00
|
|
|
void updateEvtMask();
|
2013-08-21 20:57:17 -04:00
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
virtual LocationError setGpsLockSync(GnssConfigGpsLock lock);
|
2013-08-21 20:57:17 -04:00
|
|
|
/*
|
|
|
|
Returns
|
|
|
|
Current value of GPS Lock on success
|
|
|
|
-1 on failure
|
|
|
|
*/
|
|
|
|
virtual int getGpsLock(void);
|
2014-12-15 20:47:50 -05:00
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
virtual LocationError setXtraVersionCheckSync(uint32_t check);
|
2016-05-10 15:07:28 -04:00
|
|
|
|
2018-05-20 09:59:46 -04:00
|
|
|
/* Requests for SV/Constellation Control */
|
|
|
|
virtual LocationError setBlacklistSvSync(const GnssSvIdConfig& config);
|
|
|
|
virtual void setBlacklistSv(const GnssSvIdConfig& config);
|
|
|
|
virtual void getBlacklistSv();
|
|
|
|
virtual void setConstellationControl(const GnssSvTypeConfig& config);
|
|
|
|
virtual void getConstellationControl();
|
|
|
|
virtual void resetConstellationControl();
|
2013-08-07 21:40:27 -04:00
|
|
|
};
|
|
|
|
|
2018-01-22 19:04:50 -05:00
|
|
|
typedef LocApiBase* (getLocApi_t)(LOC_API_ADAPTER_EVENT_MASK_T exMask,
|
2014-02-24 14:13:57 -05:00
|
|
|
ContextBase *context);
|
2013-08-07 21:40:27 -04:00
|
|
|
|
|
|
|
} // namespace loc_core
|
|
|
|
|
|
|
|
#endif //LOC_API_BASE_H
|