mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-22 23:56:13 +01:00
EthernetInterface
This commit is contained in:
parent
692f97e480
commit
dc481a2f0c
|
@ -141,6 +141,7 @@ void setup()
|
||||||
CommandDistributor::broadcastPower();
|
CommandDistributor::broadcastPower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************** for future reference
|
||||||
void looptimer(unsigned long timeout, const FSH* message)
|
void looptimer(unsigned long timeout, const FSH* message)
|
||||||
{
|
{
|
||||||
static unsigned long lasttimestamp = 0;
|
static unsigned long lasttimestamp = 0;
|
||||||
|
@ -156,58 +157,46 @@ void looptimer(unsigned long timeout, const FSH* message)
|
||||||
}
|
}
|
||||||
lasttimestamp = now;
|
lasttimestamp = now;
|
||||||
}
|
}
|
||||||
|
*********************************************/
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// The main sketch has responsibilities during loop()
|
// The main sketch has responsibilities during loop()
|
||||||
|
|
||||||
// Responsibility 1: Handle DCC background processes
|
// Responsibility 1: Handle DCC background processes
|
||||||
// (loco reminders and power checks)
|
// (loco reminders and power checks)
|
||||||
looptimer(0, F(""));
|
|
||||||
DCC::loop();
|
DCC::loop();
|
||||||
looptimer(5000, F("DCC")); // got warnings up to 3884 during prog track read
|
|
||||||
|
|
||||||
// Responsibility 2: handle any incoming commands on USB connection
|
// Responsibility 2: handle any incoming commands on USB connection
|
||||||
SerialManager::loop();
|
SerialManager::loop();
|
||||||
looptimer(2000, F("Serial")); // got warnings up to 1900 during start
|
|
||||||
|
|
||||||
// Responsibility 3: Optionally handle any incoming WiFi traffic
|
// Responsibility 3: Optionally handle any incoming WiFi traffic
|
||||||
#ifndef ARDUINO_ARCH_ESP32
|
#ifndef ARDUINO_ARCH_ESP32
|
||||||
#if WIFI_ON
|
#if WIFI_ON
|
||||||
WifiInterface::loop();
|
WifiInterface::loop();
|
||||||
looptimer(9000, F("Wifi")); // got warnings up to 8000
|
|
||||||
|
|
||||||
#endif //WIFI_ON
|
#endif //WIFI_ON
|
||||||
#else //ARDUINO_ARCH_ESP32
|
#else //ARDUINO_ARCH_ESP32
|
||||||
#ifndef WIFI_TASK_ON_CORE0
|
#ifndef WIFI_TASK_ON_CORE0
|
||||||
WifiESP::loop();
|
WifiESP::loop();
|
||||||
looptimer(1000, F("WifiESP"));
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif //ARDUINO_ARCH_ESP32
|
#endif //ARDUINO_ARCH_ESP32
|
||||||
#if ETHERNET_ON
|
#if ETHERNET_ON
|
||||||
EthernetInterface::loop();
|
EthernetInterface::loop();
|
||||||
looptimer(10000, F("Ethernet"));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RMFT::loop(); // ignored if no automation
|
RMFT::loop(); // ignored if no automation
|
||||||
looptimer(1000, F("RMFT"));
|
|
||||||
|
|
||||||
#if defined(LCN_SERIAL)
|
#if defined(LCN_SERIAL)
|
||||||
LCN::loop();
|
LCN::loop();
|
||||||
looptimer(1000, F("LCN"));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Display refresh
|
// Display refresh
|
||||||
DisplayInterface::loop();
|
DisplayInterface::loop();
|
||||||
looptimer(2000, F("Display")); // got warnings around 1150
|
|
||||||
|
|
||||||
// Handle/update IO devices.
|
// Handle/update IO devices.
|
||||||
IODevice::loop();
|
IODevice::loop();
|
||||||
looptimer(1000, F("IODevice"));
|
|
||||||
|
|
||||||
Sensor::checkAll(); // Update and print changes
|
Sensor::checkAll(); // Update and print changes
|
||||||
looptimer(1000, F("Sensor"));
|
|
||||||
|
|
||||||
// Report any decrease in memory (will automatically trigger on first call)
|
// Report any decrease in memory (will automatically trigger on first call)
|
||||||
static int ramLowWatermark = __INT_MAX__; // replaced on first loop
|
static int ramLowWatermark = __INT_MAX__; // replaced on first loop
|
||||||
|
|
|
@ -36,9 +36,6 @@
|
||||||
MDNS mdns(udp);
|
MDNS mdns(udp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern void looptimer(unsigned long timeout, const FSH* message);
|
|
||||||
|
|
||||||
bool EthernetInterface::connected=false;
|
bool EthernetInterface::connected=false;
|
||||||
EthernetServer * EthernetInterface::server= nullptr;
|
EthernetServer * EthernetInterface::server= nullptr;
|
||||||
EthernetClient EthernetInterface::clients[MAX_SOCK_NUM]; // accept up to MAX_SOCK_NUM client connections at the same time; This depends on the chipset used on the Shield
|
EthernetClient EthernetInterface::clients[MAX_SOCK_NUM]; // accept up to MAX_SOCK_NUM client connections at the same time; This depends on the chipset used on the Shield
|
||||||
|
@ -127,8 +124,7 @@ void EthernetInterface::setup() // STM32 VERSION
|
||||||
void EthernetInterface::loop()
|
void EthernetInterface::loop()
|
||||||
{
|
{
|
||||||
if (!connected) return;
|
if (!connected) return;
|
||||||
looptimer(5000, F("E.loop"));
|
|
||||||
|
|
||||||
static bool warnedAboutLink=false;
|
static bool warnedAboutLink=false;
|
||||||
if (Ethernet.linkStatus() == LinkOFF){
|
if (Ethernet.linkStatus() == LinkOFF){
|
||||||
if (warnedAboutLink) return;
|
if (warnedAboutLink) return;
|
||||||
|
@ -136,8 +132,7 @@ void EthernetInterface::loop()
|
||||||
warnedAboutLink=true;
|
warnedAboutLink=true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
looptimer(5000, F("E.loop warn"));
|
|
||||||
|
|
||||||
// link status must be ok here
|
// link status must be ok here
|
||||||
if (warnedAboutLink) {
|
if (warnedAboutLink) {
|
||||||
DIAG(F("Ethernet link RESTORED"));
|
DIAG(F("Ethernet link RESTORED"));
|
||||||
|
@ -147,8 +142,6 @@ void EthernetInterface::loop()
|
||||||
#ifdef DO_MDNS
|
#ifdef DO_MDNS
|
||||||
// Always do this because we don't want traffic to intefere with being found!
|
// Always do this because we don't want traffic to intefere with being found!
|
||||||
mdns.run();
|
mdns.run();
|
||||||
looptimer(5000, F("E.mdns"));
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -168,8 +161,7 @@ void EthernetInterface::loop()
|
||||||
//DIAG(F("maintained"));
|
//DIAG(F("maintained"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
looptimer(5000, F("E.maintain"));
|
|
||||||
|
|
||||||
// get client from the server
|
// get client from the server
|
||||||
#if defined (STM32_ETHERNET)
|
#if defined (STM32_ETHERNET)
|
||||||
// STM32Ethernet doesn't use accept(), just available()
|
// STM32Ethernet doesn't use accept(), just available()
|
||||||
|
@ -224,7 +216,6 @@ void EthernetInterface::loop()
|
||||||
if (Diag::ETHERNET) DIAG(F("Ethernet s=%d, c=%d b=:%e"), socket, count, buffer);
|
if (Diag::ETHERNET) DIAG(F("Ethernet s=%d, c=%d b=:%e"), socket, count, buffer);
|
||||||
// execute with data going directly back
|
// execute with data going directly back
|
||||||
CommandDistributor::parse(socket,buffer,outboundRing);
|
CommandDistributor::parse(socket,buffer,outboundRing);
|
||||||
//looptimer(5000, F("Ethloop2 parse"));
|
|
||||||
return; // limit the amount of processing that takes place within 1 loop() cycle.
|
return; // limit the amount of processing that takes place within 1 loop() cycle.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
|
|
||||||
#define VERSION "5.2.79"
|
#define VERSION "5.2.80"
|
||||||
|
// 5.2.80 - EthernetInterface upgrade
|
||||||
// 5.2.79 - serial manager loop that handles quoted strings
|
// 5.2.79 - serial manager loop that handles quoted strings
|
||||||
// - WiFiESP32 reconfig
|
// - WiFiESP32 reconfig
|
||||||
// 5.2.78 - NeoPixel support.
|
// 5.2.78 - NeoPixel support.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user