Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 61 additions & 51 deletions Firmware/RTK_Everywhere/Developer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ void ntpServerStop() {}

#endif // COMPILE_ETHERNET

#ifndef COMPILE_NETWORK

//----------------------------------------
// Network layer
//----------------------------------------

#ifndef COMPILE_NETWORK

void menuTcpUdp() {systemPrint("**Network not compiled**");}
void networkBegin() {}
void networkConsumerAdd(NETCONSUMER_t consumer, NetIndex_t network, const char * fileName, uint32_t lineNumber) {}
Expand Down Expand Up @@ -62,101 +62,111 @@ void networkUserRemove(NETCONSUMER_t consumer, const char * fileName, uint32_t l
void networkValidateIndex(NetIndex_t index) {}
void networkVerifyTables() {}

#endif // COMPILE_NETWORK

//----------------------------------------
// Automatic Over-The-Air (OTA) firmware updates
//----------------------------------------

#ifndef COMPILE_OTA_AUTO

void otaAutoUpdate() {}
bool otaCheckVersion(char *versionAvailable, uint8_t versionAvailableLength) {return false;}
void otaMenuDisplay(char * currentVersion) {}
bool otaMenuProcessInput(byte incoming) {return false;}
void otaUpdate() {}
void otaUpdateStop() {}
void otaVerifyTables() {}

#endif // COMPILE_OTA_AUTO

//----------------------------------------
// HTTP Client
//----------------------------------------

#ifndef COMPILE_HTTP_CLIENT

void httpClientPrintStatus() {}
void httpClientUpdate() {}
void httpClientValidateTables() {}

#endif // COMPILE_HTTP_CLIENT

//----------------------------------------
// MQTT Client
//----------------------------------------

#ifndef COMPILE_MQTT_CLIENT

bool mqttClientIsConnected() {return false;}
void mqttClientPrintStatus() {}
void mqttClientRestart() {}
void mqttClientStartEnabled() {}
void mqttClientUpdate() {}
void mqttClientValidateTables() {}

#endif // COMPILE_MQTT_CLIENT

//----------------------------------------
// NTRIP client
//----------------------------------------

#ifndef COMPILE_NTRIP_CLIENT
void ntripClientPrintStatus() {systemPrintln("**NTRIP Client not compiled**");}
void ntripClientPushGGA(const char * ggaString) {}
void ntripClientStop(bool clientAllocated) {online.ntripClient = false;}
void ntripClientUpdate() {}
void ntripClientValidateTables() {}
#endif // COMPILE_NTRIP_CLIENT

//----------------------------------------
// NTRIP server
//----------------------------------------

#ifndef COMPILE_NTRIP_SERVER
bool ntripServerIsCasting(int serverIndex) {return false;}
void ntripServerPrintStatus(int serverIndex) {systemPrintf("**NTRIP Server %d not compiled**\r\n", serverIndex);}
void ntripServerProcessRTCM(int serverIndex, uint8_t incoming) {}
void ntripServerStop(int serverIndex, bool shutdown) {online.ntripServer[serverIndex] = false;}
void ntripServerUpdate() {}
void ntripServerValidateTables() {}
bool ntripServerIsCasting(int serverIndex) {
return (false);
}
#endif // COMPILE_NTRIP_SERVER

//----------------------------------------
// TCP client
//----------------------------------------

#ifndef COMPILE_TCP_CLIENT
void tcpClientDiscardBytes(RING_BUFFER_OFFSET previousTail, RING_BUFFER_OFFSET newTail) {}
int32_t tcpClientSendData(uint16_t dataHead) {return 0;}
void tcpClientUpdate() {}
void tcpClientValidateTables() {}
void tcpClientZeroTail() {}
#endif // COMPILE_TCP_CLIENT

//----------------------------------------
// TCP server
//----------------------------------------

#ifndef COMPILE_TCP_SERVER
void tcpServerDiscardBytes(RING_BUFFER_OFFSET previousTail, RING_BUFFER_OFFSET newTail) {}
int32_t tcpServerSendData(uint16_t dataHead) {return 0;}
void tcpServerZeroTail() {}
void tcpServerUpdate() {}
void tcpServerValidateTables() {}
void tcpServerZeroTail() {}
#endif // COMPILE_TCP_SERVER

//----------------------------------------
// UDP server
//----------------------------------------

#ifndef COMPILE_UDP_SERVER
void udpServerDiscardBytes(RING_BUFFER_OFFSET previousTail, RING_BUFFER_OFFSET newTail) {}
int32_t udpServerSendData(uint16_t dataHead) {return 0;}
void udpServerStop() {}
void udpServerUpdate() {}
void udpServerZeroTail() {}

#endif // COMPILE_NETWORK

//----------------------------------------
// Automatic Over-The-Air (OTA) firmware updates
//----------------------------------------

#ifndef COMPILE_OTA_AUTO

void otaAutoUpdate() {}
bool otaCheckVersion(char *versionAvailable, uint8_t versionAvailableLength) {return false;}
void otaMenuDisplay(char * currentVersion) {}
bool otaMenuProcessInput(byte incoming) {return false;}
void otaUpdate() {}
void otaUpdateStop() {}
void otaVerifyTables() {}

#endif // COMPILE_OTA_AUTO

//----------------------------------------
// MQTT Client
//----------------------------------------

#ifndef COMPILE_MQTT_CLIENT

bool mqttClientIsConnected() {return false;}
void mqttClientPrintStatus() {}
void mqttClientRestart() {}
void mqttClientStartEnabled() {}
void mqttClientUpdate() {}
void mqttClientValidateTables() {}

#endif // COMPILE_MQTT_CLIENT

//----------------------------------------
// HTTP Client
//----------------------------------------

#ifndef COMPILE_HTTP_CLIENT

void httpClientPrintStatus() {}
void httpClientUpdate() {}
void httpClientValidateTables() {}

#endif // COMPILE_HTTP_CLIENT
#endif // COMPILE_UDP_SERVER

//----------------------------------------
// Web Server
Expand Down
46 changes: 10 additions & 36 deletions Firmware/RTK_Everywhere/GNSS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ GNSS.ino
GNSS layer implementation
------------------------------------------------------------------------------*/

extern int NTRIPCLIENT_MS_BETWEEN_GGA;

#ifdef COMPILE_NETWORK
extern NetworkClient *ntripClient;
#endif // COMPILE_NETWORK

extern unsigned long lastGGAPush;

//----------------------------------------
// Setup the general configuration of the GNSS
// Not Rover or Base specific (ie, baud rates)
Expand Down Expand Up @@ -92,38 +84,20 @@ static void pushGPGGA(char *ggaData)

if (xSemaphoreTake(reentrant, 10 / portTICK_PERIOD_MS) == pdPASS)
{
if (ggaData)
{
snprintf(storedGPGGA, sizeof(storedGPGGA), "%s", ggaData);
xSemaphoreGive(reentrant);
return;
}

#ifdef COMPILE_NETWORK
// Wait until the client has been created
if (ntripClient != nullptr)
do
{
// Provide the caster with our current position as needed
if (ntripClient->connected() && settings.ntripClient_TransmitGGA == true)
// Save the ggaData string
if (ggaData)
{
if ((millis() - lastGGAPush) > NTRIPCLIENT_MS_BETWEEN_GGA)
{
lastGGAPush = millis();

if ((settings.debugNtripClientRtcm || PERIODIC_DISPLAY(PD_NTRIP_CLIENT_GGA)) && !inMainMenu)
{
PERIODIC_CLEAR(PD_NTRIP_CLIENT_GGA);
systemPrintf("NTRIP Client pushing GGA to server: %s", (const char *)storedGPGGA);
}

// Push our current GGA sentence to caster
if (strlen(storedGPGGA) > 0)
ntripClient->write((const uint8_t *)storedGPGGA, strlen(storedGPGGA));
}
snprintf(storedGPGGA, sizeof(storedGPGGA), "%s", ggaData);
break;
}
}
#endif // COMPILE_NETWORK

// Verify that a GGA string has been saved
if (storedGPGGA[0])
// Push our current GGA sentence to caster
ntripClientPushGGA(storedGPGGA);
} while (0);
xSemaphoreGive(reentrant);
}
}
Expand Down
32 changes: 30 additions & 2 deletions Firmware/RTK_Everywhere/NtripClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ NtripClient.ino

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#ifdef COMPILE_NETWORK
#ifdef COMPILE_NTRIP_CLIENT

