Skip to content

Commit f0291af

Browse files
authored
Merge pull request #527 from LeeLeahy2/wifi-comments
Change NTRIP to use network or NTRIP instead of WiFi
2 parents f651ba7 + 6bdf09d commit f0291af

File tree

4 files changed

+102
-102
lines changed

4 files changed

+102
-102
lines changed

Firmware/RTK_Surveyor/NtripClient.ino

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ void ntripClientUpdate() {}
1111

1212
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1313
NTRIP Client States:
14-
NTRIP_CLIENT_OFF: WiFi off or using NTRIP server
14+
NTRIP_CLIENT_OFF: Network off or using NTRIP server
1515
NTRIP_CLIENT_ON: WIFI_START state
16-
NTRIP_CLIENT_WIFI_ETHERNET_STARTED: Connecting to WiFi access point or Ethernet network
17-
NTRIP_CLIENT_WIFI_ETHERNET_CONNECTED: WiFi connected to an access point or network
16+
NTRIP_CLIENT_NETWORK_STARTED: Connecting to the network
17+
NTRIP_CLIENT_NETWORK_CONNECTED: Connected to the network
1818
NTRIP_CLIENT_CONNECTING: Attempting a connection to the NTRIP caster
1919
NTRIP_CLIENT_CONNECTED: Connected to the NTRIP caster
2020
@@ -26,11 +26,11 @@ void ntripClientUpdate() {}
2626
| |
2727
| | ntripClientStop(false)
2828
v Fail |
29-
NTRIP_CLIENT_WIFI_ETHERNET_STARTED ----->+
29+
NTRIP_CLIENT_NETWORK_STARTED ------->+
3030
| ^
3131
| |
3232
v Fail |
33-
NTRIP_CLIENT_WIFI_ETHERNET_CONNECTED --->+
33+
NTRIP_CLIENT_NETWORK_CONNECTED ------>+
3434
| ^
3535
| |
3636
v Fail |
@@ -72,7 +72,7 @@ static const int NTRIPCLIENT_MS_BETWEEN_GGA = 5000; // 5s between transmission o
7272
// Locals - compiled out
7373
//----------------------------------------
7474

75-
// The WiFi / Ethernet connection to the NTRIP caster to obtain RTCM data.
75+
// The network connection to the NTRIP caster to obtain RTCM data.
7676
static NetworkClient *ntripClient;
7777

7878
// Throttle the time between connection attempts
@@ -174,7 +174,7 @@ bool ntripClientConnect()
174174
bool ntripClientConnectLimitReached()
175175
{
176176
// Shutdown the NTRIP client
177-
ntripClientStop(false); // Allocate new wifiClient
177+
ntripClientStop(false); // Allocate new ntripClient
178178

179179
// Retry the connection a few times
180180
bool limitReached = (ntripClientConnectionAttempts >= MAX_NTRIP_CLIENT_CONNECTION_ATTEMPTS);
@@ -194,8 +194,8 @@ bool ntripClientConnectLimitReached()
194194
// No more connection attempts, switching to Bluetooth
195195
systemPrintln("NTRIP Client connection attempts exceeded!");
196196

197-
// Stop WiFi operations
198-
ntripClientStop(true); // Do not allocate new wifiClient
197+
// Stop NTRIP client operations
198+
ntripClientStop(true); // Do not allocate new ntripClient
199199
}
200200
return limitReached;
201201
}
@@ -241,11 +241,11 @@ void ntripClientSetState(NTRIPClientState newState)
241241
case NTRIP_CLIENT_ON:
242242
systemPrintln("NTRIP_CLIENT_ON");
243243
break;
244-
case NTRIP_CLIENT_WIFI_ETHERNET_STARTED:
245-
systemPrintln("NTRIP_CLIENT_WIFI_ETHERNET_STARTED");
244+
case NTRIP_CLIENT_NETWORK_STARTED:
245+
systemPrintln("NTRIP_CLIENT_NETWORK_STARTED");
246246
break;
247-
case NTRIP_CLIENT_WIFI_ETHERNET_CONNECTED:
248-
systemPrintln("NTRIP_CLIENT_WIFI_ETHERNET_CONNECTED");
247+
case NTRIP_CLIENT_NETWORK_CONNECTED:
248+
systemPrintln("NTRIP_CLIENT_NETWORK_CONNECTED");
249249
break;
250250
case NTRIP_CLIENT_CONNECTING:
251251
systemPrintln("NTRIP_CLIENT_CONNECTING");
@@ -262,8 +262,8 @@ void ntripClientSetState(NTRIPClientState newState)
262262

