MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
mrtk_has.h
Go to the documentation of this file.
1/*------------------------------------------------------------------------------
2 * mrtk_has.h : Galileo HAS (High Accuracy Service) decode functions
3 *
4 * Copyright (C) 2026 H.SHIONO (MRTKLIB Project)
5 *
6 * SPDX-License-Identifier: BSD-2-Clause
7 *
8 * Reference:
9 * Galileo High Accuracy Service Signal-in-Space Interface Control Document
10 * (HAS SIS ICD), Issue 1.0, May 2022, European Union.
11 *----------------------------------------------------------------------------*/
12/**
13 * @file mrtk_has.h
14 * @brief MRTKLIB Galileo HAS Module — E6-B C/NAV HAS page collection and
15 * Message Type 1 (MT1) decode into ssr_t corrections.
16 *
17 * This header provides the public API for collecting Galileo HAS pages
18 * (keyed by Message ID / Message Type), recovering the encoded message via
19 * the RS(255,32) erasure decoder, decoding MT1 (mask, orbit, clock, code
20 * bias, phase bias blocks) and filling an internal ssr_t array that callers
21 * copy into nav->ssr_ch[0].
22 *
23 * @note Functions declared here are implemented in src/has/mrtk_has.c.
24 */
25#ifndef MRTK_HAS_H
26#define MRTK_HAS_H
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include <stdint.h>
33#include <stdio.h>
34
36#include "mrtklib/mrtk_nav.h"
37#include "mrtklib/mrtk_time.h"
38
39/*============================================================================
40 * Galileo HAS Constants
41 *===========================================================================*/
42
43#define HAS_MAX_MID 32 /* number of distinct Mask IDs (5-bit field) */
44#define HAS_MAX_IODSET 32 /* number of distinct IOD Set IDs (5-bit field) */
45#define HAS_MAX_PAGES 32 /* max non-encoded pages per message (MS, 1..32) */
46#define HAS_PAGE_BYTES 53 /* encoded-page payload length (424 bits) */
47#define HAS_MAX_INFLIGHT 2 /* in-flight collection slots (current + previous) */
48#define HAS_MAX_GNSS_SAT 40 /* satellites per GNSS satellite mask (SatM) */
49#define HAS_MAX_SIG 16 /* signals per GNSS signal mask (SigM) */
50
51/*============================================================================
52 * Galileo HAS Decode Context
53 *===========================================================================*/
54
55typedef struct { /* cached HAS mask (per Mask ID) */
56 int valid; /* 0:empty, 1:populated */
57 int nsys; /* number of GNSS in the mask */
58 int nsat; /* total masked satellites (all GNSS) */
59 int sat[MAXSAT]; /* satno per mask slot (0:unsupported) */
60 int gnssid[MAXSAT]; /* HAS GNSS ID per mask slot */
61 uint8_t code[MAXSAT][HAS_MAX_SIG]; /* obs code per (sat,signal slot) */
62 int nsig[MAXSAT]; /* number of signals per satellite */
63 uint16_t cellmask[MAXSAT]; /* signal cell mask per satellite (MSB=sig0) */
64 int navmsg[MAXSAT]; /* navigation message index per satellite */
66
67typedef struct { /* cached IOD set (per Mask ID + IOD Set ID) */
68 int valid; /* 0:empty, 1:populated */
69 int iodref[MAXSAT]; /* reference IOD per mask slot */
71
72typedef struct { /* in-flight page collector */
73 int active; /* 0:idle, 1:collecting */
74 int mid; /* Message ID being collected */
75 int mt; /* Message Type being collected */
76 int ms; /* message size (distinct pages needed) */
77 int npid; /* number of distinct PIDs collected */
78 gtime_t t0; /* reception time of first page */
79 uint8_t pid[HAS_MAX_PAGES]; /* collected PIDs */
80 uint8_t page[HAS_MAX_PAGES][HAS_PAGE_BYTES]; /* collected encoded-page payloads */
82
83typedef struct { /* Galileo HAS decode context */
84 has_collect_t collect[HAS_MAX_INFLIGHT]; /* in-flight collectors */
85 has_mask_t mask[HAS_MAX_MID]; /* mask cache keyed by Mask ID */
87 ssr_t ssr[MAXSAT]; /* decoded SSR corrections */
88} has_t;
89
90/*============================================================================
91 * Galileo HAS Functions
92 *===========================================================================*/
93
94/**
95 * @brief Allocate and initialize a Galileo HAS decode context.
96 * @return Pointer to a heap-allocated has_t (NULL on allocation failure or RS
97 * init failure). Free with has_free().
98 * @note Calls has_rs_init() to build the RS(255,32) erasure-decoder tables.
99 */
100has_t* has_new(void);
101
102/**
103 * @brief Free a Galileo HAS decode context.
104 * @param[in,out] has Context allocated by has_new() (NULL: no-op)
105 */
106void has_free(has_t* has);
107
108/**
109 * @brief Input one received Galileo HAS page.
110 * @param[in,out] has HAS decode context
111 * @param[in] prn Galileo PRN of the transmitting satellite (1-40)
112 * @param[in] page56 56-byte HAS page (24-bit header + 424-bit encoded page)
113 * @param[in] time Page reception time (GPST)
114 * @return 10 when a complete MT1 was decoded and ssr[] updated, 0 when no
115 * message completed, <0 on error.
116 */
117int has_input_page(has_t* has, int prn, const uint8_t* page56, gtime_t time);
118
119/**
120 * @brief Read .has records from a file and feed them to has_input_page().
121 * @param[in,out] has HAS decode context
122 * @param[in] fp Open .has file pointer (64-byte little-endian records)
123 * @param[in] tmax Stop after reading records past this time (GPST)
124 * @return 10 if any message completed during the call, 0 otherwise (including
125 * at end of file).
126 */
127int has_input_file(has_t* has, FILE* fp, gtime_t tmax);
128
129/**
130 * @brief Select the HAS bias slot obs code for an observation code.
131 * @param[in] sys Satellite system (SYS_GPS or SYS_GAL)
132 * @param[in] code Observation code (CODE_???)
133 * @return Obs code under which the HAS bias is stored, with same-frequency
134 * fallback (component <-> combined on the same carrier per HAS SIS ICD
135 * Table 20); 0 (CODE_NONE) if no mapping exists.
136 */
137int has_sel_biascode(int sys, uint8_t code);
138
139#ifdef __cplusplus
140}
141#endif
142
143#endif /* MRTK_HAS_H */
#define MAXSAT
Definition mrtk_coords.c:45
MRTKLIB Foundation — Common types, standard includes, and system constants (MAXSAT,...
#define HAS_MAX_MID
Definition mrtk_has.h:43
void has_free(has_t *has)
Free a Galileo HAS decode context.
Definition mrtk_has.c:801
#define HAS_MAX_SIG
Definition mrtk_has.h:49
#define HAS_MAX_IODSET
Definition mrtk_has.h:44
int has_input_file(has_t *has, FILE *fp, gtime_t tmax)
Read .has records from a file and feed them to has_input_page().
Definition mrtk_has.c:872
int has_input_page(has_t *has, int prn, const uint8_t *page56, gtime_t time)
Input one received Galileo HAS page.
Definition mrtk_has.c:804
#define HAS_MAX_PAGES
Definition mrtk_has.h:45
#define HAS_MAX_INFLIGHT
Definition mrtk_has.h:47
has_t * has_new(void)
Allocate and initialize a Galileo HAS decode context.
Definition mrtk_has.c:790
int has_sel_biascode(int sys, uint8_t code)
Select the HAS bias slot obs code for an observation code.
Definition mrtk_has.c:902
#define HAS_PAGE_BYTES
Definition mrtk_has.h:46
MRTKLIB Navigation Module — Navigation data types and satellite/nav utility functions.
MRTKLIB Time Module — GNSS time types and conversion functions.
GNSS time representation.
Definition mrtk_time.h:49
uint8_t page[32][53]
Definition mrtk_has.h:80
uint8_t pid[32]
Definition mrtk_has.h:79
gtime_t t0
Definition mrtk_has.h:78
int iodref[MAXSAT]
Definition mrtk_has.h:69
int gnssid[MAXSAT]
Definition mrtk_has.h:60
int sat[MAXSAT]
Definition mrtk_has.h:59
int navmsg[MAXSAT]
Definition mrtk_has.h:64
int nsig[MAXSAT]
Definition mrtk_has.h:62
uint16_t cellmask[MAXSAT]
Definition mrtk_has.h:63
uint8_t code[MAXSAT][16]
Definition mrtk_has.h:61
int valid
Definition mrtk_has.h:56
has_collect_t collect[2]
Definition mrtk_has.h:84
has_mask_t mask[32]
Definition mrtk_has.h:85
ssr_t ssr[MAXSAT]
Definition mrtk_has.h:87
has_iodset_t iodset[32][32]
Definition mrtk_has.h:86