Skip to content

NMEA stream over UDP #644

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

Merged
merged 12 commits into from
Sep 29, 2023
45 changes: 36 additions & 9 deletions Firmware/RTK_Surveyor/AP-Config/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1274,41 +1274,68 @@
</div>

<div class="form-check mt-3">
<label class="form-check-label" for="enableTcpClient">TCP Client</label>
<input class="form-check-input" type="checkbox" value="" id="enableTcpClient"
<label class="form-check-label" for="enablePvtClient">TCP Client</label>
<input class="form-check-input" type="checkbox" value="" id="enablePvtClient"
onClick="tcpBoxes()">
<span class="tt" data-bs-placement="right"
title="If enabled, device will connect to WiFi and push NMEA over the given TCP port.">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</div>
<div class="form-group row">
<p id="enableTcpClientError" class="inlineError"></p>
<p id="enablePvtClientError" class="inlineError"></p>
</div>

<div class="form-check mt-3">
<label class="form-check-label" for="enableTcpServer">TCP Server</label>
<input class="form-check-input" type="checkbox" value="" id="enableTcpServer"
<label class="form-check-label" for="enablePvtServer">TCP Server</label>
<input class="form-check-input" type="checkbox" value="" id="enablePvtServer"
onClick="tcpBoxes()">
<span class="tt" data-bs-placement="right"
title="If enabled, device will allow inbound TCP connections and push NMEA when a client is connected.">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</div>
<div class="form-group row">
<p id="enableTcpServerError" class="inlineError"></p>
<p id="enablePvtServerError" class="inlineError"></p>
</div>

<div id="tcpSettingsConfig">
<div class="form-group row">
<label for="wifiTcpPort" class="box-margin20 col-sm-3 col-4 col-form-label">Port:
<label for="pvtServerPort" class="box-margin20 col-sm-3 col-4 col-form-label">Port:
<span class="tt" data-bs-placement="right" title="TCP port to use. Default: 2947">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</label>
<div class="col-sm-8 col-7">
<input type="text" class="form-control" id="wifiTcpPort">
<p id="wifiTcpPortError" class="inlineError"></p>
<input type="text" class="form-control" id="pvtServerPort">
<p id="pvtServerPortError" class="inlineError"></p>
</div>
</div>
</div>

<div class="form-check mt-3">
<label class="form-check-label" for="enablePvtUdpServer">UDP Server</label>
<input class="form-check-input" type="checkbox" value="" id="enablePvtUdpServer"
onClick="udpBoxes()">
<span class="tt" data-bs-placement="right"
title="If enabled, device will broadcast NMEA sentences over UPD">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</div>
<div class="form-group row">
<p id="enablePvtUdpServerError" class="inlineError"></p>
</div>

