Skip to content

Commit 8e5cb92

Browse files
authored
Merge pull request #686 from sparkfun/TCPWiFiSourceControl
Add WiFi controls for TCP/UDP Server
2 parents 546e42c + 692f150 commit 8e5cb92

File tree

7 files changed

+31
-2135
lines changed

7 files changed

+31
-2135
lines changed

Firmware/RTK_Everywhere/AP-Config/index.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,18 @@
17091709
<p id="enableUdpServerError" class="inlineError"></p>
17101710
</div>
17111711

1712+
<div id="tcpUdpWiFiTypeDropdown" class="mt-3">
1713+
<label for="tcpUdpOverWiFiStation">TCP/UDP Server Connection: </label>
1714+
<select name="tcpUdpWiFiType" id="tcpUdpOverWiFiStation" class="form-dropdown">
1715+
<option value="1">WiFi</option>
1716+
<option value="0">AP</option>
1717+
</select>
1718+
<span class="tt" data-bs-placement="right"
1719+
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.">
1720+
<span class="icon-info-circle text-primary ms-2"></span>
1721+
</span>
1722+
</div>
1723+
17121724
</div>
17131725
</div>
17141726

@@ -2181,7 +2193,7 @@
21812193
</div>
21822194

21832195
<div id="measurementScaleDropdown" class="mb-2 mt-3">
2184-
<label for="measurementScale">Measurement Scale: </label>
2196+
<label for="measurementScale">Units: </label>
21852197
<select name="measurementScale" id="measurementScale" class="form-dropdown">
21862198
<option value="0">Meters</option>
21872199
<option value="1">Feet/Inches</option>

Firmware/RTK_Everywhere/Network.ino

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ void menuTcpUdp()
226226
if (settings.mdnsEnable)
227227
systemPrintf("n) MDNS host name: %s\r\n", settings.mdnsHostName);
228228

229+
systemPrint("a) Broadcast TCP/UDP Server packets over local WiFi or act as Access Point: ");
230+
systemPrintf("%s\r\n", settings.tcpUdpOverWiFiStation ? "WiFi" : "AP");
231+
229232
//------------------------------
230233
// Finish the menu and get the input
231234
//------------------------------
@@ -320,6 +323,11 @@ void menuTcpUdp()
320323
getUserInputString((char *)&settings.mdnsHostName, sizeof(settings.mdnsHostName));
321324
}
322325

326+
else if (incoming == 'a')
327+
{
328+
settings.tcpUdpOverWiFiStation ^= 1;
329+
wifiUpdateSettings();
330+
}
323331
//------------------------------
324332
// Handle exit and invalid input
325333
//------------------------------

Firmware/RTK_Everywhere/TcpServer.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ void tcpServerUpdate()
449449
{
450450
if (settings.debugTcpServer && (!inMainMenu))
451451
systemPrintln("TCP server start");
452-
if (settings.wifiConfigOverAP == false)
452+
if (settings.tcpUdpOverWiFiStation == true)
453453
networkConsumerAdd(NETCONSUMER_TCP_SERVER, NETWORK_ANY, __FILE__, __LINE__);
454454
else
455455
networkSoftApConsumerAdd(NETCONSUMER_TCP_SERVER, __FILE__, __LINE__);

Firmware/RTK_Everywhere/UdpServer.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void udpServerUpdate()
360360
{
361361
if (settings.debugUdpServer && (!inMainMenu))
362362
systemPrintln("UDP server starting the network");
363-
if (settings.wifiConfigOverAP == false)
363+
if (settings.tcpUdpOverWiFiStation == true)
364364
networkConsumerAdd(NETCONSUMER_UDP_SERVER, NETWORK_ANY, __FILE__, __LINE__);
365365
else
366366
networkSoftApConsumerAdd(NETCONSUMER_UDP_SERVER, __FILE__, __LINE__);

Firmware/RTK_Everywhere/form.h

Lines changed: 0 additions & 2132 deletions
Large diffs are not rendered by default.

Firmware/RTK_Everywhere/menuCommands.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,11 +1962,17 @@ void createSettingsString(char *newSettings)
19621962
}
19631963

19641964
// Drop downs on the AP config page expect a value, whereas bools get stringRecord as true/false
1965+
// These special bool settings get added twice to the string, once above, once here.
19651966
if (settings.wifiConfigOverAP == true)
19661967
stringRecord(newSettings, "wifiConfigOverAP", 1); // 1 = AP mode, 0 = WiFi
19671968
else
19681969
stringRecord(newSettings, "wifiConfigOverAP", 0); // 1 = AP mode, 0 = WiFi
19691970

1971+
if (settings.tcpUdpOverWiFiStation == true)
1972+
stringRecord(newSettings, "tcpUdpOverWiFiStation", 1); // 1 = WiFi mode, 0 = AP
1973+
else
1974+
stringRecord(newSettings, "tcpUdpOverWiFiStation", 0); // 1 = WiFi mode, 0 = AP
1975+
19701976
// Single variables needed on Config page
19711977
stringRecord(newSettings, "minCNO", gnss->getMinCno());
19721978
stringRecord(newSettings, "enableRCFirmware", enableRCFirmware);

Firmware/RTK_Everywhere/settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ struct Settings
935935
bool debugTcpServer = false;
936936
bool enableTcpServer = false;
937937
uint16_t tcpServerPort = 2948; // TCP server port, 2948 is GPS Daemon: http://tcp-udp-ports.com/port-2948.htm
938+
bool tcpUdpOverWiFiStation = true; // Controls if TCP/UDP settings should use Station or AP
938939

939940
// Time Zone - Default to UTC
940941
int8_t timeZoneHours = 0;
@@ -1564,6 +1565,7 @@ const RTK_Settings_Entry rtkSettingsEntries[] =
15641565
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, _bool, 0, & settings.debugTcpServer, "debugTcpServer", },
15651566
{ 1, 1, 0, 1, 1, 1, 1, 1, 1, _bool, 0, & settings.enableTcpServer, "enableTcpServer", },
15661567
{ 1, 1, 0, 1, 1, 1, 1, 1, 1, _uint16_t, 0, & settings.tcpServerPort, "tcpServerPort", },
1568+
{ 1, 1, 0, 1, 1, 1, 1, 1, 1, _bool, 0, & settings.tcpUdpOverWiFiStation, "tcpUdpOverWiFiStation", },
15671569

15681570
// Time Zone
15691571
{ 0, 1, 0, 1, 1, 1, 1, 1, 1, _int8_t, 0, & settings.timeZoneHours, "timeZoneHours", },

0 commit comments

Comments
 (0)