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