From 3f0b3ccaf7818de1a71ce7131b48d733007f3853 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 31 Jul 2022 08:49:12 +0200 Subject: [PATCH] ESP32 wifi added to startup and loop --- CommandStation-EX.ino | 12 +++++++++++- DCCEX.h | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CommandStation-EX.ino b/CommandStation-EX.ino index 547f56f..c3cb478 100644 --- a/CommandStation-EX.ino +++ b/CommandStation-EX.ino @@ -82,9 +82,14 @@ void setup() // Responsibility 2: Start all the communications before the DCC engine // Start the WiFi interface on a MEGA, Uno cannot currently handle WiFi // Start Ethernet if it exists +#ifndef ARDUINO_ARCH_ESP32 #if WIFI_ON WifiInterface::setup(WIFI_SERIAL_LINK_SPEED, F(WIFI_SSID), F(WIFI_PASSWORD), F(WIFI_HOSTNAME), IP_PORT, WIFI_CHANNEL); #endif // WIFI_ON +#else + // ESP32 needs wifi on always + WifiESP::setup(WIFI_SSID, WIFI_PASSWORD, WIFI_HOSTNAME, IP_PORT, WIFI_CHANNEL); +#endif // ARDUINO_ARCH_ESP32 #if ETHERNET_ON EthernetInterface::setup(); @@ -132,9 +137,14 @@ void loop() SerialManager::loop(); // Responsibility 3: Optionally handle any incoming WiFi traffic +#ifndef ARDUINO_ARCH_ESP32 #if WIFI_ON WifiInterface::loop(); -#endif +#endif //WIFI_ON +#else + // ESP32 needs wifi on always + WifiESP::loop(); +#endif //ARDUINO_ARCH_ESP32 #if ETHERNET_ON EthernetInterface::loop(); #endif diff --git a/DCCEX.h b/DCCEX.h index c3f5540..f2eee51 100644 --- a/DCCEX.h +++ b/DCCEX.h @@ -32,7 +32,11 @@ #include "DCCEXParser.h" #include "SerialManager.h" #include "version.h" +#ifndef ARDUINO_ARCH_ESP32 #include "WifiInterface.h" +#else +#include "WifiESP32.h" +#endif #if ETHERNET_ON == true #include "EthernetInterface.h" #endif