@@ -175,6 +175,9 @@ const char * const ntripClientStateName[] =
175
175
176
176
const int ntripClientStateNameEntries = sizeof (ntripClientStateName) / sizeof (ntripClientStateName[0 ]);
177
177
178
+ const RtkMode_t ntripClientMode = RTK_MODE_ROVER
179
+ | RTK_MODE_BASE_SURVEY_IN;
180
+
178
181
// ----------------------------------------
179
182
// Locals
180
183
// ----------------------------------------
@@ -307,6 +310,10 @@ bool ntripClientConnectLimitReached()
307
310
// Retry the connection a few times
308
311
bool limitReached = (ntripClientConnectionAttempts >= MAX_NTRIP_CLIENT_CONNECTION_ATTEMPTS);
309
312
313
+ // Attempt to restart the network if possible
314
+ if (settings.enableNtripClient && (!limitReached))
315
+ networkRestart (NETWORK_USER_NTRIP_CLIENT);
316
+
310
317
// Restart the NTRIP client
311
318
ntripClientStop (limitReached || (!settings.enableNtripClient ));
312
319
@@ -345,28 +352,6 @@ bool ntripClientConnectLimitReached()
345
352
return limitReached;
346
353
}
347
354
348
- // Determine if NTRIP Client is needed
349
- bool ntripClientIsNeeded ()
350
- {
351
- if (settings.enableNtripClient == false )
352
- {
353
- // If user turns off NTRIP Client via settings, stop server
354
- if (ntripClientState > NTRIP_CLIENT_OFF)
355
- ntripClientShutdown ();
356
- return (false );
357
- }
358
-
359
- if (wifiInConfigMode ())
360
- return (false ); // Do not service NTRIP during network config
361
-
362
- // Allow NTRIP Client to run during Survey-In,
363
- // but do not allow NTRIP Client to run during Base
364
- if (systemState == STATE_BASE_TEMP_TRANSMITTING)
365
- return (false );
366
-
367
- return (true );
368
- }
369
-
370
355
// Print the NTRIP client state summary
371
356
void ntripClientPrintStateSummary ()
372
357
{
@@ -504,20 +489,12 @@ void ntripClientShutdown()
504
489
// Start the NTRIP client
505
490
void ntripClientStart ()
506
491
{
507
- // Stop NTRIP client
508
- ntripClientShutdown ();
509
-
510
492
// Display the heap state
511
493
reportHeapNow (settings.debugNtripClientState );
512
494
513
- // Start the NTRIP client if enabled
514
- if (settings.enableNtripClient == true )
515
- {
516
- systemPrintln (" NTRIP Client start" );
517
- ntripClientSetState (NTRIP_CLIENT_ON);
518
- }
519
-
520
- ntripClientConnectionAttempts = 0 ;
495
+ // Start the NTRIP client
496
+ systemPrintln (" NTRIP Client start" );
497
+ ntripClientStop (false );
521
498
}
522
499
523
500
// Shutdown or restart the NTRIP client
@@ -529,14 +506,6 @@ void ntripClientStop(bool shutdown)
529
506
if (ntripClient->connected ())
530
507
ntripClient->stop ();
531
508
532
- // Attempt to restart the network if possible
533
- if (!shutdown)
534
- networkRestart (NETWORK_USER_NTRIP_CLIENT);
535
-
536
- // Done with the network
537
- if (networkGetUserNetwork (NETWORK_USER_NTRIP_CLIENT))
538
- networkUserClose (NETWORK_USER_NTRIP_CLIENT);
539
-
540
509
// Free the NTRIP client resources
541
510
delete ntripClient;
542
511
ntripClient = nullptr ;
@@ -545,9 +514,15 @@ void ntripClientStop(bool shutdown)
545
514
546
515
// Increase timeouts if we started the network
547
516
if (ntripClientState > NTRIP_CLIENT_ON)
517
+ {
548
518
// Mark the Client stop so that we don't immediately attempt re-connect to Caster
549
519
ntripClientTimer = millis ();
550
520
521
+ // Done with the network
522
+ if (networkGetUserNetwork (NETWORK_USER_NTRIP_CLIENT))
523
+ networkUserClose (NETWORK_USER_NTRIP_CLIENT);
524
+ }
525
+
551
526
// Return the Main Talker ID to "GN".
552
527
if (online.gnss )
553
528
{
@@ -556,23 +531,42 @@ void ntripClientStop(bool shutdown)
556
531
}
557
532
558
533
// Determine the next NTRIP client state
559
- ntripClientSetState (shutdown ? NTRIP_CLIENT_OFF : NTRIP_CLIENT_ON);
560
534
online.ntripClient = false ;
561
535
netIncomingRTCM = false ;
536
+ if (shutdown)
537
+ {
538
+ ntripClientSetState (NTRIP_CLIENT_OFF);
539
+ settings.enableNtripClient = false ;
540
+ ntripClientConnectionAttempts = 0 ;
541
+ ntripClientConnectionAttemptTimeout = 0 ;
542
+ }
543
+ else
544
+ ntripClientSetState (NTRIP_CLIENT_ON);
562
545
}
563
546
564
547
// Check for the arrival of any correction data. Push it to the GNSS.
565
548
// Stop task if the connection has dropped or if we receive no data for maxTimeBeforeHangup_ms
566
549
void ntripClientUpdate ()
567
550
{
568
- if (ntripClientIsNeeded () == false )
569
- return ;
551
+ // Shutdown the NTRIP client when the mode or setting changes
552
+ DMW_st (ntripClientSetState, ntripClientState);
553
+ if (NEQ_RTK_MODE (ntripClientMode) || (!settings.enableNtripClient ))
554
+ {
555
+ if (ntripClientState > NTRIP_CLIENT_OFF)
556
+ {
557
+ ntripClientStop (false );
558
+ ntripClientConnectionAttempts = 0 ;
559
+ ntripClientConnectionAttemptTimeout = 0 ;
560
+ ntripClientSetState (NTRIP_CLIENT_OFF);
561
+ }
562
+ }
570
563
571
564
// Enable the network and the NTRIP client if requested
572
- DMW_st (ntripClientSetState, ntripClientState);
573
565
switch (ntripClientState)
574
566
{
575
567
case NTRIP_CLIENT_OFF:
568
+ if (EQ_RTK_MODE (ntripClientMode) && settings.enableNtripClient )
569
+ ntripClientStart ();
576
570
break ;
577
571
578
572
// Start the network
0 commit comments