66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
#ifndef NTRIP_CLIENT
|
|
#define NTRIP_CLIENT
|
|
|
|
#include <WiFiClient.h>
|
|
#include <Arduino.h>
|
|
#include <base64.h>
|
|
#include <iostream>
|
|
#include <SparkFun_u-blox_GNSS_Arduino_Library.h>
|
|
|
|
#include "debugTimes.h"
|
|
|
|
enum NTRIPClientStates {
|
|
openConnection,
|
|
pushData,
|
|
closeConnection,
|
|
wait
|
|
};
|
|
class NTRIPClient {
|
|
public:
|
|
NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password);
|
|
~NTRIPClient();
|
|
|
|
void loop();
|
|
|
|
void gpsConfiguration();
|
|
|
|
void setTransmitLocation(bool b) { this->transmitLocation = b; }
|
|
void setActivated(bool b) { this->activated = b; }
|
|
|
|
bool isConnected();
|
|
NTRIPClientStates getClientState() { return this->state; }
|
|
|
|
|
|
|
|
private:
|
|
void pushGPGGA(NMEA_GGA_data_t *nmeaData);
|
|
bool beginClient();
|
|
void closeConnection();
|
|
bool processConnection();
|
|
|
|
SFE_UBLOX_GNSS* gps;
|
|
WiFiClient* ntripClient;
|
|
NTRIPClientStates state = NTRIPClientStates::closeConnection;
|
|
|
|
bool transmitLocation = true;
|
|
bool activated = true;
|
|
|
|
uint16_t port;
|
|
uint32_t lastReceivedRtcmTime = 0;
|
|
uint32_t lastNtripConnectTime = 0;
|
|
uint32_t lastGPGGAPushTime = 0;
|
|
uint32_t lastLoopTime = 0;
|
|
|
|
char host[128];
|
|
char mountPoint[128];
|
|
char user[128];
|
|
char password[128];
|
|
const uint8_t delayTime = 20;
|
|
const uint16_t timeOut = 5000;
|
|
const uint16_t tryReconnectTime = 5000;
|
|
const uint16_t bufferSize = 512;
|
|
const uint16_t pushGPGGATime = 10000;
|
|
};
|
|
|
|
#endif
|