GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
gnss_sdr_supl_client.h
Go to the documentation of this file.
1 /*!
2  * \file gnss_sdr_supl_client.h
3  * \brief class that implements a C++ interface to external Secure User Location Protocol (SUPL) client library.
4  * \author Javier Arribas, 2013. jarribas(at)cttc.es
5  *
6  * TODO: put here supl.c author info
7  * class that implements a C++ interface to external Secure User Location Protocol (SUPL) client library.
8  *
9  * -----------------------------------------------------------------------------
10  *
11  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
12  *
13  * GNSS-SDR is a software defined Global Navigation
14  * Satellite Systems receiver
15  *
16  * This file is part of GNSS-SDR.
17  *
18  * SPDX-License-Identifier: GPL-3.0-or-later
19  *
20  * -----------------------------------------------------------------------------
21  */
22 
23 #ifndef GNSS_SDR_SUPL_CLIENT_H
24 #define GNSS_SDR_SUPL_CLIENT_H
25 
26 extern "C"
27 {
28 #include "supl.h"
29 }
30 #include "agnss_ref_location.h"
31 #include "agnss_ref_time.h"
32 #include "galileo_almanac.h"
33 #include "galileo_ephemeris.h"
34 #include "galileo_iono.h"
35 #include "galileo_utc_model.h"
36 #include "glonass_gnav_ephemeris.h"
37 #include "glonass_gnav_utc_model.h"
38 #include "gps_acq_assist.h"
39 #include "gps_almanac.h"
40 #include "gps_cnav_ephemeris.h"
41 #include "gps_cnav_utc_model.h"
42 #include "gps_ephemeris.h"
43 #include "gps_iono.h"
44 #include "gps_utc_model.h"
45 #include <fstream>
46 #include <map>
47 #include <string>
48 
49 /*!
50  * \brief class that implements a C++ interface to external Secure User Location Protocol (SUPL) client library..
51  */
53 {
54 public:
56  ~Gnss_Sdr_Supl_Client() = default;
57 
58  // SUPL SERVER INFO
59  std::string server_name;
60  int server_port;
61  int request;
62  // ephemeris map
63  std::map<int, Gps_Ephemeris> gps_ephemeris_map;
64  std::map<int, Galileo_Ephemeris> gal_ephemeris_map;
65  std::map<int, Gps_CNAV_Ephemeris> gps_cnav_ephemeris_map;
66  std::map<int, Glonass_Gnav_Ephemeris> glonass_gnav_ephemeris_map;
67 
68  // almanac map
69  std::map<int, Gps_Almanac> gps_almanac_map;
70  std::map<int, Galileo_Almanac> gal_almanac_map;
71 
72  // ionospheric model
73  Gps_Iono gps_iono;
74  Galileo_Iono gal_iono;
75  // reference time
76  Agnss_Ref_Time gps_time;
77  // UTC model
78  Gps_Utc_Model gps_utc;
79  Galileo_Utc_Model gal_utc;
80  Gps_CNAV_Utc_Model gps_cnav_utc;
81  Glonass_Gnav_Utc_Model glo_gnav_utc;
82  // reference location
83  Agnss_Ref_Location gps_ref_loc;
84  // Acquisition Assistance map
85  std::map<int, Gps_Acq_Assist> gps_acq_map;
86 
87  /*
88  * \brief Initiates the TCP SSL SUPL connection to the SUPL server and request assistance data using the provided GSM Base station parameters
89  * \param i_mcc Current network MCC (Mobile country code), 3 digits.
90  * \param i_mns Current network MNC (Mobile Network code), 2 or 3 digits.
91  * \param i_lac Current network LAC (Location area code),16 bits, 1-65520 are valid values.
92  * \param i_ci Cell Identity (16 bits, 0-65535 are valid values).
93  * \return Error code -> 0 no errors.
94  */
95  int get_assistance(int i_mcc, int i_mns, int i_lac, int i_ci);
96 
97  /*
98  * \brief Read the received SUPL data and stores it into the corresponding class members (gps_ephemeris_map, gps_almanac_map, gps_iono, gps_time, gps_utc, gps_acq_map, and gps_ref_loc)
99  *
100  */
101  void read_supl_data();
102 
103  /*!
104  * \brief Read GPS NAV ephemeris map from XML file
105  */
106  bool load_ephemeris_xml(const std::string& file_name);
107 
108  /*!
109  * \brief Save ephemeris map to XML file.
110  */
111  bool save_ephemeris_map_xml(const std::string& file_name,
112  std::map<int, Gps_Ephemeris> eph_map);
113 
114  /*!
115  * \brief Read GPS CNAV ephemeris map from XML file
116  */
117  bool load_cnav_ephemeris_xml(const std::string& file_name);
118 
119  /*!
120  * \brief Save GPS CNAV ephemeris map to XML file.
121  */
122  bool save_cnav_ephemeris_map_xml(const std::string file_name,
123  std::map<int, Gps_CNAV_Ephemeris> eph_map);
124 
125  /*!
126  * \brief Read Galileo ephemeris map from XML file
127  */
128  bool load_gal_ephemeris_xml(const std::string& file_name);
129 
130  /*!
131  * \brief Save Galileo ephemeris map to XML file.
132  */
133  bool save_gal_ephemeris_map_xml(const std::string file_name,
134  std::map<int, Galileo_Ephemeris> eph_map);
135 
136  /*!
137  * \brief Read GLONASS GNAV ephemeris map from XML file
138  */
139  bool load_gnav_ephemeris_xml(const std::string& file_name);
140 
141  /*!
142  * \brief Save GLONASS GNAV ephemeris map to XML file.
143  */
144  bool save_gnav_ephemeris_map_xml(const std::string file_name,
145  std::map<int, Glonass_Gnav_Ephemeris> eph_map);
146 
147  /*!
148  * \brief Read GPS utc model from XML file
149  */
150  bool load_utc_xml(const std::string& file_name);
151 
152  /*!
153  * \brief Save UTC model map to XML file
154  */
155  bool save_utc_xml(const std::string& file_name, Gps_Utc_Model& utc);
156 
157  /*!
158  * \brief Read CNAV GPS utc model from XML file
159  */
160  bool load_cnav_utc_xml(const std::string& file_name);
161 
162  /*!
163  * \brief Save CNAV UTC model map to XML file
164  */
165  bool save_cnav_utc_xml(const std::string& file_name, Gps_CNAV_Utc_Model& utc);
166 
167  /*!
168  * \brief Read Galileo utc model from XML file
169  */
170  bool load_gal_utc_xml(const std::string& file_name);
171 
172  /*!
173  * \brief Save Galileo UTC model map to XML file
174  */
175  bool save_gal_utc_xml(const std::string& file_name, Galileo_Utc_Model& utc);
176 
177  /*!
178  * \brief Read Galileo almanac map from XML file
179  */
180  bool load_gal_almanac_xml(const std::string& file_name);
181 
182  /*!
183  * \brief Save Galileo almanac map to XML file
184  */
185  bool save_gal_almanac_xml(const std::string& file_name, std::map<int, Galileo_Almanac> galileo_almanac_map_to_save);
186 
187  /*!
188  * \brief Read GPS almanac map from XML file
189  */
190  bool load_gps_almanac_xml(const std::string& file_name);
191 
192  /*!
193  * \brief Save GPS almanac map to XML file
194  */
195  bool save_gps_almanac_xml(const std::string& file_name, std::map<int, Gps_Almanac> gps_almanac_map_to_save);
196 
197  /*!
198  * \brief Read iono from XML file
199  */
200  bool load_iono_xml(const std::string& file_name);
201 
202  /*!
203  * \brief Save iono map to XML file
204  */
205  bool save_iono_xml(const std::string& file_name, Gps_Iono& iono);
206 
207  /*!
208  * \brief Read Galileo iono from XML file
209  */
210  bool load_gal_iono_xml(const std::string& file_name);
211 
212  /*!
213  * \brief Save Galileo iono map to XML file
214  */
215  bool save_gal_iono_xml(const std::string& file_name, Galileo_Iono& iono);
216 
217  /*!
218  * \brief Read Glonass utc model from XML file
219  */
220  bool load_glo_utc_xml(const std::string& file_name);
221 
222  /*!
223  * \brief Save Glonass UTC model map to XML file
224  */
225  bool save_glo_utc_xml(const std::string& file_name, Glonass_Gnav_Utc_Model& utc);
226 
227  /*!
228  * \brief Read ref time from XML file
229  */
230  bool load_ref_time_xml(const std::string& file_name);
231 
232  /*!
233  * \brief Save ref time map to XML file
234  */
235  bool save_ref_time_xml(const std::string& file_name,
236  Agnss_Ref_Time& ref_time_map);
237 
238  /*!
239  * \brief Read ref location from XML file
240  */
241  bool load_ref_location_xml(const std::string& file_name);
242 
243  /*!
244  * \brief Save ref location map to XML file
245  */
246  bool save_ref_location_xml(const std::string& file_name,
247  Agnss_Ref_Location& ref_location);
248 
249  /*
250  * Prints SUPL data to std::cout. Use it for debug purposes only.
251  */
252  void print_assistance();
253 
254 private:
255  bool read_gal_almanac_from_gsa(const std::string& file_name);
256  // assistance protocol structure
257  supl_ctx_t ctx{};
258  // assistance data
259  supl_assist_t assist{};
260  // GSM CELL INFO
261  int mcc;
262  int mns;
263  int lac;
264  int ci;
265 };
266 
267 #endif // GNSS_SDR_SUPL_CLIENT_H
This class is a storage for the GPS IONOSPHERIC data as described in IS-GPS-200K. ...
Definition: gps_iono.h:33
bool load_utc_xml(const std::string &file_name)
Read GPS utc model from XML file.
bool save_ref_location_xml(const std::string &file_name, Agnss_Ref_Location &ref_location)
Save ref location map to XML file.
Interface of a GLONASS EPHEMERIS storage.
Interface of a GLONASS GNAV UTC MODEL storage.
bool save_iono_xml(const std::string &file_name, Gps_Iono &iono)
Save iono map to XML file.
bool load_gal_ephemeris_xml(const std::string &file_name)
Read Galileo ephemeris map from XML file.
bool load_gps_almanac_xml(const std::string &file_name)
Read GPS almanac map from XML file.
bool save_ref_time_xml(const std::string &file_name, Agnss_Ref_Time &ref_time_map)
Save ref time map to XML file.
bool load_cnav_ephemeris_xml(const std::string &file_name)
Read GPS CNAV ephemeris map from XML file.
Interface of an Assisted GNSS REFERENCE TIME storage.
Interface of a GPS CNAV UTC MODEL storage.
Interface of an Assisted GNSS REFERENCE LOCATION storage.
Interface of a GPS RRLL ACQUISITION ASSISTACE storage.
bool save_cnav_ephemeris_map_xml(const std::string file_name, std::map< int, Gps_CNAV_Ephemeris > eph_map)
Save GPS CNAV ephemeris map to XML file.
bool save_glo_utc_xml(const std::string &file_name, Glonass_Gnav_Utc_Model &utc)
Save Glonass UTC model map to XML file.
bool load_gal_almanac_xml(const std::string &file_name)
Read Galileo almanac map from XML file.
Interface of a GPS UTC MODEL storage.
bool save_gps_almanac_xml(const std::string &file_name, std::map< int, Gps_Almanac > gps_almanac_map_to_save)
Save GPS almanac map to XML file.
bool load_ref_location_xml(const std::string &file_name)
Read ref location from XML file.
Interface of a Galileo ALMANAC storage.
Interface of a GPS ALMANAC storage.
bool save_cnav_utc_xml(const std::string &file_name, Gps_CNAV_Utc_Model &utc)
Save CNAV UTC model map to XML file.
bool save_gnav_ephemeris_map_xml(const std::string file_name, std::map< int, Glonass_Gnav_Ephemeris > eph_map)
Save GLONASS GNAV ephemeris map to XML file.
bool save_utc_xml(const std::string &file_name, Gps_Utc_Model &utc)
Save UTC model map to XML file.
bool load_gal_iono_xml(const std::string &file_name)
Read Galileo iono from XML file.
bool save_gal_utc_xml(const std::string &file_name, Galileo_Utc_Model &utc)
Save Galileo UTC model map to XML file.
bool save_ephemeris_map_xml(const std::string &file_name, std::map< int, Gps_Ephemeris > eph_map)
Save ephemeris map to XML file.
bool load_ref_time_xml(const std::string &file_name)
Read ref time from XML file.
bool load_ephemeris_xml(const std::string &file_name)
Read GPS NAV ephemeris map from XML file.
This class is a storage for the GPS UTC MODEL data as described in in IS-GPS-200K.
This class is a storage for the GALILEO IONOSPHERIC data as described in Galileo ICD paragraph 5...
Definition: galileo_iono.h:32
bool load_iono_xml(const std::string &file_name)
Read iono from XML file.
bool save_gal_almanac_xml(const std::string &file_name, std::map< int, Galileo_Almanac > galileo_almanac_map_to_save)
Save Galileo almanac map to XML file.
Interface of a Galileo UTC MODEL storage.
Interface of a GPS EPHEMERIS storage.
Interface of an Assisted GNSS REFERENCE TIME storage.
Interface of an Assisted GNSS REFERENCE LOCATION storage.
This class is a storage for the GLONASS GNAV UTC MODEL data as described in GLONASS ICD (Edition 5...
This class is a storage for the GPS UTC MODEL data as described in IS-GPS-200K.
Definition: gps_utc_model.h:32
bool load_gal_utc_xml(const std::string &file_name)
Read Galileo utc model from XML file.
class that implements a C++ interface to external Secure User Location Protocol (SUPL) client library...
This class is a storage for the GALILEO UTC MODEL data as described in Galileo ICD https://www...
bool load_glo_utc_xml(const std::string &file_name)
Read Glonass utc model from XML file.
bool save_gal_iono_xml(const std::string &file_name, Galileo_Iono &iono)
Save Galileo iono map to XML file.
Interface of a GPS CNAV EPHEMERIS storage.
bool load_gnav_ephemeris_xml(const std::string &file_name)
Read GLONASS GNAV ephemeris map from XML file.
Interface of a Galileo Ionospheric Model storage.
Interface of a GPS IONOSPHERIC MODEL storage.
Interface of a Galileo EPHEMERIS storage.
bool save_gal_ephemeris_map_xml(const std::string file_name, std::map< int, Galileo_Ephemeris > eph_map)
Save Galileo ephemeris map to XML file.
bool load_cnav_utc_xml(const std::string &file_name)
Read CNAV GPS utc model from XML file.