location_interface.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. /*
  29. Changes from Qualcomm Innovation Center are provided under the following license:
  30. Copyright (c) 2022, 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  31. Redistribution and use in source and binary forms, with or without
  32. modification, are permitted (subject to the limitations in the
  33. disclaimer below) provided that the following conditions are met:
  34. * Redistributions of source code must retain the above copyright
  35. notice, this list of conditions and the following disclaimer.
  36. * Redistributions in binary form must reproduce the above
  37. copyright notice, this list of conditions and the following
  38. disclaimer in the documentation and/or other materials provided
  39. with the distribution.
  40. * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
  41. contributors may be used to endorse or promote products derived
  42. from this software without specific prior written permission.
  43. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
  44. GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
  45. HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
  46. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  47. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  48. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  49. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  50. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  51. GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  52. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  53. IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  54. OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  55. IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  56. */
  57. #ifndef LOCATION_INTERFACE_H
  58. #define LOCATION_INTERFACE_H
  59. #include <LocationAPI.h>
  60. #include <gps_extended_c.h>
  61. #include <functional>
  62. /* Used for callback to deliver GNSS energy consumed */
  63. /** @fn
  64. @brief Used by query API that retrieves energy consumed by
  65. modem GNSS engine.
  66. @param gnssEnergyConsumedFromFirstBoot:
  67. Energy consumed by the GNSS engine since the first bootup
  68. in units of 0.1 milli watt seconds.
  69. A value of 0xffffffffffffffff indicates an invalid reading.
  70. */
  71. typedef std::function<void(
  72. uint64_t gnssEnergyConsumedFromFirstBoot
  73. )> GnssEnergyConsumedCallback;
  74. typedef void (*removeClientCompleteCallback)(LocationAPI* client);
  75. struct GnssInterface {
  76. size_t size;
  77. void (*initialize)(void);
  78. void (*deinitialize)(void);
  79. void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks);
  80. void (*removeClient)(LocationAPI* client, removeClientCompleteCallback rmClientCb);
  81. void (*requestCapabilities)(LocationAPI* client);
  82. uint32_t (*startTracking)(LocationAPI* client, TrackingOptions&);
  83. void (*updateTrackingOptions)(LocationAPI* client, uint32_t id, TrackingOptions&);
  84. void (*stopTracking)(LocationAPI* client, uint32_t id);
  85. void (*gnssNiResponse)(LocationAPI* client, uint32_t id, GnssNiResponse response);
  86. void (*setControlCallbacks)(LocationControlCallbacks& controlCallbacks);
  87. uint32_t (*enable)(LocationTechnologyType techType);
  88. void (*disable)(uint32_t id);
  89. uint32_t* (*gnssUpdateConfig)(const GnssConfig& config);
  90. uint32_t* (*gnssGetConfig)(GnssConfigFlagsMask config);
  91. void (*gnssUpdateSvTypeConfig)(GnssSvTypeConfig& config);
  92. void (*gnssGetSvTypeConfig)(GnssSvTypeConfigCallback& callback);
  93. void (*gnssResetSvTypeConfig)();
  94. uint32_t (*gnssDeleteAidingData)(GnssAidingData& data);
  95. void (*gnssUpdateXtraThrottle)(const bool enabled);
  96. void (*injectLocation)(double latitude, double longitude, float accuracy);
  97. void (*injectTime)(int64_t time, int64_t timeReference, int32_t uncertainty);
  98. void (*agpsInit)(const AgpsCbInfo& cbInfo);
  99. void (*agpsDataConnOpen)(AGpsExtType agpsType, const char* apnName, int apnLen, int ipType);
  100. void (*agpsDataConnClosed)(AGpsExtType agpsType);
  101. void (*agpsDataConnFailed)(AGpsExtType agpsType);
  102. void (*getDebugReport)(GnssDebugReport& report);
  103. void (*updateConnectionStatus)(bool connected, int8_t type, bool roaming,
  104. NetworkHandle networkHandle, std::string& apn);
  105. void (*odcpiInit)(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority,
  106. OdcpiCallbackTypeMask typeMask);
  107. void (*deRegisterOdcpi)(OdcpiPrioritytype priority, OdcpiCallbackTypeMask typeMask);
  108. void (*odcpiInject)(const Location& location);
  109. void (*blockCPI)(double latitude, double longitude, float accuracy,
  110. int blockDurationMsec, double latLonDiffThreshold);
  111. void (*getGnssEnergyConsumed)(GnssEnergyConsumedCallback energyConsumedCb);
  112. void (*enableNfwLocationAccess)(std::vector<std::string>& enabledNfws);
  113. void (*nfwInit)(const NfwCbInfo& cbInfo);
  114. void (*getPowerStateChanges)(std::function<void(bool)> powerStateCb);
  115. void (*injectLocationExt)(const GnssLocationInfoNotification &locationInfo);
  116. void (*updateBatteryStatus)(bool charging);
  117. void (*updateSystemPowerState)(PowerStateType systemPowerState);
  118. uint32_t (*setConstrainedTunc) (bool enable, float tuncConstraint, uint32_t energyBudget);
  119. uint32_t (*setPositionAssistedClockEstimator) (bool enable);
  120. uint32_t (*gnssUpdateSvConfig)(const GnssSvTypeConfig& constellationEnablementConfig,
  121. const GnssSvIdConfig& blacklistSvConfig);
  122. uint32_t (*configLeverArm)(const LeverArmConfigInfo& configInfo);
  123. bool (*measCorrInit)(const measCorrSetCapabilitiesCb setCapabilitiesCb);
  124. bool (*measCorrSetCorrections)(const GnssMeasurementCorrections gnssMeasCorr);
  125. void (*measCorrClose)();
  126. uint32_t (*antennaInfoInit)(const antennaInfoCb antennaInfoCallback);
  127. void (*antennaInfoClose) ();
  128. uint32_t (*configRobustLocation)(bool enable, bool enableForE911);
  129. uint32_t (*configMinGpsWeek)(uint16_t minGpsWeek);
  130. uint32_t (*configDeadReckoningEngineParams)(const DeadReckoningEngineConfig& dreConfig);
  131. void (*updateNTRIPGGAConsent)(bool consentAccepted);
  132. void (*enablePPENtripStream)(const GnssNtripConnectionParams& params, bool enableRTKEngine);
  133. void (*disablePPENtripStream)();
  134. uint32_t (*gnssUpdateSecondaryBandConfig)(const GnssSvTypeConfig& secondaryBandConfig);
  135. uint32_t (*gnssGetSecondaryBandConfig)();
  136. void (*resetNetworkInfo)();
  137. uint32_t (*configEngineRunState)(PositioningEngineMask engType,
  138. LocEngineRunState engState);
  139. uint32_t (*configOutputNmeaTypes)(GnssNmeaTypesMask enabledNmeaTypes);
  140. void (*powerIndicationInit)(const powerIndicationCb powerIndicationCallback);
  141. void (*powerIndicationRequest)();
  142. void (*setAddressRequestCb)(std::function<void(const Location&)> addressRequestCb);
  143. void (*injectLocationAndAddr)(const Location& location, const GnssCivicAddress& addr);
  144. uint32_t (*setOptInStatus)(bool userConsent);
  145. };
  146. struct BatchingInterface {
  147. size_t size;
  148. void (*initialize)(void);
  149. void (*deinitialize)(void);
  150. void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks);
  151. void (*removeClient)(LocationAPI* client, removeClientCompleteCallback rmClientCb);
  152. void (*requestCapabilities)(LocationAPI* client);
  153. uint32_t (*startBatching)(LocationAPI* client, BatchingOptions&);
  154. void (*stopBatching)(LocationAPI* client, uint32_t id);
  155. void (*updateBatchingOptions)(LocationAPI* client, uint32_t id, BatchingOptions&);
  156. void (*getBatchedLocations)(LocationAPI* client, uint32_t id, size_t count);
  157. void (*updateSystemPowerState)(PowerStateType systemPowerState);
  158. };
  159. struct GeofenceInterface {
  160. size_t size;
  161. void (*initialize)(void);
  162. void (*deinitialize)(void);
  163. void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks);
  164. void (*removeClient)(LocationAPI* client, removeClientCompleteCallback rmClientCb);
  165. void (*requestCapabilities)(LocationAPI* client);
  166. uint32_t* (*addGeofences)(LocationAPI* client, size_t count, GeofenceOption*, GeofenceInfo*);
  167. void (*removeGeofences)(LocationAPI* client, size_t count, uint32_t* ids);
  168. void (*modifyGeofences)(LocationAPI* client, size_t count, uint32_t* ids,
  169. GeofenceOption* options);
  170. void (*pauseGeofences)(LocationAPI* client, size_t count, uint32_t* ids);
  171. void (*resumeGeofences)(LocationAPI* client, size_t count, uint32_t* ids);
  172. void (*updateSystemPowerState)(PowerStateType systemPowerState);
  173. };
  174. #endif /* LOCATION_INTERFACE_H */