Home | History | Annotate | Download | only in core
      1 /* Copyright (c) 2013-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 GPS_EXTENDED_C_H
     30 #define GPS_EXTENDED_C_H
     31 
     32 #include <ctype.h>
     33 #include <stdbool.h>
     34 #include <stdlib.h>
     35 #include <string.h>
     36 #include <loc_gps.h>
     37 #include <LocationAPI.h>
     38 #include <time.h>
     39 
     40 /**
     41  * @file
     42  * @brief C++ declarations for GPS types
     43  */
     44 
     45 #ifdef __cplusplus
     46 extern "C" {
     47 #endif /* __cplusplus */
     48 
     49 /** Location has valid source information. */
     50 #define LOCATION_HAS_SOURCE_INFO   0x0020
     51 /** LocGpsLocation has valid "is indoor?" flag */
     52 #define LOC_GPS_LOCATION_HAS_IS_INDOOR   0x0040
     53 /** LocGpsLocation has valid floor number */
     54 #define LOC_GPS_LOCATION_HAS_FLOOR_NUMBER   0x0080
     55 /** LocGpsLocation has valid map URL*/
     56 #define LOC_GPS_LOCATION_HAS_MAP_URL   0x0100
     57 /** LocGpsLocation has valid map index */
     58 #define LOC_GPS_LOCATION_HAS_MAP_INDEX   0x0200
     59 
     60 /** Sizes for indoor fields */
     61 #define GPS_LOCATION_MAP_URL_SIZE 400
     62 #define GPS_LOCATION_MAP_INDEX_SIZE 16
     63 
     64 /** Position source is ULP */
     65 #define ULP_LOCATION_IS_FROM_HYBRID   0x0001
     66 /** Position source is GNSS only */
     67 #define ULP_LOCATION_IS_FROM_GNSS     0x0002
     68 /** Position source is ZPP only */
     69 #define ULP_LOCATION_IS_FROM_ZPP      0x0004
     70 /** Position is from a Geofence Breach Event */
     71 #define ULP_LOCATION_IS_FROM_GEOFENCE 0X0008
     72 /** Position is from Hardware FLP */
     73 #define ULP_LOCATION_IS_FROM_HW_FLP   0x0010
     74 /** Position is from NLP */
     75 #define ULP_LOCATION_IS_FROM_NLP      0x0020
     76 /** Position is from PIP */
     77 #define ULP_LOCATION_IS_FROM_PIP      0x0040
     78 /** Position is from external DR solution*/
     79 #define ULP_LOCATION_IS_FROM_EXT_DR   0X0080
     80 
     81 #define ULP_MIN_INTERVAL_INVALID 0xffffffff
     82 #define ULP_MAX_NMEA_STRING_SIZE 201
     83 
     84 /*Emergency SUPL*/
     85 #define LOC_GPS_NI_TYPE_EMERGENCY_SUPL    4
     86 
     87 #define LOC_AGPS_CERTIFICATE_MAX_LENGTH 2000
     88 #define LOC_AGPS_CERTIFICATE_MAX_SLOTS 10
     89 
     90 enum loc_registration_mask_status {
     91     LOC_REGISTRATION_MASK_ENABLED,
     92     LOC_REGISTRATION_MASK_DISABLED,
     93     LOC_REGISTRATION_MASK_SET
     94 };
     95 
     96 typedef enum {
     97     LOC_SUPPORTED_FEATURE_ODCPI_2_V02 = 0, /**<  Support ODCPI version 2 feature  */
     98     LOC_SUPPORTED_FEATURE_WIFI_AP_DATA_INJECT_2_V02 /**<  Support Wifi AP data inject version 2 feature  */
     99 } loc_supported_feature_enum;
    100 
    101 typedef struct {
    102     /** set to sizeof(UlpLocation) */
    103     size_t          size;
    104     LocGpsLocation     gpsLocation;
    105     /* Provider indicator for HYBRID or GPS */
    106     uint16_t        position_source;
    107     /*allows HAL to pass additional information related to the location */
    108     int             rawDataSize;         /* in # of bytes */
    109     void            * rawData;
    110     bool            is_indoor;
    111     float           floor_number;
    112     char            map_url[GPS_LOCATION_MAP_URL_SIZE];
    113     unsigned char   map_index[GPS_LOCATION_MAP_INDEX_SIZE];
    114 } UlpLocation;
    115 
    116 typedef struct {
    117     /** set to sizeof(UlpNmea) */
    118     size_t          size;
    119     char            nmea_str[ULP_MAX_NMEA_STRING_SIZE];
    120     unsigned int    len;
    121 } UlpNmea;
    122 
    123 
    124 /** AGPS type */
    125 typedef int16_t AGpsExtType;
    126 #define LOC_AGPS_TYPE_INVALID       -1
    127 #define LOC_AGPS_TYPE_ANY           0
    128 #define LOC_AGPS_TYPE_SUPL          1
    129 #define LOC_AGPS_TYPE_C2K           2
    130 #define LOC_AGPS_TYPE_WWAN_ANY      3
    131 #define LOC_AGPS_TYPE_WIFI          4
    132 #define LOC_AGPS_TYPE_SUPL_ES       5
    133 
    134 /** SSID length */
    135 #define SSID_BUF_SIZE (32+1)
    136 
    137 typedef int16_t AGpsBearerType;
    138 #define AGPS_APN_BEARER_INVALID    -1
    139 #define AGPS_APN_BEARER_IPV4        0
    140 #define AGPS_APN_BEARER_IPV6        1
    141 #define AGPS_APN_BEARER_IPV4V6      2
    142 
    143 /** GPS extended callback structure. */
    144 typedef struct {
    145     /** set to sizeof(LocGpsCallbacks) */
    146     size_t      size;
    147     loc_gps_set_capabilities set_capabilities_cb;
    148     loc_gps_acquire_wakelock acquire_wakelock_cb;
    149     loc_gps_release_wakelock release_wakelock_cb;
    150     loc_gps_create_thread create_thread_cb;
    151     loc_gps_request_utc_time request_utc_time_cb;
    152 } GpsExtCallbacks;
    153 
    154 /** Callback to report the xtra server url to the client.
    155  *  The client should use this url when downloading xtra unless overwritten
    156  *  in the gps.conf file
    157  */
    158 typedef void (* report_xtra_server)(const char*, const char*, const char*);
    159 
    160 /** Callback structure for the XTRA interface. */
    161 typedef struct {
    162     loc_gps_xtra_download_request download_request_cb;
    163     loc_gps_create_thread create_thread_cb;
    164     report_xtra_server report_xtra_server_cb;
    165 } GpsXtraExtCallbacks;
    166 
    167 /** Represents the status of AGPS. */
    168 typedef struct {
    169     /** set to sizeof(AGpsExtStatus) */
    170     size_t          size;
    171 
    172     AGpsExtType type;
    173     LocAGpsStatusValue status;
    174     uint32_t        ipv4_addr;
    175     struct sockaddr_storage addr;
    176     char            ssid[SSID_BUF_SIZE];
    177     char            password[SSID_BUF_SIZE];
    178 } AGpsExtStatus;
    179 
    180 /** Callback with AGPS status information.
    181  *  Can only be called from a thread created by create_thread_cb.
    182  */
    183 typedef void (* agps_status_extended)(AGpsExtStatus* status);
    184 
    185 /** Callback structure for the AGPS interface. */
    186 typedef struct {
    187     agps_status_extended status_cb;
    188     loc_gps_create_thread create_thread_cb;
    189 } AGpsExtCallbacks;
    190 
    191 
    192 typedef void (*loc_ni_notify_callback)(LocGpsNiNotification *notification, bool esEnalbed);
    193 /** GPS NI callback structure. */
    194 typedef struct
    195 {
    196     /**
    197      * Sends the notification request from HAL to GPSLocationProvider.
    198      */
    199     loc_ni_notify_callback notify_cb;
    200 } GpsNiExtCallbacks;
    201 
    202 typedef enum loc_server_type {
    203     LOC_AGPS_CDMA_PDE_SERVER,
    204     LOC_AGPS_CUSTOM_PDE_SERVER,
    205     LOC_AGPS_MPC_SERVER,
    206     LOC_AGPS_SUPL_SERVER
    207 } LocServerType;
    208 
    209 typedef enum loc_position_mode_type {
    210     LOC_POSITION_MODE_INVALID = -1,
    211     LOC_POSITION_MODE_STANDALONE = 0,
    212     LOC_POSITION_MODE_MS_BASED,
    213     LOC_POSITION_MODE_MS_ASSISTED,
    214     LOC_POSITION_MODE_RESERVED_1,
    215     LOC_POSITION_MODE_RESERVED_2,
    216     LOC_POSITION_MODE_RESERVED_3,
    217     LOC_POSITION_MODE_RESERVED_4,
    218     LOC_POSITION_MODE_RESERVED_5
    219 
    220 } LocPositionMode;
    221 
    222 /**
    223  * @brief Minimum allowed value for fix interval.
    224  *
    225  * This value is a sanity limit in GPS framework. The hardware has own internal
    226  * limits that may not match this value
    227  *
    228  * @sa GPS_DEFAULT_FIX_INTERVAL_MS
    229  */
    230 
    231 #define GPS_MIN_POSSIBLE_FIX_INTERVAL_MS 100
    232 /**
    233  * @brief Default value for fix interval.
    234  *
    235  * This value is used by default whenever appropriate.
    236  *
    237  * @sa GPS_MIN_POSSIBLE_FIX_INTERVAL_MS
    238  */
    239 #define GPS_DEFAULT_FIX_INTERVAL_MS      1000
    240 
    241 /** Flags to indicate which values are valid in a GpsLocationExtended. */
    242 typedef uint16_t GpsLocationExtendedFlags;
    243 /** GpsLocationExtended has valid pdop, hdop, vdop. */
    244 #define GPS_LOCATION_EXTENDED_HAS_DOP 0x0001
    245 /** GpsLocationExtended has valid altitude mean sea level. */
    246 #define GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL 0x0002
    247 /** UlpLocation has valid magnetic deviation. */
    248 #define GPS_LOCATION_EXTENDED_HAS_MAG_DEV 0x0004
    249 /** UlpLocation has valid mode indicator. */
    250 #define GPS_LOCATION_EXTENDED_HAS_MODE_IND 0x0008
    251 /** GpsLocationExtended has valid vertical uncertainty */
    252 #define GPS_LOCATION_EXTENDED_HAS_VERT_UNC 0x0010
    253 /** GpsLocationExtended has valid speed uncertainty */
    254 #define GPS_LOCATION_EXTENDED_HAS_SPEED_UNC 0x0020
    255 /** GpsLocationExtended has valid heading uncertainty */
    256 #define GPS_LOCATION_EXTENDED_HAS_BEARING_UNC 0x0040
    257 /** GpsLocationExtended has valid horizontal reliability */
    258 #define GPS_LOCATION_EXTENDED_HAS_HOR_RELIABILITY 0x0080
    259 /** GpsLocationExtended has valid vertical reliability */
    260 #define GPS_LOCATION_EXTENDED_HAS_VERT_RELIABILITY 0x0100
    261 /** GpsLocationExtended has valid Horizontal Elliptical Uncertainty (Semi-Major Axis) */
    262 #define GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_MAJOR 0x0200
    263 /** GpsLocationExtended has valid Horizontal Elliptical Uncertainty (Semi-Minor Axis) */
    264 #define GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_MINOR 0x0400
    265 /** GpsLocationExtended has valid Elliptical Horizontal Uncertainty Azimuth */
    266 #define GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_AZIMUTH 0x0800
    267 /** GpsLocationExtended has valid gnss sv used in position data */
    268 #define GPS_LOCATION_EXTENDED_HAS_GNSS_SV_USED_DATA 0x1000
    269 
    270 /** GPS PRN Range */
    271 #define GPS_SV_PRN_MIN      1
    272 #define GPS_SV_PRN_MAX      32
    273 #define GLO_SV_PRN_MIN      65
    274 #define GLO_SV_PRN_MAX      96
    275 #define BDS_SV_PRN_MIN      201
    276 #define BDS_SV_PRN_MAX      235
    277 #define GAL_SV_PRN_MIN      301
    278 #define GAL_SV_PRN_MAX      336
    279 
    280 typedef enum {
    281     LOC_RELIABILITY_NOT_SET = 0,
    282     LOC_RELIABILITY_VERY_LOW = 1,
    283     LOC_RELIABILITY_LOW = 2,
    284     LOC_RELIABILITY_MEDIUM = 3,
    285     LOC_RELIABILITY_HIGH = 4
    286 }LocReliability;
    287 
    288 typedef struct {
    289     struct timespec apTimeStamp;
    290     /*boottime received from pps-ktimer*/
    291     float apTimeStampUncertaintyMs;
    292     /* timestamp uncertainty in milli seconds */
    293 }Gnss_ApTimeStampStructType;
    294 
    295 typedef struct {
    296     uint64_t gps_sv_used_ids_mask;
    297     uint64_t glo_sv_used_ids_mask;
    298     uint64_t gal_sv_used_ids_mask;
    299     uint64_t bds_sv_used_ids_mask;
    300 } GnssSvUsedInPosition;
    301 
    302 /** Represents gps location extended. */
    303 typedef struct {
    304     /** set to sizeof(GpsLocationExtended) */
    305     size_t          size;
    306     /** Contains GpsLocationExtendedFlags bits. */
    307     uint16_t        flags;
    308     /** Contains the Altitude wrt mean sea level */
    309     float           altitudeMeanSeaLevel;
    310     /** Contains Position Dilusion of Precision. */
    311     float           pdop;
    312     /** Contains Horizontal Dilusion of Precision. */
    313     float           hdop;
    314     /** Contains Vertical Dilusion of Precision. */
    315     float           vdop;
    316     /** Contains Magnetic Deviation. */
    317     float           magneticDeviation;
    318     /** vertical uncertainty in meters */
    319     float           vert_unc;
    320     /** speed uncertainty in m/s */
    321     float           speed_unc;
    322     /** heading uncertainty in degrees (0 to 359.999) */
    323     float           bearing_unc;
    324     /** horizontal reliability. */
    325     LocReliability  horizontal_reliability;
    326     /** vertical reliability. */
    327     LocReliability  vertical_reliability;
    328     /*  Horizontal Elliptical Uncertainty (Semi-Major Axis) */
    329     float           horUncEllipseSemiMajor;
    330     /*  Horizontal Elliptical Uncertainty (Semi-Minor Axis) */
    331     float           horUncEllipseSemiMinor;
    332     /*    Elliptical Horizontal Uncertainty Azimuth */
    333     float           horUncEllipseOrientAzimuth;
    334 
    335     Gnss_ApTimeStampStructType               timeStamp;
    336     /** Gnss sv used in position data */
    337     GnssSvUsedInPosition gnss_sv_used_ids;
    338 } GpsLocationExtended;
    339 
    340 enum loc_sess_status {
    341     LOC_SESS_SUCCESS,
    342     LOC_SESS_INTERMEDIATE,
    343     LOC_SESS_FAILURE
    344 };
    345 
    346 typedef uint32_t LocPosTechMask;
    347 #define LOC_POS_TECH_MASK_DEFAULT ((LocPosTechMask)0x00000000)
    348 #define LOC_POS_TECH_MASK_SATELLITE ((LocPosTechMask)0x00000001)
    349 #define LOC_POS_TECH_MASK_CELLID ((LocPosTechMask)0x00000002)
    350 #define LOC_POS_TECH_MASK_WIFI ((LocPosTechMask)0x00000004)
    351 #define LOC_POS_TECH_MASK_SENSORS ((LocPosTechMask)0x00000008)
    352 #define LOC_POS_TECH_MASK_REFERENCE_LOCATION ((LocPosTechMask)0x00000010)
    353 #define LOC_POS_TECH_MASK_INJECTED_COARSE_POSITION ((LocPosTechMask)0x00000020)
    354 #define LOC_POS_TECH_MASK_AFLT ((LocPosTechMask)0x00000040)
    355 #define LOC_POS_TECH_MASK_HYBRID ((LocPosTechMask)0x00000080)
    356 
    357 // Nmea sentence types mask
    358 typedef uint32_t NmeaSentenceTypesMask;
    359 #define LOC_NMEA_MASK_GGA_V02   ((NmeaSentenceTypesMask)0x00000001) /**<  Enable GGA type  */
    360 #define LOC_NMEA_MASK_RMC_V02   ((NmeaSentenceTypesMask)0x00000002) /**<  Enable RMC type  */
    361 #define LOC_NMEA_MASK_GSV_V02   ((NmeaSentenceTypesMask)0x00000004) /**<  Enable GSV type  */
    362 #define LOC_NMEA_MASK_GSA_V02   ((NmeaSentenceTypesMask)0x00000008) /**<  Enable GSA type  */
    363 #define LOC_NMEA_MASK_VTG_V02   ((NmeaSentenceTypesMask)0x00000010) /**<  Enable VTG type  */
    364 #define LOC_NMEA_MASK_PQXFI_V02 ((NmeaSentenceTypesMask)0x00000020) /**<  Enable PQXFI type  */
    365 #define LOC_NMEA_MASK_PSTIS_V02 ((NmeaSentenceTypesMask)0x00000040) /**<  Enable PSTIS type  */
    366 #define LOC_NMEA_MASK_GLGSV_V02 ((NmeaSentenceTypesMask)0x00000080) /**<  Enable GLGSV type  */
    367 #define LOC_NMEA_MASK_GNGSA_V02 ((NmeaSentenceTypesMask)0x00000100) /**<  Enable GNGSA type  */
    368 #define LOC_NMEA_MASK_GNGNS_V02 ((NmeaSentenceTypesMask)0x00000200) /**<  Enable GNGNS type  */
    369 #define LOC_NMEA_MASK_GARMC_V02 ((NmeaSentenceTypesMask)0x00000400) /**<  Enable GARMC type  */
    370 #define LOC_NMEA_MASK_GAGSV_V02 ((NmeaSentenceTypesMask)0x00000800) /**<  Enable GAGSV type  */
    371 #define LOC_NMEA_MASK_GAGSA_V02 ((NmeaSentenceTypesMask)0x00001000) /**<  Enable GAGSA type  */
    372 #define LOC_NMEA_MASK_GAVTG_V02 ((NmeaSentenceTypesMask)0x00002000) /**<  Enable GAVTG type  */
    373 #define LOC_NMEA_MASK_GAGGA_V02 ((NmeaSentenceTypesMask)0x00004000) /**<  Enable GAGGA type  */
    374 #define LOC_NMEA_MASK_PQGSA_V02 ((NmeaSentenceTypesMask)0x00008000) /**<  Enable PQGSA type  */
    375 #define LOC_NMEA_MASK_PQGSV_V02 ((NmeaSentenceTypesMask)0x00010000) /**<  Enable PQGSV type  */
    376 #define LOC_NMEA_ALL_SUPPORTED_MASK  (LOC_NMEA_MASK_GGA_V02 | LOC_NMEA_MASK_RMC_V02 | \
    377               LOC_NMEA_MASK_GSV_V02 | LOC_NMEA_MASK_GSA_V02 | LOC_NMEA_MASK_VTG_V02 | \
    378         LOC_NMEA_MASK_PQXFI_V02 | LOC_NMEA_MASK_PSTIS_V02 | LOC_NMEA_MASK_GLGSV_V02 | \
    379         LOC_NMEA_MASK_GNGSA_V02 | LOC_NMEA_MASK_GNGNS_V02 | LOC_NMEA_MASK_GARMC_V02 | \
    380         LOC_NMEA_MASK_GAGSV_V02 | LOC_NMEA_MASK_GAGSA_V02 | LOC_NMEA_MASK_GAVTG_V02 | \
    381         LOC_NMEA_MASK_GAGGA_V02 | LOC_NMEA_MASK_PQGSA_V02 | LOC_NMEA_MASK_PQGSV_V02 )
    382 
    383 
    384 
    385 typedef enum {
    386   LOC_ENG_IF_REQUEST_SENDER_ID_QUIPC = 0,
    387   LOC_ENG_IF_REQUEST_SENDER_ID_MSAPM,
    388   LOC_ENG_IF_REQUEST_SENDER_ID_MSAPU,
    389   LOC_ENG_IF_REQUEST_SENDER_ID_GPSONE_DAEMON,
    390   LOC_ENG_IF_REQUEST_SENDER_ID_MODEM,
    391   LOC_ENG_IF_REQUEST_SENDER_ID_UNKNOWN
    392 } loc_if_req_sender_id_e_type;
    393 
    394 
    395 #define smaller_of(a, b) (((a) > (b)) ? (b) : (a))
    396 #define MAX_APN_LEN 100
    397 
    398 // This will be overridden by the individual adapters
    399 // if necessary.
    400 #define DEFAULT_IMPL(rtv)                                     \
    401 {                                                             \
    402     LOC_LOGD("%s: default implementation invoked", __func__); \
    403     return rtv;                                               \
    404 }
    405 
    406 enum loc_api_adapter_err {
    407     LOC_API_ADAPTER_ERR_SUCCESS             = 0,
    408     LOC_API_ADAPTER_ERR_GENERAL_FAILURE     = 1,
    409     LOC_API_ADAPTER_ERR_UNSUPPORTED         = 2,
    410     LOC_API_ADAPTER_ERR_INVALID_HANDLE      = 4,
    411     LOC_API_ADAPTER_ERR_INVALID_PARAMETER   = 5,
    412     LOC_API_ADAPTER_ERR_ENGINE_BUSY         = 6,
    413     LOC_API_ADAPTER_ERR_PHONE_OFFLINE       = 7,
    414     LOC_API_ADAPTER_ERR_TIMEOUT             = 8,
    415     LOC_API_ADAPTER_ERR_SERVICE_NOT_PRESENT = 9,
    416     LOC_API_ADAPTER_ERR_INTERNAL            = 10,
    417 
    418     /* equating engine down to phone offline, as they are the same errror */
    419     LOC_API_ADAPTER_ERR_ENGINE_DOWN         = LOC_API_ADAPTER_ERR_PHONE_OFFLINE,
    420     LOC_API_ADAPTER_ERR_FAILURE             = 101,
    421     LOC_API_ADAPTER_ERR_UNKNOWN
    422 };
    423 
    424 enum loc_api_adapter_event_index {
    425     LOC_API_ADAPTER_REPORT_POSITION = 0,               // Position report comes in loc_parsed_position_s_type
    426     LOC_API_ADAPTER_REPORT_SATELLITE,                  // Satellite in view report
    427     LOC_API_ADAPTER_REPORT_NMEA_1HZ,                   // NMEA report at 1HZ rate
    428     LOC_API_ADAPTER_REPORT_NMEA_POSITION,              // NMEA report at position report rate
    429     LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY,          // NI notification/verification request
    430     LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA,           // Assistance data, eg: time, predicted orbits request
    431     LOC_API_ADAPTER_REQUEST_LOCATION_SERVER,           // Request for location server
    432     LOC_API_ADAPTER_REPORT_IOCTL,                      // Callback report for loc_ioctl
    433     LOC_API_ADAPTER_REPORT_STATUS,                     // Misc status report: eg, engine state
    434     LOC_API_ADAPTER_REQUEST_WIFI,                      //
    435     LOC_API_ADAPTER_SENSOR_STATUS,                     //
    436     LOC_API_ADAPTER_REQUEST_TIME_SYNC,                 //
    437     LOC_API_ADAPTER_REPORT_SPI,                        //
    438     LOC_API_ADAPTER_REPORT_NI_GEOFENCE,                //
    439     LOC_API_ADAPTER_GEOFENCE_GEN_ALERT,                //
    440     LOC_API_ADAPTER_REPORT_GENFENCE_BREACH,            //
    441     LOC_API_ADAPTER_PEDOMETER_CTRL,                    //
    442     LOC_API_ADAPTER_MOTION_CTRL,                       //
    443     LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA,              // Wifi ap data
    444     LOC_API_ADAPTER_BATCH_FULL,                        // Batching on full
    445     LOC_API_ADAPTER_BATCHED_POSITION_REPORT,           // Batching on fix
    446     LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT,    //
    447     LOC_API_ADAPTER_GNSS_MEASUREMENT_REPORT,          //GNSS Measurement Report
    448     LOC_API_ADAPTER_GNSS_SV_POLYNOMIAL_REPORT,        //GNSS SV Polynomial Report
    449     LOC_API_ADAPTER_GDT_UPLOAD_BEGIN_REQ,              // GDT upload start request
    450     LOC_API_ADAPTER_GDT_UPLOAD_END_REQ,                // GDT upload end request
    451     LOC_API_ADAPTER_GNSS_MEASUREMENT,                  // GNSS Measurement report
    452     LOC_API_ADAPTER_REQUEST_TIMEZONE,                  // Timezone injection request
    453     LOC_API_ADAPTER_REPORT_GENFENCE_DWELL_REPORT,      // Geofence dwell report
    454     LOC_API_ADAPTER_EVENT_MAX
    455 };
    456 
    457 #define LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT           (1<<LOC_API_ADAPTER_REPORT_POSITION)
    458 #define LOC_API_ADAPTER_BIT_SATELLITE_REPORT                 (1<<LOC_API_ADAPTER_REPORT_SATELLITE)
    459 #define LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT                  (1<<LOC_API_ADAPTER_REPORT_NMEA_1HZ)
    460 #define LOC_API_ADAPTER_BIT_NMEA_POSITION_REPORT             (1<<LOC_API_ADAPTER_REPORT_NMEA_POSITION)
    461 #define LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST         (1<<LOC_API_ADAPTER_REQUEST_NI_NOTIFY_VERIFY)
    462 #define LOC_API_ADAPTER_BIT_ASSISTANCE_DATA_REQUEST          (1<<LOC_API_ADAPTER_REQUEST_ASSISTANCE_DATA)
    463 #define LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST          (1<<LOC_API_ADAPTER_REQUEST_LOCATION_SERVER)
    464 #define LOC_API_ADAPTER_BIT_IOCTL_REPORT                     (1<<LOC_API_ADAPTER_REPORT_IOCTL)
    465 #define LOC_API_ADAPTER_BIT_STATUS_REPORT                    (1<<LOC_API_ADAPTER_REPORT_STATUS)
    466 #define LOC_API_ADAPTER_BIT_REQUEST_WIFI                     (1<<LOC_API_ADAPTER_REQUEST_WIFI)
    467 #define LOC_API_ADAPTER_BIT_SENSOR_STATUS                    (1<<LOC_API_ADAPTER_SENSOR_STATUS)
    468 #define LOC_API_ADAPTER_BIT_REQUEST_TIME_SYNC                (1<<LOC_API_ADAPTER_REQUEST_TIME_SYNC)
    469 #define LOC_API_ADAPTER_BIT_REPORT_SPI                       (1<<LOC_API_ADAPTER_REPORT_SPI)
    470 #define LOC_API_ADAPTER_BIT_REPORT_NI_GEOFENCE               (1<<LOC_API_ADAPTER_REPORT_NI_GEOFENCE)
    471 #define LOC_API_ADAPTER_BIT_GEOFENCE_GEN_ALERT               (1<<LOC_API_ADAPTER_GEOFENCE_GEN_ALERT)
    472 #define LOC_API_ADAPTER_BIT_REPORT_GENFENCE_BREACH           (1<<LOC_API_ADAPTER_REPORT_GENFENCE_BREACH)
    473 #define LOC_API_ADAPTER_BIT_BATCHED_GENFENCE_BREACH_REPORT   (1<<LOC_API_ADAPTER_BATCHED_GENFENCE_BREACH_REPORT)
    474 #define LOC_API_ADAPTER_BIT_PEDOMETER_CTRL                   (1<<LOC_API_ADAPTER_PEDOMETER_CTRL)
    475 #define LOC_API_ADAPTER_BIT_MOTION_CTRL                      (1<<LOC_API_ADAPTER_MOTION_CTRL)
    476 #define LOC_API_ADAPTER_BIT_REQUEST_WIFI_AP_DATA             (1<<LOC_API_ADAPTER_REQUEST_WIFI_AP_DATA)
    477 #define LOC_API_ADAPTER_BIT_BATCH_FULL                       (1<<LOC_API_ADAPTER_BATCH_FULL)
    478 #define LOC_API_ADAPTER_BIT_BATCHED_POSITION_REPORT          (1<<LOC_API_ADAPTER_BATCHED_POSITION_REPORT)
    479 #define LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT_REPORT          (1<<LOC_API_ADAPTER_GNSS_MEASUREMENT_REPORT)
    480 #define LOC_API_ADAPTER_BIT_GNSS_SV_POLYNOMIAL_REPORT        (1<<LOC_API_ADAPTER_GNSS_SV_POLYNOMIAL_REPORT)
    481 #define LOC_API_ADAPTER_BIT_GDT_UPLOAD_BEGIN_REQ             (1<<LOC_API_ADAPTER_GDT_UPLOAD_BEGIN_REQ)
    482 #define LOC_API_ADAPTER_BIT_GDT_UPLOAD_END_REQ               (1<<LOC_API_ADAPTER_GDT_UPLOAD_END_REQ)
    483 #define LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT                 (1<<LOC_API_ADAPTER_GNSS_MEASUREMENT)
    484 #define LOC_API_ADAPTER_BIT_REQUEST_TIMEZONE                 (1<<LOC_API_ADAPTER_REQUEST_TIMEZONE)
    485 #define LOC_API_ADAPTER_BIT_REPORT_GENFENCE_DWELL            (1<<LOC_API_ADAPTER_REPORT_GENFENCE_DWELL_REPORT)
    486 
    487 typedef unsigned int LOC_API_ADAPTER_EVENT_MASK_T;
    488 
    489 typedef enum loc_api_adapter_msg_to_check_supported {
    490     LOC_API_ADAPTER_MESSAGE_LOCATION_BATCHING,               // Batching 1.0
    491     LOC_API_ADAPTER_MESSAGE_BATCHED_GENFENCE_BREACH,         // Geofence Batched Breach
    492     LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_TRACKING,          // DBT 2.0
    493     LOC_API_ADAPTER_MESSAGE_ADAPTIVE_LOCATION_BATCHING,      // Batching 1.5
    494     LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_LOCATION_BATCHING, // Batching 2.0
    495     LOC_API_ADAPTER_MESSAGE_UPDATE_TBF_ON_THE_FLY,           // Updating Tracking TBF On The Fly
    496 
    497     LOC_API_ADAPTER_MESSAGE_MAX
    498 } LocCheckingMessagesID;
    499 
    500 typedef int IzatDevId_t;
    501 
    502 typedef uint32_t LOC_GPS_LOCK_MASK;
    503 #define isGpsLockNone(lock) ((lock) == 0)
    504 #define isGpsLockMO(lock) ((lock) & ((LOC_GPS_LOCK_MASK)1))
    505 #define isGpsLockMT(lock) ((lock) & ((LOC_GPS_LOCK_MASK)2))
    506 #define isGpsLockAll(lock) (((lock) & ((LOC_GPS_LOCK_MASK)3)) == 3)
    507 
    508 /*++ ***********************************************
    509 **  Satellite Measurement and Satellite Polynomial
    510 **  Structure definitions
    511 **  ***********************************************
    512 --*/
    513 #define GNSS_SV_POLY_VELOCITY_COEF_MAX_SIZE         12
    514 #define GNSS_SV_POLY_XYZ_0_TH_ORDER_COEFF_MAX_SIZE  3
    515 #define GNSS_SV_POLY_XYZ_N_TH_ORDER_COEFF_MAX_SIZE  9
    516 #define GNSS_SV_POLY_SV_CLKBIAS_COEFF_MAX_SIZE      4
    517 #define GNSS_LOC_SV_MEAS_LIST_MAX_SIZE              16
    518 
    519 enum ulp_gnss_sv_measurement_valid_flags{
    520 
    521     ULP_GNSS_SV_MEAS_GPS_TIME = 0,
    522     ULP_GNSS_SV_MEAS_PSUEDO_RANGE,
    523     ULP_GNSS_SV_MEAS_MS_IN_WEEK,
    524     ULP_GNSS_SV_MEAS_SUB_MSEC,
    525     ULP_GNSS_SV_MEAS_CARRIER_PHASE,
    526     ULP_GNSS_SV_MEAS_DOPPLER_SHIFT,
    527     ULP_GNSS_SV_MEAS_CNO,
    528     ULP_GNSS_SV_MEAS_LOSS_OF_LOCK,
    529 
    530     ULP_GNSS_SV_MEAS_MAX_VALID_FLAGS
    531 };
    532 
    533 #define ULP_GNSS_SV_MEAS_BIT_GPS_TIME        (1<<ULP_GNSS_SV_MEAS_GPS_TIME)
    534 #define ULP_GNSS_SV_MEAS_BIT_PSUEDO_RANGE    (1<<ULP_GNSS_SV_MEAS_PSUEDO_RANGE)
    535 #define ULP_GNSS_SV_MEAS_BIT_MS_IN_WEEK      (1<<ULP_GNSS_SV_MEAS_MS_IN_WEEK)
    536 #define ULP_GNSS_SV_MEAS_BIT_SUB_MSEC        (1<<ULP_GNSS_SV_MEAS_SUB_MSEC)
    537 #define ULP_GNSS_SV_MEAS_BIT_CARRIER_PHASE   (1<<ULP_GNSS_SV_MEAS_CARRIER_PHASE)
    538 #define ULP_GNSS_SV_MEAS_BIT_DOPPLER_SHIFT   (1<<ULP_GNSS_SV_MEAS_DOPPLER_SHIFT)
    539 #define ULP_GNSS_SV_MEAS_BIT_CNO             (1<<ULP_GNSS_SV_MEAS_CNO)
    540 #define ULP_GNSS_SV_MEAS_BIT_LOSS_OF_LOCK    (1<<ULP_GNSS_SV_MEAS_LOSS_OF_LOCK)
    541 
    542 enum ulp_gnss_sv_poly_valid_flags{
    543 
    544     ULP_GNSS_SV_POLY_GLO_FREQ = 0,
    545     ULP_GNSS_SV_POLY_T0,
    546     ULP_GNSS_SV_POLY_IODE,
    547     ULP_GNSS_SV_POLY_FLAG,
    548     ULP_GNSS_SV_POLY_POLYCOEFF_XYZ0,
    549     ULP_GNSS_SV_POLY_POLYCOEFF_XYZN,
    550     ULP_GNSS_SV_POLY_POLYCOEFF_OTHER,
    551     ULP_GNSS_SV_POLY_SV_POSUNC,
    552     ULP_GNSS_SV_POLY_IONODELAY,
    553     ULP_GNSS_SV_POLY_IONODOT,
    554     ULP_GNSS_SV_POLY_SBAS_IONODELAY,
    555     ULP_GNSS_SV_POLY_SBAS_IONODOT,
    556     ULP_GNSS_SV_POLY_TROPODELAY,
    557     ULP_GNSS_SV_POLY_ELEVATION,
    558     ULP_GNSS_SV_POLY_ELEVATIONDOT,
    559     ULP_GNSS_SV_POLY_ELEVATIONUNC,
    560     ULP_GNSS_SV_POLY_VELO_COEFF,
    561     ULP_GNSS_SV_POLY_ENHANCED_IOD,
    562 
    563     ULP_GNSS_SV_POLY_VALID_FLAGS
    564 
    565 };
    566 
    567 #define ULP_GNSS_SV_POLY_BIT_GLO_FREQ               (1<<ULP_GNSS_SV_POLY_GLO_FREQ)
    568 #define ULP_GNSS_SV_POLY_BIT_T0                     (1<<ULP_GNSS_SV_POLY_T0)
    569 #define ULP_GNSS_SV_POLY_BIT_IODE                   (1<<ULP_GNSS_SV_POLY_IODE)
    570 #define ULP_GNSS_SV_POLY_BIT_FLAG                   (1<<ULP_GNSS_SV_POLY_FLAG)
    571 #define ULP_GNSS_SV_POLY_BIT_POLYCOEFF_XYZ0         (1<<ULP_GNSS_SV_POLY_POLYCOEFF_XYZ0)
    572 #define ULP_GNSS_SV_POLY_BIT_POLYCOEFF_XYZN         (1<<ULP_GNSS_SV_POLY_POLYCOEFF_XYZN)
    573 #define ULP_GNSS_SV_POLY_BIT_POLYCOEFF_OTHER        (1<<ULP_GNSS_SV_POLY_POLYCOEFF_OTHER)
    574 #define ULP_GNSS_SV_POLY_BIT_SV_POSUNC              (1<<ULP_GNSS_SV_POLY_SV_POSUNC)
    575 #define ULP_GNSS_SV_POLY_BIT_IONODELAY              (1<<ULP_GNSS_SV_POLY_IONODELAY)
    576 #define ULP_GNSS_SV_POLY_BIT_IONODOT                (1<<ULP_GNSS_SV_POLY_IONODOT)
    577 #define ULP_GNSS_SV_POLY_BIT_SBAS_IONODELAY         (1<<ULP_GNSS_SV_POLY_SBAS_IONODELAY)
    578 #define ULP_GNSS_SV_POLY_BIT_SBAS_IONODOT           (1<<ULP_GNSS_SV_POLY_SBAS_IONODOT)
    579 #define ULP_GNSS_SV_POLY_BIT_TROPODELAY             (1<<ULP_GNSS_SV_POLY_TROPODELAY)
    580 #define ULP_GNSS_SV_POLY_BIT_ELEVATION              (1<<ULP_GNSS_SV_POLY_ELEVATION)
    581 #define ULP_GNSS_SV_POLY_BIT_ELEVATIONDOT           (1<<ULP_GNSS_SV_POLY_ELEVATIONDOT)
    582 #define ULP_GNSS_SV_POLY_BIT_ELEVATIONUNC           (1<<ULP_GNSS_SV_POLY_ELEVATIONUNC)
    583 #define ULP_GNSS_SV_POLY_BIT_VELO_COEFF             (1<<ULP_GNSS_SV_POLY_VELO_COEFF)
    584 #define ULP_GNSS_SV_POLY_BIT_ENHANCED_IOD           (1<<ULP_GNSS_SV_POLY_ENHANCED_IOD)
    585 
    586 
    587 typedef enum
    588 {
    589     GNSS_LOC_SV_SYSTEM_GPS                    = 1,
    590     /**< GPS satellite. */
    591     GNSS_LOC_SV_SYSTEM_GALILEO                = 2,
    592     /**< GALILEO satellite. */
    593     GNSS_LOC_SV_SYSTEM_SBAS                   = 3,
    594     /**< SBAS satellite. */
    595     GNSS_LOC_SV_SYSTEM_COMPASS                = 4,
    596     /**< COMPASS satellite. */
    597     GNSS_LOC_SV_SYSTEM_GLONASS                = 5,
    598     /**< GLONASS satellite. */
    599     GNSS_LOC_SV_SYSTEM_BDS                    = 6
    600     /**< BDS satellite. */
    601 } Gnss_LocSvSystemEnumType;
    602 
    603 typedef enum
    604 {
    605     GNSS_LOC_FREQ_SOURCE_INVALID = 0,
    606     /**< Source of the frequency is invalid */
    607     GNSS_LOC_FREQ_SOURCE_EXTERNAL = 1,
    608     /**< Source of the frequency is from external injection */
    609     GNSS_LOC_FREQ_SOURCE_PE_CLK_REPORT = 2,
    610     /**< Source of the frequency is from Navigation engine */
    611     GNSS_LOC_FREQ_SOURCE_UNKNOWN = 3
    612     /**< Source of the frequency is unknown */
    613 } Gnss_LocSourceofFreqEnumType;
    614 
    615 typedef struct
    616 {
    617     size_t                          size;
    618     float                           clockDrift;
    619     /**< Receiver clock Drift \n
    620          - Units: meter per sec \n
    621     */
    622     float                           clockDriftUnc;
    623     /**< Receiver clock Drift uncertainty \n
    624          - Units: meter per sec \n
    625     */
    626     Gnss_LocSourceofFreqEnumType    sourceOfFreq;
    627 }Gnss_LocRcvrClockFrequencyInfoStructType;
    628 
    629 typedef struct
    630 {
    631     size_t      size;
    632     uint8_t     leapSec;
    633     /**< GPS time leap second delta to UTC time  \n
    634          - Units: sec \n
    635        */
    636     uint8_t     leapSecUnc;
    637     /**< Uncertainty for GPS leap second \n
    638          - Units: sec \n
    639        */
    640 }Gnss_LeapSecondInfoStructType;
    641 
    642 typedef enum
    643 {
    644    GNSS_LOC_SYS_TIME_BIAS_VALID                = 0x01,
    645    /**< System time bias valid */
    646    GNSS_LOC_SYS_TIME_BIAS_UNC_VALID            = 0x02,
    647    /**< System time bias uncertainty valid */
    648 }Gnss_LocInterSystemBiasValidMaskType;
    649 
    650 typedef struct
    651 {
    652     size_t          size;
    653     uint32_t        validMask;
    654     /* Validity mask as per Gnss_LocInterSystemBiasValidMaskType */
    655 
    656     float           timeBias;
    657     /**< System-1 to System-2 Time Bias  \n
    658         - Units: msec \n
    659     */
    660     float           timeBiasUnc;
    661     /**< System-1 to System-2 Time Bias uncertainty  \n
    662         - Units: msec \n
    663     */
    664 }Gnss_InterSystemBiasStructType;
    665 
    666 
    667 typedef struct
    668 {
    669     size_t          size;
    670     uint16_t        systemWeek;
    671     /**< System week number for GPS, BDS and GAL satellite systems. \n
    672          Set to 65535 when invalid or not available. \n
    673          Not valid for GLONASS system. \n
    674        */
    675 
    676     uint32_t        systemMsec;
    677     /**< System time msec. Time of Week for GPS, BDS, GAL and
    678          Time of Day for GLONASS.
    679          - Units: msec \n
    680       */
    681     float           systemClkTimeBias;
    682     /**< System clock time bias \n
    683          - Units: msec \n
    684          System time = systemMsec - systemClkTimeBias \n
    685       */
    686     float           systemClkTimeUncMs;
    687     /**< Single sided maximum time bias uncertainty \n
    688                                                     - Units: msec \n
    689       */
    690 }Gnss_LocSystemTimeStructType;
    691 
    692 typedef struct {
    693 
    694   size_t        size;
    695   uint8_t       gloFourYear;
    696   /**<   GLONASS four year number from 1996. Refer to GLONASS ICD.\n
    697         Applicable only for GLONASS and shall be ignored for other constellations. \n
    698         If unknown shall be set to 255
    699         */
    700 
    701   uint16_t      gloDays;
    702   /**<   GLONASS day number in four years. Refer to GLONASS ICD.
    703         Applicable only for GLONASS and shall be ignored for other constellations. \n
    704         If unknown shall be set to 65535
    705         */
    706 
    707   uint32_t      gloMsec;
    708   /**<   GLONASS time of day in msec. Refer to GLONASS ICD.
    709             - Units: msec \n
    710         */
    711 
    712   float         gloClkTimeBias;
    713   /**<   System clock time bias (sub-millisecond) \n
    714             - Units: msec \n
    715         System time = systemMsec - systemClkTimeBias \n
    716     */
    717 
    718   float         gloClkTimeUncMs;
    719   /**<   Single sided maximum time bias uncertainty \n
    720                 - Units: msec \n
    721         */
    722 }Gnss_LocGloTimeStructType;  /* Type */
    723 
    724 typedef struct {
    725 
    726   size_t    size;
    727   uint32_t  refFCount;
    728   /**<   Receiver frame counter value at reference tick */
    729 
    730   uint8_t   systemRtc_valid;
    731   /**<   Validity indicator for System RTC */
    732 
    733   uint64_t  systemRtcMs;
    734   /**<   Platform system RTC value \n
    735         - Units: msec \n
    736         */
    737 
    738   uint32_t  sourceOfTime;
    739   /**<   Source of time information */
    740 
    741 }Gnss_LocGnssTimeExtStructType;
    742 
    743 
    744 
    745 typedef enum
    746 {
    747     GNSS_LOC_MEAS_STATUS_NULL                    = 0x00000000,
    748     /**< No information state */
    749     GNSS_LOC_MEAS_STATUS_SM_VALID                = 0x00000001,
    750     /**< Code phase is known */
    751     GNSS_LOC_MEAS_STATUS_SB_VALID                = 0x00000002,
    752     /**< Sub-bit time is known */
    753     GNSS_LOC_MEAS_STATUS_MS_VALID                = 0x00000004,
    754     /**< Satellite time is known */
    755     GNSS_LOC_MEAS_STATUS_BE_CONFIRM              = 0x00000008,
    756     /**< Bit edge is confirmed from signal   */
    757     GNSS_LOC_MEAS_STATUS_VELOCITY_VALID          = 0x00000010,
    758     /**< Satellite Doppler measured */
    759     GNSS_LOC_MEAS_STATUS_VELOCITY_FINE           = 0x00000020,
    760     /**< TRUE: Fine Doppler measured, FALSE: Coarse Doppler measured */
    761     GNSS_LOC_MEAS_STATUS_FROM_RNG_DIFF           = 0x00000200,
    762     /**< Range update from Satellite differences */
    763     GNSS_LOC_MEAS_STATUS_FROM_VE_DIFF            = 0x00000400,
    764     /**< Doppler update from Satellite differences */
    765     GNSS_LOC_MEAS_STATUS_DONT_USE_X              = 0x00000800,
    766     /**< Don't use measurement if bit is set */
    767     GNSS_LOC_MEAS_STATUS_DONT_USE_M              = 0x000001000,
    768     /**< Don't use measurement if bit is set */
    769     GNSS_LOC_MEAS_STATUS_DONT_USE_D              = 0x000002000,
    770     /**< Don't use measurement if bit is set */
    771     GNSS_LOC_MEAS_STATUS_DONT_USE_S              = 0x000004000,
    772     /**< Don't use measurement if bit is set */
    773     GNSS_LOC_MEAS_STATUS_DONT_USE_P              = 0x000008000
    774     /**< Don't use measurement if bit is set */
    775 }Gnss_LocSvMeasStatusMaskType;
    776 
    777 typedef struct
    778 {
    779     size_t              size;
    780     uint32_t            svMs;
    781     /**<  Satellite time milisecond.\n
    782           For GPS, BDS, GAL range of 0 thru (604800000-1) \n
    783           For GLONASS range of 0 thru (86400000-1) \n
    784           Valid when PD_LOC_MEAS_STATUS_MS_VALID bit is set in measurement status \n
    785           Note: All SV times in the current measurement block are alredy propagated to common reference time epoch. \n
    786             - Units: msec \n
    787        */
    788     float               svSubMs;
    789     /**<Satellite time sub-millisecond. \n
    790         Total SV Time = svMs + svSubMs \n
    791         - Units: msec \n
    792        */
    793     float               svTimeUncMs;
    794     /**<  Satellite Time uncertainty \n
    795           - Units: msec \n
    796        */
    797     float               dopplerShift;
    798     /**< Satellite Doppler \n
    799             - Units: meter per sec \n
    800        */
    801     float               dopplerShiftUnc;
    802     /**< Satellite Doppler uncertainty\n
    803             - Units: meter per sec \n
    804        */
    805 }Gnss_LocSVTimeSpeedStructType;
    806 
    807 typedef enum
    808 {
    809   GNSS_SV_STATE_IDLE = 0,
    810   GNSS_SV_STATE_SEARCH = 1,
    811   GNSS_SV_STATE_SEARCH_VERIFY = 2,
    812   GNSS_SV_STATE_BIT_EDGE = 3,
    813   GNSS_SV_STATE_VERIFY_TRACK = 4,
    814   GNSS_SV_STATE_TRACK = 5,
    815   GNSS_SV_STATE_RESTART = 6,
    816   GNSS_SV_STATE_DPO_TRACK = 7
    817 } Gnss_LocSVStateEnumType;
    818 
    819 typedef enum
    820 {
    821   GNSS_LOC_SVINFO_MASK_HAS_EPHEMERIS   = 0x01,
    822   /**< Ephemeris is available for this SV */
    823   GNSS_LOC_SVINFO_MASK_HAS_ALMANAC     = 0x02
    824   /**< Almanac is available for this SV */
    825 }Gnss_LocSvInfoMaskT;
    826 
    827 typedef enum
    828 {
    829   GNSS_LOC_SV_SRCH_STATUS_IDLE      = 1,
    830     /**< SV is not being actively processed */
    831   GNSS_LOC_SV_SRCH_STATUS_SEARCH    = 2,
    832     /**< The system is searching for this SV */
    833   GNSS_LOC_SV_SRCH_STATUS_TRACK     = 3
    834     /**< SV is being tracked */
    835 }Gnss_LocSvSearchStatusEnumT;
    836 
    837 
    838 typedef struct
    839 {
    840     size_t                          size;
    841     uint16_t                        gnssSvId;
    842     /**< GNSS SV ID.
    843          \begin{itemize1}
    844          \item Range:  \begin{itemize1}
    845            \item For GPS:      1 to 32
    846            \item For GLONASS:  1 to 32
    847            \item For SBAS:     120 to 151
    848            \item For BDS:      201 to 237
    849          \end{itemize1} \end{itemize1}
    850         The GPS and GLONASS SVs can be disambiguated using the system field.
    851     */
    852     uint8_t                         gloFrequency;
    853     /**< GLONASS frequency number + 7 \n
    854          Valid only for GLONASS System \n
    855          Shall be ignored for all other systems \n
    856           - Range: 1 to 14 \n
    857     */
    858     Gnss_LocSvSearchStatusEnumT     svStatus;
    859     /**< Satellite search state \n
    860         @ENUM()
    861     */
    862     bool                         healthStatus_valid;
    863     /**< SV Health Status validity flag\n
    864         - 0: Not valid \n
    865         - 1: Valid \n
    866     */
    867     uint8_t                         healthStatus;
    868     /**< Health status.
    869          \begin{itemize1}
    870          \item    Range: 0 to 1; 0 = unhealthy, \n 1 = healthy, 2 = unknown
    871          \vspace{-0.18in} \end{itemize1}
    872     */
    873     Gnss_LocSvInfoMaskT             svInfoMask;
    874     /**< Indicates whether almanac and ephemeris information is available. \n
    875         @MASK()
    876     */
    877     uint64_t                        measurementStatus;
    878     /**< Bitmask indicating SV measurement status.
    879          Valid bitmasks: \n
    880          @MASK()
    881     */
    882     uint16_t                        CNo;
    883     /**< Carrier to Noise ratio  \n
    884         - Units: 0.1 dBHz \n
    885     */
    886     uint16_t                          gloRfLoss;
    887     /**< GLONASS Rf loss reference to Antenna. \n
    888          - Units: dB, Scale: 0.1 \n
    889     */
    890     bool                         lossOfLock;
    891     /**< Loss of signal lock indicator  \n
    892          - 0: Signal in continuous track \n
    893          - 1: Signal not in track \n
    894     */
    895     int16_t                         measLatency;
    896     /**< Age of the measurement. Positive value means measurement precedes ref time. \n
    897          - Units: msec \n
    898     */
    899     Gnss_LocSVTimeSpeedStructType   svTimeSpeed;
    900     /**< Unfiltered SV Time and Speed information
    901     */
    902     float                           dopplerAccel;
    903     /**< Satellite Doppler Accelertion\n
    904          - Units: Hz/s \n
    905     */
    906     bool                         multipathEstValid;
    907     /**< Multipath estimate validity flag\n
    908         - 0: Multipath estimate not valid \n
    909         - 1: Multipath estimate valid \n
    910     */
    911     float                           multipathEstimate;
    912     /**< Estimate of multipath in measurement\n
    913          - Units: Meters \n
    914     */
    915     bool                         fineSpeedValid;
    916     /**< Fine speed validity flag\n
    917          - 0: Fine speed not valid \n
    918          - 1: Fine speed valid \n
    919     */
    920     float                           fineSpeed;
    921     /**< Carrier phase derived speed \n
    922          - Units: m/s \n
    923     */
    924     bool                         fineSpeedUncValid;
    925     /**< Fine speed uncertainty validity flag\n
    926          - 0: Fine speed uncertainty not valid \n
    927          - 1: Fine speed uncertainty valid \n
    928     */
    929     float                           fineSpeedUnc;
    930     /**< Carrier phase derived speed \n
    931         - Units: m/s \n
    932     */
    933     bool                         carrierPhaseValid;
    934     /**< Carrier Phase measurement validity flag\n
    935          - 0: Carrier Phase not valid \n
    936          - 1: Carrier Phase valid \n
    937     */
    938     double                          carrierPhase;
    939     /**< Carrier phase measurement [L1 cycles] \n
    940     */
    941     bool                         cycleSlipCountValid;
    942      /**< Cycle slup count validity flag\n
    943          - 0: Not valid \n
    944          - 1: Valid \n
    945     */
    946     uint8_t                         cycleSlipCount;
    947     /**< Increments when a CSlip is detected */
    948 
    949     bool                         svDirectionValid;
    950     /**< Validity flag for SV direction */
    951 
    952     float                           svAzimuth;
    953     /**< Satellite Azimuth
    954         - Units: radians \n
    955     */
    956     float                           svElevation;
    957     /**< Satellite Elevation
    958         - Units: radians \n
    959     */
    960 } Gnss_SVMeasurementStructType;
    961 
    962 /**< Maximum number of satellites in measurement block for given system. */
    963 
    964 typedef struct
    965 {
    966     size_t                          size;
    967     Gnss_LocSvSystemEnumType        system;
    968     /**< Specifies the Satellite System Type
    969     */
    970     bool                            isSystemTimeValid;
    971     /**< Indicates whether System Time is Valid:\n
    972          - 0x01 (TRUE) --  System Time is valid \n
    973          - 0x00 (FALSE) -- System Time is not valid
    974     */
    975     Gnss_LocSystemTimeStructType    systemTime;
    976     /**< System Time Information \n
    977     */
    978     bool                            isGloTime_valid;
    979     Gnss_LocGloTimeStructType       gloTime;
    980 
    981     bool                            isSystemTimeExt_valid;
    982     Gnss_LocGnssTimeExtStructType   systemTimeExt;
    983 
    984     uint8_t                         numSvs;
    985     /* Number of SVs in this report block */
    986 
    987     Gnss_SVMeasurementStructType    svMeasurement[GNSS_LOC_SV_MEAS_LIST_MAX_SIZE];
    988     /**< Satellite measurement Information \n
    989     */
    990 } Gnss_ClockMeasurementStructType;
    991 
    992 
    993 typedef struct
    994 {
    995     size_t                                      size;
    996     uint8_t                                     seqNum;
    997     /**< Current message Number */
    998     uint8_t                                     maxMessageNum;
    999     /**< Maximum number of message that will be sent for present time epoch. */
   1000 
   1001     bool                                     leapSecValid;
   1002     Gnss_LeapSecondInfoStructType               leapSec;
   1003 
   1004     Gnss_InterSystemBiasStructType              gpsGloInterSystemBias;
   1005 
   1006     Gnss_InterSystemBiasStructType              gpsBdsInterSystemBias;
   1007 
   1008     Gnss_InterSystemBiasStructType              gpsGalInterSystemBias;
   1009 
   1010     Gnss_InterSystemBiasStructType              bdsGloInterSystemBias;
   1011 
   1012     Gnss_InterSystemBiasStructType              galGloInterSystemBias;
   1013 
   1014     Gnss_InterSystemBiasStructType              galBdsInterSystemBias;
   1015 
   1016     bool                                     clockFreqValid;
   1017     Gnss_LocRcvrClockFrequencyInfoStructType    clockFreq;   /* Freq */
   1018     bool                                     gnssMeasValid;
   1019     Gnss_ClockMeasurementStructType             gnssMeas;
   1020     Gnss_ApTimeStampStructType               timeStamp;
   1021 
   1022 } GnssSvMeasurementSet;
   1023 
   1024 typedef enum
   1025 {
   1026    GNSS_SV_POLY_COEFF_VALID             = 0x01,
   1027    /**< SV position in orbit coefficients are valid */
   1028    GNSS_SV_POLY_IONO_VALID              = 0x02,
   1029    /**< Iono estimates are valid */
   1030 
   1031    GNSS_SV_POLY_TROPO_VALID             = 0x04,
   1032    /**< Tropo estimates are valid */
   1033 
   1034    GNSS_SV_POLY_ELEV_VALID              = 0x08,
   1035    /**< Elevation, rate, uncertainty are valid */
   1036 
   1037    GNSS_SV_POLY_SRC_ALM_CORR            = 0x10,
   1038    /**< Polynomials based on XTRA */
   1039 
   1040    GNSS_SV_POLY_SBAS_IONO_VALID         = 0x20,
   1041    /**< SBAS IONO and rate are valid */
   1042 
   1043    GNSS_SV_POLY_GLO_STR4                = 0x40
   1044    /**< GLONASS String 4 has been received */
   1045 }Gnss_SvPolyStatusMaskType;
   1046 
   1047 
   1048 typedef struct
   1049 {
   1050     size_t      size;
   1051     uint16_t     gnssSvId;
   1052     /* GPS: 1-32, GLO: 65-96, 0: Invalid,
   1053        SBAS: 120-151, BDS:201-237,GAL:301 to 336
   1054        All others are reserved
   1055     */
   1056     int8_t      freqNum;
   1057     /* Freq index, only valid if u_SysInd is GLO */
   1058 
   1059     uint8_t     svPolyFlags;
   1060     /* Indicate the validity of the elements
   1061     as per Gnss_SvPolyStatusMaskType
   1062     */
   1063 
   1064     uint32_t    is_valid;
   1065 
   1066     uint16_t     iode;
   1067     /* Ephemeris reference time
   1068        GPS:Issue of Data Ephemeris used [unitless].
   1069        GLO: Tb 7-bit, refer to ICD02
   1070     */
   1071     double      T0;
   1072     /* Reference time for polynominal calculations
   1073        GPS: Secs in week.
   1074        GLO: Full secs since Jan/01/96
   1075     */
   1076     double      polyCoeffXYZ0[GNSS_SV_POLY_XYZ_0_TH_ORDER_COEFF_MAX_SIZE];
   1077     /* C0X, C0Y, C0Z */
   1078     double      polyCoefXYZN[GNSS_SV_POLY_XYZ_N_TH_ORDER_COEFF_MAX_SIZE];
   1079     /* C1X, C2X ... C2Z, C3Z */
   1080     float       polyCoefOther[GNSS_SV_POLY_SV_CLKBIAS_COEFF_MAX_SIZE];
   1081     /* C0T, C1T, C2T, C3T */
   1082     float       svPosUnc;       /* SV position uncertainty [m]. */
   1083     float       ionoDelay;    /* Ionospheric delay at d_T0 [m]. */
   1084     float       ionoDot;      /* Iono delay rate [m/s].  */
   1085     float       sbasIonoDelay;/* SBAS Ionospheric delay at d_T0 [m]. */
   1086     float       sbasIonoDot;  /* SBAS Iono delay rate [m/s].  */
   1087     float       tropoDelay;   /* Tropospheric delay [m]. */
   1088     float       elevation;    /* Elevation [rad] at d_T0 */
   1089     float       elevationDot;      /* Elevation rate [rad/s] */
   1090     float       elevationUnc;      /* SV elevation [rad] uncertainty */
   1091     double      velCoef[GNSS_SV_POLY_VELOCITY_COEF_MAX_SIZE];
   1092     /* Coefficients of velocity poly */
   1093     uint32_t    enhancedIOD;    /*  Enhanced Reference Time */
   1094 } GnssSvPolynomial;
   1095 
   1096 #ifdef __cplusplus
   1097 }
   1098 #endif /* __cplusplus */
   1099 
   1100 #endif /* GPS_EXTENDED_C_H */
   1101