1 /* Copyright (c) 2017-2019 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 LOCATION_INTERFACE_H 30 #define LOCATION_INTERFACE_H 31 32 #include <LocationAPI.h> 33 #include <gps_extended_c.h> 34 35 /* Used for callback to deliver GNSS energy consumed */ 36 /** @fn 37 @brief Used by query API that retrieves energy consumed by 38 modem GNSS engine. 39 40 @param gnssEnergyConsumedFromFirstBoot: 41 Energy consumed by the GNSS engine since the first bootup 42 in units of 0.1 milli watt seconds. 43 A value of 0xffffffffffffffff indicates an invalid reading. 44 */ 45 typedef std::function<void( 46 uint64_t gnssEnergyConsumedFromFirstBoot 47 )> GnssEnergyConsumedCallback; 48 49 typedef void (*removeClientCompleteCallback)(LocationAPI* client); 50 51 struct GnssInterface { 52 size_t size; 53 void (*initialize)(void); 54 void (*deinitialize)(void); 55 void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks); 56 void (*removeClient)(LocationAPI* client, removeClientCompleteCallback rmClientCb); 57 void (*requestCapabilities)(LocationAPI* client); 58 uint32_t (*startTracking)(LocationAPI* client, TrackingOptions&); 59 void (*updateTrackingOptions)(LocationAPI* client, uint32_t id, TrackingOptions&); 60 void (*stopTracking)(LocationAPI* client, uint32_t id); 61 void (*gnssNiResponse)(LocationAPI* client, uint32_t id, GnssNiResponse response); 62 void (*setControlCallbacks)(LocationControlCallbacks& controlCallbacks); 63 uint32_t (*enable)(LocationTechnologyType techType); 64 void (*disable)(uint32_t id); 65 uint32_t* (*gnssUpdateConfig)(GnssConfig config); 66 uint32_t* (*gnssGetConfig)(GnssConfigFlagsMask config); 67 void (*gnssUpdateSvTypeConfig)(GnssSvTypeConfig& config); 68 void (*gnssGetSvTypeConfig)(GnssSvTypeConfigCallback& callback); 69 void (*gnssResetSvTypeConfig)(); 70 uint32_t (*gnssDeleteAidingData)(GnssAidingData& data); 71 void (*gnssUpdateXtraThrottle)(const bool enabled); 72 void (*injectLocation)(double latitude, double longitude, float accuracy); 73 void (*injectTime)(int64_t time, int64_t timeReference, int32_t uncertainty); 74 void (*agpsInit)(const AgpsCbInfo& cbInfo); 75 void (*agpsDataConnOpen)(AGpsExtType agpsType, const char* apnName, int apnLen, int ipType); 76 void (*agpsDataConnClosed)(AGpsExtType agpsType); 77 void (*agpsDataConnFailed)(AGpsExtType agpsType); 78 void (*getDebugReport)(GnssDebugReport& report); 79 void (*updateConnectionStatus)(bool connected, int8_t type, bool roaming, 80 NetworkHandle networkHandle); 81 void (*odcpiInit)(const OdcpiRequestCallback& callback); 82 void (*odcpiInject)(const Location& location); 83 void (*blockCPI)(double latitude, double longitude, float accuracy, 84 int blockDurationMsec, double latLonDiffThreshold); 85 void (*getGnssEnergyConsumed)(GnssEnergyConsumedCallback energyConsumedCb); 86 void (*enableNfwLocationAccess)(bool enable); 87 void (*nfwInit)(const NfwCbInfo& cbInfo); 88 void (*getPowerStateChanges)(void* powerStateCb); 89 void (*injectLocationExt)(const GnssLocationInfoNotification &locationInfo); 90 void (*updateBatteryStatus)(bool charging); 91 void (*updateSystemPowerState)(PowerStateType systemPowerState); 92 uint32_t (*setConstrainedTunc) (bool enable, float tuncConstraint, uint32_t energyBudget); 93 uint32_t (*setPositionAssistedClockEstimator) (bool enable); 94 uint32_t (*gnssUpdateSvConfig)(const GnssSvTypeConfig& svTypeConfig, 95 const GnssSvIdConfig& svIdConfig); 96 uint32_t (*gnssResetSvConfig)(); 97 uint32_t (*configLeverArm)(const LeverArmConfigInfo& configInfo); 98 }; 99 100 struct BatchingInterface { 101 size_t size; 102 void (*initialize)(void); 103 void (*deinitialize)(void); 104 void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks); 105 void (*removeClient)(LocationAPI* client, removeClientCompleteCallback rmClientCb); 106 void (*requestCapabilities)(LocationAPI* client); 107 uint32_t (*startBatching)(LocationAPI* client, BatchingOptions&); 108 void (*stopBatching)(LocationAPI* client, uint32_t id); 109 void (*updateBatchingOptions)(LocationAPI* client, uint32_t id, BatchingOptions&); 110 void (*getBatchedLocations)(LocationAPI* client, uint32_t id, size_t count); 111 }; 112 113 struct GeofenceInterface { 114 size_t size; 115 void (*initialize)(void); 116 void (*deinitialize)(void); 117 void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks); 118 void (*removeClient)(LocationAPI* client, removeClientCompleteCallback rmClientCb); 119 void (*requestCapabilities)(LocationAPI* client); 120 uint32_t* (*addGeofences)(LocationAPI* client, size_t count, GeofenceOption*, GeofenceInfo*); 121 void (*removeGeofences)(LocationAPI* client, size_t count, uint32_t* ids); 122 void (*modifyGeofences)(LocationAPI* client, size_t count, uint32_t* ids, 123 GeofenceOption* options); 124 void (*pauseGeofences)(LocationAPI* client, size_t count, uint32_t* ids); 125 void (*resumeGeofences)(LocationAPI* client, size_t count, uint32_t* ids); 126 }; 127 128 #endif /* LOCATION_INTERFACE_H */ 129