- remove NtripReconnect from Autopilot and CaptureRoute

- shiftet moveControl States in the class namespace
- added auto reconeect to NtripClient
- a lot of refactor
This commit is contained in:
2023-05-30 23:40:05 +02:00
parent 98b65c4aec
commit 22eb6788c3
18 changed files with 369 additions and 280 deletions
@@ -15,31 +15,28 @@ CaptureRoute::CaptureRoute(MoveControl* moveControl, const ControlPadInput *inpu
: ManualControl(moveControl, input) {
this->navigation = navigation;
this->navigation->getRoute()->clear();
this->navigation->getNTRIPClient()->setAutoReconnect(true);
this->routeInfo = navigation->getRouteInfo();
}
CaptureRoute::~CaptureRoute() {
this->navigation->getNTRIPClient()->setActivated(false);
// this->navigation->getNTRIPClient()->setActivated(false);
}
void CaptureRoute::loop() {
ManualControl::loop();
if (millis() - this->lastMillis < this->delay) {
if (millis() - this->lastMillis < this->delay)
return;
}
this->runCaptureRoute();
this->lastMillis = millis();
}
void CaptureRoute::runCaptureRoute() {
this->checkNtrip();
if (this->state != NtripState::Enabled)
return;
if (ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action)) {
if (this->navigation->addCurrentPosToRoute()) {
this->status = this->navigation->addCurrentPosToRoute();
if (this->status == Navigation::Status::Updated) {
this->lastSavedPoint = this->navigation->getCurrentPosition();
this->routeInfo = navigation->getRouteInfo();
this->updateDisplay = true;
@@ -60,27 +57,3 @@ bool CaptureRoute::shouldUpdate() {
}
return false;
}
void CaptureRoute::checkNtrip() {
NTRIPClient* client = this->navigation->getNTRIPClient();
NTRIPClientStates state = client->getClientState();
if (state == NTRIPClientStates::notAvailable) {
this->state = NtripState::NoNtrip;
} else if (state == NTRIPClientStates::pushData) {
this->ntripReconnectAttemps = 0;
this->state = NtripState::Enabled;
} else if (state ==NTRIPClientStates::wait) {
this->state = NtripState::Waiting;
if (millis() - this->reconnectNtripLastMillis < this->reconnectNtripDelayMillis)
return;
if (this->ntripReconnectAttemps > this->ntripReconnectMaxAttemps) {
this->state = NtripState::NoNtrip;
return;
}
this->reconnectNtripLastMillis = millis();
client->setActivated(true);
this->ntripReconnectAttemps++;
}
}