1 /* Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation, nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 #ifndef GNSS_ADAPTER_H 30 #define GNSS_ADAPTER_H 31 32 #include <LocAdapterBase.h> 33 #include <LocContext.h> 34 #include <IOsObserver.h> 35 #include <EngineHubProxyBase.h> 36 #include <LocationAPI.h> 37 #include <Agps.h> 38 #include <SystemStatus.h> 39 #include <XtraSystemStatusObserver.h> 40 #include <map> 41 42 #define MAX_URL_LEN 256 43 #define NMEA_SENTENCE_MAX_LENGTH 200 44 #define GLONASS_SV_ID_OFFSET 64 45 #define MAX_SATELLITES_IN_USE 12 46 #define LOC_NI_NO_RESPONSE_TIME 20 47 #define LOC_GPS_NI_RESPONSE_IGNORE 4 48 #define ODCPI_EXPECTED_INJECTION_TIME_MS 10000 49 50 class GnssAdapter; 51 52 typedef std::map<LocationSessionKey, LocationOptions> LocationSessionMap; 53 typedef std::map<LocationSessionKey, TrackingOptions> TrackingOptionsMap; 54 55 class OdcpiTimer : public LocTimer { 56 public: OdcpiTimer(GnssAdapter * adapter)57 OdcpiTimer(GnssAdapter* adapter) : 58 LocTimer(), mAdapter(adapter), mActive(false) {} 59 start()60 inline void start() { 61 mActive = true; 62 LocTimer::start(ODCPI_EXPECTED_INJECTION_TIME_MS, false); 63 } stop()64 inline void stop() { 65 mActive = false; 66 LocTimer::stop(); 67 } restart()68 inline void restart() { 69 stop(); 70 start(); 71 } isActive()72 inline bool isActive() { 73 return mActive; 74 } 75 76 private: 77 // Override 78 virtual void timeOutCallback() override; 79 80 GnssAdapter* mAdapter; 81 bool mActive; 82 }; 83 84 typedef struct { 85 pthread_t thread; /* NI thread */ 86 uint32_t respTimeLeft; /* examine time for NI response */ 87 bool respRecvd; /* NI User reponse received or not from Java layer*/ 88 void* rawRequest; 89 uint32_t reqID; /* ID to check against response */ 90 GnssNiResponse resp; 91 pthread_cond_t tCond; 92 pthread_mutex_t tLock; 93 GnssAdapter* adapter; 94 } NiSession; 95 typedef struct { 96 NiSession session; /* SUPL NI Session */ 97 NiSession sessionEs; /* Emergency SUPL NI Session */ 98 uint32_t reqIDCounter; 99 } NiData; 100 101 typedef enum { 102 NMEA_PROVIDER_AP = 0, // Application Processor Provider of NMEA 103 NMEA_PROVIDER_MP // Modem Processor Provider of NMEA 104 } NmeaProviderType; 105 typedef struct { 106 GnssSvType svType; 107 const char* talker; 108 uint64_t mask; 109 uint32_t svIdOffset; 110 } NmeaSvMeta; 111 112 typedef struct { 113 double latitude; 114 double longitude; 115 float accuracy; 116 // the CPI will be blocked until the boot time 117 // specified in blockedTillTsMs 118 int64_t blockedTillTsMs; 119 // CPIs whose both latitude and longitude differ 120 // no more than latLonThreshold will be blocked 121 // in units of degree 122 double latLonDiffThreshold; 123 } BlockCPIInfo; 124 125 typedef struct { 126 bool isValid; 127 bool enable; 128 float tuncThresholdMs; // need to be specified if enable is true 129 uint32_t energyBudget; // need to be specified if enable is true 130 } TuncConfigInfo; 131 132 typedef struct { 133 bool isValid; 134 bool enable; 135 } PaceConfigInfo; 136 137 typedef struct { 138 bool isValid; 139 bool enable; 140 bool enableFor911; 141 } RobustLocationConfigInfo; 142 143 typedef struct { 144 TuncConfigInfo tuncConfigInfo; 145 PaceConfigInfo paceConfigInfo; 146 RobustLocationConfigInfo robustLocationConfigInfo; 147 } LocIntegrationConfigInfo; 148 149 using namespace loc_core; 150 151 namespace loc_core { 152 class SystemStatus; 153 } 154 155 typedef std::function<void( 156 uint64_t gnssEnergyConsumedFromFirstBoot 157 )> GnssEnergyConsumedCallback; 158 159 typedef void (*powerStateCallback)(bool on); 160 161 typedef void* QDgnssListenerHDL; 162 typedef std::function<void( 163 bool sessionActive 164 )> QDgnssSessionActiveCb; 165 166 struct CdfwInterface { 167 QDgnssListenerHDL (*createUsableReporter)( 168 QDgnssSessionActiveCb sessionActiveCb); 169 170 void (*destroyUsableReporter)(QDgnssListenerHDL handle); 171 172 void (*reportUsable)(QDgnssListenerHDL handle, bool usable); 173 }; 174 175 class GnssAdapter : public LocAdapterBase { 176 177 /* ==== Engine Hub ===================================================================== */ 178 EngineHubProxyBase* mEngHubProxy; 179 bool mNHzNeeded; 180 bool mSPEAlreadyRunningAtHighestInterval; 181 182 /* ==== TRACKING ======================================================================= */ 183 TrackingOptionsMap mTimeBasedTrackingSessions; 184 LocationSessionMap mDistanceBasedTrackingSessions; 185 LocPosMode mLocPositionMode; 186 GnssSvUsedInPosition mGnssSvIdUsedInPosition; 187 bool mGnssSvIdUsedInPosAvail; 188 GnssSvMbUsedInPosition mGnssMbSvIdUsedInPosition; 189 bool mGnssMbSvIdUsedInPosAvail; 190 191 /* ==== CONTROL ======================================================================== */ 192 LocationControlCallbacks mControlCallbacks; 193 uint32_t mAfwControlId; 194 uint32_t mNmeaMask; 195 uint64_t mPrevNmeaRptTimeNsec; 196 GnssSvIdConfig mGnssSvIdConfig; 197 GnssSvTypeConfig mGnssSvTypeConfig; 198 GnssSvTypeConfigCallback mGnssSvTypeConfigCb; 199 bool mSupportNfwControl; 200 LocIntegrationConfigInfo mLocConfigInfo; 201 202 /* ==== NI ============================================================================= */ 203 NiData mNiData; 204 205 /* ==== AGPS =========================================================================== */ 206 // This must be initialized via initAgps() 207 AgpsManager mAgpsManager; 208 void initAgps(const AgpsCbInfo& cbInfo); 209 210 /* ==== NFW =========================================================================== */ 211 NfwStatusCb mNfwCb; 212 IsInEmergencySession mIsE911Session; initNfw(const NfwCbInfo & cbInfo)213 inline void initNfw(const NfwCbInfo& cbInfo) { 214 mNfwCb = (NfwStatusCb)cbInfo.visibilityControlCb; 215 mIsE911Session = (IsInEmergencySession)cbInfo.isInEmergencySession; 216 } 217 218 /* ==== Measurement Corrections========================================================= */ 219 bool mIsMeasCorrInterfaceOpen; 220 measCorrSetCapabilitiesCb mMeasCorrSetCapabilitiesCb; 221 bool initMeasCorr(bool bSendCbWhenNotSupported); 222 bool mIsAntennaInfoInterfaceOpened; 223 224 /* ==== DGNSS Data Usable Report======================================================== */ 225 QDgnssListenerHDL mQDgnssListenerHDL; 226 const CdfwInterface* mCdfwInterface; 227 bool mDGnssNeedReport; 228 bool mDGnssDataUsage; 229 void reportDGnssDataUsable(const GnssSvMeasurementSet &svMeasurementSet); 230 231 /* ==== ODCPI ========================================================================== */ 232 OdcpiRequestCallback mOdcpiRequestCb; 233 bool mOdcpiRequestActive; 234 OdcpiTimer mOdcpiTimer; 235 OdcpiRequestInfo mOdcpiRequest; 236 void odcpiTimerExpire(); 237 238 /* === SystemStatus ===================================================================== */ 239 SystemStatus* mSystemStatus; 240 std::string mServerUrl; 241 std::string mMoServerUrl; 242 XtraSystemStatusObserver mXtraObserver; 243 LocationSystemInfo mLocSystemInfo; 244 std::vector<GnssSvIdSource> mBlacklistedSvIds; 245 PowerStateType mSystemPowerState; 246 247 /* === Misc ===================================================================== */ 248 BlockCPIInfo mBlockCPIInfo; 249 bool mPowerOn; 250 uint32_t mAllowFlpNetworkFixes; 251 252 /* === Misc callback from QMI LOC API ============================================== */ 253 GnssEnergyConsumedCallback mGnssEnergyConsumedCb; 254 powerStateCallback mPowerStateCb; 255 256 /*==== CONVERSION ===================================================================*/ 257 static void convertOptions(LocPosMode& out, const TrackingOptions& trackingOptions); 258 static void convertLocation(Location& out, const UlpLocation& ulpLocation, 259 const GpsLocationExtended& locationExtended, 260 const LocPosTechMask techMask); 261 static void convertLocationInfo(GnssLocationInfoNotification& out, 262 const GpsLocationExtended& locationExtended); 263 static uint16_t getNumSvUsed(uint64_t svUsedIdsMask, 264 int totalSvCntInThisConstellation); 265 266 /* ======== UTILITIES ================================================================== */ 267 inline void initOdcpi(const OdcpiRequestCallback& callback); 268 inline void injectOdcpi(const Location& location); 269 static bool isFlpClient(LocationCallbacks& locationCallbacks); 270 271 protected: 272 273 /* ==== CLIENT ========================================================================= */ 274 virtual void updateClientsEventMask(); 275 virtual void stopClientSessions(LocationAPI* client); 276 277 public: 278 279 GnssAdapter(); ~GnssAdapter()280 virtual inline ~GnssAdapter() { } 281 282 /* ==== SSR ============================================================================ */ 283 /* ======== EVENTS ====(Called from QMI Thread)========================================= */ 284 virtual void handleEngineUpEvent(); 285 /* ======== UTILITIES ================================================================== */ 286 void restartSessions(bool modemSSR = false); 287 void checkAndRestartTimeBasedSession(); 288 void checkAndRestartSPESession(); 289 void suspendSessions(); 290 291 /* ==== CLIENT ========================================================================= */ 292 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 293 virtual void addClientCommand(LocationAPI* client, const LocationCallbacks& callbacks); 294 295 /* ==== TRACKING ======================================================================= */ 296 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 297 uint32_t startTrackingCommand( 298 LocationAPI* client, TrackingOptions& trackingOptions); 299 void updateTrackingOptionsCommand( 300 LocationAPI* client, uint32_t id, TrackingOptions& trackingOptions); 301 void stopTrackingCommand(LocationAPI* client, uint32_t id); 302 /* ======== RESPONSES ================================================================== */ 303 void reportResponse(LocationAPI* client, LocationError err, uint32_t sessionId); 304 /* ======== UTILITIES ================================================================== */ 305 bool isTimeBasedTrackingSession(LocationAPI* client, uint32_t sessionId); 306 bool isDistanceBasedTrackingSession(LocationAPI* client, uint32_t sessionId); 307 bool hasCallbacksToStartTracking(LocationAPI* client); 308 bool isTrackingSession(LocationAPI* client, uint32_t sessionId); 309 void saveTrackingSession(LocationAPI* client, uint32_t sessionId, 310 const TrackingOptions& trackingOptions); 311 void eraseTrackingSession(LocationAPI* client, uint32_t sessionId); 312 313 bool setLocPositionMode(const LocPosMode& mode); getLocPositionMode()314 LocPosMode& getLocPositionMode() { return mLocPositionMode; } 315 316 bool startTimeBasedTrackingMultiplex(LocationAPI* client, uint32_t sessionId, 317 const TrackingOptions& trackingOptions); 318 void startTimeBasedTracking(LocationAPI* client, uint32_t sessionId, 319 const TrackingOptions& trackingOptions); 320 bool stopTimeBasedTrackingMultiplex(LocationAPI* client, uint32_t id); 321 void stopTracking(LocationAPI* client, uint32_t id); 322 bool updateTrackingMultiplex(LocationAPI* client, uint32_t id, 323 const TrackingOptions& trackingOptions); 324 void updateTracking(LocationAPI* client, uint32_t sessionId, 325 const TrackingOptions& updatedOptions, const TrackingOptions& oldOptions); 326 bool checkAndSetSPEToRunforNHz(TrackingOptions & out); 327 328 void setConstrainedTunc(bool enable, float tuncConstraint, 329 uint32_t energyBudget, uint32_t sessionId); 330 void setPositionAssistedClockEstimator(bool enable, uint32_t sessionId); 331 void updateSvConfig(uint32_t sessionId, const GnssSvTypeConfig& svTypeConfig, 332 const GnssSvIdConfig& svIdConfig); 333 void resetSvConfig(uint32_t sessionId); 334 void configLeverArm(uint32_t sessionId, const LeverArmConfigInfo& configInfo); 335 void configRobustLocation(uint32_t sessionId, bool enable, bool enableForE911); 336 void configMinGpsWeek(uint32_t sessionId, uint16_t minGpsWeek); 337 338 /* ==== NI ============================================================================= */ 339 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 340 void gnssNiResponseCommand(LocationAPI* client, uint32_t id, GnssNiResponse response); 341 /* ======================(Called from NI Thread)======================================== */ 342 void gnssNiResponseCommand(GnssNiResponse response, void* rawRequest); 343 /* ======== UTILITIES ================================================================== */ 344 bool hasNiNotifyCallback(LocationAPI* client); getNiData()345 NiData& getNiData() { return mNiData; } 346 347 /* ==== CONTROL CLIENT ================================================================= */ 348 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 349 uint32_t enableCommand(LocationTechnologyType techType); 350 void disableCommand(uint32_t id); 351 void setControlCallbacksCommand(LocationControlCallbacks& controlCallbacks); 352 void readConfigCommand(); 353 void requestUlpCommand(); 354 void initEngHubProxyCommand(); 355 uint32_t* gnssUpdateConfigCommand(GnssConfig config); 356 uint32_t* gnssGetConfigCommand(GnssConfigFlagsMask mask); 357 uint32_t gnssDeleteAidingDataCommand(GnssAidingData& data); 358 void deleteAidingData(const GnssAidingData &data, uint32_t sessionId); 359 void gnssUpdateXtraThrottleCommand(const bool enabled); 360 std::vector<LocationError> gnssUpdateConfig(const std::string& oldMoServerUrl, 361 GnssConfig& gnssConfigRequested, 362 GnssConfig& gnssConfigNeedEngineUpdate, size_t count = 0); 363 364 /* ==== GNSS SV TYPE CONFIG ============================================================ */ 365 /* ==== COMMANDS ====(Called from Client Thread)======================================== */ 366 /* ==== These commands are received directly from client bypassing Location API ======== */ 367 void gnssUpdateSvTypeConfigCommand(GnssSvTypeConfig config); 368 void gnssGetSvTypeConfigCommand(GnssSvTypeConfigCallback callback); 369 void gnssResetSvTypeConfigCommand(); 370 371 /* ==== UTILITIES ====================================================================== */ 372 LocationError gnssSvIdConfigUpdateSync(const std::vector<GnssSvIdSource>& blacklistedSvIds); 373 LocationError gnssSvIdConfigUpdateSync(); 374 void gnssSvIdConfigUpdate(const std::vector<GnssSvIdSource>& blacklistedSvIds); 375 void gnssSvIdConfigUpdate(); 376 void gnssSvTypeConfigUpdate(const GnssSvTypeConfig& config); 377 void gnssSvTypeConfigUpdate(bool sendReset = false); gnssSetSvTypeConfig(const GnssSvTypeConfig & config)378 inline void gnssSetSvTypeConfig(const GnssSvTypeConfig& config) 379 { mGnssSvTypeConfig = config; } gnssSetSvTypeConfigCallback(GnssSvTypeConfigCallback callback)380 inline void gnssSetSvTypeConfigCallback(GnssSvTypeConfigCallback callback) 381 { mGnssSvTypeConfigCb = callback; } gnssGetSvTypeConfigCallback()382 inline GnssSvTypeConfigCallback gnssGetSvTypeConfigCallback() 383 { return mGnssSvTypeConfigCb; } 384 void setConfig(); 385 386 /* ========= AGPS ====================================================================== */ 387 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 388 void initDefaultAgpsCommand(); 389 void initAgpsCommand(const AgpsCbInfo& cbInfo); 390 void initNfwCommand(const NfwCbInfo& cbInfo); 391 void dataConnOpenCommand(AGpsExtType agpsType, 392 const char* apnName, int apnLen, AGpsBearerType bearerType); 393 void dataConnClosedCommand(AGpsExtType agpsType); 394 void dataConnFailedCommand(AGpsExtType agpsType); 395 void getGnssEnergyConsumedCommand(GnssEnergyConsumedCallback energyConsumedCb); 396 void nfwControlCommand(bool enable); 397 uint32_t setConstrainedTuncCommand (bool enable, float tuncConstraint, 398 uint32_t energyBudget); 399 uint32_t setPositionAssistedClockEstimatorCommand (bool enable); 400 uint32_t gnssUpdateSvConfigCommand(const GnssSvTypeConfig& svTypeConfig, 401 const GnssSvIdConfig& svIdConfig); 402 uint32_t gnssResetSvConfigCommand(); 403 uint32_t configLeverArmCommand(const LeverArmConfigInfo& configInfo); 404 uint32_t configRobustLocationCommand(bool enable, bool enableForE911); 405 bool openMeasCorrCommand(const measCorrSetCapabilitiesCb setCapabilitiesCb); 406 bool measCorrSetCorrectionsCommand(const GnssMeasurementCorrections gnssMeasCorr); closeMeasCorrCommand()407 inline void closeMeasCorrCommand() { mIsMeasCorrInterfaceOpen = false; } 408 uint32_t antennaInfoInitCommand(const antennaInfoCb antennaInfoCallback); antennaInfoCloseCommand()409 inline void antennaInfoCloseCommand() { mIsAntennaInfoInterfaceOpened = false; } 410 uint32_t configMinGpsWeekCommand(uint16_t minGpsWeek); 411 uint32_t configBodyToSensorMountParamsCommand(const BodyToSensorMountParams& b2sParams); 412 413 /* ========= ODCPI ===================================================================== */ 414 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 415 void initOdcpiCommand(const OdcpiRequestCallback& callback); 416 void injectOdcpiCommand(const Location& location); 417 /* ======== RESPONSES ================================================================== */ 418 void reportResponse(LocationError err, uint32_t sessionId); 419 void reportResponse(size_t count, LocationError* errs, uint32_t* ids); 420 /* ======== UTILITIES ================================================================== */ getControlCallbacks()421 LocationControlCallbacks& getControlCallbacks() { return mControlCallbacks; } setControlCallbacks(const LocationControlCallbacks & controlCallbacks)422 void setControlCallbacks(const LocationControlCallbacks& controlCallbacks) 423 { mControlCallbacks = controlCallbacks; } setAfwControlId(uint32_t id)424 void setAfwControlId(uint32_t id) { mAfwControlId = id; } getAfwControlId()425 uint32_t getAfwControlId() { return mAfwControlId; } isInSession()426 virtual bool isInSession() { return !mTimeBasedTrackingSessions.empty(); } 427 void initDefaultAgps(); 428 bool initEngHubProxy(); 429 void initDGnssUsableReporter(); 430 void odcpiTimerExpireEvent(); 431 432 /* ==== REPORTS ======================================================================== */ 433 /* ======== EVENTS ====(Called from QMI/EngineHub Thread)===================================== */ 434 virtual void reportPositionEvent(const UlpLocation& ulpLocation, 435 const GpsLocationExtended& locationExtended, 436 enum loc_sess_status status, 437 LocPosTechMask techMask, 438 GnssDataNotification* pDataNotify = nullptr, 439 int msInWeek = -1); 440 virtual void reportEnginePositionsEvent(unsigned int count, 441 EngineLocationInfo* locationArr); 442 443 virtual void reportSvEvent(const GnssSvNotification& svNotify, 444 bool fromEngineHub=false); 445 virtual void reportNmeaEvent(const char* nmea, size_t length); 446 virtual void reportDataEvent(const GnssDataNotification& dataNotify, int msInWeek); 447 virtual bool requestNiNotifyEvent(const GnssNiNotification& notify, const void* data, 448 const LocInEmergency emergencyState); 449 virtual void reportGnssMeasurementsEvent(const GnssMeasurements& gnssMeasurements, 450 int msInWeek); 451 virtual void reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial); 452 virtual void reportSvEphemerisEvent(GnssSvEphemerisReport & svEphemeris); 453 virtual void reportGnssSvIdConfigEvent(const GnssSvIdConfig& config); 454 virtual void reportGnssSvTypeConfigEvent(const GnssSvTypeConfig& config); 455 virtual void reportGnssConfigEvent(uint32_t sessionId, const GnssConfig& gnssConfig); 456 virtual bool reportGnssEngEnergyConsumedEvent(uint64_t energyConsumedSinceFirstBoot); 457 virtual void reportLocationSystemInfoEvent(const LocationSystemInfo& locationSystemInfo); 458 459 virtual bool requestATL(int connHandle, LocAGpsType agps_type, LocApnTypeMask apn_type_mask); 460 virtual bool releaseATL(int connHandle); 461 virtual bool requestOdcpiEvent(OdcpiRequestInfo& request); 462 virtual bool reportDeleteAidingDataEvent(GnssAidingData& aidingData); 463 virtual bool reportKlobucharIonoModelEvent(GnssKlobucharIonoModel& ionoModel); 464 virtual bool reportGnssAdditionalSystemInfoEvent( 465 GnssAdditionalSystemInfo& additionalSystemInfo); 466 virtual void reportNfwNotificationEvent(GnssNfwNotification& notification); 467 468 /* ======== UTILITIES ================================================================= */ 469 bool needReportForGnssClient(const UlpLocation& ulpLocation, 470 enum loc_sess_status status, LocPosTechMask techMask); 471 bool needReportForFlpClient(enum loc_sess_status status, LocPosTechMask techMask); 472 bool needToGenerateNmeaReport(const uint32_t &gpsTimeOfWeekMs, 473 const struct timespec32_t &apTimeStamp); 474 void reportPosition(const UlpLocation &ulpLocation, 475 const GpsLocationExtended &locationExtended, 476 enum loc_sess_status status, 477 LocPosTechMask techMask); 478 void reportEnginePositions(unsigned int count, 479 const EngineLocationInfo* locationArr); 480 void reportSv(GnssSvNotification& svNotify); 481 void reportNmea(const char* nmea, size_t length); 482 void reportData(GnssDataNotification& dataNotify); 483 bool requestNiNotify(const GnssNiNotification& notify, const void* data, 484 const bool bInformNiAccept); 485 void reportGnssMeasurementData(const GnssMeasurementsNotification& measurements); 486 void reportGnssSvIdConfig(const GnssSvIdConfig& config); 487 void reportGnssSvTypeConfig(const GnssSvTypeConfig& config); 488 void reportGnssConfig(uint32_t sessionId, const GnssConfig& gnssConfig); 489 void requestOdcpi(const OdcpiRequestInfo& request); 490 void invokeGnssEnergyConsumedCallback(uint64_t energyConsumedSinceFirstBoot); 491 void saveGnssEnergyConsumedCallback(GnssEnergyConsumedCallback energyConsumedCb); 492 void reportLocationSystemInfo(const LocationSystemInfo & locationSystemInfo); reportNfwNotification(const GnssNfwNotification & notification)493 inline void reportNfwNotification(const GnssNfwNotification& notification) { 494 if (NULL != mNfwCb) { 495 mNfwCb(notification); 496 } 497 } getE911State(void)498 inline bool getE911State(void) { 499 if (NULL != mIsE911Session) { 500 return mIsE911Session(); 501 } 502 return false; 503 } 504 505 void updateSystemPowerState(PowerStateType systemPowerState); 506 void reportSvPolynomial(const GnssSvPolynomial &svPolynomial); 507 508 509 std::vector<double> parseDoublesString(char* dString); 510 void reportGnssAntennaInformation(const antennaInfoCb antennaInfoCallback); 511 512 /*======== GNSSDEBUG ================================================================*/ 513 bool getDebugReport(GnssDebugReport& report); 514 /* get AGC information from system status and fill it */ 515 void getAgcInformation(GnssMeasurementsNotification& measurements, int msInWeek); 516 /* get Data information from system status and fill it */ 517 void getDataInformation(GnssDataNotification& data, int msInWeek); 518 519 /*==== SYSTEM STATUS ================================================================*/ getSystemStatus(void)520 inline SystemStatus* getSystemStatus(void) { return mSystemStatus; } getServerUrl(void)521 std::string& getServerUrl(void) { return mServerUrl; } getMoServerUrl(void)522 std::string& getMoServerUrl(void) { return mMoServerUrl; } 523 524 /*==== CONVERSION ===================================================================*/ 525 static uint32_t convertSuplVersion(const GnssConfigSuplVersion suplVersion); 526 static uint32_t convertLppProfile(const GnssConfigLppProfile lppProfile); 527 static uint32_t convertEP4ES(const GnssConfigEmergencyPdnForEmergencySupl); 528 static uint32_t convertSuplEs(const GnssConfigSuplEmergencyServices suplEmergencyServices); 529 static uint32_t convertLppeCp(const GnssConfigLppeControlPlaneMask lppeControlPlaneMask); 530 static uint32_t convertLppeUp(const GnssConfigLppeUserPlaneMask lppeUserPlaneMask); 531 static uint32_t convertAGloProt(const GnssConfigAGlonassPositionProtocolMask); 532 static uint32_t convertSuplMode(const GnssConfigSuplModeMask suplModeMask); 533 static void convertSatelliteInfo(std::vector<GnssDebugSatelliteInfo>& out, 534 const GnssSvType& in_constellation, 535 const SystemStatusReports& in); 536 static bool convertToGnssSvIdConfig( 537 const std::vector<GnssSvIdSource>& blacklistedSvIds, GnssSvIdConfig& config); 538 static void convertFromGnssSvIdConfig( 539 const GnssSvIdConfig& svConfig, std::vector<GnssSvIdSource>& blacklistedSvIds); 540 static void convertGnssSvIdMaskToList( 541 uint64_t svIdMask, std::vector<GnssSvIdSource>& svIds, 542 GnssSvId initialSvId, GnssSvType svType); 543 544 void injectLocationCommand(double latitude, double longitude, float accuracy); 545 void injectLocationExtCommand(const GnssLocationInfoNotification &locationInfo); 546 547 void injectTimeCommand(int64_t time, int64_t timeReference, int32_t uncertainty); 548 void blockCPICommand(double latitude, double longitude, float accuracy, 549 int blockDurationMsec, double latLonDiffThreshold); 550 551 /* ==== MISCELLANEOUS ================================================================== */ 552 /* ======== COMMANDS ====(Called from Client Thread)==================================== */ 553 void getPowerStateChangesCommand(void* powerStateCb); 554 /* ======== UTILITIES ================================================================== */ 555 void reportPowerStateIfChanged(); savePowerStateCallback(powerStateCallback powerStateCb)556 void savePowerStateCallback(powerStateCallback powerStateCb){ mPowerStateCb = powerStateCb; } getPowerState()557 bool getPowerState() { return mPowerOn; } getSystemPowerState()558 inline PowerStateType getSystemPowerState() { return mSystemPowerState; } 559 setAllowFlpNetworkFixes(uint32_t allow)560 void setAllowFlpNetworkFixes(uint32_t allow) { mAllowFlpNetworkFixes = allow; } getAllowFlpNetworkFixes()561 uint32_t getAllowFlpNetworkFixes() { return mAllowFlpNetworkFixes; } 562 void setSuplHostServer(const char* server, int port, LocServerType type); 563 void notifyClientOfCachedLocationSystemInfo(LocationAPI* client, 564 const LocationCallbacks& callbacks); 565 void updateSystemPowerStateCommand(PowerStateType systemPowerState); 566 567 /*==== DGnss Usable Report Flag ====================================================*/ setDGnssUsableFLag(bool dGnssNeedReport)568 inline void setDGnssUsableFLag(bool dGnssNeedReport) { mDGnssNeedReport = dGnssNeedReport;} 569 }; 570 571 #endif //GNSS_ADAPTER_H 572