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

Compare commits

...

4 Commits

Author SHA1 Message Date
Travis Farmer
8927ec2e29
Merge 5aca3a62d8 into d46a6f092a 2023-11-19 08:10:27 +00:00
travis-farmer
5aca3a62d8
solved WiFiNINA reset/restart bug 2023-11-19 03:09:53 -05:00
travis-farmer
1d881a4b43
cleaning up 2023-11-18 14:07:19 -05:00
travis-farmer
330bdf58a1
works, but uses multi connects per client 2023-11-18 13:43:31 -05:00

View File

@ -122,6 +122,8 @@ bool WifiNINA::setup(const char *SSid,
DIAG(F("Forcing one more Wifi restart"));
// esp_wifi_start();
// esp_wifi_connect();
WiFi.end();
WiFi.begin(SSid, password);
tries=40;
while (WiFi.status() != WL_CONNECTED && tries) {
Serial.print('.');
@ -219,8 +221,7 @@ void WifiNINA::checkForNewClient() {
for (byte clientId=0; clientId<MAX_CLIENTS; clientId++){
if (!clients[clientId]) {
clients[clientId]= new WiFiClient(newClient); // use this slot
clients[clientId]->flush(); // clear out the input buffer
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;
}
}
@ -231,9 +232,8 @@ void WifiNINA::checkForLostClients() {
auto c=clients[clientId];
if(c && !c->connected()) {
clients[clientId]->stop();
DIAG(F("Remove client %d"), clientId);
//DIAG(F("Remove client %d"), clientId);
CommandDistributor::forget(clientId);
//delete c; //TJF: this causes a crash when client drops.. commenting out for now.
clients[clientId]=nullptr;
}
}
@ -266,16 +266,11 @@ void WifiNINA::checkForClientOutput() {
if (!c) {
// client is gone, throw away msg
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;
}
// emit data to the client object
// This should work in theory, the
//DIAG(F("send message")); //TJF: only for diag
//TJF: the old code had to add a 0x00 byte to the end to terminate the
//TJF: c string, before sending it. i take it this is not needed?
for (int i=0;i<replySize;i++) c->write(outboundRing->read());
//c->write((byte)0x00);
}
void WifiNINA::loop() {