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
4 changes: 4 additions & 0 deletions Firmware/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ ARG DEBUG_LEVEL=error
# Set to false for releases
ARG ENABLE_DEVELOPER=true

# arduino-cli warnings: none default more all
ARG WARNINGS=default

# If you have your own u-blox PointPerfect token(s), define them here
# or pass in as args when building the Dockerfile
# POINTPERFECT_LBAND_TOKEN is the token for the deprecated u-blox L-band SPARTN service
Expand Down Expand Up @@ -116,6 +119,7 @@ RUN cp RTKEverywhere.csv "/root/.arduino15/packages/esp32/hardware/esp32/${CORE_
# Compile Sketch
RUN cd ./RTK_Everywhere \
&& arduino-cli compile --fqbn "esp32:esp32:esp32":DebugLevel=${DEBUG_LEVEL},PSRAM=enabled \
--warnings ${WARNINGS} \
./RTK_Everywhere.ino \
--build-property build.partitions=RTKEverywhere \
--build-property upload.maximum_size=4055040 \
Expand Down
5 changes: 3 additions & 2 deletions Firmware/RTK_Everywhere/Developer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
// Ethernet
//----------------------------------------

bool ethernetLinkUp() {return false;}
void menuEthernet() {systemPrintln("**Ethernet not compiled**");}
bool ethernetLinkUp() {return false;}
void menuEthernet() {systemPrintln("**Ethernet not compiled**");}
void ethernetUpdate() {}

bool ntpLogIncreasing = false;

Expand Down
6 changes: 3 additions & 3 deletions Firmware/RTK_Everywhere/Display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,7 @@ void paintIPAddress()
char ipAddress[16];
snprintf(ipAddress, sizeof(ipAddress), "%s",
#ifdef COMPILE_ETHERNET
ETH.localIP().toString());
ETH.localIP().toString().c_str());
#else // COMPILE_ETHERNET
"0.0.0.0");
#endif // COMPILE_ETHERNET
Expand Down Expand Up @@ -2032,7 +2032,7 @@ void displayFullIPAddress(std::vector<iconPropertyBlinking> *iconList) // Bottom
{
static IPAddress ipAddress;
NetPriority_t priority;
static NetPriority_t previousPriority;
static NetPriority_t previousPriority = NETWORK_NONE;

// Max width: 15*6 = 90 pixels (6 pixels per character, nnn.nnn.nnn.nnn)
if (present.display_type == DISPLAY_128x64)
Expand All @@ -2052,7 +2052,7 @@ void displayFullIPAddress(std::vector<iconPropertyBlinking> *iconList) // Bottom
// Display the IP address when it is available
if (ipAddress != IPAddress((uint32_t)0))
{
snprintf(myAddress, sizeof(myAddress), "%s", ipAddress.toString());
snprintf(myAddress, sizeof(myAddress), "%s", ipAddress.toString().c_str());

oled->setFont(QW_FONT_5X7); // Set font to smallest
oled->setCursor(0, 55);
Expand Down
17 changes: 17 additions & 0 deletions Firmware/RTK_Everywhere/Ethernet.ino
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ void ethernetEvent(arduino_event_id_t event, arduino_event_info_t info)
case ARDUINO_EVENT_ETH_DISCONNECTED:
if (settings.enablePrintEthernetDiag && (!inMainMenu))
systemPrintln("ETH Disconnected");

ethernetRestartRequested = true; // Perform ETH.end() to disconnect TCP resources

break;

case ARDUINO_EVENT_ETH_STOP:
Expand Down Expand Up @@ -236,6 +239,20 @@ const char *ethernetGetEventName(arduino_event_id_t event)
}
}

//----------------------------------------
// Update Ethernet. Restart if requested
//----------------------------------------
void ethernetUpdate()
{
if (ethernetRestartRequested)
{
if (settings.enablePrintEthernetDiag && (!inMainMenu))
systemPrintln("Restarting Ethernet");
ethernetRestart();
ethernetRestartRequested = false;
}
}