//----------------------------------------
// Constants
Expand Down Expand Up @@ -494,6 +494,34 @@ void ntripClientPrintStatus()
}
}

//----------------------------------------
// Push GGA string to the NTRIP caster
//----------------------------------------
void ntripClientPushGGA(const char * ggaString)
{
// Wait until the client has been created
if (ntripClient != nullptr)
{
// Provide the caster with our current position as needed
if (ntripClient->connected() && settings.ntripClient_TransmitGGA == true)
{
if ((millis() - lastGGAPush) > NTRIPCLIENT_MS_BETWEEN_GGA)
{
lastGGAPush = millis();

if ((settings.debugNtripClientRtcm || PERIODIC_DISPLAY(PD_NTRIP_CLIENT_GGA)) && !inMainMenu)
{
PERIODIC_CLEAR(PD_NTRIP_CLIENT_GGA);
systemPrintf("NTRIP Client pushing GGA to server: %s", ggaString);
}

// Push the current GGA sentence to caster
ntripClient->write((const uint8_t *)ggaString, strlen(ggaString));
}
}
}
}

//----------------------------------------
// Determine if NTRIP client data is available
//----------------------------------------
Expand Down Expand Up @@ -972,4 +1000,4 @@ void ntripClientValidateTables()
reportFatalError("Fix ntripClientStateNameEntries to match NTRIPClientState");
}

