@@ -1080,7 +1080,6 @@ void networkTypeUpdate(uint8_t networkType)
10801080 {
10811081 if (settings.debugNetworkLayer )
10821082 systemPrintf (" Network connected to %s\r\n " , networkName[network->type ]);
1083- network->connectionAttempt = 0 ;
10841083 network->timerStart = millis ();
10851084 network->timeout = NETWORK_MAX_IDLE_TIME;
10861085 network->activeUsers = network->userOpens ;
@@ -1095,14 +1094,6 @@ void networkTypeUpdate(uint8_t networkType)
10951094 if (network->shutdown )
10961095 networkStop (network->type );
10971096
1098- // Without users there is no need for the network.
1099- else if ((!network->activeUsers ) && ((millis () - network->timerStart ) >= network->timeout ))
1100- {
1101- if (settings.debugNetworkLayer )
1102- systemPrintf (" Network shutting down %s, no users\r\n " , networkName[network->type ]);
1103- networkStop (network->type );
1104- }
1105-
11061097 // Verify that the RTK device is still connected to the network
11071098 else if (!networkIsMediaConnected (network))
11081099 {
@@ -1112,6 +1103,29 @@ void networkTypeUpdate(uint8_t networkType)
11121103 networkRestartNetwork (network);
11131104 networkStop (network->type );
11141105 }
1106+
1107+ // Check for the idle timeout
1108+ else if ((millis () - network->timerStart ) >= network->timeout )
1109+ {
1110+ // Determine if the network is in use
1111+ network->timerStart = millis ();
1112+ if (network->activeUsers )
1113+ {
1114+ // Network in use, reduce future connection delays
1115+ network->connectionAttempt = 0 ;
1116+
1117+ // Set the next time that network idle should be checked
1118+ network->timeout = NETWORK_MAX_IDLE_TIME;
1119+ }
1120+
1121+ // Without users there is no need for the network.
1122+ else
1123+ {
1124+ if (settings.debugNetworkLayer )
1125+ systemPrintf (" Network shutting down %s, no users\r\n " , networkName[network->type ]);
1126+ networkStop (network->type );
1127+ }
1128+ }
11151129 break ;
11161130
11171131 case NETWORK_STATE_WAIT_NO_USERS:
0 commit comments