ntrip client safe without wlan

This commit is contained in:
2022-12-14 08:45:46 +01:00
parent 1f80548797
commit d431fa72bb
5 changed files with 46 additions and 18 deletions
+23 -5
View File
@@ -11,7 +11,15 @@
#include "ntripClient.h"
NTRIPClient::NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password) {
NTRIPClient::NTRIPClient() {
}
NTRIPClient::~NTRIPClient() {
delete this->ntripClient;
}
void NTRIPClient::init(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password) {
this->gps = gps;
strcpy(this->host, host);
this->port = port;
@@ -20,10 +28,7 @@ NTRIPClient::NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, c
strcpy(this->password, password);
this->ntripClient = new WiFiClient;
}
NTRIPClient::~NTRIPClient() {
delete this->ntripClient;
this->state = NTRIPClientStates::closeConnection;
}
void NTRIPClient::loop() {
@@ -84,6 +89,9 @@ void NTRIPClient::loop() {
}
break;
case NTRIPClientStates::notAvailable:
break;
default:
std::cout << "Wrong state in NTRIPClient.cpp..." << std::endl;
this->state = NTRIPClientStates::closeConnection;
@@ -100,6 +108,16 @@ void NTRIPClient::gpsConfiguration() {
this->gps->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_SPI, 10);
}
bool NTRIPClient::setActivated(bool b) {
if (b && this->state != NTRIPClientStates::notAvailable)
this->activated = true;
else if (b)
return false;
this->activated = false;
return true;
}
bool NTRIPClient::beginClient() {
std::cout << "Opening socket to " << this->host << std::endl;