263263
void ntripClientStart()
264264
{
265-
// Stop NTRIP client and WiFi
266-
ntripClientStop(true); // Do not allocate new wifiClient
265+
// Stop NTRIP client
266+
ntripClientStop(true); // Do not allocate new ntripClient
267267

268268
// Start the NTRIP client if enabled
269269
if (settings.enableNtripClient == true)
@@ -275,7 +275,7 @@ void ntripClientStart()
275275
// Allocate the ntripClient structure
276276
ntripClient = new NetworkClient(false);
277277

278-
// Startup WiFi and the NTRIP client
278+
// Startup the network and the NTRIP client
279279
if (ntripClient)
280280
ntripClientSetState(NTRIP_CLIENT_ON);
281281
}
@@ -284,7 +284,7 @@ void ntripClientStart()
284284
}
285285

286286
// Stop the NTRIP client
287-
void ntripClientStop(bool wifiClientAllocated)
287+
void ntripClientStop(bool clientAllocated)
288288
{
289289
if (ntripClient)
290290
{
@@ -297,11 +297,11 @@ void ntripClientStop(bool wifiClientAllocated)
297297
ntripClient = nullptr;
298298

299299
// Allocate the ntripClient structure if not done
300-
if (wifiClientAllocated == false)
300+
if (clientAllocated == false)
301301
ntripClient = new NetworkClient(false);
302302
}
303303

304-
// Increase timeouts if we started WiFi
304+
// Increase timeouts if we started the network
305305
if (ntripClientState > NTRIP_CLIENT_ON)
306306
{
307307
ntripClientLastConnectionAttempt =
@@ -318,7 +318,7 @@ void ntripClientStop(bool wifiClientAllocated)
318318
}
319319

320320
// Determine the next NTRIP client state
321-
ntripClientSetState((ntripClient && (wifiClientAllocated == false)) ? NTRIP_CLIENT_ON : NTRIP_CLIENT_OFF);
321+
ntripClientSetState((ntripClient && (clientAllocated == false)) ? NTRIP_CLIENT_ON : NTRIP_CLIENT_OFF);
322322
online.ntripClient = false;
323323
netIncomingRTCM = false;
324324
}
@@ -330,12 +330,12 @@ bool ntripClientIsNeeded()
330330
{
331331
// If user turns off NTRIP Client via settings, stop server
332332
if (ntripClientState > NTRIP_CLIENT_OFF)
333-
ntripClientStop(true); // Don't allocate new wifiClient
333+
ntripClientStop(true); // Don't allocate new ntripClient
334334
return (false);
335335
}
336336

337337
if (wifiInConfigMode())
338-
return (false); // Do not service NTRIP during WiFi config
338+
return (false); // Do not service NTRIP during network config
339339

340340
// Allow NTRIP Client to run during Survey-In,
341341
// but do not allow NTRIP Client to run during Base
@@ -366,20 +366,20 @@ void ntripClientUpdate()
366366
lastNtripClientState = millis();
367367
}
368368

369-
// Enable WiFi and the NTRIP client if requested
369+
// Enable the network and the NTRIP client if requested
370370
switch (ntripClientState)
371371
{
372372
case NTRIP_CLIENT_OFF:
373373
break;
374374

375-
// Start WiFi
375+
// Start the network
376376
case NTRIP_CLIENT_ON: {
377377
if (HAS_ETHERNET) // && !settings.ntripClientUseWiFiNotEthernet) //For future expansion
378378
{
379379
if (online.ethernetStatus == ETH_NOT_STARTED)
380380
{
381381
systemPrintln("Ethernet not started. Can not start NTRIP Client");
382-
ntripClientStop(false); // Do allocate new WiFi / Ethernet Client
382+
ntripClientStop(false); // Allocate a new ntripClient
383383
}
384384
else if ((online.ethernetStatus >= ETH_STARTED_CHECK_CABLE) && (online.ethernetStatus <= ETH_CONNECTED))
385385
{
@@ -389,21 +389,21 @@ void ntripClientUpdate()
389389
ntripClientLastConnectionAttempt = millis();
390390
log_d("NTRIP Client starting on Ethernet");
391391
ntripClientTimer = millis();
392-
ntripClientSetState(NTRIP_CLIENT_WIFI_ETHERNET_STARTED);
392+
ntripClientSetState(NTRIP_CLIENT_NETWORK_STARTED);
393393
}
394394
}
395395
else
396396
{
397397
systemPrintln("Error: Please connect Ethernet before starting NTRIP Client");
398-
ntripClientStop(true); // Do not allocate new wifiClient
398+
ntripClientStop(true); // Do not allocate new ntripClient
399399
}
400400
}
401401
else
402402
{
403403
if (wifiNetworkCount() == 0)
404404
{
405405
systemPrintln("Error: Please enter at least one SSID before starting NTRIP Client");
406-
ntripClientStop(true); // Do not allocate new wifiClient
406+
ntripClientStop(true); // Do not allocate new ntripClient
407407
}
408408
else
409409
{
@@ -414,30 +414,30 @@ void ntripClientUpdate()
414414
log_d("NTRIP Client starting WiFi");
415415
wifiStart();
416416
ntripClientTimer = millis();
417-
ntripClientSetState(NTRIP_CLIENT_WIFI_ETHERNET_STARTED);
417+
ntripClientSetState(NTRIP_CLIENT_NETWORK_STARTED);
418418
}
419419
}
420420
}
421421
}
422422
break;
423423

