diff --git a/CommandStation-EX.ino b/CommandStation-EX.ino
index 21487f9..6613d9e 100644
--- a/CommandStation-EX.ino
+++ b/CommandStation-EX.ino
@@ -12,16 +12,13 @@
// REFER TO SEPARATE EXAMPLE.
////////////////////////////////////////////////////////////////////////////////////
-// This defines the speed at which the Arduino will communicate with the ESP8266 module.
-// Currently only Arduino Mega and 115200 is supported.
-#define WIFI_SERIAL_LINK_SPEED 115200
-
#include "config.h"
+#include "defines.h"
#include "DCC.h"
#include "DIAG.h"
#include "DCCEXParser.h"
#include "version.h"
-#if ENABLE_WIFI && (defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560))
+#ifdef WIFI_ON
#include "WifiInterface.h"
#endif
#if ENABLE_FREE_MEM_WARNING
@@ -169,7 +166,7 @@ void setup()
DIAG(F("\n===== DCC::getLocoId has returned, but the callback wont be executed until we are in loop() ======\n"));
#endif
-#if ENABLE_WIFI && (defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560))
+#ifdef WIFI_ON
bool wifiUp = false;
const __FlashStringHelper *wifiESSID = F(WIFI_SSID);
const __FlashStringHelper *wifiPassword = F(WIFI_PASSWORD);
@@ -215,7 +212,7 @@ void loop()
serialParser.loop(Serial);
// Responsibility 3: Optionally handle any incoming WiFi traffic
-#if ENABLE_WIFI && (defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560))
+#ifdef WIFI_ON
WifiInterface::loop();
#endif
diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp
index 8b26da7..282237b 100644
--- a/DCCEXParser.cpp
+++ b/DCCEXParser.cpp
@@ -1,7 +1,8 @@
/*
* © 2020, Chris Harlow. All rights reserved.
+ * © 2020, Harald Barth.
*
- * This file is part of Asbelos DCC API
+ * This file is part of CommandStation-EX
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,11 +17,13 @@
* You should have received a copy of the GNU General Public License
* along with CommandStation. If not, see .
*/
+#include "config.h"
+#include "defines.h"
#include "StringFormatter.h"
#include "DCCEXParser.h"
#include "DCC.h"
#include "DCCWaveform.h"
-#if ENABLE_WIFI && (defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560))
+#ifdef WIFI_ON
#include "WifiInterface.h"
#endif
#include "Turnouts.h"
@@ -391,7 +394,7 @@ void DCCEXParser::parse(Print *stream, byte *com, bool blocking)
DIAG(F("Setting loco %d F%d %S"), p[0], p[1], p[2] ? F("ON") : F("OFF"));
DCC::setFn(p[0], p[1], p[2] == 1);
return;
-#if ENABLE_WIFI && (defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560))
+#ifdef WIFI_ON
case '+': // Complex Wifi interface command (not usual parse)
WifiInterface::ATCommand(com);
return;
diff --git a/WifiInterface.cpp b/WifiInterface.cpp
index 9ea5738..6dcacae 100644
--- a/WifiInterface.cpp
+++ b/WifiInterface.cpp
@@ -1,7 +1,8 @@
/*
© 2020, Chris Harlow. All rights reserved.
+ © 2020, Harald Barth.
- This file is part of Asbelos DCC API
+ This file is part of CommandStation-EX
This is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,8 +18,9 @@
along with CommandStation. If not, see .
*/
+#include "WifiInterface.h" /* config.h and defines.h included here */
+#ifdef WIFI_ON /* from config.h and defines.h */
#include
-#include "WifiInterface.h"
#include "DIAG.h"
#include "StringFormatter.h"
#include "WiThrottle.h"
@@ -400,3 +402,4 @@ void WifiInterface::loop() {
loopTimeoutStart = millis();
loopstate = 10; // non-blocking loop waits for > before sending
}
+#endif // WIFI_ON
diff --git a/WifiInterface.h b/WifiInterface.h
index 003ef2d..fbfde77 100644
--- a/WifiInterface.h
+++ b/WifiInterface.h
@@ -1,7 +1,8 @@
/*
* © 2020, Chris Harlow. All rights reserved.
+ * © 2020, Harald Barth.
*
- * This file is part of Asbelos DCC API
+ * This file is part of CommandStation-EX
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,9 +17,11 @@
* You should have received a copy of the GNU General Public License
* along with CommandStation. If not, see .
*/
-
#ifndef WifiInterface_h
#define WifiInterface_h
+#include "config.h"
+#include "defines.h"
+#ifdef WIFI_ON
#include "DCCEXParser.h"
#include "MemStream.h"
@@ -55,5 +58,5 @@ private:
static byte buffer[MAX_WIFI_BUFFER + 1];
static MemStream streamer;
};
-
+#endif // WIFI_ON
#endif
diff --git a/defines.h b/defines.h
new file mode 100644
index 0000000..8279b8b
--- /dev/null
+++ b/defines.h
@@ -0,0 +1,35 @@
+/*
+ © 2020, Harald Barth.
+
+ This file is part of CommandStation-EX
+
+ This is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ It is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with CommandStation. If not, see .
+
+*/
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// WIFI_ON: All prereqs for running with WIFI are met
+//
+#if ENABLE_WIFI && (defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560))
+#define WIFI_ON
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// This defines the speed at which the Arduino will communicate with the ESP8266 module.
+// Currently only devices which can communicate at 115200 are supported.
+//
+#define WIFI_SERIAL_LINK_SPEED 115200
+