ntrip client safe without wlan
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -13,19 +13,21 @@ enum NTRIPClientStates {
|
||||
openConnection,
|
||||
pushData,
|
||||
closeConnection,
|
||||
wait
|
||||
wait,
|
||||
notAvailable
|
||||
};
|
||||
class NTRIPClient {
|
||||
public:
|
||||
NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password);
|
||||
NTRIPClient();
|
||||
~NTRIPClient();
|
||||
|
||||
void init(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password);
|
||||
void loop();
|
||||
|
||||
void gpsConfiguration();
|
||||
|
||||
void setTransmitLocation(bool b) { this->transmitLocation = b; }
|
||||
void setActivated(bool b) { this->activated = b; }
|
||||
bool setActivated(bool b);
|
||||
|
||||
bool isConnected();
|
||||
NTRIPClientStates getClientState() { return this->state; }
|
||||
@@ -40,7 +42,7 @@ class NTRIPClient {
|
||||
|
||||
SFE_UBLOX_GNSS* gps;
|
||||
WiFiClient* ntripClient;
|
||||
NTRIPClientStates state = NTRIPClientStates::closeConnection;
|
||||
NTRIPClientStates state = NTRIPClientStates::notAvailable;
|
||||
|
||||
bool transmitLocation = true;
|
||||
bool activated = true;
|
||||
|
||||
Reference in New Issue
Block a user