From 16f94ecbdc8f3f21a64c1d2e1ec83ea675d7b2d5 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 21 May 2023 20:20:32 +0200 Subject: [PATCH] Restict where what SerialX is used --- GITHUB_SHA.h | 2 +- WifiInterface.cpp | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index 19661bf..8db811c 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "devel-202305210948Z" +#define GITHUB_SHA "devel-202305211819Z" diff --git a/WifiInterface.cpp b/WifiInterface.cpp index d5504b6..732b393 100644 --- a/WifiInterface.cpp +++ b/WifiInterface.cpp @@ -58,20 +58,14 @@ Stream * WifiInterface::wifiStream; #define NUM_SERIAL 1 #endif -// To be able to define these in platform specific -// DCCTimer.cpp files, we here make the -// assumption that these exist to link against. -// if enough serial interfaces exist. -#if NUM_SERIAL > 0 -extern HardwareSerial Serial1; -#endif -#if NUM_SERIAL > 1 -extern HardwareSerial Serial2; -#endif +// For STM32 we need to define Serial3 in the platform specific +// DCCTimerSTM32.cpp file, we here make the assumption that it +// exists to link against. +#ifdef ARDUINO_ARCH_STM32 #if NUM_SERIAL > 2 extern HardwareSerial Serial3; #endif - +#endif bool WifiInterface::setup(long serial_link_speed, const FSH *wifiESSID, const FSH *wifiPassword, @@ -97,6 +91,8 @@ bool WifiInterface::setup(long serial_link_speed, #endif // Other serials are tried, depending on hardware. +// Currently only the Arduino Mega 2560 has usable Serial2 +#if defined(ARDUINO_AVR_MEGA2560) #if NUM_SERIAL > 1 && !defined(SERIAL2_COMMANDS) if (wifiUp == WIFI_NOAT) { @@ -104,7 +100,10 @@ bool WifiInterface::setup(long serial_link_speed, wifiUp = setup(Serial2, wifiESSID, wifiPassword, hostname, port, channel); } #endif - +#endif + +// We guess here that in all architctures that have a Serial3 +// we can use it for our purpose. #if NUM_SERIAL > 2 && !defined(SERIAL3_COMMANDS) if (wifiUp == WIFI_NOAT) {