Skip to content

Commit

Permalink
Merge pull request #448 from sparkfun/Add_Ref_Stn_Ethernet
Browse files Browse the repository at this point in the history
Reference Station: Add NTRIP Server/Client over WiFi and TCP Client over Ethernet
  • Loading branch information
nseidle authored May 5, 2023
2 parents 5074c60 + ccb0b5a commit 4b1817d
Show file tree
Hide file tree
Showing 17 changed files with 2,290 additions and 1,726 deletions.
151 changes: 106 additions & 45 deletions Firmware/RTK_Surveyor/AP-Config/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,17 @@
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</div>

<div id="allowWiFiOverEthernetClient">
<div class="form-check mt-1 box-margin20">
<label class="form-check-label" for="ntripClientUseWiFiNotEthernet">Use WiFi for NTRIP Client - not Ethernet</label>
<input class="form-check-input" type="checkbox" value="" id="ntripClientUseWiFiNotEthernet">
<span class="tt" data-bs-placement="right"
title="On RTK products which have Ethernet connectivity, you can use WiFi instead of Ethernet for NTRIP Client by enabling this option. Default: Disabled">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</div>
</div>
</div>

<div id="messageRateButton">
Expand Down Expand Up @@ -875,6 +886,17 @@
<p id="ntripServer_MountPointPWError" class="inlineError"></p>
</div>
</div>

<div id="allowWiFiOverEthernetServer">
<div class="form-check mt-1 box-margin20">
<label class="form-check-label" for="ntripUseWiFiNotEthernet">Use WiFi for NTRIP Server - not Ethernet</label>
<input class="form-check-input" type="checkbox" value="" id="ntripServerUseWiFiNotEthernet">
<span class="tt" data-bs-placement="right"
title="On RTK products which have Ethernet connectivity, you can use WiFi instead of Ethernet for NTRIP Server by enabling this option. Default: Disabled">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</div>
</div>
</div>

<div>
Expand Down Expand Up @@ -1576,9 +1598,9 @@
<div class="collapse" id="collapseEthernetConfig">
<div class="card card-body">

<div class="form-check mt-1 box-margin20">
<div class="form-check mt-3">
<label class="form-check-label" for="ethernetDHCP">Ethernet uses DHCP</label>
<input class="form-check-input" type="checkbox" value="" id="ethernetDHCP" checked>
<input class="form-check-input" type="checkbox" value="" id="ethernetDHCP" onClick="dhcpEthernet()" checked>
<span class="tt" data-bs-placement="right"
title="If enabled, Ethernet will use DHCP. Disable to use a fixed IP Address, DNS, Gateway and Subnet Mask. Default: Enabled">
<span class="icon-info-circle text-primary ms-2"></span>
Expand All @@ -1587,52 +1609,54 @@

<br>

<div class="form-group row">
<label for="ethernetIP" class="col-5 col-form-label">Fixed IP Address:
<span class="tt" data-bs-placement="right"
title="If DHCP is disabled, Ethernet will use this fixed IP Address">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="ethernetIP">
<p id="ethernetIPError" class="inlineError"></p>
<div id="fixedIPSettingsConfigEthernet">
<div class="form-group row">
<label for="ethernetIP" class="col-5 col-form-label">Fixed IP Address:
<span class="tt" data-bs-placement="right"
title="If DHCP is disabled, Ethernet will use this fixed IP Address">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="ethernetIP">
<p id="ethernetIPError" class="inlineError"></p>
</div>
</div>
</div>
<div class="form-group row">
<label for="ethernetDNS" class="col-5 col-form-label">DNS:
<span class="tt" data-bs-placement="right"
title="If DHCP is disabled, Ethernet will use this DNS">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="ethernetDNS">
<p id="ethernetDNSError" class="inlineError"></p>
<div class="form-group row">
<label for="ethernetDNS" class="col-5 col-form-label">DNS:
<span class="tt" data-bs-placement="right"
title="If DHCP is disabled, Ethernet will use this DNS">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="ethernetDNS">
<p id="ethernetDNSError" class="inlineError"></p>
</div>
</div>
</div>
<div class="form-group row">
<label for="ethernetGateway" class="col-5 col-form-label">Gateway:
<span class="tt" data-bs-placement="right"
title="If DHCP is disabled, Ethernet will use this Gateway">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="ethernetGateway">
<p id="ethernetGatewayError" class="inlineError"></p>
<div class="form-group row">
<label for="ethernetGateway" class="col-5 col-form-label">Gateway:
<span class="tt" data-bs-placement="right"
title="If DHCP is disabled, Ethernet will use this Gateway">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="ethernetGateway">
<p id="ethernetGatewayError" class="inlineError"></p>
</div>
</div>
</div>
<div class="form-group row">
<label for="ethernetSubnet" class="col-5 col-form-label">Subnet Mask:
<span class="tt" data-bs-placement="right"
title="If DHCP is disabled, Ethernet will use this subnet mask">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="ethernetSubnet">
<p id="ethernetSubnetError" class="inlineError"></p>
<div class="form-group row">
<label for="ethernetSubnet" class="col-5 col-form-label">Subnet Mask:
<span class="tt" data-bs-placement="right"
title="If DHCP is disabled, Ethernet will use this subnet mask">
<span class="icon-info-circle text-primary ms-2"></span>
</span>
</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="ethernetSubnet">
<p id="ethernetSubnetError" class="inlineError"></p>
</div>
</div>
</div>

