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