Main MRPT website > C++ reference for MRPT 1.9.9
CNTRIPClient.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #ifndef CNTRIPClient_H
11 #define CNTRIPClient_H
12 
14 
15 #include <future>
16 #include <list>
17 
18 namespace mrpt
19 {
20 namespace hwdrivers
21 {
22 /** A client for NTRIP (HTTP) sources of differential GPS corrections from
23  *internet servers, or Global navigation satellite system (GNSS) internet
24  *radio.
25  * Usage:
26  * - To open the server, invoke "open" with the proper parameters. Then use
27  *"stream_data" to read the read data.
28  * - To obtain a list of all the mountpoints available at a given NTRIP
29  *Caster, call "retrieveListOfMountpoints" (it's a static method).
30  *
31  * It is not neccesary to call "close", the connection is ended at
32  *destruction.
33  *
34  * \note For a good reference of the NTRIP protocol, see
35  *http://gnss.itacyl.es/opencms/opencms/system/modules/es.jcyl.ita.site.gnss/resources/documentos_gnss/NtripDocumentation.pdf
36  * \ingroup mrpt_hwdrivers_grp
37  *
38  */
40 {
41  public:
42  /** A descriptor of one stream in an NTRIP Caster - See
43  * CNTRIPClient::retrieveListOfMountpoints
44  */
45  struct TMountPoint
46  {
48  /** City name */
50  /** RTCM 2.3, RTCM 3, CMR+, etc... */
53  /** 0: No carrier phase, 1: L1, 2: L1+L2 */
54  int carrier;
55  /** GPS, ... */
57  /** IGS, ... */
59  /** ITA, ESP, DEU,... */
62  bool needs_nmea;
65  /** "none" */
67  /** "N": none, "B": basic, "D": digest */
72 
74  : carrier(0),
75  latitude(0),
76  longitude(0),
77  needs_nmea(false),
78  net_ref_stations(false),
79  authentication('B'),
80  pay_service(false),
82  {
83  }
84  };
85 
86  /** Used in CNTRIPClient::retrieveListOfMountpoints */
87  using TListMountPoints = std::list<TMountPoint>;
88 
89  /** The arguments for connecting to a NTRIP stream, used in
90  * CNTRIPClient::open
91  */
92  struct NTRIPArgs
93  {
95  int port;
99 
100  /** Default params */
102  : server("www.euref-ip.net"),
103  port(2101),
104  user(""),
105  password(""),
106  mountpoint()
107  {
108  }
109  };
110 
111  protected:
112  /** The working thread */
113  void private_ntrip_thread();
114 
115  std::thread m_thread;
116  std::promise<void> m_sem_sock_closed;
117  std::promise<void> m_sem_first_connect_done;
118 
119  mutable bool m_thread_exit;
120  /** Will be "true" between "open" and "close" */
121  mutable bool m_thread_do_process;
123 
125  {
126  connOk = 0,
129  };
130 
132  /** All the parameters for the NTRIP connection */
133  mutable NTRIPArgs m_args;
134 
135  /** Buffer for data to be sent back to the server */
137 
138  public:
139  /** Default constructor */
140  CNTRIPClient();
141  /** Default destructor */
142  virtual ~CNTRIPClient();
143 
144  /** Tries to open a given NTRIP stream and, if successful, launches a thread
145  * for continuously reading from it.
146  * \sa close, stream_data
147  *
148  * \return false On any kind of error, with a description of the error in
149  * errmsg, if provided.
150  */
151  bool open(const NTRIPArgs& params, std::string& out_errmsg);
152 
153  /** Closes the connection.
154  * \sa open
155  */
156  void close();
157 
158  /** The buffer with all the bytes so-far read from the NTRIP server stream.
159  * Call its "readAndClear" method in a timely fashion to get the stream
160  * contents.
161  * \sa open, close
162  */
164 
165  /** Connect to a given NTRIP caster and get the list of all available
166  *mountpoints and their parameters.
167  * Note that the authentication parameters "auth_user" and "auth_pass"
168  *will be left empty in most situations, since LISTING the Caster normally
169  *doesn't require special rights.
170  *
171  * Example:
172  * \code
173  * CNTRIPClient::TListMountPoints lst;
174  * std::string errMsg;
175  * bool ret =
176  *CNTRIPClient::retrieveListOfMountpoints(lst,errMsg,"www.euref-ip.net",
177  *2101);
178  * \endcode
179  *
180  * \return False on any error, then "errmsg" holds the reason.
181  */
182  static bool retrieveListOfMountpoints(
183  TListMountPoints& out_list, std::string& out_errmsg,
184  const std::string& server, int port = 2101,
185  const std::string& auth_user = std::string(),
186  const std::string& auth_pass = std::string());
187 
188  /** Enqueues a string to be sent back to the NTRIP server (e.g. GGA frames)
189  */
190  void sendBackToServer(const std::string& data);
191 
192 }; // End of class
193 
194 } // End of namespace
195 
196 } // End of namespace
197 
198 #endif
std::promise< void > m_sem_sock_closed
Definition: CNTRIPClient.h:116
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...
A client for NTRIP (HTTP) sources of differential GPS corrections from internet servers, or Global navigation satellite system (GNSS) internet radio.
Definition: CNTRIPClient.h:39
void close()
Closes the connection.
A descriptor of one stream in an NTRIP Caster - See CNTRIPClient::retrieveListOfMountpoints.
Definition: CNTRIPClient.h:45
virtual ~CNTRIPClient()
Default destructor.
This class is a bulk sequence of bytes with MultiThread (MT)-safe read and write operations.
Definition: MT_buffer.h:24
std::string format
RTCM 2.3, RTCM 3, CMR+, etc...
Definition: CNTRIPClient.h:51
NTRIPArgs m_args
All the parameters for the NTRIP connection.
Definition: CNTRIPClient.h:133
std::string country_code
ITA, ESP, DEU,...
Definition: CNTRIPClient.h:60
int carrier
0: No carrier phase, 1: L1, 2: L1+L2
Definition: CNTRIPClient.h:54
bool m_thread_do_process
Will be "true" between "open" and "close".
Definition: CNTRIPClient.h:121
GLsizei const GLchar ** string
Definition: glext.h:4101
CNTRIPClient()
Default constructor.
mrpt::containers::MT_buffer m_upload_data
Buffer for data to be sent back to the server.
Definition: CNTRIPClient.h:136
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::promise< void > m_sem_first_connect_done
Definition: CNTRIPClient.h:117
std::list< TMountPoint > TListMountPoints
Used in CNTRIPClient::retrieveListOfMountpoints.
Definition: CNTRIPClient.h:87
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3546
char authentication
"N": none, "B": basic, "D": digest
Definition: CNTRIPClient.h:68
GLenum const GLfloat * params
Definition: glext.h:3534
The arguments for connecting to a NTRIP stream, used in CNTRIPClient::open.
Definition: CNTRIPClient.h:92
mrpt::containers::MT_buffer stream_data
The buffer with all the bytes so-far read from the NTRIP server stream.
Definition: CNTRIPClient.h:163
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 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019