GNSS (Global Navigation Satellite System)
Overview
GNSS is a general term which covers satellite systems used for navigation, like GPS (Global Positioning System). GNSS services are usually accessed through GNSS modems which receive and process GNSS signals to determine their position, or more specifically, their antennas position. They usually additionally provide a precise time synchronization mechanism, commonly named PPS (Pulse-Per-Second).
Subsystem support
The GNSS subsystem is based on the Modem modules. The GNSS subsystem covers everything from sending and receiving commands to and from the modem, to parsing, creating and processing NMEA0183 messages.
Adding support for additional NMEA0183 based GNSS modems requires little more than implementing power management and configuration for the specific GNSS modem.
Adding support for GNSS modems which use other protocols and/or buses than the usual NMEA0183 over UART is possible, but will require a bit more work from the driver developer.
Configuration Options
Related configuration options:
Navigation Reference
Related code samples
- GNSS
Connect to a GNSS device to obtain time, navigation data, and satellite information.
- group navigation
Navigation utilities.
Functions
-
int navigation_distance(uint64_t *distance, const struct navigation_data *p1, const struct navigation_data *p2)
Calculate the distance between two navigation points along the surface of the sphere they are relative to.
- Parameters:
distance – Destination for calculated distance in millimeters
p1 – First navigation point
p2 – Second navigation point
- Returns:
0 if successful
- Returns:
-EINVAL if either navigation point is invalid
-
int navigation_bearing(uint32_t *bearing, const struct navigation_data *from, const struct navigation_data *to)
Calculate the bearing from one navigation point to another.
- Parameters:
bearing – Destination for calculated bearing angle in millidegrees
from – First navigation point
to – Second navigation point
- Returns:
0 if successful
- Returns:
-EINVAL if either navigation point is invalid
-
struct navigation_data
- #include <navigation.h>
Navigation data structure.
The structure describes the momentary navigation details of a point relative to a sphere (commonly Earth)
Public Members
-
int64_t latitude
Latitudal position in nanodegrees (0 to +-180E9)
-
int64_t longitude
Longitudal position in nanodegrees (0 to +-180E9)
-
uint32_t bearing
Bearing angle in millidegrees (0 to 360E3)
-
uint32_t speed
Speed in millimeters per second.
-
int32_t altitude
Altitude in millimeters.
-
int64_t latitude
-
int navigation_distance(uint64_t *distance, const struct navigation_data *p1, const struct navigation_data *p2)
GNSS API Reference
Related code samples
- GNSS
Connect to a GNSS device to obtain time, navigation data, and satellite information.
- group gnss_interface
GNSS Interface.
- Since
3.6
- Version
0.1.0
Defines
-
GNSS_DATA_CALLBACK_DEFINE(_dev, _callback)
Register a callback structure for GNSS data published.
- Parameters:
_dev – Device pointer
_callback – The callback function
-
GNSS_SATELLITES_CALLBACK_DEFINE(_dev, _callback)
Register a callback structure for GNSS satellites published.
- Parameters:
_dev – Device pointer
_callback – The callback function
Typedefs
-
typedef int (*gnss_set_fix_rate_t)(const struct device *dev, uint32_t fix_interval_ms)
API for setting fix rate.
-
typedef int (*gnss_get_fix_rate_t)(const struct device *dev, uint32_t *fix_interval_ms)
API for getting fix rate.
-
typedef int (*gnss_set_periodic_config_t)(const struct device *dev, const struct gnss_periodic_config *periodic_config)
API for setting periodic tracking configuration.
-
typedef int (*gnss_get_periodic_config_t)(const struct device *dev, struct gnss_periodic_config *periodic_config)
API for setting periodic tracking configuration.
-
typedef int (*gnss_set_navigation_mode_t)(const struct device *dev, enum gnss_navigation_mode mode)
API for setting navigation mode.
-
typedef int (*gnss_get_navigation_mode_t)(const struct device *dev, enum gnss_navigation_mode *mode)
API for getting navigation mode.
-
typedef uint32_t gnss_systems_t
Type storing bitmask of GNSS systems.
-
typedef int (*gnss_set_enabled_systems_t)(const struct device *dev, gnss_systems_t systems)
API for enabling systems.
-
typedef int (*gnss_get_enabled_systems_t)(const struct device *dev, gnss_systems_t *systems)
API for getting enabled systems.
-
typedef int (*gnss_get_supported_systems_t)(const struct device *dev, gnss_systems_t *systems)
API for getting enabled systems.
-
typedef void (*gnss_data_callback_t)(const struct device *dev, const struct gnss_data *data)
Template for GNSS data callback.
-
typedef void (*gnss_satellites_callback_t)(const struct device *dev, const struct gnss_satellite *satellites, uint16_t size)
Template for GNSS satellites callback.
Enums
-
enum gnss_pps_mode
GNSS PPS modes.
Values:
-
enumerator GNSS_PPS_MODE_DISABLED = 0
PPS output disabled.
-
enumerator GNSS_PPS_MODE_ENABLED = 1
PPS output always enabled.
-
enumerator GNSS_PPS_MODE_ENABLED_AFTER_LOCK = 2
PPS output enabled from first lock.
-
enumerator GNSS_PPS_MODE_ENABLED_WHILE_LOCKED = 3
PPS output enabled while locked.
-
enumerator GNSS_PPS_MODE_DISABLED = 0
-
enum gnss_navigation_mode
GNSS navigation modes.
Values:
-
enumerator GNSS_NAVIGATION_MODE_ZERO_DYNAMICS = 0
Dynamics have no impact on tracking.
-
enumerator GNSS_NAVIGATION_MODE_LOW_DYNAMICS = 1
Low dynamics have higher impact on tracking.
-
enumerator GNSS_NAVIGATION_MODE_BALANCED_DYNAMICS = 2
Low and high dynamics have equal impact on tracking.
-
enumerator GNSS_NAVIGATION_MODE_HIGH_DYNAMICS = 3
High dynamics have higher impact on tracking.
-
enumerator GNSS_NAVIGATION_MODE_ZERO_DYNAMICS = 0
-
enum gnss_system
Systems contained in gnss_systems_t.
Values:
-
enum gnss_fix_status
GNSS fix status.
Values:
-
enumerator GNSS_FIX_STATUS_NO_FIX = 0
No GNSS fix aqcuired.
-
enumerator GNSS_FIX_STATUS_GNSS_FIX = 1
GNSS fix aqcuired.
-
enumerator GNSS_FIX_STATUS_DGNSS_FIX = 2
Differential GNSS fix acquired.
-
enumerator GNSS_FIX_STATUS_ESTIMATED_FIX = 3
Estimated fix acquired.
-
enumerator GNSS_FIX_STATUS_NO_FIX = 0
-
enum gnss_fix_quality
GNSS fix quality.
Values:
-
enumerator GNSS_FIX_QUALITY_INVALID = 0
Invalid fix.
-
enumerator GNSS_FIX_QUALITY_GNSS_SPS = 1
Standard positioning service.
-
enumerator GNSS_FIX_QUALITY_DGNSS = 2
Differential GNSS.
-
enumerator GNSS_FIX_QUALITY_GNSS_PPS = 3
Precise positioning service.
-
enumerator GNSS_FIX_QUALITY_RTK = 4
Real-time kinematic.
-
enumerator GNSS_FIX_QUALITY_FLOAT_RTK = 5
Floating real-time kinematic.
-
enumerator GNSS_FIX_QUALITY_ESTIMATED = 6
Estimated fix.
-
enumerator GNSS_FIX_QUALITY_INVALID = 0
Functions
-
int gnss_set_fix_rate(const struct device *dev, uint32_t fix_interval_ms)
Set the GNSS fix rate.
- Parameters:
dev – Device instance
fix_interval_ms – Fix interval to set in milliseconds
- Returns:
0 if successful
- Returns:
-errno negative errno code on failure
-
int gnss_get_fix_rate(const struct device *dev, uint32_t *fix_interval_ms)
Get the GNSS fix rate.
- Parameters:
dev – Device instance
fix_interval_ms – Destination for fix interval in milliseconds
- Returns:
0 if successful
- Returns:
-errno negative errno code on failure
-
int gnss_set_periodic_config(const struct device *dev, const struct gnss_periodic_config *config)
Set the GNSS periodic tracking configuration.
- Parameters:
dev – Device instance
config – Periodic tracking configuration to set
- Returns:
0 if successful
- Returns:
-errno negative errno code on failure
-
int gnss_get_periodic_config(const struct device *dev, struct gnss_periodic_config *config)
Get the GNSS periodic tracking configuration.
- Parameters:
dev – Device instance
config – Destination for periodic tracking configuration
- Returns:
0 if successful
- Returns:
-errno negative errno code on failure
-
int gnss_set_navigation_mode(const struct device *dev, enum gnss_navigation_mode mode)
Set the GNSS navigation mode.
- Parameters:
dev – Device instance
mode – Navigation mode to set
- Returns:
0 if successful
- Returns:
-errno negative errno code on failure
-
int gnss_get_navigation_mode(const struct device *dev, enum gnss_navigation_mode *mode)
Get the GNSS navigation mode.
- Parameters:
dev – Device instance
mode – Destination for navigation mode
- Returns:
0 if successful
- Returns:
-errno negative errno code on failure
-
int gnss_set_enabled_systems(const struct device *dev, gnss_systems_t systems)
Set enabled GNSS systems.
- Parameters:
dev – Device instance
systems – Systems to enable
- Returns:
0 if successful
- Returns:
-errno negative errno code on failure
-
int gnss_get_enabled_systems(const struct device *dev, gnss_systems_t *systems)
Get enabled GNSS systems.
- Parameters:
dev – Device instance
systems – Destination for enabled systems
- Returns:
0 if successful
- Returns:
-errno negative errno code on failure
-
int gnss_get_supported_systems(const struct device *dev, gnss_systems_t *systems)
Get supported GNSS systems.
- Parameters:
dev – Device instance
systems – Destination for supported systems
- Returns:
0 if successful
- Returns:
-errno negative errno code on failure
-
struct gnss_periodic_config
- #include <gnss.h>
GNSS periodic tracking configuration.
Note
Setting either active_time or inactive_time to 0 will disable periodic function.
-
struct gnss_info
- #include <gnss.h>
GNSS info data structure.
Public Members
-
uint16_t satellites_cnt
Number of satellites being tracked.
-
uint32_t hdop
Horizontal dilution of precision in 1/1000.
-
enum gnss_fix_status fix_status
The fix status.
-
enum gnss_fix_quality fix_quality
The fix quality.
-
uint16_t satellites_cnt
-
struct gnss_time
- #include <gnss.h>
GNSS time data structure.
-
struct gnss_driver_api
- #include <gnss.h>
GNSS API structure.
-
struct gnss_data
- #include <gnss.h>
GNSS data structure.
-
struct gnss_data_callback
- #include <gnss.h>
GNSS callback structure.
Public Members
-
gnss_data_callback_t callback
Callback called when GNSS data is published.
-
gnss_data_callback_t callback
-
struct gnss_satellite
- #include <gnss.h>
GNSS satellite structure.
Public Members
-
uint8_t prn
Pseudo-random noise sequence.
-
uint8_t snr
Signal-to-noise ratio in dB.
-
uint8_t elevation
Elevation in degrees [0, 90].
-
uint16_t azimuth
Azimuth relative to True North in degrees [0, 359].
-
enum gnss_system system
System of satellite.
-
uint8_t is_tracked
True if satellite is being tracked.
-
uint8_t prn
-
struct gnss_satellites_callback
- #include <gnss.h>
GNSS callback structure.
Public Members
-
gnss_satellites_callback_t callback
Callback called when GNSS satellites is published.
-
gnss_satellites_callback_t callback