Expand Down Expand Up @@ -1661,6 +1685,43 @@
</div>
</div>

<br>

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

<div id="tcpSettingsConfigEthernet">
<div class="form-group row">
<label for="ethernetTcpPort" 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="ethernetTcpPort">
<p id="ethernetTcpPortError" class="inlineError"></p>
</div>
</div>

<div class="form-group row">
<label for="hostForTCPClient" class="box-margin20 col-sm-3 col-4 col-form-label">Host for TCP Client:
<span class="tt" data-bs-placement="right" title="The name or address of the host which the TCP client data will be pushed to.">
<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="hostForTCPClient" value="test">
<p id="hostForTCPClientError" class="inlineError"></p>
</div>
</div>
</div>
</div>
</div>

Expand Down
35 changes: 35 additions & 0 deletions Firmware/RTK_Surveyor/AP-Config/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ function parseIncoming(msg) {
hide("ppConfig");
hide("ethernetConfig");
hide("ntpConfig");
hide("allowWiFiOverEthernetClient")
hide("allowWiFiOverEthernetServer")

hide("dataPortChannelDropdown");
}
Expand All @@ -104,13 +106,17 @@ function parseIncoming(msg) {
hide("ppConfig");
hide("ethernetConfig");
hide("ntpConfig");
hide("allowWiFiOverEthernetClient")
hide("allowWiFiOverEthernetServer")
}
else if (platformPrefix == "Express Plus") {
hide("baseConfig");
show("sensorConfig");
hide("ppConfig");
hide("ethernetConfig");
hide("ntpConfig");
hide("allowWiFiOverEthernetClient")
hide("allowWiFiOverEthernetServer")

ge("muxChannel2").innerHTML = "Wheel/Dir Encoder";
}
Expand All @@ -120,13 +126,17 @@ function parseIncoming(msg) {
show("ppConfig");
hide("ethernetConfig");
hide("ntpConfig");
hide("allowWiFiOverEthernetClient")
hide("allowWiFiOverEthernetServer")
}
else if (platformPrefix == "Reference Station") {
show("baseConfig");
hide("sensorConfig");
hide("ppConfig");
show("ethernetConfig");
show("ntpConfig");
show("allowWiFiOverEthernetClient")
show("allowWiFiOverEthernetServer")
}
}
else if (id.includes("zedFirmwareVersionInt")) {
Expand Down Expand Up @@ -339,6 +349,8 @@ function parseIncoming(msg) {
updateECEFList();
updateGeodeticList();
tcpBoxes();
tcpBoxesEthernet();
dhcpEthernet();
updateLatLong();
}

Expand Down Expand Up @@ -599,6 +611,10 @@ function validateFields() {
checkElementIPAddress("ethernetSubnet", "Must be nnn.nnn.nnn.nnn", "collapseEthernetConfig");
checkElementValue("ethernetHttpPort", 0, 65535, "Must be 0 to 65535", "collapseEthernetConfig");
checkElementValue("ethernetNtpPort", 0, 65535, "Must be 0 to 65535", "collapseEthernetConfig");
if (ge("enableTcpClientEthernet").checked) {
checkElementString("ethernetTcpPort", 1, 65535, "Must be 1 to 65535", "collapseEthernetConfig");
checkElementString("hostForTCPClient", 0, 50, "Must be 0 to 50 characters", "collapseEthernetConfig");
}
//}
//else {
// clearElement("ethernetIP", "192.168.0.123");
Expand Down Expand Up @@ -1517,6 +1533,25 @@ function tcpBoxes() {
}
}

function tcpBoxesEthernet() {
if (ge("enableTcpClientEthernet").checked) {
show("tcpSettingsConfigEthernet");
}
else {
hide("tcpSettingsConfigEthernet");
//ge("ethernetTcpPort").value = 2947;
}
}

function dhcpEthernet() {
if (ge("ethernetDHCP").checked) {
hide("fixedIPSettingsConfigEthernet");
}
else {
show("fixedIPSettingsConfigEthernet");
}
}

function networkCount() {
var count = 0;

Expand Down
21 changes: 17 additions & 4 deletions Firmware/RTK_Surveyor/Display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ void displayBatteryVsEthernet()
icons |= ICON_BATTERY; //Top right
else //if (HAS_ETHERNET)
{
if (online.ethernetStatus == ETH_CONNECTED)
if (online.ethernetStatus == ETH_NOT_STARTED)
blinking_icons &= ~ICON_ETHERNET; //If Ethernet has not stated because not needed, don't display the icon
else if (online.ethernetStatus == ETH_CONNECTED)
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
else
blinking_icons ^= ICON_ETHERNET;
Expand Down Expand Up @@ -1811,6 +1813,10 @@ void paintIPAddress()

static uint8_t ipAddressPosition = 0;

//Check if IP address is all single digits and can be printed without scrolling
if (strlen(ipAddress) <= 21)
ipAddressPosition = 7;

//Print seven characters of IP address
char printThis[9];
snprintf(printThis, sizeof(printThis), "%c%c%c%c%c%c%c",
Expand Down Expand Up @@ -3246,6 +3252,13 @@ void displayConfigViaEthernet()

//Print ten characters of IP address
char printThis[12];

//Check if the IP address is <= 10 chars and will fit without scrolling
if (strlen(ipAddress) <= 28)
ipAddressPosition = 9;
else if (strlen(ipAddress) <= 30)
ipAddressPosition = 10;

snprintf(printThis, sizeof(printThis), "%c%c%c%c%c%c%c%c%c%c",
ipAddress[ipAddressPosition + 0], ipAddress[ipAddressPosition + 1],
ipAddress[ipAddressPosition + 2], ipAddress[ipAddressPosition + 3],
Expand Down Expand Up @@ -3277,14 +3290,14 @@ const uint8_t * getMacAddress()
#ifdef COMPILE_BT
if (bluetoothState != BT_OFF)
return btMACAddress;
#endif
#ifdef COMPILE_WIFI
else if (wifiState != WIFI_OFF)
if (wifiState != WIFI_OFF)
return wifiMACAddress;
#endif
#ifdef COMPILE_ETHERNET
else if ((online.ethernetStatus >= ETH_STARTED_CHECK_CABLE) && (online.ethernetStatus <= ETH_CONNECTED))
if ((online.ethernetStatus >= ETH_STARTED_CHECK_CABLE) && (online.ethernetStatus <= ETH_CONNECTED))
return ethernetMACAddress;
#endif
#endif
return zero;
}
20 changes: 19 additions & 1 deletion Firmware/RTK_Surveyor/Form.ino
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,9 @@ void createSettingsString(char* newSettings)
stringRecord(newSettings, "ntripClient_MountPointPW", settings.ntripClient_MountPointPW);
stringRecord(newSettings, "ntripClient_TransmitGGA", settings.ntripClient_TransmitGGA);

stringRecord(newSettings, "ntripServerUseWiFiNotEthernet", settings.ntripServerUseWiFiNotEthernet);
stringRecord(newSettings, "ntripClientUseWiFiNotEthernet", settings.ntripClientUseWiFiNotEthernet);

//Sensor Fusion Config
stringRecord(newSettings, "enableSensorFusion", settings.enableSensorFusion);
stringRecord(newSettings, "autoIMUmountAlignment", settings.autoIMUmountAlignment);
Expand Down Expand Up @@ -649,7 +652,10 @@ void createSettingsString(char* newSettings)
stringRecord(newSettings, "ethernetSubnet", ipAddressChar);
stringRecord(newSettings, "ethernetHttpPort", settings.ethernetHttpPort);
stringRecord(newSettings, "ethernetNtpPort", settings.ethernetNtpPort);

stringRecord(newSettings, "enableTcpClientEthernet", settings.enableTcpClientEthernet);
stringRecord(newSettings, "ethernetTcpPort", settings.ethernetTcpPort);
stringRecord(newSettings, "hostForTCPClient", settings.hostForTCPClient);

//NTP
stringRecord(newSettings, "ntpPollExponent", settings.ntpPollExponent);
stringRecord(newSettings, "ntpPrecision", settings.ntpPrecision);
Expand Down Expand Up @@ -1100,6 +1106,12 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
strcpy(settings.ntripClient_MountPointPW, settingValueStr);
else if (strcmp(settingName, "ntripClient_TransmitGGA") == 0)
settings.ntripClient_TransmitGGA = settingValueBool;

else if (strcmp(settingName, "ntripServerUseWiFiNotEthernet") == 0)
settings.ntripServerUseWiFiNotEthernet = settingValueBool;
else if (strcmp(settingName, "ntripClientUseWiFiNotEthernet") == 0)
settings.ntripClientUseWiFiNotEthernet = settingValueBool;

else if (strcmp(settingName, "serialTimeoutGNSS") == 0)
settings.serialTimeoutGNSS = settingValue;
else if (strcmp(settingName, "pointPerfectDeviceProfileToken") == 0)
Expand Down Expand Up @@ -1203,6 +1215,12 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
settings.ethernetHttpPort = settingValue;
else if (strcmp(settingName, "ethernetNtpPort") == 0)
settings.ethernetNtpPort = settingValue;
else if (strcmp(settingName, "enableTcpClientEthernet") == 0)
settings.enableTcpClientEthernet = settingValueBool;
else if (strcmp(settingName, "ethernetTcpPort") == 0)
settings.ethernetTcpPort = settingValue;
else if (strcmp(settingName, "hostForTCPClient") == 0)
strcpy(settings.hostForTCPClient, settingValueStr);

//NTP
else if (strcmp(settingName, "ntpPollExponent") == 0)
Expand Down
Loading

0 comments on commit 4b1817d

Please sign in to comment.