@@ -130,16 +130,24 @@ bool ntripServerConnectLimitReached()
130
130
ntripServerStop (false ); // Allocate new wifiClient
131
131
132
132
// Retry the connection a few times
133
- bool limitReached = false ;
134
- if (ntripServerConnectionAttempts++ >= MAX_NTRIP_SERVER_CONNECTION_ATTEMPTS)
135
- limitReached = true ;
133
+ bool limitReached = (ntripServerConnectionAttempts >= MAX_NTRIP_SERVER_CONNECTION_ATTEMPTS);
136
134
135
+ ntripServerConnectionAttempts++;
137
136
ntripServerConnectionAttemptsTotal++;
138
137
139
138
if (limitReached == false )
140
139
{
141
- ntripServerConnectionAttemptTimeout =
142
- ntripServerConnectionAttempts * 5 * 60 * 1000L ; // Wait 5, 10, 15, etc minutes between attempts
140
+ if (ntripServerConnectionAttempts == 1 )
141
+ ntripServerConnectionAttemptTimeout = 15 * 1000L ; // Wait 15s
142
+ else if (ntripServerConnectionAttempts == 2 )
143
+ ntripServerConnectionAttemptTimeout = 30 * 1000L ; // Wait 30s
144
+ else if (ntripServerConnectionAttempts == 3 )
145
+ ntripServerConnectionAttemptTimeout = 1 * 60 * 1000L ; // Wait 1 minute
146
+ else if (ntripServerConnectionAttempts == 4 )
147
+ ntripServerConnectionAttemptTimeout = 2 * 60 * 1000L ; // Wait 2 minutes
148
+ else
149
+ ntripServerConnectionAttemptTimeout =
150
+ (ntripServerConnectionAttempts - 4 ) * 5 * 60 * 1000L ; // Wait 5, 10, 15, etc minutes between attempts
143
151
144
152
reportHeapNow ();
145
153
}
@@ -419,8 +427,18 @@ void ntripServerUpdate()
419
427
{
420
428
if (online.ethernetStatus == ETH_CONNECTED)
421
429
ntripServerSetState (NTRIP_SERVER_WIFI_ETHERNET_CONNECTED);
422
- else
430
+ else if (online. ethernetStatus == ETH_CAN_NOT_BEGIN) // Ethernet hardware failure or not available
423
431
ntripServerSetState (NTRIP_SERVER_OFF);
432
+ else
433
+ {
434
+ // Wait for ethernet to connect
435
+ static unsigned long lastDebug = millis ();
436
+ if (millis () > (lastDebug + 5000 ))
437
+ {
438
+ lastDebug = millis ();
439
+ log_d (" NTRIP Server: Ethernet not connected. Waiting to retry." );
440
+ }
441
+ }
424
442
}
425
443
else
426
444
{
@@ -456,18 +474,20 @@ void ntripServerUpdate()
456
474
// Attempt a connection to the NTRIP caster
457
475
if (!ntripServerConnectCaster ())
458
476
{
459
- if (ntripServerConnectionAttemptTimeout / 1000 < 120 )
460
- systemPrintf (" NTRIP Server failed to connect to caster. Trying again in %d seconds.\r\n " ,
461
- ntripServerConnectionAttemptTimeout / 1000 );
462
- else
463
- systemPrintf (" NTRIP Server failed to connect to caster. Trying again in %d minutes.\r\n " ,
464
- ntripServerConnectionAttemptTimeout / 1000 / 60 );
465
-
466
477
// Assume service not available
467
- if (ntripServerConnectLimitReached ())
478
+ if (ntripServerConnectLimitReached ()) // Update ntripServerConnectionAttemptTimeout
468
479
{
469
480
systemPrintln (" NTRIP Server failed to connect! Do you have your caster address and port correct?" );
470
481
}
482
+ else
483
+ {
484
+ if (ntripServerConnectionAttemptTimeout / 1000 < 120 )
485
+ systemPrintf (" NTRIP Server failed to connect to caster. Trying again in %d seconds.\r\n " ,
486
+ ntripServerConnectionAttemptTimeout / 1000 );
487
+ else
488
+ systemPrintf (" NTRIP Server failed to connect to caster. Trying again in %d minutes.\r\n " ,
489
+ ntripServerConnectionAttemptTimeout / 1000 / 60 );
490
+ }
471
491
}
472
492
else
473
493
{
0 commit comments