1
0
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:
Asbelos 2024-09-23 09:34:26 +01:00
parent 692f97e480
commit dc481a2f0c
3 changed files with 10 additions and 29 deletions

View File

@ -141,6 +141,7 @@ void setup()
CommandDistributor::broadcastPower();
}
/**************** for future reference
void looptimer(unsigned long timeout, const FSH* message)
{
static unsigned long lasttimestamp = 0;
@ -156,58 +157,46 @@ void looptimer(unsigned long timeout, const FSH* message)
}
lasttimestamp = now;
}
*********************************************/
void loop()
{
// The main sketch has responsibilities during loop()
// Responsibility 1: Handle DCC background processes
// (loco reminders and power checks)
looptimer(0, F(""));
DCC::loop();
looptimer(5000, F("DCC")); // got warnings up to 3884 during prog track read
// Responsibility 2: handle any incoming commands on USB connection
SerialManager::loop();
looptimer(2000, F("Serial")); // got warnings up to 1900 during start
// Responsibility 3: Optionally handle any incoming WiFi traffic
#ifndef ARDUINO_ARCH_ESP32
#if WIFI_ON
WifiInterface::loop();
looptimer(9000, F("Wifi")); // got warnings up to 8000
#endif //WIFI_ON
#else //ARDUINO_ARCH_ESP32
#ifndef WIFI_TASK_ON_CORE0
WifiESP::loop();
looptimer(1000, F("WifiESP"));
#endif
#endif //ARDUINO_ARCH_ESP32
#if ETHERNET_ON
EthernetInterface::loop();
looptimer(10000, F("Ethernet"));
#endif
RMFT::loop(); // ignored if no automation
looptimer(1000, F("RMFT"));
#if defined(LCN_SERIAL)
LCN::loop();
looptimer(1000, F("LCN"));
#endif
// Display refresh
DisplayInterface::loop();
looptimer(2000, F("Display")); // got warnings around 1150
// Handle/update IO devices.
IODevice::loop();
looptimer(1000, F("IODevice"));
Sensor::checkAll(); // Update and print changes
looptimer(1000, F("Sensor"));
// Report any decrease in memory (will automatically trigger on first call)
static int ramLowWatermark = __INT_MAX__; // replaced on first loop

View File

@ -36,9 +36,6 @@
MDNS mdns(udp);
#endif
extern void looptimer(unsigned long timeout, const FSH* message);
bool EthernetInterface::connected=false;
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
@ -127,7 +124,6 @@ void EthernetInterface::setup() // STM32 VERSION
void EthernetInterface::loop()
{
if (!connected) return;
looptimer(5000, F("E.loop"));
static bool warnedAboutLink=false;
if (Ethernet.linkStatus() == LinkOFF){
@ -136,7 +132,6 @@ void EthernetInterface::loop()
warnedAboutLink=true;
return;
}
looptimer(5000, F("E.loop warn"));
// link status must be ok here
if (warnedAboutLink) {
@ -147,8 +142,6 @@ void EthernetInterface::loop()
#ifdef DO_MDNS
// Always do this because we don't want traffic to intefere with being found!
mdns.run();
looptimer(5000, F("E.mdns"));
#endif
//
@ -168,7 +161,6 @@ void EthernetInterface::loop()
//DIAG(F("maintained"));
break;
}
looptimer(5000, F("E.maintain"));
// get client from the server
#if defined (STM32_ETHERNET)
@ -224,7 +216,6 @@ void EthernetInterface::loop()
if (Diag::ETHERNET) DIAG(F("Ethernet s=%d, c=%d b=:%e"), socket, count, buffer);
// execute with data going directly back
CommandDistributor::parse(socket,buffer,outboundRing);
//looptimer(5000, F("Ethloop2 parse"));
return; // limit the amount of processing that takes place within 1 loop() cycle.
}

View File

@ -3,7 +3,8 @@
#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
// - WiFiESP32 reconfig
// 5.2.78 - NeoPixel support.