@@ -130,16 +130,24 @@ bool ntripServerConnectLimitReached()
130130 ntripServerStop (false ); // Allocate new wifiClient
131131
132132 // 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);
136134
135+ ntripServerConnectionAttempts++;
137136 ntripServerConnectionAttemptsTotal++;
138137
139138 if (limitReached == false )
140139 {
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
143151
144152 reportHeapNow ();
145153 }
@@ -419,8 +427,18 @@ void ntripServerUpdate()
419427 {
420428 if (online.ethernetStatus == ETH_CONNECTED)
421429 ntripServerSetState (NTRIP_SERVER_WIFI_ETHERNET_CONNECTED);
422- else
430+ else if (online. ethernetStatus == ETH_CAN_NOT_BEGIN) // Ethernet hardware failure or not available
423431 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+ }
424442 }
425443 else
426444 {
@@ -456,18 +474,20 @@ void ntripServerUpdate()
456474 // Attempt a connection to the NTRIP caster
457475 if (!ntripServerConnectCaster ())
458476 {
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-
466477 // Assume service not available
467- if (ntripServerConnectLimitReached ())
478+ if (ntripServerConnectLimitReached ()) // Update ntripServerConnectionAttemptTimeout
468479 {
469480 systemPrintln (" NTRIP Server failed to connect! Do you have your caster address and port correct?" );
470481 }
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+ }
471491 }
472492 else
473493 {
0 commit comments