API Reference
Decoder State
GNSSDecoder.GNSSDecoderState — Type
struct GNSSDecoderState{D<:GNSSDecoder.AbstractGNSSData, C<:GNSSDecoder.AbstractGNSSConstants, CA<:GNSSDecoder.AbstractGNSSCache, B<:Unsigned}Generic decoder state for GNSS signal decoding. This parametric struct holds all state required for decoding navigation messages from GNSS satellites.
Type Parameters
D<:AbstractGNSSData: The data type holding decoded navigation message fieldsC<:AbstractGNSSConstants: Constants specific to the GNSS system (e.g., preamble, timing)CA<:AbstractGNSSCache: Cache for intermediate decoding stateB<:Unsigned: Buffer type for storing raw bits (sized for the specific GNSS system)
Fields
prn::Int64: Pseudo-Random Noise code identifier for the satelliteraw_buffer::Unsigned: Raw bit buffer before phase correctionbuffer::Unsigned: Bit buffer after phase correctionraw_data::GNSSDecoder.AbstractGNSSData: Partially decoded navigation data (not yet validated)data::GNSSDecoder.AbstractGNSSData: Validated navigation data ready for useconstants::GNSSDecoder.AbstractGNSSConstants: System-specific constants (preamble, timing parameters)cache::GNSSDecoder.AbstractGNSSCache: Cache for intermediate decoding statenum_bits_buffered::Int64: Number of bits currently stored in buffernum_bits_after_valid_syncro_sequence::Union{Nothing, Int64}: Number of bits received after last valid synchronization sequence, ornothingif not yet synchronizedis_shifted_by_180_degrees::Any: Whether the signal phase is inverted by 180 degrees
See Also
GPSL1DecoderState: Constructor for GPS L1 C/A decoder stateGalileoE1BDecoderState: Constructor for Galileo E1B decoder statedecode: Main function to decode bits using this statereset_decoder_state: Reset decoder state after signal loss
Constructors
GNSSDecoder.GPSL1DecoderState — Function
GPSL1DecoderState(
prn
) -> GNSSDecoderState{GNSSDecoder.GPSL1Data, GNSSDecoder.GPSL1Constants, GNSSDecoder.GPSL1Cache, GNSSDecoder.UInt320}
Create a decoder state for GPS L1 C/A navigation messages.
Initializes a GNSSDecoderState configured for decoding GPS L1 C/A (Coarse/Acquisition) civil navigation messages. The decoder extracts ephemeris, clock correction, and health data from the 50 bps LNAV data stream.
Arguments
prn::Int: Pseudo-Random Noise code identifier (1-32 for GPS satellites)
Returns
GNSSDecoderState{GPSL1Data}: Initialized decoder state for GPS L1
Example
state = GPSL1DecoderState(1) # Create decoder for PRN 1
state = decode(state, bits, num_bits)
if is_sat_healthy(state)
# Use state.data for positioning
endSee Also
GNSSDecoderState: The underlying state structuredecode: Decode bits using this statereset_decoder_state: Reset after signal lossis_sat_healthy: Check satellite health status
GNSSDecoder.GalileoE1BDecoderState — Function
GalileoE1BDecoderState(
prn
) -> GNSSDecoderState{GNSSDecoder.GalileoE1BData, GNSSDecoder.GalileoE1BConstants, GNSSDecoder.GalileoE1BCache, GNSSDecoder.UInt288}
Create a decoder state for Galileo E1B I/NAV navigation messages.
Initializes a GNSSDecoderState configured for decoding Galileo E1B (Open Service) navigation messages. The decoder extracts ephemeris, clock correction, ionospheric parameters, and health data from the 250 bps I/NAV data stream using Viterbi decoding.
Arguments
prn::Int: Pseudo-Random Noise code identifier (1-36 for Galileo satellites)
Returns
GNSSDecoderState{GalileoE1BData}: Initialized decoder state for Galileo E1B
Example
state = GalileoE1BDecoderState(1) # Create decoder for PRN 1
state = decode(state, bits, num_bits)
if is_sat_healthy(state)
# Use state.data for positioning
endSee Also
GNSSDecoderState: The underlying state structuredecode: Decode bits using this statereset_decoder_state: Reset after signal lossis_sat_healthy: Check satellite health status
Decoding
GNSSDecoder.decode — Function
decode(
state::GNSSDecoderState,
bits::Unsigned,
num_bits::Int64;
decode_once
) -> GNSSDecoderState
Decode GNSS navigation message bits and update the decoder state.
Processes incoming bits from a GNSS signal, detecting preambles and decoding synchronization sequences to extract navigation data. The function handles both normal and 180-degree phase-shifted signals automatically.
Arguments
state::GNSSDecoderState: Current decoder statebits::T: Unsigned integer containing the bits to decode (MSB first)num_bits::Int: Number of valid bits inbitsto process
Keywords
decode_once::Bool=false: Iftrue, stops decoding after all required positioning data has been decoded (subframes 1-3 for GPS, pages 1-5 for Galileo)
Returns
GNSSDecoderState: Updated decoder state with newly decoded data
Example
state = GPSL1DecoderState(1) # PRN 1
state = decode(state, UInt8(0b10110010), 8)See Also
GNSSDecoderState: The state structure being updatedis_sat_healthy: Check if satellite health is good after decoding
State Management
GNSSDecoder.reset_decoder_state — Function
reset_decoder_state(
state::GNSSDecoderState{<:GNSSDecoder.GPSL1Data}
) -> GNSSDecoderState{GNSSDecoder.GPSL1Data, C, CA, GNSSDecoder.UInt320} where {C<:GNSSDecoder.AbstractGNSSConstants, CA<:GNSSDecoder.AbstractGNSSCache}
Reset the GPS L1 decoder state after a signal loss or reacquisition.
Clears the bit buffers and time-of-week (TOW) field while preserving other decoded ephemeris and clock data in raw_data. This allows faster recovery after brief signal outages without requiring a full re-decode of all subframes.
The trans_week field is intentionally not reset as it is only broadcast in subframe 1. This may cause brief errors if a GPS week rollover occurs during a signal outage.
Arguments
state::GNSSDecoderState{<:GPSL1Data}: Current GPS L1 decoder state
Returns
GNSSDecoderState{<:GPSL1Data}: Reset decoder state with cleared buffers
Example
# After detecting signal loss
state = reset_decoder_state(state)
# Continue decoding with preserved ephemeris
state = decode(state, new_bits, num_bits)See Also
GPSL1DecoderState: Create a fresh decoder statedecode: Continue decoding after reset
reset_decoder_state(
state::GNSSDecoderState{<:GNSSDecoder.GalileoE1BData}
) -> GNSSDecoderState{GNSSDecoder.GalileoE1BData, C, CA, GNSSDecoder.UInt288} where {C<:GNSSDecoder.AbstractGNSSConstants, CA<:GNSSDecoder.AbstractGNSSCache}
Reset the Galileo E1B decoder state after a signal loss or reacquisition.
Clears the bit buffers and time-of-week (TOW) field while preserving other decoded ephemeris and clock data in raw_data. This allows faster recovery after brief signal outages without requiring a full re-decode of all pages.
The week number (WN) field is intentionally not reset as it is not broadcast as frequently as TOW. This may cause brief errors if a week rollover occurs during a signal outage.
Arguments
state::GNSSDecoderState{<:GalileoE1BData}: Current Galileo E1B decoder state
Returns
GNSSDecoderState{<:GalileoE1BData}: Reset decoder state with cleared buffers
Example
# After detecting signal loss
state = reset_decoder_state(state)
# Continue decoding with preserved ephemeris
state = decode(state, new_bits, num_bits)See Also
GalileoE1BDecoderState: Create a fresh decoder statedecode: Continue decoding after reset
Health Status
GNSSDecoder.is_sat_healthy — Function
is_sat_healthy(
state::GNSSDecoderState{<:GNSSDecoder.GPSL1Data}
) -> Bool
Check if the GPS satellite is healthy and usable for positioning.
Examines the 6-bit satellite health field (svhealth) from subframe 1. A satellite is considered healthy only if all health bits are zero ("000000").
This function requires that subframe 1 has been successfully decoded. Check that state.data.svhealth is not nothing before relying on this result.
Arguments
state::GNSSDecoderState{<:GPSL1Data}: GPS L1 decoder state with decoded data
Returns
Bool:trueif satellite health status indicates normal operation
Example
state = GPSL1DecoderState(1)
state = decode(state, bits, num_bits)
if is_sat_healthy(state)
# Safe to use for positioning
endSee Also
GPSL1DecoderState: Create decoder statedecode: Decode navigation data
is_sat_healthy(
state::GNSSDecoderState{<:GNSSDecoder.GalileoE1BData}
) -> Bool
Check if the Galileo satellite is healthy and usable for positioning.
Examines both the signal health status (signal_health_e1b) and data validity status (data_validity_status_e1b) from page type 5. A satellite is considered healthy only if both conditions are met:
- Signal health is
signal_ok - Data validity is
navigation_data_valid
This function requires that page type 5 has been successfully decoded. Check that state.data.signal_health_e1b is not nothing before relying on this result.
Arguments
state::GNSSDecoderState{<:GalileoE1BData}: Galileo E1B decoder state with decoded data
Returns
Bool:trueif satellite health and data validity indicate normal operation
Example
state = GalileoE1BDecoderState(1)
state = decode(state, bits, num_bits)
if is_sat_healthy(state)
# Safe to use for positioning
endSee Also
GalileoE1BDecoderState: Create decoder statedecode: Decode navigation data
Data Types
GPS L1
GNSSDecoder.GPSL1Constants — Type
GPSL1ConstantsWGS 84 constants and LNAV message structure parameters for GPS L1 C/A signal decoding.
The physical constants are defined in IS-GPS-200 (Interface Specification) and are used for computing satellite positions and clock corrections from broadcast ephemeris data.
Fields
syncro_sequence_length::Int: Length of synchronization sequence in bits (300 bits = 10 words × 30 bits)preamble::UInt8: TLM word preamble pattern (10001011 binary, 0x8B)preamble_length::Int: Length of preamble in bits (8)word_length::Int: Length of each LNAV word in bits (30)PI::Float64: Mathematical constant π = 3.1415926535898 (IS-GPS-200 Table 20-IV)Ω_dot_e::Float64: WGS 84 Earth rotation rate = 7.2921151467×10⁻⁵ rad/sc::Float64: Speed of light = 2.99792458×10⁸ m/sμ::Float64: WGS 84 Earth gravitational parameter = 3.986005×10¹⁴ m³/s²F::Float64: Relativistic correction constant = -4.442807633×10⁻¹⁰ s/√m
Reference
IS-GPS-200N, Section 20.3.3 and Table 20-IV
GNSSDecoder.GPSL1Data — Type
GPSL1DataDecoded GPS L1 C/A LNAV navigation message data.
Contains ephemeris, clock correction, and satellite health parameters decoded from subframes 1, 2, and 3 of the GPS LNAV message. All parameters conform to IS-GPS-200N.
Telemetry and Handover Word (TLM/HOW) Fields
last_subframe_id::Int: ID of the last decoded subframe (1-5)integrity_status_flag::Bool: LNAV data integrity status (0=OK, 1=bad)TOW::Int64: Time of Week at message transmission (seconds, 0-604784)alert_flag::Bool: URA may be worse than indicated (0=OK, 1=alert)anti_spoof_flag::Bool: Anti-spoofing mode (0=off, 1=on)
Subframe 1 - Clock Correction Parameters
trans_week::Int64: GPS week number (modulo 1024)codeonl2::Int64: Code on L2 channel (0=invalid, 1=P-code, 2=C/A-code, 3=invalid)ura::Float64: User Range Accuracy (meters), derived from URA indexsvhealth::String: 6-bit satellite health status ("000000" = healthy)IODC::String: Issue of Data, Clock (10-bit binary string)l2pcode::Bool: L2 P-code data flag (1=LNAV OFF on P-code)T_GD::Float64: L1-L2 group delay correction (seconds)t_0c::Int64: Clock reference time (seconds)a_f0::Float64: Clock bias correction coefficient (seconds)a_f1::Float64: Clock drift correction coefficient (s/s)a_f2::Float64: Clock drift rate correction coefficient (s/s²)
Subframe 2 - Ephemeris Parameters (Part 1)
IODE_Sub_2::String: Issue of Data, Ephemeris from subframe 2 (8-bit binary string)C_rs::Float64: Sine harmonic correction to orbit radius (meters)Δn::Float64: Mean motion difference from computed value (semi-circles/s)M_0::Float64: Mean anomaly at reference time (semi-circles)C_uc::Float64: Cosine harmonic correction to argument of latitude (rad)e::Float64: Eccentricity (dimensionless, range 0-0.03)C_us::Float64: Sine harmonic correction to argument of latitude (rad)sqrt_A::Float64: Square root of semi-major axis (√m)t_0e::Int64: Ephemeris reference time (seconds)fit_interval::Bool: Curve fit interval flag (0=4h, 1=>4h)AODO::Int64: Age of Data Offset for NMCT (seconds)
Subframe 3 - Ephemeris Parameters (Part 2)
C_ic::Float64: Cosine harmonic correction to inclination (rad)Ω_0::Float64: Longitude of ascending node at weekly epoch (semi-circles)C_is::Float64: Sine harmonic correction to inclination (rad)i_0::Float64: Inclination angle at reference time (semi-circles)C_rc::Float64: Cosine harmonic correction to orbit radius (meters)ω::Float64: Argument of perigee (semi-circles)Ω_dot::Float64: Rate of right ascension (semi-circles/s)IODE_Sub_3::String: Issue of Data, Ephemeris from subframe 3 (8-bit binary string)i_dot::Float64: Rate of inclination angle (semi-circles/s)
Reference
IS-GPS-200N, Tables 20-I, 20-II, 20-III, Sections 20.3.3.3-20.3.3.4
Galileo E1B
GNSSDecoder.GalileoE1BConstants — Type
GalileoE1BConstantsGTRF constants and I/NAV message structure parameters for Galileo E1B signal decoding.
The physical constants are defined in the Galileo OS SIS ICD (Open Service Signal-In-Space Interface Control Document) and are used for computing satellite positions and clock corrections from broadcast ephemeris data.
Fields
syncro_sequence_length::Int: Length of synchronization sequence in bits (250 bits per page)preamble::UInt16: Page synchronization pattern (0101100000 binary)preamble_length::Int: Length of preamble in bits (10)PI::Float64: Mathematical constant π = 3.1415926535898 (Galileo OS SIS ICD Table 68)Ω_dot_e::Float64: Mean angular velocity of the Earth = 7.2921151467×10⁻⁵ rad/sc::Float64: Speed of light = 2.99792458×10⁸ m/sμ::Float64: Geocentric gravitational constant = 3.986004418×10¹⁴ m³/s²F::Float64: Relativistic correction constant = -4.442807309×10⁻¹⁰ s/√m
Reference
Galileo OS SIS ICD, Issue 2.2, Table 68
GNSSDecoder.GalileoE1BData — Type
GalileoE1BDataDecoded Galileo E1B I/NAV navigation message data.
Contains ephemeris, clock correction, signal health, and group delay parameters decoded from word types 1-5 of the Galileo I/NAV message. All parameters conform to the Galileo OS SIS ICD.
Galileo System Time (GST) Fields
WN::Int64: Week Number (0-4095)TOW::Int64: Time of Week at message transmission (seconds, 0-604799)
Ephemeris Parameters (Word Types 1-3)
t_0e::Float64: Ephemeris reference time (seconds)M_0::Float64: Mean anomaly at reference time (semi-circles)e::Float64: Eccentricity (dimensionless)sqrt_A::Float64: Square root of semi-major axis (√m)Ω_0::Float64: Longitude of ascending node at weekly epoch (semi-circles)i_0::Float64: Inclination angle at reference time (semi-circles)ω::Float64: Argument of perigee (semi-circles)i_dot::Float64: Rate of change of inclination angle (semi-circles/s)Ω_dot::Float64: Rate of change of right ascension (semi-circles/s)Δn::Float64: Mean motion difference from computed value (semi-circles/s)C_uc::Float64: Cosine harmonic correction to argument of latitude (rad)C_us::Float64: Sine harmonic correction to argument of latitude (rad)C_rc::Float64: Cosine harmonic correction to orbit radius (meters)C_rs::Float64: Sine harmonic correction to orbit radius (meters)C_ic::Float64: Cosine harmonic correction to inclination (rad)C_is::Float64: Sine harmonic correction to inclination (rad)
Clock Correction Parameters (Word Type 4)
t_0c::Float64: Clock correction reference time (seconds)a_f0::Float64: SV clock bias correction coefficient (seconds)a_f1::Float64: SV clock drift correction coefficient (s/s)a_f2::Float64: SV clock drift rate correction coefficient (s/s²)
Issue of Data (Word Types 1-4)
IOD_nav1::UInt: Issue of Data from word type 1 (10-bit)IOD_nav2::UInt: Issue of Data from word type 2 (10-bit)IOD_nav3::UInt: Issue of Data from word type 3 (10-bit)IOD_nav4::UInt: Issue of Data from word type 4 (10-bit)num_pages_after_last_TOW::Int: Pages decoded since last TOW updatenum_bits_after_valid_syncro_sequence_after_last_TOW::Int: Bits since last TOW sync
Signal Health and Data Validity (Word Type 5)
signal_health_e1b::SignalHealth: E1-B/C signal health status (0=OK, 1=out of service, 2=in test, 3=will be out of service)signal_health_e5b::SignalHealth: E5b signal health statusdata_validity_status_e1b::DataValidityStatus: E1-B data validity (0=valid, 1=working without guarantee)data_validity_status_e5b::DataValidityStatus: E5b data validity
Broadcast Group Delay (Word Type 5)
broadcast_group_delay_e1_e5a::Float64: E1-E5a group delay correction (seconds)broadcast_group_delay_e1_e5b::Float64: E1-E5b group delay correction (seconds)
Reference
Galileo OS SIS ICD, Issue 2.2, Tables 42-46, 67, 70, 72
GNSSDecoder.SignalHealth — Type
SignalHealthGalileo signal health status enumeration.
Indicates the operational status of a Galileo signal component as broadcast in word type 5.
Values
signal_ok: Signal is operating normally (value 0)signal_out_of_service: Signal is out of service (value 1)signal_will_be_out_of_service: Signal is in Extended Operations Mode (value 2)signal_component_currently_in_test: Signal component is currently in test (value 3)
Reference
Galileo OS SIS ICD, Issue 2.2, Table 84
GNSSDecoder.DataValidityStatus — Type
DataValidityStatusGalileo navigation data validity status enumeration.
Indicates whether the broadcast navigation data should be trusted for positioning.
Values
navigation_data_valid: Navigation data is valid (value 0)working_without_guarantee: Navigation data is working without guarantee (value 1)
Reference
Galileo OS SIS ICD, Issue 2.2, Table 81