mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-27 18:16:13 +01:00
Compare commits
7 Commits
911421e8d7
...
c8f1e76172
Author | SHA1 | Date | |
---|---|---|---|
|
c8f1e76172 | ||
|
bd44184f57 | ||
|
e7d3d92c23 | ||
|
e3bab887a2 | ||
|
041a6534da | ||
|
198d762a21 | ||
|
2afb5f3d6c |
|
@ -1 +1 @@
|
||||||
#define GITHUB_SHA "devel-202312131041Z"
|
#define GITHUB_SHA "devel-202312251647Z"
|
||||||
|
|
|
@ -74,25 +74,39 @@ class NetworkClient {
|
||||||
public:
|
public:
|
||||||
NetworkClient(WiFiClient c) {
|
NetworkClient(WiFiClient c) {
|
||||||
wifi = c;
|
wifi = c;
|
||||||
|
inUse = true;
|
||||||
};
|
};
|
||||||
bool ok() {
|
bool active(byte clientId) {
|
||||||
return (inUse && wifi.connected());
|
if (!inUse)
|
||||||
};
|
|
||||||
bool recycle(WiFiClient c) {
|
|
||||||
|
|
||||||
if (inUse == true) return false;
|
|
||||||
|
|
||||||
// return false here until we have
|
|
||||||
// implemented a LRU timer
|
|
||||||
// if (LRU too recent) return false;
|
|
||||||
return false;
|
return false;
|
||||||
|
if(!wifi.connected()) {
|
||||||
|
DIAG(F("Remove client %d"), clientId);
|
||||||
|
CommandDistributor::forget(clientId);
|
||||||
|
wifi.stop();
|
||||||
|
inUse = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool recycle(WiFiClient c) {
|
||||||
|
if (wifi == c) {
|
||||||
|
if (inUse == true)
|
||||||
|
DIAG(F("WARNING: Duplicate"));
|
||||||
|
else
|
||||||
|
DIAG(F("Returning"));
|
||||||
|
inUse = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (inUse == false) {
|
||||||
wifi = c;
|
wifi = c;
|
||||||
inUse = true;
|
inUse = true;
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
WiFiClient wifi;
|
WiFiClient wifi;
|
||||||
bool inUse = true;
|
private:
|
||||||
|
bool inUse;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<NetworkClient> clients; // a list to hold all clients
|
static std::vector<NetworkClient> clients; // a list to hold all clients
|
||||||
|
@ -282,37 +296,26 @@ void WifiESP::loop() {
|
||||||
// really no good way to check for LISTEN especially in AP mode?
|
// really no good way to check for LISTEN especially in AP mode?
|
||||||
wl_status_t wlStatus;
|
wl_status_t wlStatus;
|
||||||
if (APmode || (wlStatus = WiFi.status()) == WL_CONNECTED) {
|
if (APmode || (wlStatus = WiFi.status()) == WL_CONNECTED) {
|
||||||
// loop over all clients and remove inactive
|
|
||||||
for (clientId=0; clientId<clients.size(); clientId++){
|
|
||||||
// check if client is there and alive
|
|
||||||
if(clients[clientId].inUse && !clients[clientId].wifi.connected()) {
|
|
||||||
DIAG(F("Remove client %d"), clientId);
|
|
||||||
CommandDistributor::forget(clientId);
|
|
||||||
clients[clientId].wifi.stop();
|
|
||||||
clients[clientId].inUse = false;
|
|
||||||
//Do NOT clients.erase(clients.begin()+clientId) as
|
|
||||||
//that would mix up clientIds for later.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (server->hasClient()) {
|
if (server->hasClient()) {
|
||||||
WiFiClient client;
|
WiFiClient client;
|
||||||
while (client = server->available()) {
|
while (client = server->available()) {
|
||||||
for (clientId=0; clientId<clients.size(); clientId++){
|
for (clientId=0; clientId<clients.size(); clientId++){
|
||||||
if (clients[clientId].recycle(client)) {
|
if (clients[clientId].recycle(client)) {
|
||||||
DIAG(F("Recycle client %d %s"), clientId, client.remoteIP().toString().c_str());
|
DIAG(F("Recycle client %d %s:%d"), clientId, client.remoteIP().toString().c_str(),client.remotePort());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (clientId>=clients.size()) {
|
if (clientId>=clients.size()) {
|
||||||
NetworkClient nc(client);
|
NetworkClient nc(client);
|
||||||
clients.push_back(nc);
|
clients.push_back(nc);
|
||||||
DIAG(F("New client %d, %s"), clientId, client.remoteIP().toString().c_str());
|
DIAG(F("New client %d, %s:%d"), clientId, client.remoteIP().toString().c_str(),client.remotePort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// loop over all connected clients
|
// loop over all connected clients
|
||||||
|
// this removes as a side effect inactive clients when checking ::active()
|
||||||
for (clientId=0; clientId<clients.size(); clientId++){
|
for (clientId=0; clientId<clients.size(); clientId++){
|
||||||
if(clients[clientId].ok()) {
|
if(clients[clientId].active(clientId)) {
|
||||||
int len;
|
int len;
|
||||||
if ((len = clients[clientId].wifi.available()) > 0) {
|
if ((len = clients[clientId].wifi.available()) > 0) {
|
||||||
// read data from client
|
// read data from client
|
||||||
|
@ -350,7 +353,7 @@ void WifiESP::loop() {
|
||||||
}
|
}
|
||||||
// buffer filled, end with '\0' so we can use it as C string
|
// buffer filled, end with '\0' so we can use it as C string
|
||||||
buffer[count]='\0';
|
buffer[count]='\0';
|
||||||
if((unsigned int)clientId <= clients.size() && clients[clientId].ok()) {
|
if((unsigned int)clientId <= clients.size() && clients[clientId].active(clientId)) {
|
||||||
if (Diag::CMD || Diag::WITHROTTLE)
|
if (Diag::CMD || Diag::WITHROTTLE)
|
||||||
DIAG(F("SEND %d:%s"), clientId, buffer);
|
DIAG(F("SEND %d:%s"), clientId, buffer);
|
||||||
clients[clientId].wifi.write(buffer,count);
|
clients[clientId].wifi.write(buffer,count);
|
||||||
|
@ -383,8 +386,9 @@ void WifiESP::loop() {
|
||||||
// prio task. On core1 this is not a problem
|
// prio task. On core1 this is not a problem
|
||||||
// as there the wdt is disabled by the
|
// as there the wdt is disabled by the
|
||||||
// arduio IDE startup routines.
|
// arduio IDE startup routines.
|
||||||
if (xPortGetCoreID() == 0)
|
if (xPortGetCoreID() == 0) {
|
||||||
feedTheDog0();
|
feedTheDog0();
|
||||||
yield();
|
yield();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif //ESP32
|
#endif //ESP32
|
||||||
|
|
|
@ -68,7 +68,9 @@ Stream * WifiInterface::wifiStream;
|
||||||
#define NUM_SERIAL 3
|
#define NUM_SERIAL 3
|
||||||
#define SERIAL1 Serial3
|
#define SERIAL1 Serial3
|
||||||
#define SERIAL3 Serial5
|
#define SERIAL3 Serial5
|
||||||
#elif defined(ARDUINO_NUCLEO_F413ZH) || defined(ARDUINO_NUCLEO_F429ZI) || defined(ARDUINO_NUCLEO_F446ZE) || defined(ARDUINO_NUCLEO_F412ZG)
|
#elif defined(ARDUINO_NUCLEO_F413ZH) || defined(ARDUINO_NUCLEO_F429ZI) \
|
||||||
|
|| defined(ARDUINO_NUCLEO_F446ZE) || defined(ARDUINO_NUCLEO_F412ZG) \
|
||||||
|
|| defined(ARDUINO_NUCLEO_F439ZI)
|
||||||
#define NUM_SERIAL 2
|
#define NUM_SERIAL 2
|
||||||
#define SERIAL1 Serial6
|
#define SERIAL1 Serial6
|
||||||
#else
|
#else
|
||||||
|
|
16
version.h
16
version.h
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
|
|
||||||
#define VERSION "5.2.16"
|
#define VERSION "5.2.17"
|
||||||
|
// 5.2.17 - ESP32 simplify network logic
|
||||||
// 5.2.16 - Bugfix to allow for devices using the EX-IOExpander protocol to have no analogue or no digital pins
|
// 5.2.16 - Bugfix to allow for devices using the EX-IOExpander protocol to have no analogue or no digital pins
|
||||||
// 5.2.15 - move call to CommandDistributor::broadcastPower() into the TrackManager::setTrackPower(*) functions
|
// 5.2.15 - move call to CommandDistributor::broadcastPower() into the TrackManager::setTrackPower(*) functions
|
||||||
// - add repeats to function packets that are not reminded in accordance with accessory packets
|
// - add repeats to function packets that are not reminded in accordance with accessory packets
|
||||||
|
@ -207,9 +208,18 @@
|
||||||
// TrackManager DCC & DC up to 8 Districts Architecture
|
// TrackManager DCC & DC up to 8 Districts Architecture
|
||||||
// Automatic ALIAS(name)
|
// Automatic ALIAS(name)
|
||||||
// Command Parser now accepts Underscore in Alias Names
|
// Command Parser now accepts Underscore in Alias Names
|
||||||
|
// 4.1.6 Support for new EX-MotorShield8874 Dual 5Amp Shield
|
||||||
|
// 4.1.5 Bugfix LCN number parsing
|
||||||
|
// 4.1.4 Bugfix for issue #299 Turnout Description NULL
|
||||||
|
// 4.1.3 Bugfix: Ethernet init order
|
||||||
|
// 4.1.2 Bugfix: Ethernet shield W5100 does not report HW or link level
|
||||||
// 4.1.1 Bugfix: preserve turnout format
|
// 4.1.1 Bugfix: preserve turnout format
|
||||||
// Bugfix: parse multiple commands in one buffer string correct
|
// Bugfix: parse multiple commands in one buffer string correctly (ex: <s><Q>)
|
||||||
// Bugfix: </> command signal status in Exrail
|
// Bugfix: </> command signal status of EX-RAIL tasks or threads
|
||||||
|
// Bugfix: EX-RAIL read long loco address
|
||||||
|
// Bugfix: Add space character after version string 4.1.1 for JMRI parsing.
|
||||||
|
// Improved display and loop time for signals make service start to be outside the DONT_TOUCH_WIFI_CONF area
|
||||||
|
// Improve WiFi startup by making service start to be outside the DONT_TOUCH_WIFI_CONF area
|
||||||
// 4.1.0 ...
|
// 4.1.0 ...
|
||||||
//
|
//
|
||||||
// 4.0.2 EXRAIL additions:
|
// 4.0.2 EXRAIL additions:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user