Home | History | Annotate | Download | only in location
      1 /* Copyright (c) 2017 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_H
     30 #define LOCATION_H
     31 
     32 #include <vector>
     33 #include <stdint.h>
     34 #include <functional>
     35 #include <list>
     36 
     37 #define GNSS_NI_REQUESTOR_MAX  256
     38 #define GNSS_NI_MESSAGE_ID_MAX 2048
     39 #define GNSS_SV_MAX 64
     40 #define GNSS_MEASUREMENTS_MAX 64
     41 #define GNSS_UTC_TIME_OFFSET   (3657)
     42 
     43 #define GNSS_BUGREPORT_GPS_MIN  (1)
     44 #define GNSS_BUGREPORT_SBAS_MIN (120)
     45 #define GNSS_BUGREPORT_GLO_MIN  (1)
     46 #define GNSS_BUGREPORT_QZSS_MIN (193)
     47 #define GNSS_BUGREPORT_BDS_MIN  (1)
     48 #define GNSS_BUGREPORT_GAL_MIN  (1)
     49 
     50 typedef enum {
     51     LOCATION_ERROR_SUCCESS = 0,
     52     LOCATION_ERROR_GENERAL_FAILURE,
     53     LOCATION_ERROR_CALLBACK_MISSING,
     54     LOCATION_ERROR_INVALID_PARAMETER,
     55     LOCATION_ERROR_ID_EXISTS,
     56     LOCATION_ERROR_ID_UNKNOWN,
     57     LOCATION_ERROR_ALREADY_STARTED,
     58     LOCATION_ERROR_GEOFENCES_AT_MAX,
     59     LOCATION_ERROR_NOT_SUPPORTED
     60 } LocationError;
     61 
     62 // Flags to indicate which values are valid in a Location
     63 typedef uint16_t LocationFlagsMask;
     64 typedef enum {
     65     LOCATION_HAS_LAT_LONG_BIT          = (1<<0), // location has valid latitude and longitude
     66     LOCATION_HAS_ALTITUDE_BIT          = (1<<1), // location has valid altitude
     67     LOCATION_HAS_SPEED_BIT             = (1<<2), // location has valid speed
     68     LOCATION_HAS_BEARING_BIT           = (1<<3), // location has valid bearing
     69     LOCATION_HAS_ACCURACY_BIT          = (1<<4), // location has valid accuracy
     70     LOCATION_HAS_VERTICAL_ACCURACY_BIT = (1<<5), // location has valid vertical accuracy
     71     LOCATION_HAS_SPEED_ACCURACY_BIT    = (1<<6), // location has valid speed accuracy
     72     LOCATION_HAS_BEARING_ACCURACY_BIT  = (1<<7), // location has valid bearing accuracy
     73 } LocationFlagsBits;
     74 
     75 typedef uint16_t LocationTechnologyMask;
     76 typedef enum {
     77     LOCATION_TECHNOLOGY_GNSS_BIT     = (1<<0), // location was calculated using GNSS
     78     LOCATION_TECHNOLOGY_CELL_BIT     = (1<<1), // location was calculated using Cell
     79     LOCATION_TECHNOLOGY_WIFI_BIT     = (1<<2), // location was calculated using WiFi
     80     LOCATION_TECHNOLOGY_SENSORS_BIT  = (1<<3), // location was calculated using Sensors
     81 } LocationTechnologyBits;
     82 
     83 typedef enum {
     84     LOCATION_RELIABILITY_NOT_SET = 0,
     85     LOCATION_RELIABILITY_VERY_LOW,
     86     LOCATION_RELIABILITY_LOW,
     87     LOCATION_RELIABILITY_MEDIUM,
     88     LOCATION_RELIABILITY_HIGH,
     89 } LocationReliability;
     90 
     91 typedef uint32_t GnssLocationInfoFlagMask;
     92 typedef enum {
     93     GNSS_LOCATION_INFO_ALTITUDE_MEAN_SEA_LEVEL_BIT      = (1<<0), // valid altitude mean sea level
     94     GNSS_LOCATION_INFO_DOP_BIT                          = (1<<1), // valid pdop, hdop, and vdop
     95     GNSS_LOCATION_INFO_MAGNETIC_DEVIATION_BIT           = (1<<2), // valid magnetic deviation
     96     GNSS_LOCATION_INFO_HOR_RELIABILITY_BIT              = (1<<3), // valid horizontal reliability
     97     GNSS_LOCATION_INFO_VER_RELIABILITY_BIT              = (1<<4), // valid vertical reliability
     98     GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MAJOR_BIT = (1<<5), // valid elipsode semi major
     99     GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MINOR_BIT = (1<<6), // valid elipsode semi minor
    100     GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_AZIMUTH_BIT    = (1<<7),// valid accuracy elipsode azimuth
    101 } GnssLocationInfoFlagBits;
    102 
    103 typedef enum {
    104     GEOFENCE_BREACH_ENTER = 0,
    105     GEOFENCE_BREACH_EXIT,
    106     GEOFENCE_BREACH_DWELL_IN,
    107     GEOFENCE_BREACH_DWELL_OUT,
    108     GEOFENCE_BREACH_UNKNOWN,
    109 } GeofenceBreachType;
    110 
    111 typedef uint16_t GeofenceBreachTypeMask;
    112 typedef enum {
    113     GEOFENCE_BREACH_ENTER_BIT     = (1<<0),
    114     GEOFENCE_BREACH_EXIT_BIT      = (1<<1),
    115     GEOFENCE_BREACH_DWELL_IN_BIT  = (1<<2),
    116     GEOFENCE_BREACH_DWELL_OUT_BIT = (1<<3),
    117 } GeofenceBreachTypeBits;
    118 
    119 typedef enum {
    120     GEOFENCE_STATUS_AVAILABILE_NO = 0,
    121     GEOFENCE_STATUS_AVAILABILE_YES,
    122 } GeofenceStatusAvailable;
    123 
    124 typedef uint32_t LocationCapabilitiesMask;
    125 typedef enum {
    126     // supports startTracking API with minInterval param
    127     LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT           = (1<<0),
    128     // supports startBatching API with minInterval param
    129     LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT           = (1<<1),
    130     // supports startTracking API with minDistance param
    131     LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT       = (1<<2),
    132     // supports startBatching API with minDistance param
    133     LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT       = (1<<3),
    134     // supports addGeofences API
    135     LOCATION_CAPABILITIES_GEOFENCE_BIT                      = (1<<4),
    136     // supports GnssMeasurementsCallback
    137     LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT             = (1<<5),
    138     // supports startTracking/startBatching API with LocationOptions.mode of MSB (Ms Based)
    139     LOCATION_CAPABILITIES_GNSS_MSB_BIT                      = (1<<6),
    140     // supports startTracking/startBatching API with LocationOptions.mode of MSA (MS Assisted)
    141     LOCATION_CAPABILITIES_GNSS_MSA_BIT                      = (1<<7),
    142     // supports debug nmea sentences in the debugNmeaCallback
    143     LOCATION_CAPABILITIES_DEBUG_NMEA_BIT                    = (1<<8),
    144     // support outdoor trip batching
    145     LOCATION_CAPABILITIES_OUTDOOR_TRIP_BATCHING_BIT         = (1<<9)
    146 } LocationCapabilitiesBits;
    147 
    148 typedef enum {
    149     LOCATION_TECHNOLOGY_TYPE_GNSS = 0,
    150 } LocationTechnologyType;
    151 
    152 // Configures how GPS is locked when GPS is disabled (through GnssDisable)
    153 typedef enum {
    154     GNSS_CONFIG_GPS_LOCK_NONE = 0, // gps is not locked when GPS is disabled (GnssDisable)
    155     GNSS_CONFIG_GPS_LOCK_MO,       // gps mobile originated (MO) is locked when GPS is disabled
    156     GNSS_CONFIG_GPS_LOCK_NI,       // gps network initiated (NI) is locked when GPS is disabled
    157     GNSS_CONFIG_GPS_LOCK_MO_AND_NI,// gps MO and NI is locked when GPS is disabled
    158 } GnssConfigGpsLock;
    159 
    160 // SUPL version
    161 typedef enum {
    162     GNSS_CONFIG_SUPL_VERSION_1_0_0 = 1,
    163     GNSS_CONFIG_SUPL_VERSION_2_0_0,
    164     GNSS_CONFIG_SUPL_VERSION_2_0_2,
    165 } GnssConfigSuplVersion;
    166 
    167 // LTE Positioning Profile
    168 typedef enum {
    169     GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE = 0,              // RRLP on LTE (Default)
    170     GNSS_CONFIG_LPP_PROFILE_USER_PLANE,                   // LPP User Plane (UP) on LTE
    171     GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE,                // LPP_Control_Plane (CP)
    172     GNSS_CONFIG_LPP_PROFILE_USER_PLANE_AND_CONTROL_PLANE, // Both LPP UP and CP
    173 } GnssConfigLppProfile;
    174 
    175 // Technology for LPPe Control Plane
    176 typedef uint16_t GnssConfigLppeControlPlaneMask;
    177 typedef enum {
    178     GNSS_CONFIG_LPPE_CONTROL_PLANE_DBH_BIT                  = (1<<0), // DBH
    179     GNSS_CONFIG_LPPE_CONTROL_PLANE_WLAN_AP_MEASUREMENTS_BIT = (1<<1), // WLAN_AP_MEASUREMENTS
    180     GNSS_CONFIG_LPPE_CONTROL_PLANE_SRN_AP_MEASUREMENTS_BIT = (1<<2), // SRN_AP_MEASUREMENTS
    181     GNSS_CONFIG_LPPE_CONTROL_PLANE_SENSOR_BARO_MEASUREMENTS_BIT = (1<<3),
    182                                                              // SENSOR_BARO_MEASUREMENTS
    183 } GnssConfigLppeControlPlaneBits;
    184 
    185 // Technology for LPPe User Plane
    186 typedef uint16_t GnssConfigLppeUserPlaneMask;
    187 typedef enum {
    188     GNSS_CONFIG_LPPE_USER_PLANE_DBH_BIT                  = (1<<0), // DBH
    189     GNSS_CONFIG_LPPE_USER_PLANE_WLAN_AP_MEASUREMENTS_BIT = (1<<1), // WLAN_AP_MEASUREMENTS
    190     GNSS_CONFIG_LPPE_USER_PLANE_SRN_AP_MEASUREMENTS_BIT = (1<<2), // SRN_AP_MEASUREMENTS
    191     GNSS_CONFIG_LPPE_USER_PLANE_SENSOR_BARO_MEASUREMENTS_BIT = (1<<3),
    192                                                             // SENSOR_BARO_MEASUREMENTS
    193 } GnssConfigLppeUserPlaneBits;
    194 
    195 // Positioning Protocol on A-GLONASS system
    196 typedef uint16_t GnssConfigAGlonassPositionProtocolMask;
    197 typedef enum {
    198     GNSS_CONFIG_RRC_CONTROL_PLANE_BIT = (1<<0),  // RRC Control Plane
    199     GNSS_CONFIG_RRLP_USER_PLANE_BIT   = (1<<1),  // RRLP User Plane
    200     GNSS_CONFIG_LLP_USER_PLANE_BIT    = (1<<2),  // LPP User Plane
    201     GNSS_CONFIG_LLP_CONTROL_PLANE_BIT = (1<<3),  // LPP Control Plane
    202 } GnssConfigAGlonassPositionProtocolBits;
    203 
    204 typedef enum {
    205     GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_NO = 0,
    206     GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_YES,
    207 } GnssConfigEmergencyPdnForEmergencySupl;
    208 
    209 typedef enum {
    210     GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO = 0,
    211     GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_YES,
    212 } GnssConfigSuplEmergencyServices;
    213 
    214 typedef uint16_t GnssConfigSuplModeMask;
    215 typedef enum {
    216     GNSS_CONFIG_SUPL_MODE_MSB_BIT = (1<<0),
    217     GNSS_CONFIG_SUPL_MODE_MSA_BIT = (1<<1),
    218 } GnssConfigSuplModeBits;
    219 
    220 typedef uint32_t GnssConfigFlagsMask;
    221 typedef enum {
    222     GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT                   = (1<<0),
    223     GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT               = (1<<1),
    224     GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT        = (1<<2),
    225     GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT                = (1<<3),
    226     GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT         = (1<<4),
    227     GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT            = (1<<5),
    228     GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT = (1<<6),
    229     GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT         = (1<<7),
    230     GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT                 = (1<<8),
    231     GNSS_CONFIG_FLAGS_SUPL_MODE_BIT                        = (1<<9),
    232 } GnssConfigFlagsBits;
    233 
    234 typedef enum {
    235     GNSS_NI_ENCODING_TYPE_NONE = 0,
    236     GNSS_NI_ENCODING_TYPE_GSM_DEFAULT,
    237     GNSS_NI_ENCODING_TYPE_UTF8,
    238     GNSS_NI_ENCODING_TYPE_UCS2,
    239 } GnssNiEncodingType;
    240 
    241 typedef enum {
    242     GNSS_NI_TYPE_VOICE = 0,
    243     GNSS_NI_TYPE_SUPL,
    244     GNSS_NI_TYPE_CONTROL_PLANE,
    245     GNSS_NI_TYPE_EMERGENCY_SUPL
    246 } GnssNiType;
    247 
    248 typedef uint16_t GnssNiOptionsMask;
    249 typedef enum {
    250     GNSS_NI_OPTIONS_NOTIFICATION_BIT     = (1<<0),
    251     GNSS_NI_OPTIONS_VERIFICATION_BIT     = (1<<1),
    252     GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT = (1<<2),
    253 } GnssNiOptionsBits;
    254 
    255 typedef enum {
    256     GNSS_NI_RESPONSE_ACCEPT = 1,
    257     GNSS_NI_RESPONSE_DENY,
    258     GNSS_NI_RESPONSE_NO_RESPONSE,
    259     GNSS_NI_RESPONSE_IGNORE,
    260 } GnssNiResponse;
    261 
    262 typedef enum {
    263     GNSS_SV_TYPE_UNKNOWN = 0,
    264     GNSS_SV_TYPE_GPS,
    265     GNSS_SV_TYPE_SBAS,
    266     GNSS_SV_TYPE_GLONASS,
    267     GNSS_SV_TYPE_QZSS,
    268     GNSS_SV_TYPE_BEIDOU,
    269     GNSS_SV_TYPE_GALILEO,
    270 } GnssSvType;
    271 
    272 typedef enum {
    273     GNSS_EPH_TYPE_UNKNOWN = 0,
    274     GNSS_EPH_TYPE_EPHEMERIS,
    275     GNSS_EPH_TYPE_ALMANAC,
    276 } GnssEphemerisType;
    277 
    278 typedef enum {
    279     GNSS_EPH_SOURCE_UNKNOWN = 0,
    280     GNSS_EPH_SOURCE_DEMODULATED,
    281     GNSS_EPH_SOURCE_SUPL_PROVIDED,
    282     GNSS_EPH_SOURCE_OTHER_SERVER_PROVIDED,
    283     GNSS_EPH_SOURCE_LOCAL,
    284 } GnssEphemerisSource;
    285 
    286 typedef enum {
    287     GNSS_EPH_HEALTH_UNKNOWN = 0,
    288     GNSS_EPH_HEALTH_GOOD,
    289     GNSS_EPH_HEALTH_BAD,
    290 } GnssEphemerisHealth;
    291 
    292 typedef uint16_t GnssSvOptionsMask;
    293 typedef enum {
    294     GNSS_SV_OPTIONS_HAS_EPHEMER_BIT = (1<<0),
    295     GNSS_SV_OPTIONS_HAS_ALMANAC_BIT = (1<<1),
    296     GNSS_SV_OPTIONS_USED_IN_FIX_BIT = (1<<2),
    297 } GnssSvOptionsBits;
    298 
    299 typedef enum {
    300     GNSS_ASSISTANCE_TYPE_SUPL = 0,
    301     GNSS_ASSISTANCE_TYPE_C2K,
    302 } GnssAssistanceType;
    303 
    304 typedef enum {
    305     GNSS_SUPL_MODE_STANDALONE = 0,
    306     GNSS_SUPL_MODE_MSB,
    307     GNSS_SUPL_MODE_MSA,
    308 } GnssSuplMode;
    309 
    310 typedef enum {
    311     BATCHING_MODE_ROUTINE = 0,
    312     BATCHING_MODE_TRIP
    313 } BatchingMode;
    314 
    315 typedef enum {
    316     BATCHING_STATUS_TRIP_COMPLETED = 0,
    317     BATCHING_STATUS_POSITION_AVAILABE,
    318     BATCHING_STATUS_POSITION_UNAVAILABLE
    319 } BatchingStatus;
    320 
    321 typedef uint16_t GnssMeasurementsAdrStateMask;
    322 typedef enum {
    323     GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_UNKNOWN         = 0,
    324     GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT       = (1<<0),
    325     GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT       = (1<<1),
    326     GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT  = (1<<2),
    327 } GnssMeasurementsAdrStateBits;
    328 
    329 typedef uint32_t GnssMeasurementsDataFlagsMask;
    330 typedef enum {
    331     GNSS_MEASUREMENTS_DATA_SV_ID_BIT                        = (1<<0),
    332     GNSS_MEASUREMENTS_DATA_SV_TYPE_BIT                      = (1<<1),
    333     GNSS_MEASUREMENTS_DATA_STATE_BIT                        = (1<<2),
    334     GNSS_MEASUREMENTS_DATA_RECEIVED_SV_TIME_BIT             = (1<<3),
    335     GNSS_MEASUREMENTS_DATA_RECEIVED_SV_TIME_UNCERTAINTY_BIT = (1<<4),
    336     GNSS_MEASUREMENTS_DATA_CARRIER_TO_NOISE_BIT             = (1<<5),
    337     GNSS_MEASUREMENTS_DATA_PSEUDORANGE_RATE_BIT             = (1<<6),
    338     GNSS_MEASUREMENTS_DATA_PSEUDORANGE_RATE_UNCERTAINTY_BIT = (1<<7),
    339     GNSS_MEASUREMENTS_DATA_ADR_STATE_BIT                    = (1<<8),
    340     GNSS_MEASUREMENTS_DATA_ADR_BIT                          = (1<<9),
    341     GNSS_MEASUREMENTS_DATA_ADR_UNCERTAINTY_BIT              = (1<<10),
    342     GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT            = (1<<11),
    343     GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT               = (1<<12),
    344     GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT                = (1<<13),
    345     GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT    = (1<<14),
    346     GNSS_MEASUREMENTS_DATA_MULTIPATH_INDICATOR_BIT          = (1<<15),
    347     GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT        = (1<<16),
    348     GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT       = (1<<17),
    349 } GnssMeasurementsDataFlagsBits;
    350 
    351 typedef uint32_t GnssMeasurementsStateMask;
    352 typedef enum {
    353     GNSS_MEASUREMENTS_STATE_UNKNOWN_BIT               = 0,
    354     GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT             = (1<<0),
    355     GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT              = (1<<1),
    356     GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT         = (1<<2),
    357     GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT           = (1<<3),
    358     GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT        = (1<<4),
    359     GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT           = (1<<5),
    360     GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT       = (1<<6),
    361     GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT       = (1<<7),
    362     GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT       = (1<<8),
    363     GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT  = (1<<9),
    364     GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT    = (1<<10),
    365     GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT = (1<<11),
    366     GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT     = (1<<12),
    367     GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT             = (1<<13),
    368 } GnssMeasurementsStateBits;
    369 
    370 typedef enum {
    371     GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_UNKNOWN = 0,
    372     GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_PRESENT,
    373     GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_NOT_PRESENT,
    374 } GnssMeasurementsMultipathIndicator;
    375 
    376 typedef uint32_t GnssMeasurementsClockFlagsMask;
    377 typedef enum {
    378     GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT                  = (1<<0),
    379     GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_BIT                         = (1<<1),
    380     GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT             = (1<<2),
    381     GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT                    = (1<<3),
    382     GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT                         = (1<<4),
    383     GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT             = (1<<5),
    384     GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_BIT                        = (1<<6),
    385     GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_UNCERTAINTY_BIT            = (1<<7),
    386     GNSS_MEASUREMENTS_CLOCK_FLAGS_HW_CLOCK_DISCONTINUITY_COUNT_BIT = (1<<8),
    387 } GnssMeasurementsClockFlagsBits;
    388 
    389 typedef uint32_t GnssAidingDataSvMask;
    390 typedef enum {
    391     GNSS_AIDING_DATA_SV_EPHEMERIS_BIT    = (1<<0), // ephemeris
    392     GNSS_AIDING_DATA_SV_ALMANAC_BIT      = (1<<1), // almanac
    393     GNSS_AIDING_DATA_SV_HEALTH_BIT       = (1<<2), // health
    394     GNSS_AIDING_DATA_SV_DIRECTION_BIT    = (1<<3), // direction
    395     GNSS_AIDING_DATA_SV_STEER_BIT        = (1<<4), // steer
    396     GNSS_AIDING_DATA_SV_ALMANAC_CORR_BIT = (1<<5), // almanac correction
    397     GNSS_AIDING_DATA_SV_BLACKLIST_BIT    = (1<<6), // blacklist SVs
    398     GNSS_AIDING_DATA_SV_SA_DATA_BIT      = (1<<7), // sensitivity assistance data
    399     GNSS_AIDING_DATA_SV_NO_EXIST_BIT     = (1<<8), // SV does not exist
    400     GNSS_AIDING_DATA_SV_IONOSPHERE_BIT   = (1<<9), // ionosphere correction
    401     GNSS_AIDING_DATA_SV_TIME_BIT         = (1<<10),// reset satellite time
    402 } GnssAidingDataSvBits;
    403 
    404 typedef uint32_t GnssAidingDataSvTypeMask;
    405 typedef enum {
    406     GNSS_AIDING_DATA_SV_TYPE_GPS_BIT      = (1<<0),
    407     GNSS_AIDING_DATA_SV_TYPE_GLONASS_BIT  = (1<<1),
    408     GNSS_AIDING_DATA_SV_TYPE_QZSS_BIT     = (1<<2),
    409     GNSS_AIDING_DATA_SV_TYPE_BEIDOU_BIT   = (1<<3),
    410     GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT  = (1<<4),
    411 } GnssAidingDataSvTypeBits;
    412 
    413 typedef struct {
    414     GnssAidingDataSvMask svMask;         // bitwise OR of GnssAidingDataSvBits
    415     GnssAidingDataSvTypeMask svTypeMask; // bitwise OR of GnssAidingDataSvTypeBits
    416 } GnssAidingDataSv;
    417 
    418 typedef uint32_t GnssAidingDataCommonMask;
    419 typedef enum {
    420     GNSS_AIDING_DATA_COMMON_POSITION_BIT      = (1<<0), // position estimate
    421     GNSS_AIDING_DATA_COMMON_TIME_BIT          = (1<<1), // reset all clock values
    422     GNSS_AIDING_DATA_COMMON_UTC_BIT           = (1<<2), // UTC estimate
    423     GNSS_AIDING_DATA_COMMON_RTI_BIT           = (1<<3), // RTI
    424     GNSS_AIDING_DATA_COMMON_FREQ_BIAS_EST_BIT = (1<<4), // frequency bias estimate
    425     GNSS_AIDING_DATA_COMMON_CELLDB_BIT        = (1<<5), // all celldb info
    426 } GnssAidingDataCommonBits;
    427 
    428 typedef struct {
    429     GnssAidingDataCommonMask mask; // bitwise OR of GnssAidingDataCommonBits
    430 } GnssAidingDataCommon;
    431 
    432 typedef struct {
    433     bool deleteAll;              // if true, delete all aiding data and ignore other params
    434     GnssAidingDataSv sv;         // SV specific aiding data
    435     GnssAidingDataCommon common; // common aiding data
    436 } GnssAidingData;
    437 
    438 typedef struct {
    439     size_t size;             // set to sizeof(Location)
    440     LocationFlagsMask flags; // bitwise OR of LocationFlagsBits to mark which params are valid
    441     uint64_t timestamp;      // UTC timestamp for location fix, milliseconds since January 1, 1970
    442     double latitude;         // in degrees
    443     double longitude;        // in degrees
    444     double altitude;         // in meters above the WGS 84 reference ellipsoid
    445     float speed;             // in meters per second
    446     float bearing;           // in degrees; range [0, 360)
    447     float accuracy;          // in meters
    448     float verticalAccuracy;  // in meters
    449     float speedAccuracy;     // in meters/second
    450     float bearingAccuracy;   // in degrees (0 to 359.999)
    451     LocationTechnologyMask techMask;
    452 } Location;
    453 
    454 typedef struct  {
    455     size_t size;          // set to sizeof(LocationOptions)
    456     uint32_t minInterval; // in milliseconds
    457     uint32_t minDistance; // in meters. if minDistance > 0, gnssSvCallback/gnssNmeaCallback/
    458                           // gnssMeasurementsCallback may not be called
    459     GnssSuplMode mode;    // Standalone/MS-Based/MS-Assisted
    460 } LocationOptions;
    461 
    462 typedef struct {
    463     size_t size;
    464     BatchingMode batchingMode;
    465 } BatchingOptions;
    466 
    467 typedef struct {
    468     size_t size;
    469     BatchingStatus batchingStatus;
    470 } BatchingStatusInfo;
    471 
    472 typedef struct {
    473     size_t size;                            // set to sizeof(GeofenceOption)
    474     GeofenceBreachTypeMask breachTypeMask;  // bitwise OR of GeofenceBreachTypeBits
    475     uint32_t responsiveness;                // in milliseconds
    476     uint32_t dwellTime;                     // in seconds
    477 } GeofenceOption;
    478 
    479 typedef struct  {
    480     size_t size;      // set to sizeof(GeofenceInfo)
    481     double latitude;  // in degrees
    482     double longitude; // in degrees
    483     double radius;    // in meters
    484 } GeofenceInfo;
    485 
    486 typedef struct {
    487     size_t size;             // set to sizeof(GeofenceBreachNotification)
    488     size_t count;            // number of ids in array
    489     uint32_t* ids;           // array of ids that have breached
    490     Location location;       // location associated with breach
    491     GeofenceBreachType type; // type of breach
    492     uint64_t timestamp;      // timestamp of breach
    493 } GeofenceBreachNotification;
    494 
    495 typedef struct {
    496     size_t size;                       // set to sizeof(GeofenceBreachNotification)
    497     GeofenceStatusAvailable available; // GEOFENCE_STATUS_AVAILABILE_NO/_YES
    498     LocationTechnologyType techType;   // GNSS
    499 } GeofenceStatusNotification;
    500 
    501 typedef struct {
    502     size_t size;                        // set to sizeof(GnssLocationInfo)
    503     GnssLocationInfoFlagMask flags;     // bitwise OR of GnssLocationInfoBits for param validity
    504     float altitudeMeanSeaLevel;         // altitude wrt mean sea level
    505     float pdop;                         // position dilusion of precision
    506     float hdop;                         // horizontal dilusion of precision
    507     float vdop;                         // vertical dilusion of precision
    508     float magneticDeviation;            // magnetic deviation
    509     LocationReliability horReliability; // horizontal reliability
    510     LocationReliability verReliability; // vertical reliability
    511     float horUncEllipseSemiMajor;       // horizontal elliptical accuracy semi-major axis
    512     float horUncEllipseSemiMinor;       // horizontal elliptical accuracy semi-minor axis
    513     float horUncEllipseOrientAzimuth;   // horizontal elliptical accuracy azimuth
    514 } GnssLocationInfoNotification;
    515 
    516 typedef struct {
    517     size_t size;                           // set to sizeof(GnssNiNotification)
    518     GnssNiType type;                       // type of NI (Voice, SUPL, Control Plane)
    519     GnssNiOptionsMask options;             // bitwise OR of GnssNiOptionsBits
    520     uint32_t timeout;                      // time (seconds) to wait for user input
    521     GnssNiResponse timeoutResponse;        // the response that should be sent when timeout expires
    522     char requestor[GNSS_NI_REQUESTOR_MAX]; // the requestor that is making the request
    523     GnssNiEncodingType requestorEncoding;  // the encoding type for requestor
    524     char message[GNSS_NI_MESSAGE_ID_MAX];  // the message to show user
    525     GnssNiEncodingType messageEncoding;    // the encoding type for message
    526     char extras[GNSS_NI_MESSAGE_ID_MAX];
    527 } GnssNiNotification;
    528 
    529 typedef struct {
    530     size_t size;       // set to sizeof(GnssSv)
    531     uint16_t svId;     // Unique Identifier
    532     GnssSvType type;   // type of SV (GPS, SBAS, GLONASS, QZSS, BEIDOU, GALILEO)
    533     float cN0Dbhz;     // signal strength
    534     float elevation;   // elevation of SV (in degrees)
    535     float azimuth;     // azimuth of SV (in degrees)
    536     GnssSvOptionsMask gnssSvOptionsMask; // Bitwise OR of GnssSvOptionsBits
    537 } GnssSv;
    538 
    539 typedef struct {
    540     size_t size;             // set to sizeof(GnssConfigSetAssistanceServer)
    541     GnssAssistanceType type; // SUPL or C2K
    542     const char* hostName;    // null terminated string
    543     uint32_t port;           // port of server
    544 } GnssConfigSetAssistanceServer;
    545 
    546 typedef struct {
    547     size_t size;                               // set to sizeof(GnssMeasurementsData)
    548     GnssMeasurementsDataFlagsMask flags;       // bitwise OR of GnssMeasurementsDataFlagsBits
    549     int16_t svId;
    550     GnssSvType svType;
    551     double timeOffsetNs;
    552     GnssMeasurementsStateMask stateMask;       // bitwise OR of GnssMeasurementsStateBits
    553     int64_t receivedSvTimeNs;
    554     int64_t receivedSvTimeUncertaintyNs;
    555     double carrierToNoiseDbHz;
    556     double pseudorangeRateMps;
    557     double pseudorangeRateUncertaintyMps;
    558     GnssMeasurementsAdrStateMask adrStateMask; // bitwise OR of GnssMeasurementsAdrStateBits
    559     double adrMeters;
    560     double adrUncertaintyMeters;
    561     float carrierFrequencyHz;
    562     int64_t carrierCycles;
    563     double carrierPhase;
    564     double carrierPhaseUncertainty;
    565     GnssMeasurementsMultipathIndicator multipathIndicator;
    566     double signalToNoiseRatioDb;
    567     double agcLevelDb;
    568 } GnssMeasurementsData;
    569 
    570 typedef struct {
    571     size_t size;                          // set to sizeof(GnssMeasurementsClock)
    572     GnssMeasurementsClockFlagsMask flags; // bitwise OR of GnssMeasurementsClockFlagsBits
    573     int16_t leapSecond;
    574     int64_t timeNs;
    575     double timeUncertaintyNs;
    576     int64_t fullBiasNs;
    577     double biasNs;
    578     double biasUncertaintyNs;
    579     double driftNsps;
    580     double driftUncertaintyNsps;
    581     uint32_t hwClockDiscontinuityCount;
    582 } GnssMeasurementsClock;
    583 
    584 typedef struct {
    585     size_t size;                 // set to sizeof(GnssSvNotification)
    586     size_t count;                // number of SVs in the GnssSv array
    587     GnssSv gnssSvs[GNSS_SV_MAX]; // information on a number of SVs
    588 } GnssSvNotification;
    589 
    590 typedef struct {
    591     size_t size;         // set to sizeof(GnssNmeaNotification)
    592     uint64_t timestamp;  // timestamp
    593     const char* nmea;    // nmea text
    594     size_t length;       // length of the nmea text
    595 } GnssNmeaNotification;
    596 
    597 typedef struct {
    598     size_t size;         // set to sizeof(GnssMeasurementsNotification)
    599     size_t count;        // number of items in GnssMeasurements array
    600     GnssMeasurementsData measurements[GNSS_MEASUREMENTS_MAX];
    601     GnssMeasurementsClock clock; // clock
    602 } GnssMeasurementsNotification;
    603 
    604 typedef struct {
    605     size_t size;  // set to sizeof(GnssConfig)
    606     GnssConfigFlagsMask flags; // bitwise OR of GnssConfigFlagsBits to mark which params are valid
    607     GnssConfigGpsLock gpsLock;
    608     GnssConfigSuplVersion suplVersion;
    609     GnssConfigSetAssistanceServer assistanceServer;
    610     GnssConfigLppProfile lppProfile;
    611     GnssConfigLppeControlPlaneMask lppeControlPlaneMask;
    612     GnssConfigLppeUserPlaneMask lppeUserPlaneMask;
    613     GnssConfigAGlonassPositionProtocolMask aGlonassPositionProtocolMask;
    614     GnssConfigEmergencyPdnForEmergencySupl emergencyPdnForEmergencySupl;
    615     GnssConfigSuplEmergencyServices suplEmergencyServices;
    616     GnssConfigSuplModeMask suplModeMask; //bitwise OR of GnssConfigSuplModeBits
    617 } GnssConfig;
    618 
    619 typedef struct {
    620     size_t size;                        // set to sizeof
    621     bool                                mValid;
    622     Location                            mLocation;
    623     double                              verticalAccuracyMeters;
    624     double                              speedAccuracyMetersPerSecond;
    625     double                              bearingAccuracyDegrees;
    626     timespec                            mUtcReported;
    627 } GnssDebugLocation;
    628 
    629 typedef struct {
    630     size_t size;                        // set to sizeof
    631     bool                                mValid;
    632     int64_t                             timeEstimate;
    633     float                               timeUncertaintyNs;
    634     float                               frequencyUncertaintyNsPerSec;
    635 } GnssDebugTime;
    636 
    637 typedef struct {
    638     size_t size;                        // set to sizeof
    639     uint32_t                            svid;
    640     GnssSvType                          constellation;
    641     GnssEphemerisType                   mEphemerisType;
    642     GnssEphemerisSource                 mEphemerisSource;
    643     GnssEphemerisHealth                 mEphemerisHealth;
    644     float                               ephemerisAgeSeconds;
    645     bool                                serverPredictionIsAvailable;
    646     float                               serverPredictionAgeSeconds;
    647 } GnssDebugSatelliteInfo;
    648 
    649 typedef struct {
    650     size_t size;                        // set to sizeof
    651     GnssDebugLocation                   mLocation;
    652     GnssDebugTime                       mTime;
    653     std::vector<GnssDebugSatelliteInfo> mSatelliteInfo;
    654 } GnssDebugReport;
    655 
    656 /* Provides the capabilities of the system
    657    capabilities callback is called once soon after createInstance is called */
    658 typedef std::function<void(
    659     LocationCapabilitiesMask capabilitiesMask // bitwise OR of LocationCapabilitiesBits
    660 )> capabilitiesCallback;
    661 
    662 /* Used by tracking, batching, and miscellanous APIs
    663    responseCallback is called for every Tracking, Batching API, and Miscellanous API */
    664 typedef std::function<void(
    665     LocationError err, // if not SUCCESS, then id is not valid
    666     uint32_t id        // id to be associated to the request
    667 )> responseCallback;
    668 
    669 /* Used by APIs that gets more than one LocationError in it's response
    670    collectiveResponseCallback is called for every geofence API call.
    671    ids array and LocationError array are only valid until collectiveResponseCallback returns. */
    672 typedef std::function<void(
    673     size_t count, // number of locations in arrays
    674     LocationError* errs, // array of LocationError associated to the request
    675     uint32_t* ids // array of ids to be associated to the request
    676 )> collectiveResponseCallback;
    677 
    678 /* Used for startTracking API, optional can be NULL
    679    trackingCallback is called when delivering a location in a tracking session
    680    broadcasted to all clients, no matter if a session has started by client */
    681 typedef std::function<void(
    682     Location location
    683 )> trackingCallback;
    684 
    685 /* Used for startBatching API, optional can be NULL
    686    batchingCallback is called when delivering locations in a batching session.
    687    broadcasted to all clients, no matter if a session has started by client */
    688 typedef std::function<void(
    689     size_t count,      // number of locations in array
    690     Location* location, // array of locations
    691     BatchingOptions batchingOptions // Batching options
    692 )> batchingCallback;
    693 
    694 typedef std::function<void(
    695     BatchingStatusInfo batchingStatus, // batch status
    696     std::list<uint32_t> & listOfCompletedTrips
    697 )> batchingStatusCallback;
    698 
    699 /* Gives GNSS Location information, optional can be NULL
    700     gnssLocationInfoCallback is called only during a tracking session
    701     broadcasted to all clients, no matter if a session has started by client */
    702 typedef std::function<void(
    703     GnssLocationInfoNotification gnssLocationInfoNotification
    704 )> gnssLocationInfoCallback;
    705 
    706 /* Used for addGeofences API, optional can be NULL
    707    geofenceBreachCallback is called when any number of geofences have a state change */
    708 typedef std::function<void(
    709     GeofenceBreachNotification geofenceBreachNotification
    710 )> geofenceBreachCallback;
    711 
    712 /* Used for addGeofences API, optional can be NULL
    713        geofenceStatusCallback is called when any number of geofences have a status change */
    714 typedef std::function<void(
    715     GeofenceStatusNotification geofenceStatusNotification
    716 )> geofenceStatusCallback;
    717 
    718 /* Network Initiated request, optional can be NULL
    719    This callback should be responded to by calling gnssNiResponse */
    720 typedef std::function<void(
    721     uint32_t id, // id that should be used to respond by calling gnssNiResponse
    722     GnssNiNotification gnssNiNotification
    723 )> gnssNiCallback;
    724 
    725 /* Gives GNSS SV information, optional can be NULL
    726     gnssSvCallback is called only during a tracking session
    727     broadcasted to all clients, no matter if a session has started by client */
    728 typedef std::function<void(
    729     GnssSvNotification gnssSvNotification
    730 )> gnssSvCallback;
    731 
    732 /* Gives GNSS NMEA data, optional can be NULL
    733     gnssNmeaCallback is called only during a tracking session
    734     broadcasted to all clients, no matter if a session has started by client */
    735 typedef std::function<void(
    736     GnssNmeaNotification gnssNmeaNotification
    737 )> gnssNmeaCallback;
    738 
    739 /* Gives GNSS Measurements information, optional can be NULL
    740     gnssMeasurementsCallback is called only during a tracking session
    741     broadcasted to all clients, no matter if a session has started by client */
    742 typedef std::function<void(
    743     GnssMeasurementsNotification gnssMeasurementsNotification
    744 )> gnssMeasurementsCallback;
    745 
    746 typedef struct {
    747     size_t size; // set to sizeof(LocationCallbacks)
    748     capabilitiesCallback capabilitiesCb;             // mandatory
    749     responseCallback responseCb;                     // mandatory
    750     collectiveResponseCallback collectiveResponseCb; // mandatory
    751     trackingCallback trackingCb;                     // optional
    752     batchingCallback batchingCb;                     // optional
    753     geofenceBreachCallback geofenceBreachCb;         // optional
    754     geofenceStatusCallback geofenceStatusCb;         // optional
    755     gnssLocationInfoCallback gnssLocationInfoCb;     // optional
    756     gnssNiCallback gnssNiCb;                         // optional
    757     gnssSvCallback gnssSvCb;                         // optional
    758     gnssNmeaCallback gnssNmeaCb;                     // optional
    759     gnssMeasurementsCallback gnssMeasurementsCb;     // optional
    760     batchingStatusCallback batchingStatusCb;         // optional
    761 } LocationCallbacks;
    762 
    763 class LocationAPI
    764 {
    765 private:
    766     LocationAPI();
    767     ~LocationAPI();
    768 
    769 public:
    770     /* creates an instance to LocationAPI object.
    771        Will return NULL if mandatory parameters are invalid or if the maximum number
    772        of instances have been reached */
    773     static LocationAPI* createInstance(LocationCallbacks&);
    774 
    775     /* destroy/cleans up the instance, which should be called when LocationAPI object is
    776        no longer needed. LocationAPI* returned from createInstance will no longer valid
    777        after destroy is called */
    778     void destroy();
    779 
    780     /* updates/changes the callbacks that will be called.
    781         mandatory callbacks must be present for callbacks to be successfully updated
    782         no return value */
    783     void updateCallbacks(LocationCallbacks&);
    784 
    785     /* ================================== TRACKING ================================== */
    786 
    787     /* startTracking starts a tracking session, which returns a session id that will be
    788        used by the other tracking APIs and also in the responseCallback to match command
    789        with response. locations are reported on the trackingCallback passed in createInstance
    790        periodically according to LocationOptions.
    791         responseCallback returns:
    792                 LOCATION_ERROR_SUCCESS if session was successfully started
    793                 LOCATION_ERROR_ALREADY_STARTED if a startTracking session is already in progress
    794                 LOCATION_ERROR_CALLBACK_MISSING if no trackingCallback was passed in createInstance
    795                 LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameter is invalid */
    796     uint32_t startTracking(LocationOptions&); // returns session id
    797 
    798     /* stopTracking stops a tracking session associated with id parameter.
    799         responseCallback returns:
    800                 LOCATION_ERROR_SUCCESS if successful
    801                 LOCATION_ERROR_ID_UNKNOWN if id is not associated with a tracking session */
    802     void stopTracking(uint32_t id);
    803 
    804     /* updateTrackingOptions changes the LocationOptions of a tracking session associated with id
    805         responseCallback returns:
    806                 LOCATION_ERROR_SUCCESS if successful
    807                 LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameters are invalid
    808                 LOCATION_ERROR_ID_UNKNOWN if id is not associated with a tracking session */
    809     void updateTrackingOptions(uint32_t id, LocationOptions&);
    810 
    811     /* ================================== BATCHING ================================== */
    812 
    813     /* startBatching starts a batching session, which returns a session id that will be
    814        used by the other batching APIs and also in the responseCallback to match command
    815        with response. locations are reported on the batchingCallback passed in createInstance
    816        periodically according to LocationOptions. A batching session starts tracking on
    817        the low power processor and delivers them in batches by the batchingCallback when
    818        the batch is full or when getBatchedLocations is called. This allows for the processor
    819        that calls this API to sleep when the low power processor can batch locations in the
    820        backgroup and wake up the processor calling the API only when the batch is full, thus
    821        saving power
    822         responseCallback returns:
    823                 LOCATION_ERROR_SUCCESS if session was successful
    824                 LOCATION_ERROR_ALREADY_STARTED if a startBatching session is already in progress
    825                 LOCATION_ERROR_CALLBACK_MISSING if no batchingCallback was passed in createInstance
    826                 LOCATION_ERROR_INVALID_PARAMETER if a parameter is invalid
    827                 LOCATION_ERROR_NOT_SUPPORTED if batching is not supported */
    828     uint32_t startBatching(LocationOptions&, BatchingOptions&); // returns session id
    829 
    830     /* stopBatching stops a batching session associated with id parameter.
    831         responseCallback returns:
    832                 LOCATION_ERROR_SUCCESS if successful
    833                 LOCATION_ERROR_ID_UNKNOWN if id is not associated with batching session */
    834     void stopBatching(uint32_t id);
    835 
    836     /* updateBatchingOptions changes the LocationOptions of a batching session associated with id
    837         responseCallback returns:
    838                 LOCATION_ERROR_SUCCESS if successful
    839                 LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameters are invalid
    840                 LOCATION_ERROR_ID_UNKNOWN if id is not associated with a batching session */
    841     void updateBatchingOptions(uint32_t id, LocationOptions&, BatchingOptions&);
    842 
    843     /* getBatchedLocations gets a number of locations that are currently stored/batched
    844        on the low power processor, delivered by the batchingCallback passed in createInstance.
    845        Location are then deleted from the batch stored on the low power processor.
    846         responseCallback returns:
    847                 LOCATION_ERROR_SUCCESS if successful, will be followed by batchingCallback call
    848                 LOCATION_ERROR_CALLBACK_MISSING if no batchingCallback was passed in createInstance
    849                 LOCATION_ERROR_ID_UNKNOWN if id is not associated with a batching session */
    850     void getBatchedLocations(uint32_t id, size_t count);
    851 
    852     /* ================================== GEOFENCE ================================== */
    853 
    854     /* addGeofences adds any number of geofences and returns an array of geofence ids that
    855        will be used by the other geofence APIs and also in the collectiveResponseCallback to
    856        match command with response. The geofenceBreachCallback will deliver the status of each
    857        geofence according to the GeofenceOption for each. The geofence id array returned will
    858        be valid until the collectiveResponseCallback is called and has returned.
    859         collectiveResponseCallback returns:
    860                 LOCATION_ERROR_SUCCESS if session was successful
    861                 LOCATION_ERROR_CALLBACK_MISSING if no geofenceBreachCallback
    862                 LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
    863                 LOCATION_ERROR_NOT_SUPPORTED if geofence is not supported */
    864     uint32_t* addGeofences(size_t count, GeofenceOption*, GeofenceInfo*); // returns id array
    865 
    866     /* removeGeofences removes any number of geofences. Caller should delete ids array after
    867        removeGeofences returneds.
    868         collectiveResponseCallback returns:
    869                 LOCATION_ERROR_SUCCESS if successful
    870                 LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */
    871     void removeGeofences(size_t count, uint32_t* ids);
    872 
    873     /* modifyGeofences modifies any number of geofences. Caller should delete ids array after
    874        modifyGeofences returns.
    875         collectiveResponseCallback returns:
    876                 LOCATION_ERROR_SUCCESS if successful
    877                 LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session
    878                 LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid */
    879     void modifyGeofences(size_t count, uint32_t* ids, GeofenceOption* options);
    880 
    881     /* pauseGeofences pauses any number of geofences, which is similar to removeGeofences,
    882        only that they can be resumed at any time. Caller should delete ids array after
    883        pauseGeofences returns.
    884         collectiveResponseCallback returns:
    885                 LOCATION_ERROR_SUCCESS if successful
    886                 LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */
    887     void pauseGeofences(size_t count, uint32_t* ids);
    888 
    889     /* resumeGeofences resumes any number of geofences that are currently paused. Caller should
    890        delete ids array after resumeGeofences returns.
    891         collectiveResponseCallback returns:
    892                 LOCATION_ERROR_SUCCESS if successful
    893                 LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */
    894     void resumeGeofences(size_t count, uint32_t* ids);
    895 
    896     /* ================================== GNSS ====================================== */
    897 
    898      /* gnssNiResponse is called in response to a gnssNiCallback.
    899         responseCallback returns:
    900                 LOCATION_ERROR_SUCCESS if session was successful
    901                 LOCATION_ERROR_INVALID_PARAMETER if any parameters in GnssNiResponse are invalid
    902                 LOCATION_ERROR_ID_UNKNOWN if id does not match a gnssNiCallback */
    903     void gnssNiResponse(uint32_t id, GnssNiResponse response);
    904 };
    905 
    906 typedef struct {
    907     size_t size; // set to sizeof(LocationControlCallbacks)
    908     responseCallback responseCb;                     // mandatory
    909     collectiveResponseCallback collectiveResponseCb; // mandatory
    910 } LocationControlCallbacks;
    911 
    912 class LocationControlAPI
    913 {
    914 private:
    915     LocationControlAPI();
    916     ~LocationControlAPI();
    917 
    918 public:
    919     /* creates an instance to LocationControlAPI object.
    920        Will return NULL if mandatory parameters are invalid or if the maximum number
    921        of instances have been reached. Only once instance allowed */
    922     static LocationControlAPI* createInstance(LocationControlCallbacks&);
    923 
    924     /* destroy/cleans up the instance, which should be called when LocationControlAPI object is
    925        no longer needed. LocationControlAPI* returned from createInstance will no longer valid
    926        after destroy is called */
    927     void destroy();
    928 
    929     /* enable will enable specific location technology to be used for calculation locations and
    930        will effectively start a control session if call is successful, which returns a session id
    931        that will be returned in responseCallback to match command with response. The session id is
    932        also needed to call the disable command.
    933        This effect is global for all clients of LocationAPI
    934         responseCallback returns:
    935                 LOCATION_ERROR_SUCCESS if successful
    936                 LOCATION_ERROR_ALREADY_STARTED if an enable was already called for this techType
    937                 LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
    938                 LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason */
    939     uint32_t enable(LocationTechnologyType techType);
    940 
    941     /* disable will disable specific location technology to be used for calculation locations and
    942        effectively ends the control session if call is successful.
    943        id parameter is the session id that was returned in enable responseCallback for techType.
    944        The session id is no longer valid after disable's responseCallback returns success.
    945        This effect is global for all clients of LocationAPI
    946         responseCallback returns:
    947                 LOCATION_ERROR_SUCCESS if successful
    948                 LOCATION_ERROR_ID_UNKNOWN if id was not returned from responseCallback from enable
    949                 LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason */
    950     void disable(uint32_t id);
    951 
    952     /* gnssUpdateConfig updates the gnss specific configuration, which returns a session id array
    953        with an id for each of the bits set in GnssConfig.flags, order from low bits to high bits.
    954        The response for each config that is set will be returned in collectiveResponseCallback.
    955        The session id array returned will be valid until the collectiveResponseCallback is called
    956        and has returned. This effect is global for all clients of LocationAPI
    957         collectiveResponseCallback returns:
    958                 LOCATION_ERROR_SUCCESS if session was successful
    959                 LOCATION_ERROR_INVALID_PARAMETER if any other parameters are invalid
    960                 LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason */
    961     uint32_t* gnssUpdateConfig(GnssConfig config);
    962 
    963     /* delete specific gnss aiding data for testing, which returns a session id
    964        that will be returned in responseCallback to match command with response.
    965        Only allowed in userdebug builds. This effect is global for all clients of LocationAPI
    966         responseCallback returns:
    967                 LOCATION_ERROR_SUCCESS if successful
    968                 LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
    969                 LOCATION_ERROR_NOT_SUPPORTED if build is not userdebug */
    970     uint32_t gnssDeleteAidingData(GnssAidingData& data);
    971 };
    972 
    973 #endif /* LOCATION_H */
    974