Skip to content

Commit 68ffeeb

Browse files
committed
Add NTRIP Client/Server uptime to System menu
Fix for #321
1 parent 9480089 commit 68ffeeb

File tree

2 files changed

+116
-18
lines changed

2 files changed

+116
-18
lines changed

Firmware/RTK_Surveyor/NtripServer.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ static uint32_t ntripServerStateLastDisplayed = 0;
8484
// * Monitor last RTCM byte received for frame counting
8585
static uint32_t ntripServerTimer;
8686

87+
static uint32_t ntripServerStartTime;
88+
8789
//----------------------------------------
8890
// NTRIP Server Routines - compiled out
8991
//----------------------------------------
@@ -416,6 +418,7 @@ void ntripServerUpdate()
416418
else
417419
{
418420
//WiFi connection established
421+
ntripServerStartTime = millis();
419422
ntripServerSetState(NTRIP_SERVER_WIFI_CONNECTED);
420423

421424
// Start the SD card server

Firmware/RTK_Surveyor/menuSystem.ino

Lines changed: 113 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void menuSystem()
7171

7272
#ifdef COMPILE_WIFI
7373
Serial.print("WiFi MAC Address: ");
74-
Serial.printf("%02X-%02X-%02X-%02X-%02X-%02X\r\n", wifiMACAddress[0],
74+
Serial.printf("%02X:%02X:%02X:%02X:%02X:%02X\r\n", wifiMACAddress[0],
7575
wifiMACAddress[1], wifiMACAddress[2], wifiMACAddress[3],
7676
wifiMACAddress[4], wifiMACAddress[5]);
7777
if (wifiState == WIFI_CONNECTED)
@@ -81,26 +81,23 @@ void menuSystem()
8181
//Display the uptime
8282
uint64_t uptimeMilliseconds = millis();
8383
uint32_t uptimeDays = 0;
84-
while (uptimeMilliseconds >= MILLISECONDS_IN_A_DAY) {
85-
uptimeMilliseconds -= MILLISECONDS_IN_A_DAY;
86-
uptimeDays += 1;
87-
}
8884
byte uptimeHours = 0;
89-
while (uptimeMilliseconds >= MILLISECONDS_IN_AN_HOUR) {
90-
uptimeMilliseconds -= MILLISECONDS_IN_AN_HOUR;
91-
uptimeHours += 1;
92-
}
9385
byte uptimeMinutes = 0;
94-
while (uptimeMilliseconds >= MILLISECONDS_IN_A_MINUTE) {
95-
uptimeMilliseconds -= MILLISECONDS_IN_A_MINUTE;
96-
uptimeMinutes += 1;
97-
}
9886
byte uptimeSeconds = 0;
99-
while (uptimeMilliseconds >= MILLISECONDS_IN_A_SECOND) {
100-
uptimeMilliseconds -= MILLISECONDS_IN_A_SECOND;
101-
uptimeSeconds += 1;
102-
}
103-
Serial.print("Uptime: ");
87+
88+
uptimeDays = uptimeMilliseconds / MILLISECONDS_IN_A_DAY;
89+
uptimeMilliseconds %= MILLISECONDS_IN_A_DAY;
90+
91+
uptimeHours = uptimeMilliseconds / MILLISECONDS_IN_AN_HOUR;
92+
uptimeMilliseconds %= MILLISECONDS_IN_AN_HOUR;
93+
94+
uptimeMinutes = uptimeMilliseconds / MILLISECONDS_IN_A_MINUTE;
95+
uptimeMilliseconds %= MILLISECONDS_IN_A_MINUTE;
96+
97+
uptimeSeconds = uptimeMilliseconds / MILLISECONDS_IN_A_SECOND;
98+
uptimeMilliseconds %= MILLISECONDS_IN_A_SECOND;
99+
100+
Serial.print("System Uptime: ");
104101
Serial.printf("%d %02d:%02d:%02d.%03lld (Resets: %d)\r\n",
105102
uptimeDays,
106103
uptimeHours,
@@ -109,6 +106,104 @@ void menuSystem()
109106
uptimeMilliseconds,
110107
settings.resetCount);
111108

109+
//Display NTRIP Client status and uptime
110+
if (settings.enableNtripClient == true && (systemState >= STATE_ROVER_NOT_STARTED && systemState <= STATE_ROVER_RTK_FIX))
111+
{
112+
Serial.print("NTRIP Client ");
113+
switch (ntripClientState)
114+
{
115+
case NTRIP_CLIENT_OFF:
116+
Serial.print("Disconnected");
117+
break;
118+
case NTRIP_CLIENT_ON:
119+
case NTRIP_CLIENT_WIFI_CONNECTING:
120+
case NTRIP_CLIENT_WIFI_CONNECTED:
121+
case NTRIP_CLIENT_CONNECTING:
122+
Serial.print("Connecting");
123+
break;
124+
case NTRIP_CLIENT_CONNECTED:
125+
Serial.print("Connected");
126+
break;
127+
default:
128+
Serial.printf("Unknown: %d", ntripClientState);
129+
break;
130+
}
131+
Serial.printf(" - %s/%s:%d", settings.ntripClient_CasterHost, settings.ntripClient_MountPoint, settings.ntripClient_CasterPort);
132+
133+
uptimeMilliseconds = ntripClientTimer - ntripClientStartTime;
134+
135+
uptimeDays = uptimeMilliseconds / MILLISECONDS_IN_A_DAY;
136+
uptimeMilliseconds %= MILLISECONDS_IN_A_DAY;
137+
138+
uptimeHours = uptimeMilliseconds / MILLISECONDS_IN_AN_HOUR;
139+
uptimeMilliseconds %= MILLISECONDS_IN_AN_HOUR;
140+
141+
uptimeMinutes = uptimeMilliseconds / MILLISECONDS_IN_A_MINUTE;
142+
uptimeMilliseconds %= MILLISECONDS_IN_A_MINUTE;
143+
144+
uptimeSeconds = uptimeMilliseconds / MILLISECONDS_IN_A_SECOND;
145+
uptimeMilliseconds %= MILLISECONDS_IN_A_SECOND;
146+
147+
Serial.print(" Uptime: ");
148+
Serial.printf("%d %02d:%02d:%02d.%03lld (Reconnects: %d)\r\n",
149+
uptimeDays,
150+
uptimeHours,
151+
uptimeMinutes,
152+
uptimeSeconds,
153+
uptimeMilliseconds,
154+
ntripClientConnectionAttempts);
155+
}
156+
157+
//Display NTRIP Server status and uptime
158+
if (settings.enableNtripServer == true && (systemState >= STATE_BASE_NOT_STARTED && systemState <= STATE_BASE_FIXED_TRANSMITTING))
159+
{
160+
Serial.print("NTRIP Server ");
161+
switch (ntripServerState)
162+
{
163+
case NTRIP_SERVER_OFF:
164+
Serial.print("Disconnected");
165+
break;
166+
case NTRIP_SERVER_ON:
167+
case NTRIP_SERVER_WIFI_CONNECTING:
168+
case NTRIP_SERVER_WIFI_CONNECTED:
169+
case NTRIP_SERVER_WAIT_GNSS_DATA:
170+
case NTRIP_SERVER_CONNECTING:
171+
case NTRIP_SERVER_AUTHORIZATION:
172+
Serial.print("Connecting");
173+
break;
174+
case NTRIP_SERVER_CASTING:
175+
Serial.print("Connected");
176+
break;
177+
default:
178+
Serial.printf("Unknown: %d", ntripServerState);
179+
break;
180+
}
181+
Serial.printf(" - %s/%s:%d", settings.ntripServer_CasterHost, settings.ntripServer_MountPoint, settings.ntripServer_CasterPort);
182+
183+
uptimeMilliseconds = ntripServerTimer - ntripServerStartTime;
184+
185+
uptimeDays = uptimeMilliseconds / MILLISECONDS_IN_A_DAY;
186+
uptimeMilliseconds %= MILLISECONDS_IN_A_DAY;
187+
188+
uptimeHours = uptimeMilliseconds / MILLISECONDS_IN_AN_HOUR;
189+
uptimeMilliseconds %= MILLISECONDS_IN_AN_HOUR;
190+
191+
uptimeMinutes = uptimeMilliseconds / MILLISECONDS_IN_A_MINUTE;
192+
uptimeMilliseconds %= MILLISECONDS_IN_A_MINUTE;
193+
194+
uptimeSeconds = uptimeMilliseconds / MILLISECONDS_IN_A_SECOND;
195+
uptimeMilliseconds %= MILLISECONDS_IN_A_SECOND;
196+
197+
Serial.print(" Uptime: ");
198+
Serial.printf("%d %02d:%02d:%02d.%03lld (Reconnects: %d)\r\n",
199+
uptimeDays,
200+
uptimeHours,
201+
uptimeMinutes,
202+
uptimeSeconds,
203+
uptimeMilliseconds,
204+
ntripServerConnectionAttempts);
205+
}
206+
112207
if (settings.enableSD == true)
113208
{
114209
Serial.println("f) Display microSD Files");

0 commit comments

Comments
 (0)