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



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014