<div id="udpSettingsConfig">
<div class="form-group row">
<label for="pvtUdpServerPort" class="box-margin20 col-sm-3 col-4 col-form-label">Port:
<span class="tt" data-bs-placement="right" title="UDP port to use. Default: 10110">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</label>
<div class="col-sm-8 col-7">
<input type="text" class="form-control" id="pvtUdpServerPort">
<p id="pvtUdpServerPortError" class="inlineError"></p>
</div>
</div>
</div>
Expand Down
24 changes: 19 additions & 5 deletions Firmware/RTK_Surveyor/AP-Config/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ function parseIncoming(msg) {
updateECEFList();
updateGeodeticList();
tcpBoxes();
udpBoxes();
tcpBoxesEthernet();
dhcpEthernet();
updateLatLong();
Expand Down Expand Up @@ -592,10 +593,13 @@ function validateFields() {
checkElementString("wifiNetwork2Password", 0, 50, "Must be 0 to 50 characters", "collapseWiFiConfig");
checkElementString("wifiNetwork3SSID", 0, 50, "Must be 0 to 50 characters", "collapseWiFiConfig");
checkElementString("wifiNetwork3Password", 0, 50, "Must be 0 to 50 characters", "collapseWiFiConfig");
if (ge("enableTcpClient").checked || ge("enableTcpServer").checked) {
checkElementString("wifiTcpPort", 1, 65535, "Must be 1 to 65535", "collapseWiFiConfig");
if (ge("enablePvtClient").checked || ge("enablePvtServer").checked) {
checkElementString("pvtServerPort", 1, 65535, "Must be 1 to 65535", "collapseWiFiConfig");
}
checkCheckboxMutex("enableTcpClient", "enableTcpServer", "TCP Client and Server can not be enabled at the same time", "collapseWiFiConfig");
if (ge("enablePvtUdpServer").checked) {
checkElementString("pvtUdpServerPort", 1, 65535, "Must be 1 to 65535", "collapseWiFiConfig");
}
checkCheckboxMutex("enablePvtClient", "enablePvtServer", "TCP Client and Server can not be enabled at the same time", "collapseWiFiConfig");

//System Config
if (ge("enableLogging").checked) {
Expand Down Expand Up @@ -1567,12 +1571,22 @@ function abortHandler(event) {
}

function tcpBoxes() {
if (ge("enableTcpClient").checked || ge("enableTcpServer").checked) {
if (ge("enablePvtServer").checked || ge("enablePvtClient").checked) {
show("tcpSettingsConfig");
}
else {
hide("tcpSettingsConfig");
ge("wifiTcpPort").value = 2947;
ge("pvtServerPort").value = 2947;
}
}

function udpBoxes() {
if (ge("enablePvtUdpServer").checked) {
show("udpSettingsConfig");
}
else {
hide("udpSettingsConfig");
ge("pvtUdpServerPort").value = 10110;
}
}

Expand Down
8 changes: 8 additions & 0 deletions Firmware/RTK_Surveyor/Developer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ void pvtServerZeroTail() {}
void pvtServerValidateTables() {}
void discardPvtServerBytes(RING_BUFFER_OFFSET previousTail, RING_BUFFER_OFFSET newTail) {}

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

int pvtUdpServerSendData(uint16_t dataHead) {return 0;}
void pvtUdpServerUpdate() {}
void pvtUdpServerZeroTail() {}

//----------------------------------------
// WiFi
//----------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Firmware/RTK_Surveyor/Ethernet.ino
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ bool ethernetIsNeeded()
return true;

// Does PVT client or server need Ethernet?
if (settings.enablePvtClient || settings.enablePvtServer)
if (settings.enablePvtClient || settings.enablePvtServer || settings.enablePvtUdpServer)
return true;

return false;
Expand Down
8 changes: 8 additions & 0 deletions Firmware/RTK_Surveyor/Form.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,11 @@ void createSettingsString(char *newSettings)
else
stringRecord(newSettings, "wifiConfigOverAP", 0); // 1 = AP mode, 0 = WiFi

stringRecord(newSettings, "enablePvtServer", settings.enablePvtServer);
stringRecord(newSettings, "enablePvtClient", settings.enablePvtClient);
stringRecord(newSettings, "pvtServerPort", settings.pvtServerPort);
stringRecord(newSettings, "enablePvtUdpServer", settings.enablePvtUdpServer);
stringRecord(newSettings, "pvtUdpServerPort", settings.pvtUdpServerPort);
stringRecord(newSettings, "enableRCFirmware", enableRCFirmware);

// New settings not yet integrated
Expand Down Expand Up @@ -1250,6 +1254,8 @@ void updateSettingWithValue(const char *settingName, const char *settingValueStr
}
else if (strcmp(settingName, "pvtServerPort") == 0)
settings.pvtServerPort = settingValue;
else if (strcmp(settingName, "pvtUdpServerPort") == 0)
settings.pvtUdpServerPort = settingValue;
else if (strcmp(settingName, "wifiConfigOverAP") == 0)
{
if (settingValue == 1) // Drop downs come back as a value
Expand All @@ -1262,6 +1268,8 @@ void updateSettingWithValue(const char *settingName, const char *settingValueStr
settings.enablePvtClient = settingValueBool;
else if (strcmp(settingName, "enablePvtServer") == 0)
settings.enablePvtServer = settingValueBool;
else if (strcmp(settingName, "enablePvtUdpServer") == 0)
settings.enablePvtUdpServer = settingValueBool;
else if (strcmp(settingName, "enableRCFirmware") == 0)
enableRCFirmware = settingValueBool;
else if (strcmp(settingName, "minElev") == 0)
Expand Down
9 changes: 9 additions & 0 deletions Firmware/RTK_Surveyor/NVM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,10 @@ void recordSystemSettingsToFile(File *settingsFile)
settingsFile->printf("%s=%d\r\n", "bluetoothRadioType", settings.bluetoothRadioType);
settingsFile->printf("%s=%d\r\n", "enablePvtClient", settings.enablePvtClient);
settingsFile->printf("%s=%d\r\n", "enablePvtServer", settings.enablePvtServer);
settingsFile->printf("%s=%d\r\n", "enablePvtUdpServer", settings.enablePvtUdpServer);
settingsFile->printf("%s=%d\r\n", "debugPvtClient", settings.debugPvtClient);
settingsFile->printf("%s=%d\r\n", "debugPvtServer", settings.debugPvtServer);
settingsFile->printf("%s=%d\r\n", "debugPvtUdpServer", settings.debugPvtUdpServer);
settingsFile->printf("%s=%d\r\n", "espnowBroadcast", settings.espnowBroadcast);
settingsFile->printf("%s=%d\r\n", "antennaHeight", settings.antennaHeight);
settingsFile->printf("%s=%0.2f\r\n", "antennaReferencePoint", settings.antennaReferencePoint);
Expand All @@ -350,6 +352,7 @@ void recordSystemSettingsToFile(File *settingsFile)

settingsFile->printf("%s=%d\r\n", "wifiConfigOverAP", settings.wifiConfigOverAP);
settingsFile->printf("%s=%d\r\n", "pvtServerPort", settings.pvtServerPort);
settingsFile->printf("%s=%d\r\n", "pvtUdpServerPort", settings.pvtUdpServerPort);
settingsFile->printf("%s=%d\r\n", "minElev", settings.minElev);

settingsFile->printf("%s=%d\r\n", "imuYaw", settings.imuYaw);
Expand Down Expand Up @@ -1130,10 +1133,14 @@ bool parseLine(char *str, Settings *settings)
settings->enablePvtClient = d;
else if (strcmp(settingName, "enablePvtServer") == 0)
settings->enablePvtServer = d;
else if (strcmp(settingName, "enablePvtUdpServer") == 0)
settings->enablePvtUdpServer = d;
else if (strcmp(settingName, "debugPvtClient") == 0)
settings->debugPvtClient = d;
else if (strcmp(settingName, "debugPvtServer") == 0)
settings->debugPvtServer = d;
else if (strcmp(settingName, "debugPvtUdpServer") == 0)
settings->debugPvtUdpServer = d;
else if (strcmp(settingName, "espnowBroadcast") == 0)
settings->espnowBroadcast = d;
else if (strcmp(settingName, "antennaHeight") == 0)
Expand Down Expand Up @@ -1162,6 +1169,8 @@ bool parseLine(char *str, Settings *settings)
settings->wifiConfigOverAP = d;
else if (strcmp(settingName, "pvtServerPort") == 0)
settings->pvtServerPort = d;
else if (strcmp(settingName, "pvtUdpServerPort") == 0)
settings->pvtUdpServerPort = d;
else if (strcmp(settingName, "minElev") == 0)
{
if (settings->minElev != d)
Expand Down
34 changes: 34 additions & 0 deletions Firmware/RTK_Surveyor/Network.ino
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ const char * const networkUser[] =
"NTRIP Server",
"PVT Client",
"PVT Server",
"PVT UDP Server",
};
const int networkUserEntries = sizeof(networkUser) / sizeof(networkUser[0]);

Expand Down Expand Up @@ -228,6 +229,11 @@ void menuNetwork()
if (settings.enablePvtServer)
systemPrintf("5) PVT Server Port: %ld\r\n", settings.pvtServerPort);

systemPrintf("6) PVT UDP Server: %s\r\n", settings.enablePvtUdpServer ? "Enabled" : "Disabled");

if (settings.enablePvtUdpServer)
systemPrintf("7) PVT UDP Server Port: %ld\r\n", settings.pvtUdpServerPort);

if (HAS_ETHERNET)
{
//------------------------------
Expand Down Expand Up @@ -319,6 +325,27 @@ void menuNetwork()
}
}

//------------------------------
// Get the PVT UDP server parameters
//------------------------------

else if (incoming == 6)
// Toggle WiFi UDP NEMA server
settings.enablePvtUdpServer ^= 1;

else if (incoming == 7 && settings.enablePvtUdpServer)
{
systemPrint("Enter the UDP port to use (0 to 65535): ");
int portNumber = getNumber(); // Returns EXIT, TIMEOUT, or long
if ((portNumber != INPUT_RESPONSE_GETNUMBER_EXIT) && (portNumber != INPUT_RESPONSE_GETNUMBER_TIMEOUT))
{
if (portNumber < 0 || portNumber > 65535)
systemPrintln("Error: UDP Port out of range");
else
settings.pvtUdpServerPort = portNumber; // Recorded to NVM and file at main menu exit
}
}

//------------------------------
// Get the network layer parameters
//------------------------------
Expand Down Expand Up @@ -845,6 +872,12 @@ void networkStop(uint8_t networkType)
systemPrintln("Network layer stopping PVT server");
pvtServerStop();
break;

case NETWORK_USER_PVT_UDP_SERVER:
if (settings.debugNetworkLayer)
systemPrintln("Network layer stopping PVT UDP server");
pvtUdpServerStop();
break;
}
}
}
Expand Down Expand Up @@ -1082,6 +1115,7 @@ void networkUpdate()
ntripServerUpdate(); // Check the NTRIP server connection and move data ZED --> NTRIP
pvtClientUpdate(); // Turn on the PVT client as needed
pvtServerUpdate(); // Turn on the PVT server as needed
pvtUdpServerUpdate(); // Turn on the PVT UDP server as needed
}

// Display the IP addresses
Expand Down
Loading