Main MRPT website > C++ reference
MRPT logo
CNTRIPClient.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 
29 #ifndef CNTRIPClient_H
30 #define CNTRIPClient_H
31 
32 #include <mrpt/utils/utils_defs.h>
33 #include <mrpt/synch.h>
34 #include <mrpt/system/threads.h>
35 
37 
38 #include <list>
39 
40 namespace mrpt
41 {
42  namespace hwdrivers
43  {
44  using namespace std;
45 
46  /** A client for NTRIP (HTTP) sources of differential GPS corrections from internet servers, or Global navigation satellite system (GNSS) internet radio.
47  * Usage:
48  * - To open the server, invoke "open" with the proper parameters. Then use "stream_data" to read the read data.
49  * - To obtain a list of all the mountpoints available at a given NTRIP Caster, call "retrieveListOfMountpoints" (it's a static method).
50  *
51  * It is not neccesary to call "close", the connection is ended at destruction.
52  *
53  * \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
54  * \ingroup mrpt_hwdrivers_grp
55  *
56  */
58  {
59  public:
60 
61  /** A descriptor of one stream in an NTRIP Caster - See CNTRIPClient::retrieveListOfMountpoints
62  */
64  {
66  string id; //!< City name
67  string format; //!< RTCM 2.3, RTCM 3, CMR+, etc...
69  int carrier; //!< 0: No carrier phase, 1: L1, 2: L1+L2
70  string nav_system; //!< GPS, ...
71  string network; //!< IGS, ...
72  string country_code; //!< ITA, ESP, DEU,...
73  double latitude, longitude;
74  bool needs_nmea;
77  string compr_encryp; //!< "none"
78  char authentication; //!< "N": none, "B": basic, "D": digest
81  string extra_info;
82 
84  carrier(0),
85  latitude(0),
86  longitude(0),
87  needs_nmea(false),
88  net_ref_stations(false),
89  authentication('B'),
90  pay_service(false),
91  stream_bitspersec(0)
92  {}
93 
94  };
95 
96  typedef list<TMountPoint> TListMountPoints; //!< Used in CNTRIPClient::retrieveListOfMountpoints
97 
98  /** The arguments for connecting to a NTRIP stream, used in CNTRIPClient::open
99  */
101  {
102  string server;
103  int port;
104  string user;
105  string password;
106  string mountpoint;
107 
108  /** Default params */
110  server ( "www.euref-ip.net" ),
111  port ( 2101 ),
112  user ( "" ),
113  password ( "" ),
114  mountpoint ( )
115  {
116  }
117  };
118 
119  protected:
120  void private_ntrip_thread(); //!< The working thread
121 
125 
126  mutable bool m_thread_exit;
127  mutable bool m_thread_do_process; //!< Will be "true" between "open" and "close"
129 
130  enum TConnResult {
131  connOk = 0,
133  connUnauthorized
134  };
135 
137  mutable NTRIPArgs m_args; //!< All the parameters for the NTRIP connection
138 
139  public:
140  CNTRIPClient(); //!< Default constructor
141  virtual ~CNTRIPClient(); //!< Default destructor
142 
143  /** Tries to open a given NTRIP stream and, if successful, launches a thread 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 errmsg, if provided.
147  */
148  bool open(const NTRIPArgs &params, string &out_errmsg);
149 
150  /** Closes the connection.
151  * \sa open
152  */
153  void close();
154 
155  /** The buffer with all the bytes so-far read from the NTRIP server stream.
156  * Call its "readAndClear" method in a timely fashion to get the stream contents.
157  * \sa open, close
158  */
160 
161  /** Connect to a given NTRIP caster and get the list of all available mountpoints and their parameters.
162  * 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.
163  *
164  * Example:
165  * \code
166  * CNTRIPClient::TListMountPoints lst;
167  * std::string errMsg;
168  * bool ret = CNTRIPClient::retrieveListOfMountpoints(lst,errMsg,"www.euref-ip.net", 2101);
169  * \endcode
170  *
171  * \return False on any error, then "errmsg" holds the reason.
172  */
173  static bool retrieveListOfMountpoints(
174  TListMountPoints &out_list,
175  string &out_errmsg,
176  const string &server,
177  int port = 2101,
178  const string &auth_user = string(),
179  const string &auth_pass = string()
180  );
181 
182 
183  }; // End of class
184 
185  } // End of namespace
186 
187 } // End of namespace
188 
189 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013