MRPT  2.0.1
CNTRIPClient.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
13 
14 #include <future>
15 #include <list>
16 
17 namespace mrpt::hwdrivers
18 {
19 /** A client for NTRIP (HTTP) sources of differential GPS corrections from
20  *internet servers, or Global navigation satellite system (GNSS) internet
21  *radio.
22  * Usage:
23  * - To open the server, invoke "open" with the proper parameters. Then use
24  *"stream_data" to read the read data.
25  * - To obtain a list of all the mountpoints available at a given NTRIP
26  *Caster, call "retrieveListOfMountpoints" (it's a static method).
27  *
28  * It is not neccesary to call "close", the connection is ended at
29  *destruction.
30  *
31  * \note For a good reference of the NTRIP protocol, see
32  *http://gnss.itacyl.es/opencms/opencms/system/modules/es.jcyl.ita.site.gnss/resources/documentos_gnss/NtripDocumentation.pdf
33  * \ingroup mrpt_hwdrivers_grp
34  *
35  */
37 {
38  public:
39  /** A descriptor of one stream in an NTRIP Caster - See
40  * CNTRIPClient::retrieveListOfMountpoints
41  */
42  struct TMountPoint
43  {
44  std::string mountpoint_name;
45  /** City name */
46  std::string id;
47  /** RTCM 2.3, RTCM 3, CMR+, etc... */
48  std::string format;
49  std::string format_details;
50  /** 0: No carrier phase, 1: L1, 2: L1+L2 */
51  int carrier{0};
52  /** GPS, ... */
53  std::string nav_system;
54  /** IGS, ... */
55  std::string network;
56  /** ITA, ESP, DEU,... */
57  std::string country_code;
58  double latitude{0}, longitude{0};
59  bool needs_nmea{false};
60  bool net_ref_stations{false};
61  std::string generator_model;
62  /** "none" */
63  std::string compr_encryp;
64  /** "N": none, "B": basic, "D": digest */
65  char authentication{'B'};
66  bool pay_service{false};
68  std::string extra_info;
69 
70  TMountPoint() = default;
71  };
72 
73  /** Used in CNTRIPClient::retrieveListOfMountpoints */
74  using TListMountPoints = std::list<TMountPoint>;
75 
76  /** The arguments for connecting to a NTRIP stream, used in
77  * CNTRIPClient::open
78  */
79  struct NTRIPArgs
80  {
81  std::string server{"www.euref-ip.net"};
82  int port{2101};
83  std::string user;
84  std::string password;
85  std::string mountpoint;
86 
87  /** Default params */
88  NTRIPArgs() = default;
89  };
90 
91  protected:
92  /** The working thread */
93  void private_ntrip_thread();
94 
95  std::thread m_thread;
96  std::promise<void> m_sem_sock_closed;
97  std::promise<void> m_sem_first_connect_done;
98 
99  mutable bool m_thread_exit{false};
100  /** Will be "true" between "open" and "close" */
101  mutable bool m_thread_do_process{false};
102  mutable bool m_waiting_answer_connection{false};
103 
105  {
106  connOk = 0,
109  };
110 
112  /** All the parameters for the NTRIP connection */
113  mutable NTRIPArgs m_args;
114 
115  /** Buffer for data to be sent back to the server */
117 
118  public:
119  /** Default constructor */
120  CNTRIPClient();
121  /** Default destructor */
122  virtual ~CNTRIPClient();
123 
124  /** Tries to open a given NTRIP stream and, if successful, launches a thread
125  * for continuously reading from it.
126  * \sa close, stream_data
127  *
128  * \return false On any kind of error, with a description of the error in
129  * errmsg, if provided.
130  */
131  bool open(const NTRIPArgs& params, std::string& out_errmsg);
132 
133  /** Closes the connection.
134  * \sa open
135  */
136  void close();
137 
138  /** The buffer with all the bytes so-far read from the NTRIP server stream.
139  * Call its "readAndClear" method in a timely fashion to get the stream
140  * contents.
141  * \sa open, close
142  */
144 
145  /** Connect to a given NTRIP caster and get the list of all available
146  *mountpoints and their parameters.
147  * Note that the authentication parameters "auth_user" and "auth_pass"
148  *will be left empty in most situations, since LISTING the Caster normally
149  *doesn't require special rights.
150  *
151  * Example:
152  * \code
153  * CNTRIPClient::TListMountPoints lst;
154  * std::string errMsg;
155  * bool ret =
156  *CNTRIPClient::retrieveListOfMountpoints(lst,errMsg,"www.euref-ip.net",
157  *2101);
158  * \endcode
159  *
160  * \return False on any error, then "errmsg" holds the reason.
161  */
162  static bool retrieveListOfMountpoints(
163  TListMountPoints& out_list, std::string& out_errmsg,
164  const std::string& server, int port = 2101,
165  const std::string& auth_user = std::string(),
166  const std::string& auth_pass = std::string());
167 
168  /** Enqueues a string to be sent back to the NTRIP server (e.g. GGA frames)
169  */
170  void sendBackToServer(const std::string& data);
171 
172 }; // End of class
173 
174 } // namespace mrpt::hwdrivers
std::promise< void > m_sem_sock_closed
Definition: CNTRIPClient.h:96
bool open(const NTRIPArgs &params, std::string &out_errmsg)
Tries to open a given NTRIP stream and, if successful, launches a thread for continuously reading fro...
void private_ntrip_thread()
The working thread.
static bool retrieveListOfMountpoints(TListMountPoints &out_list, std::string &out_errmsg, const std::string &server, int port=2101, const std::string &auth_user=std::string(), const std::string &auth_pass=std::string())
Connect to a given NTRIP caster and get the list of all available mountpoints and their parameters...
Contains classes for various device interfaces.
mrpt::vision::TStereoCalibParams params
A client for NTRIP (HTTP) sources of differential GPS corrections from internet servers, or Global navigation satellite system (GNSS) internet radio.
Definition: CNTRIPClient.h:36
void close()
Closes the connection.
A descriptor of one stream in an NTRIP Caster - See CNTRIPClient::retrieveListOfMountpoints.
Definition: CNTRIPClient.h:42
virtual ~CNTRIPClient()
Default destructor.
This class is a bulk sequence of bytes with MultiThread (MT)-safe read and write operations.
Definition: MT_buffer.h:22
std::string format
RTCM 2.3, RTCM 3, CMR+, etc...
Definition: CNTRIPClient.h:48
NTRIPArgs m_args
All the parameters for the NTRIP connection.
Definition: CNTRIPClient.h:113
std::string country_code
ITA, ESP, DEU,...
Definition: CNTRIPClient.h:57
int carrier
0: No carrier phase, 1: L1, 2: L1+L2
Definition: CNTRIPClient.h:51
bool m_thread_do_process
Will be "true" between "open" and "close".
Definition: CNTRIPClient.h:101
NTRIPArgs()=default
Default params.
CNTRIPClient()
Default constructor.
mrpt::containers::MT_buffer m_upload_data
Buffer for data to be sent back to the server.
Definition: CNTRIPClient.h:116
std::promise< void > m_sem_first_connect_done
Definition: CNTRIPClient.h:97
std::list< TMountPoint > TListMountPoints
Used in CNTRIPClient::retrieveListOfMountpoints.
Definition: CNTRIPClient.h:74
char authentication
"N": none, "B": basic, "D": digest
Definition: CNTRIPClient.h:65
The arguments for connecting to a NTRIP stream, used in CNTRIPClient::open.
Definition: CNTRIPClient.h:79
mrpt::containers::MT_buffer stream_data
The buffer with all the bytes so-far read from the NTRIP server stream.
Definition: CNTRIPClient.h:143
static struct FontData data
Definition: gltext.cpp:144
void sendBackToServer(const std::string &data)
Enqueues a string to be sent back to the NTRIP server (e.g.



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020