1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-24 08:36:14 +01:00

solved WiFiNINA reset/restart bug

This commit is contained in:
travis-farmer 2023-11-19 03:09:53 -05:00
parent 1d881a4b43
commit 5aca3a62d8
No known key found for this signature in database
GPG Key ID: 0BC296791D14CB35

View File

@ -122,6 +122,8 @@ bool WifiNINA::setup(const char *SSid,
DIAG(F("Forcing one more Wifi restart")); DIAG(F("Forcing one more Wifi restart"));
// esp_wifi_start(); // esp_wifi_start();
// esp_wifi_connect(); // esp_wifi_connect();
WiFi.end();
WiFi.begin(SSid, password);
tries=40; tries=40;
while (WiFi.status() != WL_CONNECTED && tries) { while (WiFi.status() != WL_CONNECTED && tries) {
Serial.print('.'); Serial.print('.');
@ -219,7 +221,7 @@ void WifiNINA::checkForNewClient() {
for (byte clientId=0; clientId<MAX_CLIENTS; clientId++){ for (byte clientId=0; clientId<MAX_CLIENTS; clientId++){
if (!clients[clientId]) { if (!clients[clientId]) {
clients[clientId]= new WiFiClient(newClient); // use this slot clients[clientId]= new WiFiClient(newClient); // use this slot
DIAG(F("New client connected to slot %d"),clientId); //TJF: brought in for debugging. //DIAG(F("New client connected to slot %d"),clientId); //TJF: brought in for debugging.
return; return;
} }
} }
@ -230,7 +232,7 @@ void WifiNINA::checkForLostClients() {
auto c=clients[clientId]; auto c=clients[clientId];
if(c && !c->connected()) { if(c && !c->connected()) {
clients[clientId]->stop(); clients[clientId]->stop();
DIAG(F("Remove client %d"), clientId); //DIAG(F("Remove client %d"), clientId);
CommandDistributor::forget(clientId); CommandDistributor::forget(clientId);
clients[clientId]=nullptr; clients[clientId]=nullptr;
} }
@ -264,7 +266,7 @@ void WifiNINA::checkForClientOutput() {
if (!c) { if (!c) {
// client is gone, throw away msg // client is gone, throw away msg
for (int i=0;i<replySize;i++) outboundRing->read(); for (int i=0;i<replySize;i++) outboundRing->read();
DIAG(F("gone, drop message.")); //TJF: only for diag //DIAG(F("gone, drop message.")); //TJF: only for diag
return; return;
} }
// emit data to the client object // emit data to the client object