GNSS-SDR  0.0.21
An Open Source GNSS Software Defined Receiver
osnma_data.h
Go to the documentation of this file.
1 /*!
2  * \file osnma_data.h
3  * \brief Class for Galileo OSNMA data storage
4  * \author Carles Fernandez-Prades, 2020-2023 cfernandez(at)cttc.es
5  *
6  * -----------------------------------------------------------------------------
7  *
8  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
9  * This file is part of GNSS-SDR.
10  *
11  * Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
12  * SPDX-License-Identifier: GPL-3.0-or-later
13  *
14  * -----------------------------------------------------------------------------
15  */
16 
17 
18 #ifndef GNSS_SDR_OSNMA_DATA_H
19 #define GNSS_SDR_OSNMA_DATA_H
20 
21 #include "galileo_inav_message.h" // for OSNMA_msg
22 #include <array>
23 #include <cstdint>
24 #include <memory>
25 #include <string>
26 #include <vector>
27 
28 /** \addtogroup Core
29  * \{ */
30 /** \addtogroup System_Parameters
31  * \{ */
32 
34 {
35 public:
36  DSM_nma_header() = default;
37  uint8_t nmas{};
38  uint8_t cid{};
39  uint8_t cpks{};
40  bool reserved{};
41 };
42 
43 
45 {
46 public:
47  DSM_dsm_header() = default;
48  uint8_t dsm_id{};
49  uint8_t dsm_block_id{};
50 };
51 
52 
54 {
55 public:
56  MACK_header() = default;
57  uint64_t tag0{};
58  uint16_t macseq{};
59  uint8_t cop{};
60 };
61 
62 
64 {
65 public:
66  MACK_tag_info() = default;
67  uint8_t PRN_d{};
68  uint8_t ADKD{};
69  uint8_t cop{};
70 };
71 
72 
74 {
75 public:
76  MACK_tag_and_info() = default;
77  uint64_t tag; // C: 20-40 bits
78  MACK_tag_info tag_info;
79  uint32_t counter; // CTR
80 };
81 
82 
84 {
85 public:
86  DSM_PKR_message() = default;
87 
88  std::array<uint8_t, 128> itn{}; // bitset<1024>
89  std::vector<uint8_t> npk;
90  std::vector<uint8_t> p_dp;
91  uint8_t nb_dp{};
92  uint8_t mid{};
93  uint8_t npkt{};
94  uint8_t npktid{};
95 };
96 
97 
99 {
100 public:
101  DSM_KROOT_message() = default;
102 
103  std::vector<uint8_t> kroot;
104  std::vector<uint8_t> ds;
105  std::vector<uint8_t> p_dk;
106  uint64_t alpha{};
107  uint16_t wn_k{};
108  uint8_t nb_dk{};
109  uint8_t pkid{};
110  uint8_t cidkr{};
111  uint8_t reserved1{};
112  uint8_t hf{};
113  uint8_t mf{};
114  uint8_t ks{}; // key size, in bits
115  uint8_t ts{};
116  uint8_t maclt{};
117  uint8_t reserved{};
118  uint8_t towh_k{};
119  bool verified{false};
120 };
121 
122 
124 {
125 public:
126  MACK_message() = default;
127  MACK_header header;
128  std::vector<MACK_tag_and_info> tag_and_info;
129  std::vector<uint8_t> key;
130  uint32_t TOW; // TODO duplicated variable, also in OSNMA_NavData
131  uint32_t WN;
132  uint32_t PRNa;
133 };
134 
135 
137 {
138 public:
139  OSNMA_NavData() : nav_data_id(id_counter++) {}
140  const uint32_t nav_data_id;
141  std::string get_utc_data() const;
142  std::string get_ephemeris_data() const;
143  uint32_t get_verified_bits() const { return verified_bits; }
144  uint32_t get_prn_d() const { return PRNd; }
145  uint32_t get_IOD_nav() const { return IOD_nav; }
146  uint32_t get_last_received_TOW() const { return d_last_received_TOW; }
147  uint32_t get_tow_sf0() const { return d_TOW_sf0; }
148  bool have_this_bits(std::string nav_data);
149  bool get_verified_status() const { return verified; }
150  bool add_nav_data(const std::string& nav_data);
151  void set_tow_sf0(int value) { d_TOW_sf0 = value; }
152  void set_ephemeris_data(std::string value) { d_ephemeris_iono = value; }
153  void set_utc_data(std::string value) { d_utc = value; }
154  void update_last_received_timestamp(uint32_t TOW);
155  void set_prn_d(uint32_t value) { PRNd = value; }
156  void set_last_received_TOW(uint32_t TOW) { d_last_received_TOW = TOW; };
157  void set_update_verified_bits(uint32_t morebits) { verified_bits += morebits; }
158  void set_verified_status(bool value) { verified = value; }
159  void set_IOD_nav(uint32_t value) { IOD_nav = value; }
160 
161 private:
162  static uint32_t id_counter;
163  std::string d_ephemeris_iono{""};
164  std::string d_utc{""};
165  uint32_t d_TOW_sf0{0};
166  uint32_t d_last_received_TOW{0};
167  uint32_t PRNd{0};
168  uint32_t verified_bits{0};
169  uint32_t IOD_nav{0};
170  bool verified{false};
171 };
172 
173 
174 /*!
175  * \brief This class handles ONSMA data
176  * See https://www.gsc-europa.eu/sites/default/files/sites/all/files/Galileo_OSNMA_User_ICD_for_Test_Phase_v1.0.pdf
177  */
179 {
180 public:
181  OSNMA_data() = default;
182  DSM_nma_header d_nma_header;
183  DSM_dsm_header d_dsm_header;
184  DSM_PKR_message d_dsm_pkr_message;
185  DSM_KROOT_message d_dsm_kroot_message;
186  DSM_KROOT_message d_dsm_kroot_new_message;
187  MACK_message d_mack_message;
188  OSNMA_NavData d_nav_data;
189 };
190 
191 
192 class Tag
193 {
194 public:
195  enum e_verification_status
196  {
197  SUCCESS,
198  FAIL,
199  UNVERIFIED
200  };
201  Tag(const MACK_tag_and_info& MTI, uint32_t TOW, uint32_t WN, uint32_t PRNa, uint8_t CTR) // standard tag constructor, for tags within Tag&Info field
202  : tag_id(id_counter++),
203  TOW(TOW), // TODO missing for build_message WN for GST computation, CTR, NMAS, OSNMA_NavData missing
204  WN(WN),
205  PRNa(PRNa),
206  CTR(CTR),
207  status(UNVERIFIED),
208  received_tag(MTI.tag),
209  computed_tag(0),
210  PRN_d(MTI.tag_info.PRN_d),
211  ADKD(MTI.tag_info.ADKD),
212  cop(MTI.tag_info.cop),
213  skipped(0)
214  {
215  }
216  explicit Tag(const MACK_message& mack) // constructor for Tag0
217  : tag_id(id_counter++),
218  TOW(mack.TOW), // TODO missing for build_message WN for GST computation, CTR, NMAS, OSNMA_NavData missing
219  WN(mack.WN),
220  PRNa(mack.PRNa),
221  CTR(1),
222  status(UNVERIFIED),
223  received_tag(mack.header.tag0),
224  computed_tag(0),
225  PRN_d(mack.PRNa), // Tag0 are self-authenticating
226  ADKD(0),
227  cop(mack.header.cop),
228  skipped(0)
229  {
230  }
231  const uint32_t tag_id;
232  static uint32_t id_counter;
233  uint32_t TOW;
234  uint32_t WN;
235  uint32_t PRNa;
236  uint8_t CTR;
237  e_verification_status status;
238  uint64_t received_tag;
239  uint64_t computed_tag;
240  uint8_t PRN_d;
241  uint8_t ADKD;
242  uint8_t cop;
243  uint32_t skipped;
244  std::string nav_data;
245 };
246 
247 /** \} */
248 /** \} */
249 
250 #endif // GNSS_SDR_OSNMA_DATA_H
This class handles ONSMA data See https://www.gsc-europa.eu/sites/default/files/sites/all/files/Galil...
Definition: osnma_data.h:178
Implementation of a Galileo I/NAV Data message as described in Galileo OS SIS ICD Issue 2...