Skip to main content
GNSS HAT Library Documentation
Shop GitHub Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

C API

Include <jimmypaputto/GnssHat.h>. All functions are prefixed with jp_gnss_hat_ (lifecycle/navigation) or jp_gnss_ (config helpers, string converters).

Lifecycle

jp_gnss_hat_t* hat = jp_gnss_hat_create();
// ... use hat ...
jp_gnss_hat_destroy(hat);
FunctionReturnDescription
jp_gnss_hat_create(void)jp_gnss_hat_t*Create GNSS HAT instance. Auto-detects HAT variant
jp_gnss_hat_destroy(jp_gnss_hat_t* hat)voidDestroy instance and free resources
jp_gnss_hat_name(jp_gnss_hat_t* hat)const char*Get detected HAT name
jp_gnss_hat_start(jp_gnss_hat_t* hat, const jp_gnss_gnss_config_t* config)boolConfigure module and start acquisition
FunctionReturnDescription
jp_gnss_hat_wait_and_get_fresh_navigation(hat, nav)boolBlock until new data, write to nav. Returns false on error
jp_gnss_hat_get_navigation(hat, nav)boolGet last known data immediately (non-blocking)

Reset

FunctionReturnDescription
jp_gnss_hat_hard_reset_cold_start(hat)voidFull cold reset
jp_gnss_hat_soft_reset_hot_start(hat)voidSoft reset preserving almanac/ephemeris

Timepulse

FunctionReturnDescription
jp_gnss_hat_enable_timepulse(hat)boolEnable timepulse on GPIO 5
jp_gnss_hat_disable_timepulse(hat)voidDisable timepulse
jp_gnss_hat_timepulse(hat)voidBlock until next timepulse

GPSD Forwarding

FunctionReturnDescription
jp_gnss_hat_start_forward_for_gpsd(hat)boolStart NMEA forwarding to virtual TTY
jp_gnss_hat_stop_forward_for_gpsd(hat)voidStop forwarding
jp_gnss_hat_join_forward_for_gpsd(hat)voidBlock until forwarder exits
jp_gnss_hat_get_gpsd_device_path(hat)const char*Virtual serial port path

Time Mark

FunctionReturnDescription
jp_gnss_hat_get_time_mark(hat, tm)boolGet last time mark (non-blocking)
jp_gnss_hat_wait_and_get_fresh_time_mark(hat, tm)boolBlock until new time mark event
jp_gnss_hat_enable_time_mark_trigger(hat)boolEnable EXTINT as output
jp_gnss_hat_disable_time_mark_trigger(hat)voidDisable EXTINT trigger
jp_gnss_hat_trigger_time_mark(hat, edge)voidToggle/raise/lower EXTINT

Configuration

FunctionReturnDescription
jp_gnss_gnss_config_init(config)voidInitialize config struct with defaults
jp_gnss_gnss_config_add_geofence(config, geofence)boolAdd a geofence (max 4). Returns false if full

RTK

FunctionReturnDescription
jp_gnss_rtk_get_full_corrections(hat)jp_gnss_rtk_corrections_t*Full RTCM3 correction set (M7M)
jp_gnss_rtk_get_tiny_corrections(hat)jp_gnss_rtk_corrections_t*Compact RTCM3 correction set (M4M)
jp_gnss_rtk_get_rtcm3_frame(hat, id)jp_gnss_rtcm3_frame_t*Specific RTCM3 message by ID
jp_gnss_rtk_apply_corrections(hat, frames, count)boolSend corrections to rover
jp_gnss_rtk_corrections_free(corrections)voidFree corrections memory
jp_gnss_rtcm3_frame_free(frame)voidFree single frame memory
Note
Memory Management — RTK correction functions allocate memory. Always free with jp_gnss_rtk_corrections_free() or jp_gnss_rtcm3_frame_free() after use.

String Converters

All return const char* — static strings, do not free.

FunctionInput Type
jp_gnss_fix_quality_to_stringjp_gnss_fix_quality_t
jp_gnss_fix_status_to_stringjp_gnss_fix_status_t
jp_gnss_fix_type_to_stringjp_gnss_fix_type_t
jp_gnss_jamming_state_to_stringjp_gnss_jamming_state_t
jp_gnss_antenna_status_to_stringjp_gnss_antenna_status_t
jp_gnss_antenna_power_to_stringjp_gnss_antenna_power_t
jp_gnss_rf_band_to_stringjp_gnss_rf_band_t
jp_gnss_geofencing_status_to_stringjp_gnss_geofencing_status_t
jp_gnss_geofence_status_to_stringjp_gnss_geofence_status_t
jp_gnss_gnss_id_to_stringjp_gnss_gnss_id_t
jp_gnss_sv_quality_to_stringjp_gnss_sv_quality_t
jp_gnss_time_mark_mode_to_stringjp_gnss_time_mark_mode_t
jp_gnss_time_mark_run_to_stringjp_gnss_time_mark_run_t
jp_gnss_time_mark_time_base_to_stringjp_gnss_time_mark_time_base_t
jp_gnss_utc_time_iso8601const jp_gnss_position_velocity_time_t*

Key Structs

jp_gnss_navigation_t

FieldType
pvtjp_gnss_position_velocity_time_t
dopjp_gnss_dilution_over_precision_t
geofencingjp_gnss_geofencing_t
rf_blocks[UBLOX_MAX_RF_BLOCKS]jp_gnss_rf_block_t
rf_block_countuint8_t
satellites[UBLOX_MAX_SATELLITES]jp_gnss_satellite_info_t
satellite_countuint8_t

See Navigation Data for detailed field documentation.

Constants

ConstantValueDescription
UBLOX_MAX_GEOFENCES4Maximum geofence zones
UBLOX_MAX_RF_BLOCKS2Maximum RF blocks (bands)
UBLOX_MAX_SATELLITES64Maximum tracked satellites
UBLOX_SPECTRUM_BINS256Spectrum data bins per RF block