//----------------------------------------
// Restart the Ethernet controller
//----------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions Firmware/RTK_Everywhere/NTP.ino
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ bool ntpProcessOneRequest(bool process, const timeval *recTv, const timeval *syn
if (ntpDiag != nullptr)
{
char tmpbuf[128];
snprintf(tmpbuf, sizeof(tmpbuf), "Originate Timestamp (Client Transmit): %u.%06u\r\n",
snprintf(tmpbuf, sizeof(tmpbuf), "Originate Timestamp (Client Transmit): %lu.%06lu\r\n",
packet.transmitTimestampSeconds,
packet.convertFractionToMicros(packet.transmitTimestampFraction));
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
Expand All @@ -631,7 +631,7 @@ bool ntpProcessOneRequest(bool process, const timeval *recTv, const timeval *syn
if (ntpDiag != nullptr)
{
char tmpbuf[128];
snprintf(tmpbuf, sizeof(tmpbuf), "Received Timestamp: %u.%06u\r\n",
snprintf(tmpbuf, sizeof(tmpbuf), "Received Timestamp: %lu.%06lu\r\n",
packet.receiveTimestampSeconds,
packet.convertFractionToMicros(packet.receiveTimestampFraction));
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
Expand All @@ -649,7 +649,7 @@ bool ntpProcessOneRequest(bool process, const timeval *recTv, const timeval *syn
if (ntpDiag != nullptr)
{
char tmpbuf[128];
snprintf(tmpbuf, sizeof(tmpbuf), "Reference Timestamp (Last Sync): %u.%06u\r\n",
snprintf(tmpbuf, sizeof(tmpbuf), "Reference Timestamp (Last Sync): %lu.%06lu\r\n",
packet.referenceTimestampSeconds,
packet.convertFractionToMicros(packet.referenceTimestampFraction));
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
Expand Down Expand Up @@ -677,7 +677,7 @@ bool ntpProcessOneRequest(bool process, const timeval *recTv, const timeval *syn
if (ntpDiag != nullptr)
{
char tmpbuf[128];
snprintf(tmpbuf, sizeof(tmpbuf), "Transmit Timestamp: %u.%06u\r\n",
snprintf(tmpbuf, sizeof(tmpbuf), "Transmit Timestamp: %lu.%06lu\r\n",
packet.transmitTimestampSeconds,
packet.convertFractionToMicros(packet.transmitTimestampFraction));
strlcat(ntpDiag, tmpbuf, ntpDiagSize);
Expand Down
2 changes: 1 addition & 1 deletion Firmware/RTK_Everywhere/NVM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void recordSystemSettingsToFile(File *settingsFile)
break;
case _uint32_t: {
uint32_t *ptr = (uint32_t *)rtkSettingsEntries[i].var;
settingsFile->printf("%s=%d\r\n", rtkSettingsEntries[i].name, *ptr);
settingsFile->printf("%s=%lu\r\n", rtkSettingsEntries[i].name, *ptr);
}
break;
case _uint64_t: {
Expand Down
6 changes: 4 additions & 2 deletions Firmware/RTK_Everywhere/Network.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2453,10 +2453,12 @@ void networkUpdate()
// Update the WiFi state
wifiStationUpdate();

// Update Ethernet
ethernetUpdate();

// Update the network services
// Start or stop mDNS
if (networkMdnsRequests != networkMdnsRunning)
networkMulticastDNSUpdate();
networkMulticastDNSUpdate();

// Update the network services
DMW_c("mqttClientUpdate");
Expand Down
78 changes: 41 additions & 37 deletions Firmware/RTK_Everywhere/NtripServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const RtkMode_t ntripServerMode = RTK_MODE_BASE_FIXED;
//----------------------------------------

// NTRIP Servers
volatile static NTRIP_SERVER_DATA ntripServerArray[NTRIP_SERVER_MAX];
static NTRIP_SERVER_DATA ntripServerArray[NTRIP_SERVER_MAX];

//----------------------------------------
// NTRIP Server Routines
Expand All @@ -184,7 +184,7 @@ volatile static NTRIP_SERVER_DATA ntripServerArray[NTRIP_SERVER_MAX];
//----------------------------------------
bool ntripServerConnectCaster(int serverIndex)
{
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
const int SERVER_BUFFER_SIZE = 512;
char serverBuffer[SERVER_BUFFER_SIZE];

Expand Down Expand Up @@ -240,7 +240,7 @@ bool ntripServerConnectLimitReached(int serverIndex)
{
bool limitReached;
int minutes;
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
int seconds;

// Retry the connection a few times
Expand Down Expand Up @@ -312,9 +312,9 @@ bool ntripServerEnabled(int serverIndex, const char ** line)
{
if (line)
{
if (settings.ntripServer_CasterHost[0] == 0)
if (settings.ntripServer_CasterHost[serverIndex][0] == 0)
*line = ", Caster host not specified!";
else if (settings.ntripServer_CasterPort == 0)
else if (settings.ntripServer_CasterPort[serverIndex] == 0)
*line = ", Caster port not specified!";
else
*line = ", Mount point not specified!";
Expand All @@ -335,7 +335,7 @@ bool ntripServerEnabled(int serverIndex, const char ** line)
//----------------------------------------
void ntripServerPrintStateSummary(int serverIndex)
{
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];

switch (ntripServer->state)
{
Expand Down Expand Up @@ -363,7 +363,7 @@ void ntripServerPrintStateSummary(int serverIndex)
//----------------------------------------
void ntripServerPrintStatus(int serverIndex)
{
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
uint64_t milliseconds;
uint32_t days;
byte hours;
Expand All @@ -380,7 +380,7 @@ void ntripServerPrintStatus(int serverIndex)
if (ntripServer->state == NTRIP_SERVER_CASTING)
// Use ntripServer->timer since it gets reset after each successful data
// reception from the NTRIP caster
milliseconds = ntripServer->timer - ntripServer->startTime;
milliseconds = ntripServer->getUptime();
else
{
milliseconds = ntripServer->startTime;
Expand Down Expand Up @@ -411,7 +411,7 @@ void ntripServerPrintStatus(int serverIndex)
//----------------------------------------
void ntripServerProcessRTCM(int serverIndex, uint8_t incoming)
{
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];

if (ntripServer->state == NTRIP_SERVER_CASTING)
{
Expand All @@ -434,22 +434,27 @@ void ntripServerProcessRTCM(int serverIndex, uint8_t incoming)
}

// If we have not gotten new RTCM bytes for a period of time, assume end of frame
if (((millis() - ntripServer->timer) > 100) && (ntripServer->bytesSent > 0))
{
if ((!inMainMenu) && settings.debugNtripServerRtcm)
systemPrintf("NTRIP Server %d transmitted %d RTCM bytes to Caster\r\n", serverIndex,
ntripServer->bytesSent);

ntripServer->bytesSent = 0;
}
if (ntripServer->checkBytesSentAndReset(100) && (!inMainMenu) && settings.debugNtripServerRtcm)
systemPrintf("NTRIP Server %d transmitted %d RTCM bytes to Caster\r\n", serverIndex,
ntripServer->bytesSent);

if (ntripServer->networkClient && ntripServer->networkClient->connected())
{
ntripServer->networkClient->write(incoming); // Send this byte to socket
ntripServer->bytesSent = ntripServer->bytesSent + 1;
ntripServer->rtcmBytesSent = ntripServer->rtcmBytesSent + 1;
ntripServer->timer = millis();
netOutgoingRTCM = true;
if (ntripServer->networkClient->write(incoming) == 1) // Send this byte to socket
{
ntripServer->updateTimerAndBytesSent();
netOutgoingRTCM = true;
while (ntripServer->networkClient->available())
ntripServer->networkClient->read(); // Absorb any unwanted incoming traffic
}
// Failed to write the data
else
{
// Done with this client connection
if (settings.debugNtripServerRtcm && (!inMainMenu))
systemPrintf("NTRIP Server %d broken connection to %s\r\n", serverIndex,
settings.ntripServer_CasterHost[serverIndex]);
}
}
}

Expand All @@ -465,7 +470,7 @@ void ntripServerProcessRTCM(int serverIndex, uint8_t incoming)
//----------------------------------------
void ntripServerResponse(int serverIndex, char *response, size_t maxLength)
{
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
char *responseEnd;

// Make sure that we can zero terminate the response
Expand All @@ -484,11 +489,11 @@ void ntripServerResponse(int serverIndex, char *response, size_t maxLength)
//----------------------------------------
void ntripServerRestart(int serverIndex)
{
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];

// Save the previous uptime value
if (ntripServer->state == NTRIP_SERVER_CASTING)
ntripServer->startTime = ntripServer->timer - ntripServer->startTime;
ntripServer->startTime = ntripServer->getUptime();
ntripServerConnectLimitReached(serverIndex);
}

Expand All @@ -497,7 +502,7 @@ void ntripServerRestart(int serverIndex)
//----------------------------------------
void ntripServerSetState(int serverIndex, uint8_t newState)
{
volatile NTRIP_SERVER_DATA * ntripServer;
NTRIP_SERVER_DATA * ntripServer;

ntripServer = &ntripServerArray[serverIndex];
if (settings.debugNtripServerState)
Expand Down Expand Up @@ -549,7 +554,7 @@ void ntripServerStop(int serverIndex, bool shutdown)
{
bool enabled;
int index;
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];

if (ntripServer->networkClient)
{
Expand All @@ -566,7 +571,7 @@ void ntripServerStop(int serverIndex, bool shutdown)
// Increase timeouts if we started the network
if (ntripServer->state > NTRIP_SERVER_OFF)
// Mark the Server stop so that we don't immediately attempt re-connect to Caster
ntripServer->timer = millis();
ntripServer->setTimerToMillis();

// Determine the next NTRIP server state
online.ntripServer[serverIndex] = false;
Expand Down Expand Up @@ -613,7 +618,7 @@ void ntripServerUpdate(int serverIndex)
const char * line = "";

// Get the NTRIP data structure
volatile NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];
NTRIP_SERVER_DATA *ntripServer = &ntripServerArray[serverIndex];

// Shutdown the NTRIP server when the mode or setting changes
DMW_if
Expand Down Expand Up @@ -678,8 +683,7 @@ void ntripServerUpdate(int serverIndex)
// Failed to connect to to the network, attempt to restart the network
ntripServerRestart(serverIndex);

else if (settings.enableNtripServer &&
((millis() - ntripServer->lastConnectionAttempt) > ntripServer->connectionAttemptTimeout))
else if (settings.enableNtripServer)
{
// No RTCM correction data sent yet
rtcmPacketsSent = 0;
Expand All @@ -697,7 +701,7 @@ void ntripServerUpdate(int serverIndex)
// Initiate the connection to the NTRIP caster
case NTRIP_SERVER_CONNECTING:
// Delay before opening the NTRIP server connection
if ((millis() - ntripServer->timer) >= ntripServer->connectionAttemptTimeout)
if (ntripServer->checkConnectionAttemptTimeout())
{
// Attempt a connection to the NTRIP caster
if (!ntripServerConnectCaster(serverIndex))
Expand All @@ -711,7 +715,7 @@ void ntripServerUpdate(int serverIndex)
else
{
// Connection open to NTRIP caster, wait for the authorization response
ntripServer->timer = millis();
ntripServer->setTimerToMillis();
ntripServerSetState(serverIndex, NTRIP_SERVER_AUTHORIZATION);
}
}
Expand All @@ -724,7 +728,7 @@ void ntripServerUpdate(int serverIndex)
strlen("ICY 200 OK")) // Wait until at least a few bytes have arrived
{
// Check for response timeout
if ((millis() - ntripServer->timer) > 10000)
if (ntripServer->millisSinceTimer() > 10000)
{
if (ntripServerConnectLimitReached(serverIndex))
systemPrintf(
Expand Down Expand Up @@ -771,7 +775,7 @@ void ntripServerUpdate(int serverIndex)
settings.ntripServer_MountPoint[serverIndex]);

// Connection is now open, start the RTCM correction data timer
ntripServer->timer = millis();
ntripServer->setTimerToMillis();

// We don't use a task because we use I2C hardware (and don't have a semaphore).
online.ntripServer[serverIndex] = true;
Expand Down Expand Up @@ -816,7 +820,7 @@ void ntripServerUpdate(int serverIndex)
settings.ntripServer_CasterHost[serverIndex]);
ntripServerRestart(serverIndex);
}
else if ((millis() - ntripServer->timer) > (10 * 1000))
else if (ntripServer->millisSinceTimer() > (10 * 1000))
{
// GNSS stopped sending RTCM correction data
systemPrintf("NTRIP Server %d breaking connection to %s due to lack of RTCM data!\r\n", serverIndex,
Expand All @@ -831,7 +835,7 @@ void ntripServerUpdate(int serverIndex)
// connection. However increasing backoff delays should be
// added when the NTRIP caster fails after a short connection
// interval.
if (((millis() - ntripServer->startTime) > NTRIP_SERVER_CONNECTION_TIME) &&
if ((ntripServer->millisSinceStartTime() > NTRIP_SERVER_CONNECTION_TIME) &&
(ntripServer->connectionAttempts || ntripServer->connectionAttemptTimeout))
{
// After a long connection period, reset the attempt counter
Expand Down
Loading