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
+3 -1
View File
@@ -52,6 +52,8 @@ void Navigation::init(Route* route) {
this->route = route;
else
this->route = new Route();
this->ntripClient = new NTRIPClient();
}
Navigation::~Navigation() {
@@ -65,7 +67,7 @@ Navigation::~Navigation() {
}
void Navigation::initNtrip(String host, uint16_t port, String mountPoint, String user, String password) {
this->ntripClient = new NTRIPClient(this->gps, host.c_str(), port, mountPoint.c_str(), user.c_str(), password.c_str());
this->ntripClient->init(this->gps, host.c_str(), port, mountPoint.c_str(), user.c_str(), password.c_str());
this->ntripClient->gpsConfiguration();
this->ntripClient->loop();
this->ntripClient->setActivated(false);
+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;
+6 -4
View File
@@ -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;
+7 -7
View File
@@ -130,24 +130,24 @@ void MenuGPS::printPage() const {
break;
case 3: {
bool status;
if (this->ntripClient->getClientState() == NTRIPClientStates::pushData)
status = true;
else
status = false;
NTRIPClientStates status = this->ntripClient->getClientState();
if (this->lcd) {
lcd->clear();
lcd->setCursor(0, 0);
lcd->print("NTRIP Client");
lcd->setCursor(0, 1);
if (status)
if (status == NTRIPClientStates::pushData)
lcd->print("enabled");
else if (status == NTRIPClientStates::notAvailable)
lcd->print("not available");
else
lcd->print("disabled");
}
if (status)
if (status == NTRIPClientStates::pushData)
std::cout << "NTRIP Client is enabled." << std::endl;
else if (status == NTRIPClientStates::notAvailable)
std::cout << "NTRIP Client is not available." << std::endl;
else
std::cout << "NTRIP Client is disabled" << std::endl;
}
+7 -1
View File
@@ -206,9 +206,10 @@ void callbackControllerConnect() {
// because after the setup the other core control the display.
if (firstConnect) {
lcd->init();
main_m->printMenu();
firstConnect = false;
}
main_m->printMenu();
}
void callbackControllerDisconnect() {
@@ -261,6 +262,11 @@ void makeMenu() {
auto disconnectController = [&]() {
disconnectPs3 = true;
lcd->clear();
lcd->setCursor(0, 0);
lcd->print("Controller is");
lcd->setCursor(0, 1);
lcd->print("disconnected.");
};
// Create Menu