ntrip client safe without wlan
This commit is contained in:
@@ -52,6 +52,8 @@ void Navigation::init(Route* route) {
|
|||||||
this->route = route;
|
this->route = route;
|
||||||
else
|
else
|
||||||
this->route = new Route();
|
this->route = new Route();
|
||||||
|
|
||||||
|
this->ntripClient = new NTRIPClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
Navigation::~Navigation() {
|
Navigation::~Navigation() {
|
||||||
@@ -65,7 +67,7 @@ Navigation::~Navigation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Navigation::initNtrip(String host, uint16_t port, String mountPoint, String user, String password) {
|
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->gpsConfiguration();
|
||||||
this->ntripClient->loop();
|
this->ntripClient->loop();
|
||||||
this->ntripClient->setActivated(false);
|
this->ntripClient->setActivated(false);
|
||||||
|
|||||||
@@ -11,7 +11,15 @@
|
|||||||
|
|
||||||
#include "ntripClient.h"
|
#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;
|
this->gps = gps;
|
||||||
strcpy(this->host, host);
|
strcpy(this->host, host);
|
||||||
this->port = port;
|
this->port = port;
|
||||||
@@ -20,10 +28,7 @@ NTRIPClient::NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, c
|
|||||||
strcpy(this->password, password);
|
strcpy(this->password, password);
|
||||||
|
|
||||||
this->ntripClient = new WiFiClient;
|
this->ntripClient = new WiFiClient;
|
||||||
}
|
this->state = NTRIPClientStates::closeConnection;
|
||||||
|
|
||||||
NTRIPClient::~NTRIPClient() {
|
|
||||||
delete this->ntripClient;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NTRIPClient::loop() {
|
void NTRIPClient::loop() {
|
||||||
@@ -84,6 +89,9 @@ void NTRIPClient::loop() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case NTRIPClientStates::notAvailable:
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
std::cout << "Wrong state in NTRIPClient.cpp..." << std::endl;
|
std::cout << "Wrong state in NTRIPClient.cpp..." << std::endl;
|
||||||
this->state = NTRIPClientStates::closeConnection;
|
this->state = NTRIPClientStates::closeConnection;
|
||||||
@@ -100,6 +108,16 @@ void NTRIPClient::gpsConfiguration() {
|
|||||||
this->gps->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_SPI, 10);
|
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() {
|
bool NTRIPClient::beginClient() {
|
||||||
std::cout << "Opening socket to " << this->host << std::endl;
|
std::cout << "Opening socket to " << this->host << std::endl;
|
||||||
|
|
||||||
|
|||||||
@@ -13,19 +13,21 @@ enum NTRIPClientStates {
|
|||||||
openConnection,
|
openConnection,
|
||||||
pushData,
|
pushData,
|
||||||
closeConnection,
|
closeConnection,
|
||||||
wait
|
wait,
|
||||||
|
notAvailable
|
||||||
};
|
};
|
||||||
class NTRIPClient {
|
class NTRIPClient {
|
||||||
public:
|
public:
|
||||||
NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password);
|
NTRIPClient();
|
||||||
~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 loop();
|
||||||
|
|
||||||
void gpsConfiguration();
|
void gpsConfiguration();
|
||||||
|
|
||||||
void setTransmitLocation(bool b) { this->transmitLocation = b; }
|
void setTransmitLocation(bool b) { this->transmitLocation = b; }
|
||||||
void setActivated(bool b) { this->activated = b; }
|
bool setActivated(bool b);
|
||||||
|
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
NTRIPClientStates getClientState() { return this->state; }
|
NTRIPClientStates getClientState() { return this->state; }
|
||||||
@@ -40,7 +42,7 @@ class NTRIPClient {
|
|||||||
|
|
||||||
SFE_UBLOX_GNSS* gps;
|
SFE_UBLOX_GNSS* gps;
|
||||||
WiFiClient* ntripClient;
|
WiFiClient* ntripClient;
|
||||||
NTRIPClientStates state = NTRIPClientStates::closeConnection;
|
NTRIPClientStates state = NTRIPClientStates::notAvailable;
|
||||||
|
|
||||||
bool transmitLocation = true;
|
bool transmitLocation = true;
|
||||||
bool activated = true;
|
bool activated = true;
|
||||||
|
|||||||
@@ -130,24 +130,24 @@ void MenuGPS::printPage() const {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: {
|
case 3: {
|
||||||
bool status;
|
NTRIPClientStates status = this->ntripClient->getClientState();
|
||||||
if (this->ntripClient->getClientState() == NTRIPClientStates::pushData)
|
|
||||||
status = true;
|
|
||||||
else
|
|
||||||
status = false;
|
|
||||||
|
|
||||||
if (this->lcd) {
|
if (this->lcd) {
|
||||||
lcd->clear();
|
lcd->clear();
|
||||||
lcd->setCursor(0, 0);
|
lcd->setCursor(0, 0);
|
||||||
lcd->print("NTRIP Client");
|
lcd->print("NTRIP Client");
|
||||||
lcd->setCursor(0, 1);
|
lcd->setCursor(0, 1);
|
||||||
if (status)
|
if (status == NTRIPClientStates::pushData)
|
||||||
lcd->print("enabled");
|
lcd->print("enabled");
|
||||||
|
else if (status == NTRIPClientStates::notAvailable)
|
||||||
|
lcd->print("not available");
|
||||||
else
|
else
|
||||||
lcd->print("disabled");
|
lcd->print("disabled");
|
||||||
}
|
}
|
||||||
if (status)
|
if (status == NTRIPClientStates::pushData)
|
||||||
std::cout << "NTRIP Client is enabled." << std::endl;
|
std::cout << "NTRIP Client is enabled." << std::endl;
|
||||||
|
else if (status == NTRIPClientStates::notAvailable)
|
||||||
|
std::cout << "NTRIP Client is not available." << std::endl;
|
||||||
else
|
else
|
||||||
std::cout << "NTRIP Client is disabled" << std::endl;
|
std::cout << "NTRIP Client is disabled" << std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -206,9 +206,10 @@ void callbackControllerConnect() {
|
|||||||
// because after the setup the other core control the display.
|
// because after the setup the other core control the display.
|
||||||
if (firstConnect) {
|
if (firstConnect) {
|
||||||
lcd->init();
|
lcd->init();
|
||||||
main_m->printMenu();
|
|
||||||
firstConnect = false;
|
firstConnect = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main_m->printMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void callbackControllerDisconnect() {
|
void callbackControllerDisconnect() {
|
||||||
@@ -261,6 +262,11 @@ void makeMenu() {
|
|||||||
|
|
||||||
auto disconnectController = [&]() {
|
auto disconnectController = [&]() {
|
||||||
disconnectPs3 = true;
|
disconnectPs3 = true;
|
||||||
|
lcd->clear();
|
||||||
|
lcd->setCursor(0, 0);
|
||||||
|
lcd->print("Controller is");
|
||||||
|
lcd->setCursor(0, 1);
|
||||||
|
lcd->print("disconnected.");
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create Menu
|
// Create Menu
|
||||||
|
|||||||
Reference in New Issue
Block a user