GPS
The GPS interface exposes an API to access GPS devices. The API offers functionality to initialize and configure a device, to start and stop GPS search, and to request and provide GPS assistance data (A-GPS).
Note
The GPS driver is deprecated since v1.7.0. Use the GNSS interface instead.
API documentation
include/drivers/gps.h
- group gpsapi
-
Typedefs
-
typedef void (*gps_event_handler_t)(const struct device *dev, struct gps_event *evt)
Callback API on GPS event.
- Param dev
Pointer to GPS device
- Param evt
Pointer to event data
-
typedef int (*gps_start_t)(const struct device *dev, struct gps_config *cfg)
Callback API for starting GPS operation.
See gps_start() for argument description
-
typedef int (*gps_stop_t)(const struct device *dev)
Callback API for stopping GPS operation.
See gps_stop() for argument description
-
typedef int (*gps_agps_write_t)(const struct device *dev, enum gps_agps_type type, void *data, size_t data_len)
Callback API for writing to A-GPS data to GPS module.
See gps_write() for argument description
-
typedef int (*gps_init_t)(const struct device *dev, gps_event_handler_t handler)
Callback API for initializing GPS device.
See gps_init() for argument description
-
typedef int (*gps_deinit_t)(const struct device *dev)
Callback API for deinitializing GPS device.
See gps_deinit() for argument description
Enums
Values:
Search will be stopped after first fix.
Search continues until explicitly stopped.
Periodically start search, stops on fix.
-
enum gps_use_case
Values:
-
enumerator GPS_USE_CASE_SINGLE_COLD_START
Target best single cold start performance.
-
enumerator GPS_USE_CASE_MULTIPLE_HOT_START
Target best multiple hot starts performance.
-
enumerator GPS_USE_CASE_SINGLE_COLD_START
-
enum gps_accuracy
Values:
-
enumerator GPS_ACCURACY_NORMAL
Use normal accuracy thresholds for producing GPS fix.
-
enumerator GPS_ACCURACY_LOW
Allow low accuracy fixes using 3 satellites. Note that one of the two conditions must be met:
Altitude, accurate within 10s of meters provided using gps_agps_write(). Valid for 24 hours.
One fix using 5 or more satellites in the previous 24 hours, without the device rebooting in the meantime.
See the GNSS documentation for more details.
-
enumerator GPS_ACCURACY_NORMAL
-
enum gps_power_mode
Values:
-
enumerator GPS_POWER_MODE_DISABLED
Best GPS performance.
-
enumerator GPS_POWER_MODE_PERFORMANCE
Lower power, without significant GPS performance degradation.
-
enumerator GPS_POWER_MODE_SAVE
Lowest power option, with acceptable GPS performance.
-
enumerator GPS_POWER_MODE_DISABLED
-
enum gps_agps_type
GPS assistance data types.
Values:
-
enumerator GPS_AGPS_UTC_PARAMETERS
UTC parameters.
-
enumerator GPS_AGPS_EPHEMERIDES
Ephemerides.
-
enumerator GPS_AGPS_ALMANAC
Almanac.
-
enumerator GPS_AGPS_KLOBUCHAR_CORRECTION
Ionospheric correction parameters, Klobuchar model.
-
enumerator GPS_AGPS_NEQUICK_CORRECTION
Ionospheric correction parameters, NeQuick model.
-
enumerator GPS_AGPS_GPS_TOWS
Time of week.
-
enumerator GPS_AGPS_GPS_SYSTEM_CLOCK_AND_TOWS
GPS system clock and time of week
-
enumerator GPS_AGPS_LOCATION
Approximate location.
-
enumerator GPS_AGPS_INTEGRITY
Satellite integrity data.
-
enumerator GPS_AGPS_UTC_PARAMETERS
-
enum gps_event_type
GPS event types.
Values:
-
enumerator GPS_EVT_SEARCH_STARTED
-
enumerator GPS_EVT_SEARCH_STOPPED
-
enumerator GPS_EVT_SEARCH_TIMEOUT
-
enumerator GPS_EVT_PVT
-
enumerator GPS_EVT_PVT_FIX
-
enumerator GPS_EVT_NMEA
-
enumerator GPS_EVT_NMEA_FIX
-
enumerator GPS_EVT_OPERATION_BLOCKED
-
enumerator GPS_EVT_OPERATION_UNBLOCKED
-
enumerator GPS_EVT_AGPS_DATA_NEEDED
-
enumerator GPS_EVT_ERROR
-
enumerator GPS_EVT_SEARCH_STARTED
Functions
-
static inline int gps_start(const struct device *dev, struct gps_config *cfg)
Function to start GPS operation.
If GPS is already running a call to this function will restart the GPS.
- Parameters
dev – Pointer to GPS device
cfg – Pointer to GPS configuration.
- Returns
Zero on success or (negative) error code otherwise.
-
static inline int gps_stop(const struct device *dev)
Function to stop GPS operation.
- Parameters
dev – Pointer to GPS device
- Returns
Zero on success or (negative) error code otherwise.
-
static inline int gps_agps_write(const struct device *dev, enum gps_agps_type type, void *data, size_t data_len)
Function to write A-GPS data to GPS module.
- Parameters
dev – Pointer to GPS device
type – A-GPS data type
data – Pointer to A-GPS data
data_len – Length of
data
- Returns
Zero on success or (negative) error code otherwise.
-
static inline int gps_init(const struct device *dev, gps_event_handler_t handler)
Initializes GPS device.
- Parameters
dev – Pointer to GPS device.
handler – Pointer to GPS event handler.
- Returns
Zero on success or (negative) error code otherwise.
-
struct gps_nmea
- #include <gps.h>
-
struct gps_datetime
- #include <gps.h>
-
struct gps_sv
- #include <gps.h>
Public Members
-
uint16_t sv
SV number 1…32 for GPS.
-
uint16_t cn0
0.1 dB/Hz.
-
int16_t elevation
SV elevation angle in degrees.
-
int16_t azimuth
SV azimuth angle in degrees.
-
uint8_t signal
Signal type. 0: invalid, 1: GPS L1C/A.
-
uint8_t in_fix
Satellite used in fix calculation.
-
uint8_t unhealthy
Satellite is marked as unhealthy.
-
uint16_t sv
-
struct gps_pvt
- #include <gps.h>
-
struct gps_config
- #include <gps.h>
GPS search configuration.
Public Members
GPS navigation mode, gps_nav_mode.
-
enum gps_power_mode power_mode
Power mode, gps_power_mode.
-
enum gps_use_case use_case
GPS use case, gps_use_case.
-
enum gps_accuracy accuracy
Accuracy threshold for producing fix, gps_accuracy.
-
uint32_t interval
Interval, in seconds, at which to start GPS search. The value is ignored outside periodic mode. Minimum accepted value is 10 seconds.
-
int32_t timeout
Time to search for fix before giving up. If used in periodic mode, the timeout repeats every interval. K_FOREVER or 0 indicate that the GPS will search until it gets a valid PVT estimate, except in continuous mode, where it will stay on until explicitly stopped also in case of valid PVT.
-
bool delete_agps_data
Delete stored assistance data before starting GPS search.
-
bool priority
Give GPS priority in competition with other radio resource users. This may affect the operation of other protocols, such as LTE in the case of nRF9160.
-
struct gps_agps_request
- #include <gps.h>
Public Members
-
uint32_t sv_mask_ephe
Bit mask indicating the satellite PRNs for which the assistance GPS ephemeris data is needed.
-
uint32_t sv_mask_alm
Bit mask indicating the satellite PRNs for which the assistance GPS almanac data is needed.
-
uint8_t utc
GPS UTC parameters.
-
uint8_t klobuchar
Klobuchar parameters.
-
uint8_t nequick
NeQuick parameters.
-
uint8_t system_time_tow
GPS system time and SV TOWs.
-
uint8_t position
Position assistance parameters.
-
uint8_t integrity
Integrity assistance parameters.
-
uint32_t sv_mask_ephe
-
struct gps_event
- #include <gps.h>
-
struct gps_driver_api
- #include <gps.h>
GPS driver API.
This is the API all GPS drivers must expose.
-
typedef void (*gps_event_handler_t)(const struct device *dev, struct gps_event *evt)