diff --git a/Firmware/RTK_Everywhere/Developer.ino b/Firmware/RTK_Everywhere/Developer.ino index 75ce977f5..d79e929f0 100644 --- a/Firmware/RTK_Everywhere/Developer.ino +++ b/Firmware/RTK_Everywhere/Developer.ino @@ -3,36 +3,26 @@ mode (ENABLE_DEVELOPER defined). */ -#ifndef COMPILE_ETHERNET - //---------------------------------------- // Ethernet //---------------------------------------- +#ifndef COMPILE_ETHERNET + bool ethernetLinkUp() {return false;} void menuEthernet() {systemPrintln("**Ethernet not compiled**");} void ethernetUpdate() {} bool ntpLogIncreasing = false; -//---------------------------------------- -// NTP: Network Time Protocol -//---------------------------------------- - -void menuNTP() {systemPrint("**NTP not compiled**");} -void ntpServerBegin() {} -void ntpServerUpdate() {} -void ntpValidateTables() {} -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) {} @@ -62,101 +52,123 @@ 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 + +//---------------------------------------- +// NTP: Network Time Protocol +//---------------------------------------- + +#ifndef COMPILE_NTP +void menuNTP() {systemPrint("**NTP not compiled**");} +void ntpServerBegin() {} +void ntpServerUpdate() {} +void ntpValidateTables() {} +void ntpServerStop() {} +#endif // COMPILE_NTP + //---------------------------------------- // 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 diff --git a/Firmware/RTK_Everywhere/GNSS.ino b/Firmware/RTK_Everywhere/GNSS.ino index e7df01f21..2f3e361c1 100644 --- a/Firmware/RTK_Everywhere/GNSS.ino +++ b/Firmware/RTK_Everywhere/GNSS.ino @@ -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) @@ -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); } } diff --git a/Firmware/RTK_Everywhere/NTP.ino b/Firmware/RTK_Everywhere/NTP.ino index 8a8c1878d..1f306b0b3 100644 --- a/Firmware/RTK_Everywhere/NTP.ino +++ b/Firmware/RTK_Everywhere/NTP.ino @@ -51,7 +51,7 @@ NTP.ino ------------------------------------------------------------------------------*/ -#ifdef COMPILE_ETHERNET +#ifdef COMPILE_NTP //---------------------------------------- // Constants @@ -983,4 +983,4 @@ void ntpValidateTables() reportFatalError("Fix ntpServerStateNameEntries to match NTP_STATE"); } -#endif // COMPILE_ETHERNET +#endif // COMPILE_NTP diff --git a/Firmware/RTK_Everywhere/NtripClient.ino b/Firmware/RTK_Everywhere/NtripClient.ino index 0019f8614..7c4ff0a3d 100644 --- a/Firmware/RTK_Everywhere/NtripClient.ino +++ b/Firmware/RTK_Everywhere/NtripClient.ino @@ -117,7 +117,7 @@ NtripClient.ino =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ -#ifdef COMPILE_NETWORK +#ifdef COMPILE_NTRIP_CLIENT //---------------------------------------- // Constants @@ -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 //---------------------------------------- @@ -972,4 +1000,4 @@ void ntripClientValidateTables() reportFatalError("Fix ntripClientStateNameEntries to match NTRIPClientState"); } -#endif // COMPILE_NETWORK +#endif // COMPILE_NTRIP_CLIENT diff --git a/Firmware/RTK_Everywhere/NtripServer.ino b/Firmware/RTK_Everywhere/NtripServer.ino index 1353783ac..0d89974e1 100644 --- a/Firmware/RTK_Everywhere/NtripServer.ino +++ b/Firmware/RTK_Everywhere/NtripServer.ino @@ -122,7 +122,7 @@ NtripServer.ino =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ -#ifdef COMPILE_NETWORK +#ifdef COMPILE_NTRIP_SERVER //---------------------------------------- // Constants @@ -877,4 +877,4 @@ void ntripServerValidateTables() reportFatalError("Fix ntripServerStateNameEntries to match NTRIPServerState"); } -#endif // COMPILE_NETWORK +#endif // COMPILE_NTRIP_SERVER diff --git a/Firmware/RTK_Everywhere/RTK_Everywhere.ino b/Firmware/RTK_Everywhere/RTK_Everywhere.ino index 20cdf21b7..c48242401 100644 --- a/Firmware/RTK_Everywhere/RTK_Everywhere.ino +++ b/Firmware/RTK_Everywhere/RTK_Everywhere.ino @@ -93,6 +93,10 @@ #define COMPILE_AUTHENTICATION // Comment out to disable MFi authentication #endif +#ifdef COMPILE_ETHERNET +#define COMPILE_NTP // Comment out to disable NTP functionality +#endif // COMPILE_ETHERNET + #ifdef COMPILE_WIFI #define COMPILE_AP // Requires WiFi. Comment out to remove Access Point functionality #define COMPILE_ESPNOW // Requires WiFi. Comment out to remove ESP-NOW functionality. @@ -113,9 +117,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 @@ -1592,7 +1601,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)); diff --git a/Firmware/RTK_Everywhere/States.ino b/Firmware/RTK_Everywhere/States.ino index b66a06661..a5c3be861 100644 --- a/Firmware/RTK_Everywhere/States.ino +++ b/Firmware/RTK_Everywhere/States.ino @@ -564,7 +564,7 @@ void stateUpdate() } break; -#ifdef COMPILE_ETHERNET +#ifdef COMPILE_NTP case (STATE_NTPSERVER_NOT_STARTED): { RTK_MODE(RTK_MODE_NTP); firstRoverStart = false; // If NTP is starting, no test menu, normal button use. @@ -627,7 +627,7 @@ void stateUpdate() } break; -#endif // COMPILE_ETHERNET +#endif // COMPILE_NTP case (STATE_SHUTDOWN): { forceDisplayUpdate = true; diff --git a/Firmware/RTK_Everywhere/TcpClient.ino b/Firmware/RTK_Everywhere/TcpClient.ino index e45def741..feae0cff6 100644 --- a/Firmware/RTK_Everywhere/TcpClient.ino +++ b/Firmware/RTK_Everywhere/TcpClient.ino @@ -115,7 +115,7 @@ TcpClient.ino * private SNIP NTRIP caster */ -#ifdef COMPILE_NETWORK +#ifdef COMPILE_TCP_CLIENT //---------------------------------------- // Constants @@ -599,4 +599,4 @@ void tcpClientZeroTail() tcpClientTail = 0; } -#endif // COMPILE_NETWORK +#endif // COMPILE_TCP_CLIENT diff --git a/Firmware/RTK_Everywhere/TcpServer.ino b/Firmware/RTK_Everywhere/TcpServer.ino index f3ad3e840..51a47c400 100644 --- a/Firmware/RTK_Everywhere/TcpServer.ino +++ b/Firmware/RTK_Everywhere/TcpServer.ino @@ -55,7 +55,7 @@ tcpServer.ino a new connection to the TCP server. */ -#ifdef COMPILE_NETWORK +#ifdef COMPILE_TCP_SERVER //---------------------------------------- // Constants @@ -802,4 +802,4 @@ void tcpServerZeroTail() tcpServerClientTails[index] = 0; } -#endif // COMPILE_NETWORK +#endif // COMPILE_TCP_SERVER diff --git a/Firmware/RTK_Everywhere/UdpServer.ino b/Firmware/RTK_Everywhere/UdpServer.ino index ea034b153..3eddd59e2 100644 --- a/Firmware/RTK_Everywhere/UdpServer.ino +++ b/Firmware/RTK_Everywhere/UdpServer.ino @@ -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 @@ -436,4 +436,4 @@ void udpServerZeroTail() udpServerTail = 0; } -#endif // COMPILE_NETWORK +#endif // COMPILE_UDP_SERVER diff --git a/Firmware/RTK_Everywhere/check.sh b/Firmware/RTK_Everywhere/check.sh index 8d22f49a5..b7d0c1c54 100755 --- a/Firmware/RTK_Everywhere/check.sh +++ b/Firmware/RTK_Everywhere/check.sh @@ -67,6 +67,31 @@ sed -i 's|#define COMPILE_MOSAICX5|//#define COMPILE_MOSAICX5|' RTK_Everywhere.i make git reset --hard --quiet HEAD +# NTP Server +sed -i 's|#define COMPILE_NTP|//#define COMPILE_NTP|' RTK_Everywhere.ino +make +git reset --hard --quiet HEAD + +# NTRIP Client +sed -i 's|#define COMPILE_NTRIP_CLIENT|//#define COMPILE_NTRIP_CLIENT|' RTK_Everywhere.ino +make +git reset --hard --quiet HEAD + +# NTRIP Server +sed -i 's|#define COMPILE_NTRIP_SERVER|//#define COMPILE_NTRIP_SERVER|' RTK_Everywhere.ino +make +git reset --hard --quiet HEAD + +# TCP Client +sed -i 's|#define COMPILE_TCP_CLIENT|//#define COMPILE_TCP_CLIENT|' RTK_Everywhere.ino +make +git reset --hard --quiet HEAD + +# TCP Server +sed -i 's|#define COMPILE_TCP_SERVER|//#define COMPILE_TCP_SERVER|' RTK_Everywhere.ino +make +git reset --hard --quiet HEAD + # UM980 sed -i 's|#define COMPILE_UM980|//#define COMPILE_UM980|' RTK_Everywhere.ino make