32 CNTRIPClient::CNTRIPClient() : m_thread(), m_args()
    70         out_errmsg = 
"MOUNTPOINT cannot be empty.";
    75         out_errmsg = 
"Server address cannot be empty.";
    89         std::future_status::timeout)
    91         out_errmsg = 
"Timeout waiting thread response";
   101                 "Error trying to connect to server '%s'",
   106                 "Authentication failed for server '%s'", 
params.server.c_str());
   110             out_errmsg = 
"UNKNOWN m_answer_connection!!";
   146                 if (last_thread_do_process)  
   151                 std::this_thread::sleep_for(100ms);
   163                 std::vector<uint8_t> buf;
   171                         "[CNTRIPClient] Trying to connect to %s:%i\n",
   185                     req += 
"User-Agent: NTRIP MRPT Library\r\n";
   186                     req += 
"Accept: */*\r\n";
   187                     req += 
"Connection: close\r\n";
   196                         std::vector<uint8_t> v(auth_str.size());
   202                         req += 
"Authorization: Basic ";
   215                     size_t to_read_now = 30;
   216                     buf.resize(to_read_now);
   218                         my_sock.
readAsync(&buf[0], to_read_now, 4000, 200);
   225                 catch (std::exception&)
   236                     resp.resize(buf.size());
   239                     if (resp.find(
" 200 ") == string::npos)
   245                         if (resp.find(
" 401 ") != string::npos)
   266                 std::this_thread::sleep_for(500ms);
   272             std::vector<uint8_t> buf;
   273             size_t to_read_now = 1000;
   274             buf.resize(to_read_now);
   275             size_t len = my_sock.
readAsync(&buf[0], to_read_now, 10, 5);
   291             std::vector<uint8_t> upload_data;
   293             if (!upload_data.empty())
   295                 const size_t N = upload_data.size();
   296                 const size_t nWritten =
   299                     cerr << 
"*ERROR*: Couldn't write back " << N
   300                          << 
" bytes to NTRIP server!.\n";
   303             std::this_thread::sleep_for(10ms);
   309         cerr << 
"[CNTRIPClient] Exception in working thread: " << endl
   314         cerr << 
"[CNTRIPClient] Runtime exception in working thread." << endl;
   324     int port, 
const string& auth_user, 
const string& auth_pass)
   333         string(
"http://") + server, content, out_errmsg, port, auth_user,
   334         auth_pass, &http_code, &my_headers, 
nullptr, 6000);
   339     std::stringstream ss(content);
   341     while (std::getline(ss, lin, 
'\n'))
   343         if (lin.size() < 5) 
continue;
   344         if (0 != ::strncmp(
"STR;", lin.c_str(), 4)) 
continue;
   347         deque<string> fields;
   350         if (fields.size() < 13) 
continue;
   358         mnt.
carrier = atoi(fields[5].c_str());
   362         mnt.
latitude = atof(fields[9].c_str());
   363         mnt.
longitude = atof(fields[10].c_str());
   368         mnt.
needs_nmea = atoi(fields[11].c_str()) != 0;
   371         if (fields.size() >= 19) mnt.
extra_info = fields[18];
   373         out_list.push_back(mnt);
   382     if (
data.empty()) 
return;
   384     std::vector<uint8_t> d(
data.size());
 
std::promise< void > m_sem_sock_closed
 
bool open(const NTRIPArgs ¶ms, std::string &out_errmsg)
Tries to open a given NTRIP stream and, if successful, launches a thread for continuously reading fro...
 
bool m_waiting_answer_connection
 
void appendData(const std::vector< uint8_t > &d)
Append new data to the stream. 
 
void connect(const std::string &remotePartAddress, unsigned short remotePartTCPPort, unsigned int timeout_ms=0)
Establishes a connection with a remote part. 
 
std::string std::string format(std::string_view fmt, ARGS &&... args)
 
std::string mountpoint_name
 
bool isConnected()
Returns true if this objects represents a successfully connected socket. 
 
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...
 
Contains classes for various device interfaces. 
 
mrpt::vision::TStereoCalibParams params
 
void close()
Closes the connection. 
 
std::string network
IGS, ... 
 
A descriptor of one stream in an NTRIP Caster - See CNTRIPClient::retrieveListOfMountpoints. 
 
ERRORCODE_HTTP http_get(const string &url, std::vector< uint8_t > &out_content, string &out_errormsg, int port=80, const string &auth_user=string(), const string &auth_pass=string(), int *out_http_responsecode=nullptr, mrpt::system::TParameters< string > *extra_headers=nullptr, mrpt::system::TParameters< string > *out_headers=nullptr, int timeout_ms=1000)
Perform an HTTP GET operation (version for retrieving the data as a std::vector<uint8_t>) ...
 
virtual ~CNTRIPClient()
Default destructor. 
 
void tokenize(const std::string &inString, const std::string &inDelimiters, OUT_CONTAINER &outTokens, bool skipBlankTokens=true) noexcept
Tokenizes a string according to a set of delimiting characters. 
 
This base provides a set of functions for maths stuff. 
 
std::string format
RTCM 2.3, RTCM 3, CMR+, etc... 
 
ERRORCODE_HTTP
Possible returns from a HTTP request. 
 
NTRIPArgs m_args
All the parameters for the NTRIP connection. 
 
constexpr double DEG2RAD(const double x)
Degrees to radians. 
 
std::string country_code
ITA, ESP, DEU,... 
 
int carrier
0: No carrier phase, 1: L1, 2: L1+L2 
 
bool m_thread_do_process
Will be "true" between "open" and "close". 
 
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range. 
 
std::string nav_system
GPS, ... 
 
size_t writeAsync(const void *Buffer, const size_t Count, const int timeout_ms=-1)
A method for writing to the socket with optional timeouts. 
 
mrpt::containers::MT_buffer m_upload_data
Buffer for data to be sent back to the server. 
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
std::promise< void > m_sem_first_connect_done
 
void encodeBase64(const std::vector< uint8_t > &inputData, std::string &outString)
Encode a sequence of bytes as a string in base-64. 
 
std::string format_details
 
constexpr double RAD2DEG(const double x)
Radians to degrees. 
 
TConnResult m_answer_connection
 
A TCP socket that can be connected to a TCP server, implementing MRPT's CStream interface for passing...
 
void close()
Closes the connection. 
 
void readAndClear(std::vector< uint8_t > &d)
Read the whole buffer and empty it. 
 
void clear()
Empty the buffer. 
 
Serial and networking devices and utilities. 
 
size_t readAsync(void *Buffer, const size_t Count, const int timeoutStart_ms=-1, const int timeoutBetween_ms=-1)
A method for reading from the socket with an optional timeout. 
 
std::list< TMountPoint > TListMountPoints
Used in CNTRIPClient::retrieveListOfMountpoints. 
 
For usage when passing a dynamic number of (numeric) arguments to a function, by name. 
 
The arguments for connecting to a NTRIP stream, used in CNTRIPClient::open. 
 
mrpt::containers::MT_buffer stream_data
The buffer with all the bytes so-far read from the NTRIP server stream. 
 
void sendString(const std::string &str)
Writes a string to the socket. 
 
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy". 
 
size_t size()
Return the number of available bytes at this moment. 
 
static struct FontData data
 
void sendBackToServer(const std::string &data)
Enqueues a string to be sent back to the NTRIP server (e.g.