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
mrpt::hwdrivers::CNTRIPClient::m_waiting_answer_connection
bool m_waiting_answer_connection
Definition: CNTRIPClient.h:122
mrpt::hwdrivers::CNTRIPClient::connOk
@ connOk
Definition: CNTRIPClient.h:126
mrpt::hwdrivers::CNTRIPClient
A client for NTRIP (HTTP) sources of differential GPS corrections from internet servers,...
Definition: CNTRIPClient.h:39
mrpt::hwdrivers::CNTRIPClient::retrieveListOfMountpoints
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.
Definition: CNTRIPClient.cpp:327
mrpt::hwdrivers::CNTRIPClient::m_thread_do_process
bool m_thread_do_process
Will be "true" between "open" and "close".
Definition: CNTRIPClient.h:121
mrpt::hwdrivers::CNTRIPClient::TMountPoint::generator_model
std::string generator_model
Definition: CNTRIPClient.h:64
mrpt::hwdrivers::CNTRIPClient::TMountPoint::mountpoint_name
std::string mountpoint_name
Definition: CNTRIPClient.h:47
mrpt::hwdrivers::CNTRIPClient::private_ntrip_thread
void private_ntrip_thread()
The working thread.
Definition: CNTRIPClient.cpp:123
mrpt::hwdrivers::CNTRIPClient::connError
@ connError
Definition: CNTRIPClient.h:127
mrpt::hwdrivers::CNTRIPClient::stream_data
mrpt::containers::MT_buffer stream_data
The buffer with all the bytes so-far read from the NTRIP server stream.
Definition: CNTRIPClient.h:163
mrpt::hwdrivers::CNTRIPClient::TMountPoint::latitude
double latitude
Definition: CNTRIPClient.h:61
mrpt::hwdrivers::CNTRIPClient::TMountPoint::pay_service
bool pay_service
Definition: CNTRIPClient.h:69
mrpt::hwdrivers::CNTRIPClient::NTRIPArgs::server
std::string server
Definition: CNTRIPClient.h:94
mrpt::hwdrivers::CNTRIPClient::NTRIPArgs::mountpoint
std::string mountpoint
Definition: CNTRIPClient.h:98
mrpt::hwdrivers::CNTRIPClient::NTRIPArgs::password
std::string password
Definition: CNTRIPClient.h:97
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::hwdrivers::CNTRIPClient::TMountPoint::compr_encryp
std::string compr_encryp
"none"
Definition: CNTRIPClient.h:66
mrpt::hwdrivers::CNTRIPClient::NTRIPArgs
The arguments for connecting to a NTRIP stream, used in CNTRIPClient::open.
Definition: CNTRIPClient.h:92
mrpt::hwdrivers::CNTRIPClient::TMountPoint::format
std::string format
RTCM 2.3, RTCM 3, CMR+, etc...
Definition: CNTRIPClient.h:51
mrpt::hwdrivers::CNTRIPClient::TMountPoint::network
std::string network
IGS, ...
Definition: CNTRIPClient.h:58
mrpt::hwdrivers::CNTRIPClient::open
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...
Definition: CNTRIPClient.cpp:69
mrpt::hwdrivers::CNTRIPClient::TMountPoint::needs_nmea
bool needs_nmea
Definition: CNTRIPClient.h:62
mrpt::hwdrivers::CNTRIPClient::TMountPoint::country_code
std::string country_code
ITA, ESP, DEU,...
Definition: CNTRIPClient.h:60
mrpt::hwdrivers::CNTRIPClient::TMountPoint::longitude
double longitude
Definition: CNTRIPClient.h:61
mrpt::hwdrivers::CNTRIPClient::NTRIPArgs::user
std::string user
Definition: CNTRIPClient.h:96
mrpt::hwdrivers::CNTRIPClient::m_args
NTRIPArgs m_args
All the parameters for the NTRIP connection.
Definition: CNTRIPClient.h:133
mrpt::hwdrivers::CNTRIPClient::TMountPoint::extra_info
std::string extra_info
Definition: CNTRIPClient.h:71
mrpt::hwdrivers::CNTRIPClient::TMountPoint::carrier
int carrier
0: No carrier phase, 1: L1, 2: L1+L2
Definition: CNTRIPClient.h:54
data
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3547
mrpt::hwdrivers::CNTRIPClient::TMountPoint::id
std::string id
City name.
Definition: CNTRIPClient.h:49
mrpt::hwdrivers::CNTRIPClient::TMountPoint::net_ref_stations
bool net_ref_stations
Definition: CNTRIPClient.h:63
mrpt::hwdrivers::CNTRIPClient::m_sem_first_connect_done
std::promise< void > m_sem_first_connect_done
Definition: CNTRIPClient.h:117
mrpt::hwdrivers::CNTRIPClient::~CNTRIPClient
virtual ~CNTRIPClient()
Default destructor.
Definition: CNTRIPClient.cpp:45
MT_buffer.h
mrpt::hwdrivers::CNTRIPClient::m_thread
std::thread m_thread
Definition: CNTRIPClient.h:115
mrpt::hwdrivers::CNTRIPClient::m_upload_data
mrpt::containers::MT_buffer m_upload_data
Buffer for data to be sent back to the server.
Definition: CNTRIPClient.h:136
mrpt::hwdrivers::CNTRIPClient::m_answer_connection
TConnResult m_answer_connection
Definition: CNTRIPClient.h:131
mrpt::hwdrivers::CNTRIPClient::close
void close()
Closes the connection.
Definition: CNTRIPClient.cpp:58
mrpt::hwdrivers::CNTRIPClient::TMountPoint::format_details
std::string format_details
Definition: CNTRIPClient.h:52
mrpt::hwdrivers::CNTRIPClient::TMountPoint::nav_system
std::string nav_system
GPS, ...
Definition: CNTRIPClient.h:56
mrpt::hwdrivers::CNTRIPClient::TMountPoint::stream_bitspersec
int stream_bitspersec
Definition: CNTRIPClient.h:70
mrpt::hwdrivers::CNTRIPClient::TConnResult
TConnResult
Definition: CNTRIPClient.h:124
mrpt::hwdrivers::CNTRIPClient::m_sem_sock_closed
std::promise< void > m_sem_sock_closed
Definition: CNTRIPClient.h:116
mrpt::hwdrivers::CNTRIPClient::connUnauthorized
@ connUnauthorized
Definition: CNTRIPClient.h:128
mrpt::hwdrivers::CNTRIPClient::NTRIPArgs::port
int port
Definition: CNTRIPClient.h:95
mrpt::containers::MT_buffer
This class is a bulk sequence of bytes with MultiThread (MT)-safe read and write operations.
Definition: MT_buffer.h:24
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::hwdrivers::CNTRIPClient::TMountPoint::authentication
char authentication
"N": none, "B": basic, "D": digest
Definition: CNTRIPClient.h:68
mrpt::hwdrivers::CNTRIPClient::NTRIPArgs::NTRIPArgs
NTRIPArgs()
Default params.
Definition: CNTRIPClient.h:101
mrpt::hwdrivers::CNTRIPClient::TMountPoint::TMountPoint
TMountPoint()
Definition: CNTRIPClient.h:73
mrpt::hwdrivers::CNTRIPClient::m_thread_exit
bool m_thread_exit
Definition: CNTRIPClient.h:119
params
GLenum const GLfloat * params
Definition: glext.h:3534
mrpt::hwdrivers::CNTRIPClient::TMountPoint
A descriptor of one stream in an NTRIP Caster - See CNTRIPClient::retrieveListOfMountpoints.
Definition: CNTRIPClient.h:45
mrpt::hwdrivers::CNTRIPClient::sendBackToServer
void sendBackToServer(const std::string &data)
Enqueues a string to be sent back to the NTRIP server (e.g.
Definition: CNTRIPClient.cpp:385
mrpt::hwdrivers::CNTRIPClient::CNTRIPClient
CNTRIPClient()
Default constructor.
Definition: CNTRIPClient.cpp:31
mrpt::hwdrivers::CNTRIPClient::TListMountPoints
std::list< TMountPoint > TListMountPoints
Used in CNTRIPClient::retrieveListOfMountpoints.
Definition: CNTRIPClient.h:87



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST