location_interface.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /* Copyright (c) 2017-2021 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. #ifndef LOCATION_INTERFACE_H
  29. #define LOCATION_INTERFACE_H
  30. #include <LocationAPI.h>
  31. #include <gps_extended_c.h>
  32. #include <functional>
  33. /* Used for callback to deliver GNSS energy consumed */
  34. /** @fn
  35. @brief Used by query API that retrieves energy consumed by
  36. modem GNSS engine.
  37. @param gnssEnergyConsumedFromFirstBoot:
  38. Energy consumed by the GNSS engine since the first bootup
  39. in units of 0.1 milli watt seconds.
  40. A value of 0xffffffffffffffff indicates an invalid reading.
  41. */
  42. typedef std::function<void(
  43. uint64_t gnssEnergyConsumedFromFirstBoot
  44. )> GnssEnergyConsumedCallback;
  45. typedef void (*removeClientCompleteCallback)(LocationAPI* client);
  46. struct GnssInterface {
  47. size_t size;
  48. void (*initialize)(void);
  49. void (*deinitialize)(void);
  50. void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks);
  51. void (*removeClient)(LocationAPI* client, removeClientCompleteCallback rmClientCb);
  52. void (*requestCapabilities)(LocationAPI* client);
  53. uint32_t (*startTracking)(LocationAPI* client, TrackingOptions&);
  54. void (*updateTrackingOptions)(LocationAPI* client, uint32_t id, TrackingOptions&);
  55. void (*stopTracking)(LocationAPI* client, uint32_t id);
  56. void (*gnssNiResponse)(LocationAPI* client, uint32_t id, GnssNiResponse response);
  57. void (*setControlCallbacks)(LocationControlCallbacks& controlCallbacks);
  58. uint32_t (*enable)(LocationTechnologyType techType);
  59. void (*disable)(uint32_t id);
  60. uint32_t* (*gnssUpdateConfig)(const GnssConfig& config);
  61. uint32_t* (*gnssGetConfig)(GnssConfigFlagsMask config);
  62. void (*gnssUpdateSvTypeConfig)(GnssSvTypeConfig& config);
  63. void (*gnssGetSvTypeConfig)(GnssSvTypeConfigCallback& callback);
  64. void (*gnssResetSvTypeConfig)();
  65. uint32_t (*gnssDeleteAidingData)(GnssAidingData& data);
  66. void (*gnssUpdateXtraThrottle)(const bool enabled);
  67. void (*injectLocation)(double latitude, double longitude, float accuracy);
  68. void (*injectTime)(int64_t time, int64_t timeReference, int32_t uncertainty);
  69. void (*agpsInit)(const AgpsCbInfo& cbInfo);
  70. void (*agpsDataConnOpen)(AGpsExtType agpsType, const char* apnName, int apnLen, int ipType);
  71. void (*agpsDataConnClosed)(AGpsExtType agpsType);
  72. void (*agpsDataConnFailed)(AGpsExtType agpsType);
  73. void (*getDebugReport)(GnssDebugReport& report);
  74. void (*updateConnectionStatus)(bool connected, int8_t type, bool roaming,
  75. NetworkHandle networkHandle, std::string& apn);
  76. void (*odcpiInit)(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority);
  77. void (*odcpiInject)(const Location& location);
  78. void (*blockCPI)(double latitude, double longitude, float accuracy,
  79. int blockDurationMsec, double latLonDiffThreshold);
  80. void (*getGnssEnergyConsumed)(GnssEnergyConsumedCallback energyConsumedCb);
  81. void (*enableNfwLocationAccess)(std::vector<std::string>& enabledNfws);
  82. void (*nfwInit)(const NfwCbInfo& cbInfo);
  83. void (*getPowerStateChanges)(std::function<void(bool)> powerStateCb);
  84. void (*injectLocationExt)(const GnssLocationInfoNotification &locationInfo);
  85. void (*updateBatteryStatus)(bool charging);
  86. void (*updateSystemPowerState)(PowerStateType systemPowerState);
  87. uint32_t (*setConstrainedTunc) (bool enable, float tuncConstraint, uint32_t energyBudget);
  88. uint32_t (*setPositionAssistedClockEstimator) (bool enable);
  89. uint32_t (*gnssUpdateSvConfig)(const GnssSvTypeConfig& constellationEnablementConfig,
  90. const GnssSvIdConfig& blacklistSvConfig);
  91. uint32_t (*configLeverArm)(const LeverArmConfigInfo& configInfo);
  92. bool (*measCorrInit)(const measCorrSetCapabilitiesCb setCapabilitiesCb);
  93. bool (*measCorrSetCorrections)(const GnssMeasurementCorrections gnssMeasCorr);
  94. void (*measCorrClose)();
  95. uint32_t (*antennaInfoInit)(const antennaInfoCb antennaInfoCallback);
  96. void (*antennaInfoClose) ();
  97. uint32_t (*configRobustLocation)(bool enable, bool enableForE911);
  98. uint32_t (*configMinGpsWeek)(uint16_t minGpsWeek);
  99. uint32_t (*configDeadReckoningEngineParams)(const DeadReckoningEngineConfig& dreConfig);
  100. void (*updateNTRIPGGAConsent)(bool consentAccepted);
  101. void (*enablePPENtripStream)(const GnssNtripConnectionParams& params, bool enableRTKEngine);
  102. void (*disablePPENtripStream)();
  103. uint32_t (*gnssUpdateSecondaryBandConfig)(const GnssSvTypeConfig& secondaryBandConfig);
  104. uint32_t (*gnssGetSecondaryBandConfig)();
  105. void (*resetNetworkInfo)();
  106. uint32_t (*configEngineRunState)(PositioningEngineMask engType,
  107. LocEngineRunState engState);
  108. uint32_t (*configOutputNmeaTypes)(GnssNmeaTypesMask enabledNmeaTypes);
  109. void (*powerIndicationInit)(const powerIndicationCb powerIndicationCallback);
  110. void (*powerIndicationRequest)();
  111. void (*setAddressRequestCb)(std::function<void(const Location&)> addressRequestCb);
  112. void (*injectLocationAndAddr)(const Location& location, const GnssCivicAddress& addr);
  113. uint32_t (*setOptInStatus)(bool userConsent);
  114. };
  115. struct BatchingInterface {
  116. size_t size;
  117. void (*initialize)(void);
  118. void (*deinitialize)(void);
  119. void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks);
  120. void (*removeClient)(LocationAPI* client, removeClientCompleteCallback rmClientCb);
  121. void (*requestCapabilities)(LocationAPI* client);
  122. uint32_t (*startBatching)(LocationAPI* client, BatchingOptions&);
  123. void (*stopBatching)(LocationAPI* client, uint32_t id);
  124. void (*updateBatchingOptions)(LocationAPI* client, uint32_t id, BatchingOptions&);
  125. void (*getBatchedLocations)(LocationAPI* client, uint32_t id, size_t count);
  126. void (*updateSystemPowerState)(PowerStateType systemPowerState);
  127. };
  128. struct GeofenceInterface {
  129. size_t size;
  130. void (*initialize)(void);
  131. void (*deinitialize)(void);
  132. void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks);
  133. void (*removeClient)(LocationAPI* client, removeClientCompleteCallback rmClientCb);
  134. void (*requestCapabilities)(LocationAPI* client);
  135. uint32_t* (*addGeofences)(LocationAPI* client, size_t count, GeofenceOption*, GeofenceInfo*);
  136. void (*removeGeofences)(LocationAPI* client, size_t count, uint32_t* ids);
  137. void (*modifyGeofences)(LocationAPI* client, size_t count, uint32_t* ids,
  138. GeofenceOption* options);
  139. void (*pauseGeofences)(LocationAPI* client, size_t count, uint32_t* ids);
  140. void (*resumeGeofences)(LocationAPI* client, size_t count, uint32_t* ids);
  141. void (*updateSystemPowerState)(PowerStateType systemPowerState);
  142. };
  143. #endif /* LOCATION_INTERFACE_H */