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



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 8277875f6 Mon Jun 11 02:47:32 2018 +0200 at lun oct 28 01:50:49 CET 2019