added virtual destuctor for menu things
This commit is contained in:
Vendored
+2
@@ -85,11 +85,13 @@
|
||||
"blox",
|
||||
"gast",
|
||||
"GNSS",
|
||||
"GPGGA",
|
||||
"Huus",
|
||||
"Keine",
|
||||
"kleiax",
|
||||
"Lebennig",
|
||||
"NMEA",
|
||||
"NMEAGPGGA",
|
||||
"NTRIP",
|
||||
"pidl",
|
||||
"pidr",
|
||||
|
||||
@@ -14,6 +14,11 @@ Menu::Menu() {
|
||||
this->selectedEntry = this->entrys.begin();
|
||||
}
|
||||
|
||||
Menu::~Menu() {
|
||||
for (std::list<MenuAction*>::iterator iter = this->entrys.begin(); iter != this->entrys.end(); iter++)
|
||||
delete *iter;
|
||||
}
|
||||
|
||||
void Menu::addEntry(MenuAction* entry) {
|
||||
this->entrys.push_back(entry);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ class MenuAction;
|
||||
class Menu : public MenuControl {
|
||||
public:
|
||||
Menu();
|
||||
~Menu() override;
|
||||
|
||||
/**
|
||||
* @brief Add a menu action to the menu
|
||||
|
||||
@@ -23,6 +23,11 @@ MenuAction::MenuAction(const char* name, MenuControl* menu) {
|
||||
this->callback = nullptr;
|
||||
}
|
||||
|
||||
MenuAction::~MenuAction() {
|
||||
if (this->menu)
|
||||
delete this->menu;
|
||||
}
|
||||
|
||||
void MenuAction::runAction() {
|
||||
if (isMenu)
|
||||
this->menu->printMenu();
|
||||
|
||||
@@ -43,6 +43,8 @@ class MenuAction {
|
||||
*/
|
||||
MenuAction(const char* name, MenuControl* menu);
|
||||
|
||||
~MenuAction();
|
||||
|
||||
/**
|
||||
* @brief activates the entry
|
||||
*/
|
||||
@@ -80,7 +82,7 @@ class MenuAction {
|
||||
void (*callback) () = nullptr;
|
||||
|
||||
bool isMenu = false;
|
||||
MenuControl* menu;
|
||||
MenuControl* menu = nullptr;
|
||||
};
|
||||
|
||||
#endif // MENU_ENTRY_H
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
class MenuControl {
|
||||
public:
|
||||
virtual ~MenuControl() {};
|
||||
|
||||
/** @name UserInputs
|
||||
* @brief This functions should be called be user actions.
|
||||
|
||||
@@ -25,9 +25,7 @@ Navigation::Navigation(Route* route) {
|
||||
this->gps->setI2COutput(COM_TYPE_UBX);
|
||||
this->gps->setUSBOutput(COM_TYPE_UBX | COM_TYPE_NMEA);
|
||||
|
||||
this->gps->setPortInput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3);
|
||||
|
||||
this->gps->getNavigationFrequency(1);
|
||||
this->gps->setNavigationFrequency(1);
|
||||
|
||||
if (route)
|
||||
this->route = route;
|
||||
@@ -38,55 +36,17 @@ Navigation::Navigation(Route* route) {
|
||||
Navigation::~Navigation() {
|
||||
delete this->gps;
|
||||
|
||||
if (this->isNtripInit) {
|
||||
if (this->isNtripInit)
|
||||
delete this->ntripClient;
|
||||
|
||||
delete this->host;
|
||||
delete this->mountPoint;
|
||||
delete this->user;
|
||||
delete this->password;
|
||||
}
|
||||
|
||||
if (this->route)
|
||||
delete this->route;
|
||||
}
|
||||
|
||||
void Navigation::initNtrip(String host, uint16_t port, String mountPoint, String user, String password) {
|
||||
this->host = new char[host.length() + 1];
|
||||
this->mountPoint = new char[mountPoint.length() + 1];
|
||||
this->user = new char[user.length() + 1];
|
||||
this->password = new char[password.length() + 1];
|
||||
|
||||
strcpy(this->host, host.c_str());
|
||||
strcpy(this->mountPoint, mountPoint.c_str());
|
||||
strcpy(this->user, user.c_str());
|
||||
strcpy(this->password, password.c_str());
|
||||
this->port = port;
|
||||
|
||||
this->ntripClient = new NTRIPClient;
|
||||
this->ntripClient = new NTRIPClient(this->gps, host.c_str(), port, mountPoint.c_str(), user.c_str(), password.c_str());
|
||||
this->ntripClient->gpsConfiguration();
|
||||
this->isNtripInit = true;
|
||||
|
||||
std::cout << "Requesting SourceTable." << std::endl;
|
||||
if(this->ntripClient->reqSrcTbl(this->host, (int) this->port)){
|
||||
char buffer[512];
|
||||
delay(5);
|
||||
while(this->ntripClient->available()) {
|
||||
this->ntripClient->readLine(buffer,sizeof(buffer));
|
||||
std::cout << buffer << std::endl;
|
||||
}
|
||||
} else {
|
||||
std::cout << "SourceTable request error" << std::endl;
|
||||
}
|
||||
std::cout << "Requesting SourceTable is OK" << std::endl;
|
||||
this->ntripClient->stop(); //Need to call "stop" function for next request.
|
||||
|
||||
std::cout << "Requesting MountPoint's Raw data" << std::endl;
|
||||
if(!this->ntripClient->reqRaw(this->host, this->port, this->mountPoint,
|
||||
this->user, this->password)){
|
||||
delay(15000);
|
||||
ESP.restart();
|
||||
}
|
||||
std::cout << "Requesting MountPoint is OK" << std::endl;
|
||||
}
|
||||
|
||||
void Navigation::loop() {
|
||||
@@ -95,14 +55,8 @@ void Navigation::loop() {
|
||||
if (millis() - this->lastMillis < this->timeToWait)
|
||||
return;
|
||||
|
||||
if (this->isNtripInit) {
|
||||
uint8_t rtcmData[512 * 4];
|
||||
uint16_t rtcmCount = this->ntripClient->available();
|
||||
if (rtcmCount) {
|
||||
this->ntripClient->readBytes(rtcmData, rtcmCount);
|
||||
this->gps->pushRawData(rtcmData, rtcmCount);
|
||||
}
|
||||
}
|
||||
if (this->isNtripInit)
|
||||
this->ntripClient->loop();
|
||||
}
|
||||
|
||||
void Navigation::newRoute() {
|
||||
|
||||
@@ -34,6 +34,13 @@ void NTRIPClient::loop() {
|
||||
this->gps->checkUblox();
|
||||
this->gps->checkCallbacks();
|
||||
|
||||
if (millis() - this->lastGPGGAPushTime > this->pushGPGGATime) {
|
||||
NMEA_GGA_data_t *data = nullptr;
|
||||
uint8_t res = this->gps->getLatestNMEAGPGGA(data);
|
||||
if (res == 2)
|
||||
this->pushGPGGA(data);
|
||||
}
|
||||
|
||||
switch (this->state) {
|
||||
case NTRIPClientStates::openConnection:
|
||||
if (millis() - this->lastNtripConnectTime > this->tryReconnectTime)
|
||||
@@ -72,12 +79,11 @@ void NTRIPClient::loop() {
|
||||
void NTRIPClient::gpsConfiguration() {
|
||||
this->gps->setI2COutput(COM_TYPE_UBX | COM_TYPE_NMEA);
|
||||
this->gps->setPortInput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3);
|
||||
this->gps->(SFE_UBLOX_DGNSS_MODE_FIXED); // Set the differential mode - ambiguities are fixed whenever possible
|
||||
this->gps->setDGNSSConfiguration(SFE_UBLOX_DGNSS_MODE_FIXED); // Set the differential mode - ambiguities are fixed whenever possible
|
||||
this->gps->setNavigationFrequency(1);
|
||||
this->gps->setMainTalkerID(SFE_UBLOX_MAIN_TALKER_ID_GP);
|
||||
this->gps->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_I2C, 10);
|
||||
|
||||
this->gps->setNMEAGPGGAcallbackPtr(&pushGPGGA); // Set up the callback for GPGGA
|
||||
this->gps->setAutoPVTcallbackPtr(&(NTRIPClient::printPVTdata));
|
||||
}
|
||||
|
||||
@@ -140,7 +146,7 @@ bool NTRIPClient::beginClient() {
|
||||
this->ntripClient->stop();
|
||||
return false;
|
||||
}
|
||||
delay(10)
|
||||
delay(10);
|
||||
}
|
||||
|
||||
//Check reply
|
||||
@@ -214,7 +220,7 @@ bool NTRIPClient::processConnection() {
|
||||
|
||||
void NTRIPClient::pushGPGGA(NMEA_GGA_data_t *nmeaData) {
|
||||
if (this->ntripClient->connected() && this->transmitLocation) {
|
||||
std::cout << "Pushing GGA to server: " << (const char *)nmeaData->nmea) << std::endl;
|
||||
std::cout << "Pushing GGA to server: " << (const char *)nmeaData->nmea << std::endl;
|
||||
this->ntripClient->print((const char *)nmeaData->nmea);
|
||||
}
|
||||
}
|
||||
@@ -262,3 +268,9 @@ void NTRIPClient::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) {
|
||||
<< "Carrier Solution: " << carrSolnString
|
||||
<< "Horizontal Accuracy Estimate: " << hAcc << " mm" << std::endl;
|
||||
}
|
||||
|
||||
bool NTRIPClient::isConnected() {
|
||||
if (this->state == NTRIPClientStates::pushData)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -21,13 +21,17 @@ class NTRIPClient {
|
||||
void loop();
|
||||
|
||||
void gpsConfiguration();
|
||||
void pushGPGGA(NMEA_GGA_data_t *nmeaData);
|
||||
|
||||
void setTransmitLocation(bool b) { this->transmitLocation = b; }
|
||||
void setActivated(bool b) { this->activated = b; }
|
||||
|
||||
bool isConnected();
|
||||
NTRIPClientStates getClientState() { return this->state; }
|
||||
|
||||
static void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct);
|
||||
|
||||
private:
|
||||
void pushGPGGA(NMEA_GGA_data_t *nmeaData);
|
||||
bool beginClient();
|
||||
void closeConnection();
|
||||
bool processConnection();
|
||||
@@ -42,6 +46,7 @@ class NTRIPClient {
|
||||
uint16_t port;
|
||||
uint32_t lastReceivedRtcmTime = 0;
|
||||
uint32_t lastNtripConnectTime = 0;
|
||||
uint32_t lastGPGGAPushTime = 0;
|
||||
uint32_t lastLoopTime = 0;
|
||||
|
||||
const char* host;
|
||||
@@ -52,6 +57,7 @@ class NTRIPClient {
|
||||
const uint16_t timeOut = 5000;
|
||||
const uint16_t tryReconnectTime = 5000;
|
||||
const uint16_t bufferSize = 512;
|
||||
const uint16_t pushGPGGATime = 10000;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user