ntrip, testMode, zed9 gnss modul
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <iostream>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
||||
@@ -21,6 +21,10 @@ void Menu::addEntry(MenuAction* entry) {
|
||||
this->selectedEntry = this->entrys.begin();
|
||||
}
|
||||
|
||||
bool Menu::isInSubmenu() {
|
||||
return this->inSubmenu;
|
||||
}
|
||||
|
||||
void Menu::printMenu() {
|
||||
if (this->lcd) {
|
||||
lcd->clear();
|
||||
|
||||
@@ -31,6 +31,7 @@ class Menu : public MenuControl {
|
||||
* @param entry
|
||||
*/
|
||||
void addEntry(MenuAction* entry);
|
||||
bool isInSubmenu();
|
||||
|
||||
void printMenu() override;
|
||||
void update() override;
|
||||
|
||||
@@ -32,20 +32,20 @@ class MenuControl {
|
||||
* class.
|
||||
*/
|
||||
///@{
|
||||
virtual void down();
|
||||
virtual void up();
|
||||
virtual void right();
|
||||
virtual void left();
|
||||
virtual void yes();
|
||||
virtual void no();
|
||||
virtual void down() = 0;
|
||||
virtual void up() = 0;
|
||||
virtual void right() = 0;
|
||||
virtual void left() = 0;
|
||||
virtual void yes() = 0;
|
||||
virtual void no() = 0;
|
||||
///@}
|
||||
|
||||
/**
|
||||
* @brief can be called to update shown data
|
||||
*/
|
||||
virtual void update();
|
||||
virtual void update() {}
|
||||
|
||||
virtual void printMenu();
|
||||
virtual void printMenu() = 0;
|
||||
|
||||
/**
|
||||
* @brief Set the Parent Menu
|
||||
@@ -56,6 +56,7 @@ class MenuControl {
|
||||
* @param menu
|
||||
*/
|
||||
void setParentMenu(MenuControl* menu) { this->parentMenu = menu; }
|
||||
// MenuControl* getParentMenu() { return this->parentMenu; }
|
||||
|
||||
/**
|
||||
* @brief Set the Lcd object
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* @file menuIntInput.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-09-12
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#include "menuIntInput.h"
|
||||
|
||||
MenuIntInput::MenuIntInput(int16_t values[], char *names, uint8_t length, MenuIntInputWrapper* wrapper) {
|
||||
this->values = values;
|
||||
this->names = names;
|
||||
this->length = length;
|
||||
this->wrapper = wrapper;
|
||||
}
|
||||
|
||||
void MenuIntInput::down() {
|
||||
if (values[currentPosition] > this->min)
|
||||
values[currentPosition]--;
|
||||
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuIntInput::up() {
|
||||
if (values[currentPosition] < this->max)
|
||||
values[currentPosition]++;
|
||||
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuIntInput::right() {
|
||||
if (currentPosition < this->length - 1)
|
||||
currentPosition++;
|
||||
else
|
||||
currentPosition = 0;
|
||||
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuIntInput::left() {
|
||||
if (currentPosition > 0)
|
||||
currentPosition--;
|
||||
else
|
||||
currentPosition = this->length - 1;
|
||||
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuIntInput::no() {
|
||||
if (parentMenu)
|
||||
this->parentMenu->printMenu();
|
||||
}
|
||||
|
||||
void MenuIntInput::yes() {
|
||||
this->wrapper->action(this->values, this->length);
|
||||
if (parentMenu)
|
||||
this->parentMenu->printMenu();
|
||||
}
|
||||
|
||||
void MenuIntInput::printMenu() {
|
||||
// TODO: Name max 12 chars
|
||||
|
||||
char bufferName[17];
|
||||
if (this->currentPosition == 0 && this->length == 1) {
|
||||
// No arrow
|
||||
sprintf(bufferName, " %s ", this->names[this->currentPosition]);
|
||||
} else if (this->currentPosition > 0 && this->length - 1 == this->currentPosition) {
|
||||
// Left arrow only
|
||||
sprintf(bufferName, "< %s ", this->names[this->currentPosition]);
|
||||
} else if (this->currentPosition == 0 && this->length > 1) {
|
||||
// Right arrow only
|
||||
sprintf(bufferName, " %s >", this->names[this->currentPosition]);
|
||||
} else {
|
||||
// Both arrow
|
||||
sprintf(bufferName, "< %s >", this->names[this->currentPosition]);
|
||||
}
|
||||
|
||||
char bufferValue[17];
|
||||
sprintf(bufferValue, " -> %5.d", this->values[this->currentPosition]);
|
||||
|
||||
|
||||
if (this->lcd) {
|
||||
lcd->clear();
|
||||
lcd->setCursor(0, 0);
|
||||
lcd->print(bufferName);
|
||||
lcd->setCursor(0, 1);
|
||||
lcd->print(bufferValue);
|
||||
}
|
||||
std::cout << bufferName << " : " << bufferValue << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @file menuIntInput.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-09-12
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#ifndef MENU_INT_INPUT_H
|
||||
#define MENU_INT_INPUT_H
|
||||
|
||||
#include "menuControl.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define MAX_NAME_LENGTH 12
|
||||
|
||||
class MenuIntInputWrapper {
|
||||
public:
|
||||
virtual void action(int16_t* values, uint8_t length) = 0;
|
||||
};
|
||||
|
||||
class MenuIntInput : public MenuControl {
|
||||
public:
|
||||
MenuIntInput(int16_t values[], char *names, uint8_t length, MenuIntInputWrapper* wrapper);
|
||||
|
||||
void setMin(int16_t min = 0) { this->min = min; }
|
||||
void setMax(int16_t max = 100) { this->max = max; }
|
||||
|
||||
/**
|
||||
* @brief Decrement selected value
|
||||
*/
|
||||
void down() override;
|
||||
|
||||
/**
|
||||
* @brief Increment selected value
|
||||
*/
|
||||
void up() override;
|
||||
|
||||
/**
|
||||
* @brief Select next value
|
||||
*/
|
||||
void right() override;
|
||||
|
||||
/**
|
||||
* @brief Select previous value
|
||||
*/
|
||||
void left() override;
|
||||
|
||||
/**
|
||||
* @brief Leave menu without saving
|
||||
*/
|
||||
void no() override;
|
||||
|
||||
/**
|
||||
* @brief Leave menu with saving
|
||||
*/
|
||||
void yes() override;
|
||||
|
||||
/**
|
||||
* @brief Prints the Information to display and console
|
||||
*
|
||||
* The informations are only printed to the display if it
|
||||
* set.
|
||||
*/
|
||||
void printMenu() override;
|
||||
|
||||
void update() override {};
|
||||
|
||||
private:
|
||||
MenuIntInputWrapper* wrapper;
|
||||
|
||||
uint8_t currentPosition = 0;
|
||||
uint8_t length;
|
||||
int16_t *values;
|
||||
int16_t min = INT16_MIN;
|
||||
int16_t max = INT16_MAX;
|
||||
char *names;
|
||||
|
||||
};
|
||||
|
||||
#endif // MENU_INT_INPUT_H
|
||||
@@ -36,14 +36,14 @@ void MotorControl::init(uint8_t pwm_pin, uint8_t pwm_channel, uint8_t dir_1, uin
|
||||
|
||||
uint16_t MotorControl::loop() {
|
||||
uint32_t time = millis();
|
||||
uint16_t elapsed_time = time - this->last_millis;
|
||||
uint16_t elapsed_time = time - this->lastMillis;
|
||||
|
||||
//Cancel if delay is not reached
|
||||
if (elapsed_time < delay)
|
||||
return elapsed_time;
|
||||
|
||||
runMotorControl();
|
||||
this->last_millis = time;
|
||||
this->lastMillis = time;
|
||||
return elapsed_time;
|
||||
}
|
||||
|
||||
@@ -199,4 +199,4 @@ void MotorControl::increasePower(int8_t power) {
|
||||
}
|
||||
|
||||
this->setRealPower(this->power + power);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ class MotorControl {
|
||||
uint8_t delay = DELAY;
|
||||
uint8_t powersteps = POWERSTEPS;
|
||||
|
||||
uint32_t last_millis = 0;
|
||||
uint32_t lastMillis = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -20,11 +20,14 @@ Navigation::Navigation(Route* route) {
|
||||
|
||||
uint8_t versionHigh = this->gps->getProtocolVersionHigh();
|
||||
uint8_t versionLow = this->gps->getProtocolVersionLow();
|
||||
std::cout << "Neo-M8Q protocol version: " << unsigned(versionHigh) << "." << unsigned(versionLow) << std::endl;
|
||||
std::cout << "u-blox protocol version: " << unsigned(versionHigh) << "." << unsigned(versionLow) << std::endl;
|
||||
|
||||
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);
|
||||
|
||||
if (route)
|
||||
this->route = route;
|
||||
@@ -34,13 +37,70 @@ Navigation::Navigation(Route* route) {
|
||||
|
||||
Navigation::~Navigation() {
|
||||
delete this->gps;
|
||||
|
||||
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->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() {
|
||||
//FIXME: Hier sollte funktion zum aktualisieren des GPS Moduls stehen
|
||||
//this->gps->checkUbloxI2C();
|
||||
|
||||
if (millis() - this->lastMillis < this->timeToWait)
|
||||
return;
|
||||
|
||||
uint8_t rtcmData[512 * 4];
|
||||
uint16_t rtcmCount = this->ntripClient->available();
|
||||
if (rtcmCount) {
|
||||
this->ntripClient->readBytes(rtcmData, rtcmCount);
|
||||
this->gps->pushRawData(rtcmData, rtcmCount);
|
||||
}
|
||||
}
|
||||
|
||||
void Navigation::newRoute() {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "route.h"
|
||||
#include "navigationUtils.h"
|
||||
#include "NTRIPClient.h"
|
||||
|
||||
/**
|
||||
* @brief The minimal distance between Points
|
||||
@@ -64,6 +65,17 @@ class Navigation {
|
||||
*/
|
||||
~Navigation();
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param host
|
||||
* @param port
|
||||
* @param mountPoint
|
||||
* @param user
|
||||
* @param password
|
||||
*/
|
||||
void initNtrip(String host, uint16_t port, String mountPoint, String user, String password);
|
||||
|
||||
/**
|
||||
* @brief Decodes new GPS information
|
||||
*
|
||||
@@ -169,12 +181,23 @@ class Navigation {
|
||||
|
||||
SFE_UBLOX_GNSS* gps;
|
||||
Route* route = nullptr;
|
||||
NTRIPClient* ntripClient = nullptr;
|
||||
|
||||
Point lastPoint;
|
||||
Point targetPoint;
|
||||
|
||||
bool navigationStarted = false;
|
||||
bool navigationFinished = false;
|
||||
bool isNtripInit = false;
|
||||
|
||||
char* host;
|
||||
char* mountPoint;
|
||||
char* user;
|
||||
char* password;
|
||||
|
||||
uint8_t timeToWait = 5;
|
||||
uint16_t port;
|
||||
uint32_t lastMillis = 0;
|
||||
};
|
||||
|
||||
#endif // NAVIGATION_H
|
||||
|
||||
+33
-36
@@ -1,37 +1,34 @@
|
||||
#include"NTRIPClient.h"
|
||||
bool NTRIPClient::reqSrcTbl(char* host,int &port)
|
||||
{
|
||||
if(!connect(host,port)){
|
||||
Serial.print("Cannot connect to ");
|
||||
Serial.println(host);
|
||||
return false;
|
||||
}/*p = String("GET ") + String("/") + String(" HTTP/1.0\r\n");
|
||||
p = p + String("User-Agent: NTRIP Enbeded\r\n");*/
|
||||
print(
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: NTRIPClient for Arduino v1.0\r\n"
|
||||
);
|
||||
unsigned long timeout = millis();
|
||||
while (available() == 0) {
|
||||
if (millis() - timeout > 5000) {
|
||||
Serial.println("Client Timeout !");
|
||||
stop();
|
||||
return false;
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
char buffer[50];
|
||||
readLine(buffer,sizeof(buffer));
|
||||
if(strncmp((char*)buffer,"SOURCETABLE 200 OK",17))
|
||||
{
|
||||
Serial.print((char*)buffer);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
bool NTRIPClient::reqSrcTbl(char* host,uint16_t port){
|
||||
if(!connect(host,port)){
|
||||
Serial.print("Cannot connect to ");
|
||||
Serial.println(host);
|
||||
return false;
|
||||
} /*p = String("GET ") + String("/") + String(" HTTP/1.0\r\n");
|
||||
p = p + String("User-Agent: NTRIP Enbeded\r\n");*/
|
||||
print(
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: NTRIPClient for Arduino v1.0\r\n"
|
||||
);
|
||||
unsigned long timeout = millis();
|
||||
while (available() == 0) {
|
||||
if (millis() - timeout > 5000) {
|
||||
Serial.println("Client Timeout !");
|
||||
stop();
|
||||
return false;
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
char buffer[50];
|
||||
readLine(buffer,sizeof(buffer));
|
||||
if(strncmp((char*)buffer,"SOURCETABLE 200 OK",17)) {
|
||||
Serial.print((char*)buffer);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool NTRIPClient::reqRaw(char* host,int &port,char* mntpnt,char* user,char* psw)
|
||||
{
|
||||
|
||||
bool NTRIPClient::reqRaw(char* host,uint16_t port,char* mntpnt,char* user,char* psw) {
|
||||
if(!connect(host,port))return false;
|
||||
String p="GET /";
|
||||
String auth="";
|
||||
@@ -79,12 +76,12 @@ bool NTRIPClient::reqRaw(char* host,int &port,char* mntpnt,char* user,char* psw)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool NTRIPClient::reqRaw(char* host,int &port,char* mntpnt)
|
||||
{
|
||||
|
||||
bool NTRIPClient::reqRaw(char* host,uint16_t port,char* mntpnt) {
|
||||
return reqRaw(host,port,mntpnt,"","");
|
||||
}
|
||||
int NTRIPClient::readLine(char* _buffer,int size)
|
||||
{
|
||||
|
||||
int NTRIPClient::readLine(char* _buffer,int size) {
|
||||
int len = 0;
|
||||
while(available()) {
|
||||
_buffer[len] = read();
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
class NTRIPClient : public WiFiClient{
|
||||
public :
|
||||
bool reqSrcTbl(char* host,int &port); //request MountPoints List serviced the NTRIP Caster
|
||||
bool reqRaw(char* host,int &port,char* mntpnt,char* user,char* psw); //request RAW data from Caster
|
||||
bool reqRaw(char* host,int &port,char* mntpnt); //non user
|
||||
bool reqSrcTbl(char* host,uint16_t port); //request MountPoints List serviced the NTRIP Caster
|
||||
bool reqRaw(char* host,uint16_t port,char* mntpnt,char* user,char* psw); //request RAW data from Caster
|
||||
bool reqRaw(char* host,uint16_t port,char* mntpnt); //non user
|
||||
int readLine(char* buffer,int size);
|
||||
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* @file rtcmInsert.cpp
|
||||
* @author * @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-03-24
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#include "rtcmInsert.h"
|
||||
|
||||
|
||||
RtcmInsert::RtcmInsert(uint8_t address, char* ntripHost, uint16_t ntripPort, char* ntripMountPoint, char* ntripUser, char* ntripPassword)
|
||||
: address() {
|
||||
this->ntrip_c = new NTRIPClient();
|
||||
|
||||
std::cout << "Requesting SourceTable." << std::endl;
|
||||
if(this->ntrip_c->reqSrcTbl(ntripHost, ntripPort)) {
|
||||
char buffer[512];
|
||||
delay(5);
|
||||
while(this->ntrip_c->available()) {
|
||||
this->ntrip_c->readLine(buffer,sizeof(buffer));
|
||||
std::cout << buffer;
|
||||
}
|
||||
}
|
||||
else
|
||||
std::cout << "SourceTable request error" << std::endl;
|
||||
|
||||
std::cout << "Requesting SourceTable is OK." << std::endl;
|
||||
this->ntrip_c->stop(); //Need to call "stop" function for next request.
|
||||
|
||||
std::cout << "Requesting MountPoint's Raw data" << std::endl;
|
||||
if(!this->ntrip_c->reqRaw(ntripHost, ntripPort, ntripMountPoint, ntripUser, ntripPassword))
|
||||
std::cout << "Error Requesting MountPoint's Raw data" << std::endl;
|
||||
else
|
||||
std::cout << "Requesting MountPoint is OK" << std::endl;
|
||||
}
|
||||
|
||||
void RtcmInsert::loop() {
|
||||
if (this->ntrip_c->available()) {
|
||||
Wire.beginTransmission(this->address);
|
||||
while(this->ntrip_c->available()) {
|
||||
char ch = this->ntrip_c->read();
|
||||
Wire.write(ch);
|
||||
}
|
||||
Wire.endTransmission();
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* @file rtcmInsert.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-03-24
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef RTCM_INSERT_H
|
||||
#define RTCM_INSERT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "NTRIPClient.h"
|
||||
|
||||
class RtcmInsert {
|
||||
public:
|
||||
RtcmInsert(uint8_t address, char* ntripHost, uint16_t ntripPort, char* ntripMountPoint, char* ntripUser, char* ntripPassword);
|
||||
|
||||
void loop();
|
||||
|
||||
private:
|
||||
uint8_t address;
|
||||
|
||||
NTRIPClient* ntrip_c;
|
||||
};
|
||||
|
||||
#endif // RTCM_INSERT_H
|
||||
Reference in New Issue
Block a user