gps now over spi
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
*/
|
||||
|
||||
#include "ntripClient.h"
|
||||
bool NTRIPClient::outputStatusPrintPVTdata = false;
|
||||
|
||||
NTRIPClient::NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password) {
|
||||
this->gps = gps;
|
||||
@@ -32,9 +31,6 @@ void NTRIPClient::loop() {
|
||||
return;
|
||||
this->lastLoopTime = millis();
|
||||
|
||||
this->gps->checkUblox();
|
||||
this->gps->checkCallbacks();
|
||||
|
||||
if (millis() - this->lastGPGGAPushTime > this->pushGPGGATime && this->activated) {
|
||||
this->lastGPGGAPushTime = millis();
|
||||
// std::cout << "Try to push GPGGA data." << std::endl;
|
||||
@@ -96,15 +92,12 @@ 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->setSPIOutput(COM_TYPE_UBX | COM_TYPE_NMEA);
|
||||
this->gps->setPortInput(COM_PORT_SPI, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3);
|
||||
// Set the differential mode - ambiguities are fixed whenever possible
|
||||
this->gps->setDGNSSConfiguration(SFE_UBLOX_DGNSS_MODE_FIXED);
|
||||
this->gps->setNavigationFrequency(1);
|
||||
this->gps->setDGNSSConfiguration(SFE_UBLOX_DGNSS_MODE_FIXED);
|
||||
this->gps->setMainTalkerID(SFE_UBLOX_MAIN_TALKER_ID_GP);
|
||||
this->gps->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_I2C, 10);
|
||||
|
||||
this->gps->setAutoPVTcallbackPtr(&(NTRIPClient::printPVTdata));
|
||||
this->gps->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_SPI, 10);
|
||||
}
|
||||
|
||||
bool NTRIPClient::beginClient() {
|
||||
@@ -249,58 +242,6 @@ void NTRIPClient::pushGPGGA(NMEA_GGA_data_t *nmeaData) {
|
||||
std::cout << "Failed to pushing GGA to server: " << (const char *)nmeaData->nmea << std::endl;
|
||||
}
|
||||
|
||||
void NTRIPClient::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) {
|
||||
if (!NTRIPClient::outputStatusPrintPVTdata)
|
||||
return;
|
||||
|
||||
double latitude = (double) ubxDataStruct->lat / 10000000.0;
|
||||
double longitude = (double) ubxDataStruct->lon / 10000000.0;
|
||||
double altitude = (double) ubxDataStruct->hMSL / 1000.0;
|
||||
|
||||
uint8_t fixType = ubxDataStruct->fixType;
|
||||
char fixTypeString[32];
|
||||
if (fixType == 0)
|
||||
strcpy(fixTypeString, "None");
|
||||
else if (fixType == 1)
|
||||
strcpy(fixTypeString, "Dead Reckoning");
|
||||
else if (fixType == 2)
|
||||
strcpy(fixTypeString, "2D");
|
||||
else if (fixType == 3)
|
||||
strcpy(fixTypeString, "3D");
|
||||
else if (fixType == 3)
|
||||
strcpy(fixTypeString, "GNSS + Dead Reckoning");
|
||||
else if (fixType == 5)
|
||||
|
||||
strcpy(fixTypeString, "Time Only");
|
||||
else
|
||||
strcpy(fixTypeString, "UNKNOWN");
|
||||
|
||||
uint8_t carrSoln = ubxDataStruct->flags.bits.carrSoln;
|
||||
char carrSolnString[16];
|
||||
if (carrSoln == 0)
|
||||
strcpy(carrSolnString, "None");
|
||||
else if (carrSoln == 1)
|
||||
strcpy(carrSolnString, "Floating");
|
||||
else if (carrSoln == 2)
|
||||
strcpy(carrSolnString, "Fixed");
|
||||
else
|
||||
strcpy(carrSolnString, "UNKNOWN");
|
||||
|
||||
uint32_t hAcc = ubxDataStruct->hAcc;
|
||||
|
||||
std::cout << "Lat: " << latitude
|
||||
<< " Lng: " << longitude
|
||||
<< " Alt: " << altitude << std::endl;
|
||||
|
||||
std::cout << "Fix: " << fixTypeString
|
||||
<< " Carrier Solution: " << carrSolnString
|
||||
<< " Horizontal Accuracy Estimate: " << hAcc << " mm" << std::endl;
|
||||
}
|
||||
|
||||
void NTRIPClient::setOutputStatusPrintPVTdata(bool status) {
|
||||
NTRIPClient::outputStatusPrintPVTdata = status;
|
||||
}
|
||||
|
||||
bool NTRIPClient::isConnected() {
|
||||
if (this->state == NTRIPClientStates::pushData)
|
||||
return true;
|
||||
|
||||
@@ -30,8 +30,7 @@ class NTRIPClient {
|
||||
bool isConnected();
|
||||
NTRIPClientStates getClientState() { return this->state; }
|
||||
|
||||
static void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct);
|
||||
static void setOutputStatusPrintPVTdata(bool status);
|
||||
|
||||
|
||||
private:
|
||||
void pushGPGGA(NMEA_GGA_data_t *nmeaData);
|
||||
@@ -61,8 +60,6 @@ class NTRIPClient {
|
||||
const uint16_t tryReconnectTime = 5000;
|
||||
const uint16_t bufferSize = 512;
|
||||
const uint16_t pushGPGGATime = 10000;
|
||||
|
||||
static bool outputStatusPrintPVTdata;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user