Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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#include <mrpt/synch.h>
15#include <mrpt/system/threads.h>
16
18
19#include <list>
20
21namespace mrpt
22{
23 namespace hwdrivers
24 {
25 /** A client for NTRIP (HTTP) sources of differential GPS corrections from internet servers, or Global navigation satellite system (GNSS) internet radio.
26 * Usage:
27 * - To open the server, invoke "open" with the proper parameters. Then use "stream_data" to read the read data.
28 * - To obtain a list of all the mountpoints available at a given NTRIP Caster, call "retrieveListOfMountpoints" (it's a static method).
29 *
30 * It is not neccesary to call "close", the connection is ended at destruction.
31 *
32 * \note For a good reference of the NTRIP protocol, see 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
40 /** A descriptor of one stream in an NTRIP Caster - See CNTRIPClient::retrieveListOfMountpoints
41 */
43 {
44 std::string mountpoint_name;
45 std::string id; //!< City name
46 std::string format; //!< RTCM 2.3, RTCM 3, CMR+, etc...
47 std::string format_details;
48 int carrier; //!< 0: No carrier phase, 1: L1, 2: L1+L2
49 std::string nav_system; //!< GPS, ...
50 std::string network; //!< IGS, ...
51 std::string country_code; //!< ITA, ESP, DEU,...
52 double latitude, longitude;
55 std::string generator_model;
56 std::string compr_encryp; //!< "none"
57 char authentication; //!< "N": none, "B": basic, "D": digest
60 std::string extra_info;
61
63 carrier(0),
64 latitude(0),
65 longitude(0),
66 needs_nmea(false),
67 net_ref_stations(false),
68 authentication('B'),
69 pay_service(false),
70 stream_bitspersec(0)
71 {}
72
73 };
74
75 typedef std::list<TMountPoint> TListMountPoints; //!< Used in CNTRIPClient::retrieveListOfMountpoints
76
77 /** The arguments for connecting to a NTRIP stream, used in CNTRIPClient::open
78 */
80 {
81 std::string server;
82 int port;
83 std::string user;
84 std::string password;
85 std::string mountpoint;
86
87 /** Default params */
89 server ( "www.euref-ip.net" ),
90 port ( 2101 ),
91 user ( "" ),
92 password ( "" ),
93 mountpoint ( )
94 {
95 }
96 };
97
98 protected:
99 void private_ntrip_thread(); //!< The working thread
100
104
105 mutable bool m_thread_exit;
106 mutable bool m_thread_do_process; //!< Will be "true" between "open" and "close"
108
110 connOk = 0,
112 connUnauthorized
113 };
114
116 mutable NTRIPArgs m_args; //!< All the parameters for the NTRIP connection
117
118 mrpt::synch::MT_buffer m_upload_data; //!< Buffer for data to be sent back to the server
119
120 public:
121 CNTRIPClient(); //!< Default constructor
122 virtual ~CNTRIPClient(); //!< Default destructor
123
124 /** Tries to open a given NTRIP stream and, if successful, launches a thread for continuously reading from it.
125 * \sa close, stream_data
126 *
127 * \return false On any kind of error, with a description of the error in errmsg, if provided.
128 */
129 bool open(const NTRIPArgs &params, std::string &out_errmsg);
130
131 /** Closes the connection.
132 * \sa open
133 */
134 void close();
135
136 /** The buffer with all the bytes so-far read from the NTRIP server stream.
137 * Call its "readAndClear" method in a timely fashion to get the stream contents.
138 * \sa open, close
139 */
141
142 /** Connect to a given NTRIP caster and get the list of all available mountpoints and their parameters.
143 * Note that the authentication parameters "auth_user" and "auth_pass" will be left empty in most situations, since LISTING the Caster normally doesn't require special rights.
144 *
145 * Example:
146 * \code
147 * CNTRIPClient::TListMountPoints lst;
148 * std::string errMsg;
149 * bool ret = CNTRIPClient::retrieveListOfMountpoints(lst,errMsg,"www.euref-ip.net", 2101);
150 * \endcode
151 *
152 * \return False on any error, then "errmsg" holds the reason.
153 */
155 TListMountPoints &out_list,
156 std::string &out_errmsg,
157 const std::string &server,
158 int port = 2101,
159 const std::string &auth_user = std::string(),
160 const std::string &auth_pass = std::string()
161 );
162
163 /** Enqueues a string to be sent back to the NTRIP server (e.g. GGA frames) */
164 void sendBackToServer(const std::string &data);
165
166
167 }; // End of class
168
169 } // End of namespace
170
171} // End of namespace
172
173#endif
A client for NTRIP (HTTP) sources of differential GPS corrections from internet servers,...
Definition: CNTRIPClient.h:37
mrpt::synch::CSemaphore m_sem_first_connect_done
Definition: CNTRIPClient.h:103
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.
virtual ~CNTRIPClient()
Default destructor.
mrpt::synch::MT_buffer m_upload_data
Buffer for data to be sent back to the server.
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:140
NTRIPArgs m_args
All the parameters for the NTRIP connection.
Definition: CNTRIPClient.h:116
mrpt::synch::CSemaphore m_sem_sock_closed
Definition: CNTRIPClient.h:102
mrpt::system::TThreadHandle m_thread
Definition: CNTRIPClient.h:101
bool m_thread_do_process
Will be "true" between "open" and "close".
Definition: CNTRIPClient.h:106
CNTRIPClient()
Default constructor.
std::list< TMountPoint > TListMountPoints
Used in CNTRIPClient::retrieveListOfMountpoints.
Definition: CNTRIPClient.h:75
void close()
Closes the connection.
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 sendBackToServer(const std::string &data)
Enqueues a string to be sent back to the NTRIP server (e.g.
A semaphore for inter-thread synchronization.
Definition: CSemaphore.h:32
This class is a bulk sequence of bytes with MultiThread (MT)-safe read and write operations.
Definition: MT_buffer.h:24
#define HWDRIVERS_IMPEXP
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
The arguments for connecting to a NTRIP stream, used in CNTRIPClient::open.
Definition: CNTRIPClient.h:80
A descriptor of one stream in an NTRIP Caster - See CNTRIPClient::retrieveListOfMountpoints.
Definition: CNTRIPClient.h:43
int carrier
0: No carrier phase, 1: L1, 2: L1+L2
Definition: CNTRIPClient.h:48
char authentication
"N": none, "B": basic, "D": digest
Definition: CNTRIPClient.h:57
std::string country_code
ITA, ESP, DEU,...
Definition: CNTRIPClient.h:51
std::string format
RTCM 2.3, RTCM 3, CMR+, etc...
Definition: CNTRIPClient.h:46
This structure contains the information needed to interface the threads API on each platform:
Definition: threads.h:26



Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Wed Mar 22 20:12:58 UTC 2023