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