Skip to content

Update TCP server to better work as an NTRIP or base caster #664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: release_candidate
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
4bc9088
Revert "Add a semaphore for tcpServer - UNTESTED"
LeeLeahy2 Jul 29, 2025
5555408
TcpServer: Periodically display data sent messages for all clients
LeeLeahy2 Jul 1, 2025
2b71961
TcpServer: Output TCP Server, NTRIP Caster or Base Caster messages
LeeLeahy2 Jul 1, 2025
94169c4
TcpServer: Make port selection in tcpServerEnabled
LeeLeahy2 Jul 1, 2025
9d8471e
TcpServer: Determine operating mode in tcpServerEnabled
LeeLeahy2 Jul 1, 2025
54c0955
TcpServer: Select WiFi mode in tcpServerEnabled
LeeLeahy2 Jul 1, 2025
5c3bd53
TcpServer: Move the client handling into tcpServerClientUpdate
LeeLeahy2 Jul 1, 2025
0916654
TcpServer: Rework the client connection logic
LeeLeahy2 Jul 1, 2025
72fb0bb
TcpServer: Periodically display all of the client connections
LeeLeahy2 Jul 1, 2025
b2963d5
TcpServer: Separate the tcpServerTimer from the tcpServerClientTimers
LeeLeahy2 Jul 1, 2025
b7285c3
TcpServer: Use client states to wait for and process caster request
LeeLeahy2 Jul 1, 2025
eb888e4
TcpServer: Handle client allocation failures
LeeLeahy2 Jul 1, 2025
4272cf5
TcpServer: Don't send data until the client enters *_CLIENT_SENDING_DATA
LeeLeahy2 Jul 1, 2025
a40d155
TcpServer: Support building with COMPILE_NETWORK compiled out
LeeLeahy2 Jul 6, 2025
9bbf0c8
TcpServer: Rename settings.tcpUdpOverWiFiStation to tcpOverWiFiStation
LeeLeahy2 Jul 29, 2025
2b2921e
TcpServer: Fix use of baseCasterOverride and tcpOverWiFiStation
LeeLeahy2 Jul 29, 2025
710f300
Web Config: Move tcpWiFiTypeDropdown location
LeeLeahy2 Jul 29, 2025
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
23 changes: 11 additions & 12 deletions Firmware/RTK_Everywhere/AP-Config/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,17 @@
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</div>
<div id="tcpWiFiTypeDropdown" class="mt-3">
<label for="tcpOverWiFiStation">TCP Server Connection: </label>
<select name="tcpWiFiType" id="tcpOverWiFiStation" class="form-dropdown">
<option value="1">WiFi</option>
<option value="0">AP</option>
</select>
<span class="tt" data-bs-placement="right"
title="In WiFi mode, the device will attempt to connect to local WiFi to broadcast TCP packets. In AP mode, the device will become an Access Point that devices can connect to over WiFi.">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</div>
</div>
<div class="form-group row">
<p id="enableTcpServerError" class="inlineError"></p>
Expand Down Expand Up @@ -1677,18 +1688,6 @@
<div class="form-group row">
<p id="enableUdpServerError" class="inlineError"></p>
</div>

<div id="tcpUdpWiFiTypeDropdown" class="mt-3">
<label for="tcpUdpOverWiFiStation">TCP/UDP Server Connection: </label>
<select name="tcpUdpWiFiType" id="tcpUdpOverWiFiStation" class="form-dropdown">
<option value="1">WiFi</option>
<option value="0">AP</option>
</select>
<span class="tt" data-bs-placement="right"
title="In WiFi mode, the device will attempt to connect to local WiFi to broadcast TCP/UDP packets. In AP mode, the device will become an Access Point that devices can connect to over WiFi.">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</div>
</div>
</div>

Expand Down
2 changes: 2 additions & 0 deletions Firmware/RTK_Everywhere/Developer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ bool webServerStart(int httpPort = 80)
bool parseIncomingSettings() {return false;}
void sendStringToWebsocket(const char* stringToSend) {}
void stopWebServer() {}
bool webServerSettingsCheckAndFree() {return false;}
void webServerSettingsClone() {}
void webServerStop() {}
void webServerUpdate() {}
void webServerVerifyTables() {}
Expand Down
8 changes: 4 additions & 4 deletions Firmware/RTK_Everywhere/Network.ino
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ void menuTcpUdp()
if (settings.mdnsEnable)
systemPrintf("n) MDNS host name: %s\r\n", settings.mdnsHostName);

systemPrint("a) Broadcast TCP/UDP Server packets over local WiFi or act as Access Point: ");
systemPrintf("%s\r\n", settings.tcpUdpOverWiFiStation ? "WiFi" : "AP");
systemPrint("t) Broadcast TCP/UDP Server packets over local WiFi or act as Access Point: ");
systemPrintf("%s\r\n", settings.tcpOverWiFiStation ? "WiFi" : "AP");

systemPrint("u) Broadcast UDP Server packets over local WiFi or act as Access Point: ");
systemPrintf("%s\r\n", settings.udpOverWiFiStation ? "WiFi" : "AP");
Expand Down Expand Up @@ -326,9 +326,9 @@ void menuTcpUdp()
getUserInputString((char *)&settings.mdnsHostName, sizeof(settings.mdnsHostName));
}

else if (incoming == 'a')
else if (incoming == 't')
{
settings.tcpUdpOverWiFiStation ^= 1;
settings.tcpOverWiFiStation ^= 1;
wifiUpdateSettings();
}

Expand Down
6 changes: 1 addition & 5 deletions Firmware/RTK_Everywhere/RTK_Everywhere.ino
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,6 @@ const TickType_t ringBuffer_longWait_ms = 300 / portTICK_PERIOD_MS;
SemaphoreHandle_t ringBufferSemaphore = NULL;
const char *ringBufferSemaphoreHolder = "None";

// tcpServer semaphore - prevent tcpServerClientSendData (handleGnssDataTask) and tcpServerUpdate
// from gatecrashing each other. See #695 for why this is needed.
SemaphoreHandle_t tcpServerSemaphore = NULL;
const char *tcpServerSemaphoreHolder = "None";

// Display used/free space in menu and config page
uint64_t sdCardSize;
uint64_t sdFreeSpace;
Expand Down Expand Up @@ -444,6 +439,7 @@ bool otaRequestFirmwareUpdate = false;

bool enableRCFirmware; // Goes true from AP config page
bool currentlyParsingData; // Goes true when we hit 750ms timeout with new data
bool tcpServerInCasterMode;// True when TCP server is running in caster mode

// Give up connecting after this number of attempts
// Connection attempts are throttled to increase the time between attempts
Expand Down
2 changes: 1 addition & 1 deletion Firmware/RTK_Everywhere/Tasks.ino
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ void processUart1Message(SEMP_PARSE_STATE *parse, uint16_t type)
// If BaseCasterOverride is enabled, remove everything but RTCM from the circular buffer
// to avoid saturating the downstream radio link that is consuming over a TCP (NTRIP Caster) connection
// Remove NMEA, etc after passing to the GNSS receiver library so that we still have SIV and other stats available
if (settings.baseCasterOverride == true)
if (tcpServerInCasterMode)
{
if (type != RTK_RTCM_PARSER_INDEX)
{
Expand Down
Loading