#endif // COMPILE_NETWORK
#endif // COMPILE_NTRIP_CLIENT
4 changes: 2 additions & 2 deletions Firmware/RTK_Everywhere/NtripServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ NtripServer.ino

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#ifdef COMPILE_NETWORK
#ifdef COMPILE_NTRIP_SERVER

//----------------------------------------
// Constants
Expand Down Expand Up @@ -877,4 +877,4 @@ void ntripServerValidateTables()
reportFatalError("Fix ntripServerStateNameEntries to match NTRIPServerState");
}

#endif // COMPILE_NETWORK
#endif // COMPILE_NTRIP_SERVER
13 changes: 9 additions & 4 deletions Firmware/RTK_Everywhere/RTK_Everywhere.ino
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,14 @@

#if defined(COMPILE_WIFI) || defined(COMPILE_ETHERNET) || defined(COMPILE_CELLULAR)
#define COMPILE_NETWORK
#define COMPILE_MQTT_CLIENT // Comment out to remove MQTT Client functionality
#define COMPILE_OTA_AUTO // Comment out to disable automatic over-the-air firmware update
#define COMPILE_HTTP_CLIENT // Comment out to disable HTTP Client (PointPerfect ZTP) functionality
#define COMPILE_HTTP_CLIENT // Comment out to disable HTTP Client (PointPerfect ZTP) functionality
#define COMPILE_MQTT_CLIENT // Comment out to remove MQTT Client functionality
#define COMPILE_NTRIP_CLIENT // Comment out to remove NTRIP client functionality
#define COMPILE_NTRIP_SERVER // Comment out to remove NTRIP server functionality
#define COMPILE_OTA_AUTO // Comment out to disable automatic over-the-air firmware update
#define COMPILE_TCP_CLIENT // Comment out to remove TCP client functionality
#define COMPILE_TCP_SERVER // Comment out to remove TCP server functionality
#define COMPILE_UDP_SERVER // Comment out to remove UDP server functionality
#endif // COMPILE_WIFI || COMPILE_ETHERNET || COMPILE_CELLULAR

// Always define ENABLE_DEVELOPER to enable its use in conditional statements
Expand Down Expand Up @@ -1592,7 +1597,7 @@ bool logLengthExceeded() // Limit individual files to maxLogLength_minutes

if (nextLogTime_ms == 0) // Keep logging if nextLogTime_ms has not been set
return false;

// Note: this will roll over every 49.71 days...
// Solution: https://stackoverflow.com/a/3097744 - see issue #742
return (!((long)(nextLogTime_ms - millis()) > 0));
Expand Down
4 changes: 2 additions & 2 deletions Firmware/RTK_Everywhere/TcpClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ TcpClient.ino
* private SNIP NTRIP caster
*/

#ifdef COMPILE_NETWORK
#ifdef COMPILE_TCP_CLIENT

//----------------------------------------
// Constants
Expand Down Expand Up @@ -599,4 +599,4 @@ void tcpClientZeroTail()
tcpClientTail = 0;
}

#endif // COMPILE_NETWORK
#endif // COMPILE_TCP_CLIENT
4 changes: 2 additions & 2 deletions Firmware/RTK_Everywhere/TcpServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ tcpServer.ino
a new connection to the TCP server.
*/

#ifdef COMPILE_NETWORK
#ifdef COMPILE_TCP_SERVER

//----------------------------------------
// Constants
Expand Down Expand Up @@ -802,4 +802,4 @@ void tcpServerZeroTail()
tcpServerClientTails[index] = 0;
}

#endif // COMPILE_NETWORK
#endif // COMPILE_TCP_SERVER
4 changes: 2 additions & 2 deletions Firmware/RTK_Everywhere/UdpServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ UdpServer.ino
3. Verify that the displayed coordinates, fix tpe etc. are valid
*/

#ifdef COMPILE_NETWORK
#ifdef COMPILE_UDP_SERVER

//----------------------------------------
// Constants
Expand Down Expand Up @@ -436,4 +436,4 @@ void udpServerZeroTail()
udpServerTail = 0;
}

#endif // COMPILE_NETWORK
#endif // COMPILE_UDP_SERVER
Loading