424-
case NTRIP_CLIENT_WIFI_ETHERNET_STARTED:
424+
case NTRIP_CLIENT_NETWORK_STARTED:
425425
if ((millis() - ntripClientTimer) > (1 * 60 * 1000))
426426
// Failed to connect to to the network, attempt to restart the network
427427
ntripClientStop(false);
428428
else if (HAS_ETHERNET) // && !settings.ntripClientUseWiFiNotEthernet) //For future expansion
429429
{
430430
if (online.ethernetStatus == ETH_CONNECTED)
431-
ntripClientSetState(NTRIP_CLIENT_WIFI_ETHERNET_CONNECTED);
431+
ntripClientSetState(NTRIP_CLIENT_NETWORK_CONNECTED);
432432
}
433433
else
434434
{
435435
if (wifiIsConnected())
436-
ntripClientSetState(NTRIP_CLIENT_WIFI_ETHERNET_CONNECTED);
436+
ntripClientSetState(NTRIP_CLIENT_NETWORK_CONNECTED);
437437
}
438438
break;
439439

440-
case NTRIP_CLIENT_WIFI_ETHERNET_CONNECTED: {
440+
case NTRIP_CLIENT_NETWORK_CONNECTED: {
441441
// If GGA transmission is enabled, wait for GNSS lock before connecting to NTRIP Caster
442442
// If GGA transmission is not enabled, start connecting to NTRIP Caster
443443
if ((settings.ntripClient_TransmitGGA == true && (fixType == 3 || fixType == 4 || fixType == 5)) ||
@@ -478,8 +478,8 @@ void ntripClientUpdate()
478478
{
479479
systemPrintln("NTRIP Caster failed to respond. Do you have your caster address and port correct?");
480480

481-
// Stop WiFi operations
482-
ntripClientStop(true); // Do not allocate new wifiClient
481+
// Stop NTRIP client operations
482+
ntripClientStop(true); // Do not allocate new ntripClient
483483
}
484484
else
485485
{
@@ -541,25 +541,25 @@ void ntripClientUpdate()
541541
"NTRIP Caster responded with bad news: %s. Are you sure your caster credentials are correct?\r\n",
542542
response);
543543

544-
// Stop WiFi operations
545-
ntripClientStop(true); // Do not allocate new wifiClient
544+
// Stop NTRIP client operations
545+
ntripClientStop(true); // Do not allocate new ntripClient
546546
}
547547
else if (strstr(response, "banned") != nullptr)
548548
{
549549
// Look for 'HTTP/1.1 200 OK' and banned IP information
550550
systemPrintf("NTRIP Client connected to caster but caster responded with problem: %s\r\n", response);
551551

552-
// Stop WiFi operations
553-
ntripClientStop(true); // Do not allocate new wifiClient
552+
// Stop NTRIP client operations
553+
ntripClientStop(true); // Do not allocate new ntripClient
554554
}
555555
else if (strstr(response, "SOURCETABLE") != nullptr)
556556
{
557557
// Look for 'SOURCETABLE 200 OK'
558558
systemPrintf("Caster may not have mountpoint %s. Caster responded with problem: %s\r\n",
559559
settings.ntripClient_MountPoint, response);
560560

561-
// Stop WiFi operations
562-
ntripClientStop(true); // Do not allocate new wifiClient
561+
// Stop NTRIP client operations
562+
ntripClientStop(true); // Do not allocate new ntripClient
563563
}
564564
// Other errors returned by the caster
565565
else
@@ -590,7 +590,7 @@ void ntripClientUpdate()
590590
{
591591
// Broken connection, retry the NTRIP client connection
592592
systemPrintln("NTRIP Client connection to caster was broken");
593-
ntripClientStop(false); // Allocate new wifiClient
593+
ntripClientStop(false); // Allocate new ntripClient
594594
}
595595
else
596596
{
@@ -601,7 +601,7 @@ void ntripClientUpdate()
601601
{
602602
// Timeout receiving NTRIP data, retry the NTRIP client connection
603603
systemPrintln("NTRIP Client: No data received timeout");
604-
ntripClientStop(false); // Allocate new wifiClient
604+
ntripClientStop(false); // Allocate new ntripClient
605605
}
606606
}
607607
else

0 commit comments

Comments
 (0)