mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-23 21:01:25 +01:00
Make all Wifi code disappear if Wifi is not enabled.
This commit is contained in:
parent
bc8b01fbd6
commit
32f1d7d890
@ -12,16 +12,13 @@
|
|||||||
// REFER TO SEPARATE EXAMPLE.
|
// 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 "config.h"
|
||||||
|
#include "defines.h"
|
||||||
#include "DCC.h"
|
#include "DCC.h"
|
||||||
#include "DIAG.h"
|
#include "DIAG.h"
|
||||||
#include "DCCEXParser.h"
|
#include "DCCEXParser.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#if ENABLE_WIFI && (defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560))
|
#ifdef WIFI_ON
|
||||||
#include "WifiInterface.h"
|
#include "WifiInterface.h"
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FREE_MEM_WARNING
|
#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"));
|
DIAG(F("\n===== DCC::getLocoId has returned, but the callback wont be executed until we are in loop() ======\n"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLE_WIFI && (defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560))
|
#ifdef WIFI_ON
|
||||||
bool wifiUp = false;
|
bool wifiUp = false;
|
||||||
const __FlashStringHelper *wifiESSID = F(WIFI_SSID);
|
const __FlashStringHelper *wifiESSID = F(WIFI_SSID);
|
||||||
const __FlashStringHelper *wifiPassword = F(WIFI_PASSWORD);
|
const __FlashStringHelper *wifiPassword = F(WIFI_PASSWORD);
|
||||||
@ -215,7 +212,7 @@ void loop()
|
|||||||
serialParser.loop(Serial);
|
serialParser.loop(Serial);
|
||||||
|
|
||||||
// Responsibility 3: Optionally handle any incoming WiFi traffic
|
// Responsibility 3: Optionally handle any incoming WiFi traffic
|
||||||
#if ENABLE_WIFI && (defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560))
|
#ifdef WIFI_ON
|
||||||
WifiInterface::loop();
|
WifiInterface::loop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* © 2020, Chris Harlow. All rights reserved.
|
* © 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
|
* This is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include "config.h"
|
||||||
|
#include "defines.h"
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
#include "DCCEXParser.h"
|
#include "DCCEXParser.h"
|
||||||
#include "DCC.h"
|
#include "DCC.h"
|
||||||
#include "DCCWaveform.h"
|
#include "DCCWaveform.h"
|
||||||
#if ENABLE_WIFI && (defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560))
|
#ifdef WIFI_ON
|
||||||
#include "WifiInterface.h"
|
#include "WifiInterface.h"
|
||||||
#endif
|
#endif
|
||||||
#include "Turnouts.h"
|
#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"));
|
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);
|
DCC::setFn(p[0], p[1], p[2] == 1);
|
||||||
return;
|
return;
|
||||||
#if ENABLE_WIFI && (defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560))
|
#ifdef WIFI_ON
|
||||||
case '+': // Complex Wifi interface command (not usual parse)
|
case '+': // Complex Wifi interface command (not usual parse)
|
||||||
WifiInterface::ATCommand(com);
|
WifiInterface::ATCommand(com);
|
||||||
return;
|
return;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
© 2020, Chris Harlow. All rights reserved.
|
© 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
|
This is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -17,8 +18,9 @@
|
|||||||
along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "WifiInterface.h" /* config.h and defines.h included here */
|
||||||
|
#ifdef WIFI_ON /* from config.h and defines.h */
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include "WifiInterface.h"
|
|
||||||
#include "DIAG.h"
|
#include "DIAG.h"
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
#include "WiThrottle.h"
|
#include "WiThrottle.h"
|
||||||
@ -400,3 +402,4 @@ void WifiInterface::loop() {
|
|||||||
loopTimeoutStart = millis();
|
loopTimeoutStart = millis();
|
||||||
loopstate = 10; // non-blocking loop waits for > before sending
|
loopstate = 10; // non-blocking loop waits for > before sending
|
||||||
}
|
}
|
||||||
|
#endif // WIFI_ON
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* © 2020, Chris Harlow. All rights reserved.
|
* © 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
|
* This is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WifiInterface_h
|
#ifndef WifiInterface_h
|
||||||
#define WifiInterface_h
|
#define WifiInterface_h
|
||||||
|
#include "config.h"
|
||||||
|
#include "defines.h"
|
||||||
|
#ifdef WIFI_ON
|
||||||
#include "DCCEXParser.h"
|
#include "DCCEXParser.h"
|
||||||
#include "MemStream.h"
|
#include "MemStream.h"
|
||||||
|
|
||||||
@ -55,5 +58,5 @@ private:
|
|||||||
static byte buffer[MAX_WIFI_BUFFER + 1];
|
static byte buffer[MAX_WIFI_BUFFER + 1];
|
||||||
static MemStream streamer;
|
static MemStream streamer;
|
||||||
};
|
};
|
||||||
|
#endif // WIFI_ON
|
||||||
#endif
|
#endif
|
||||||
|
35
defines.h
Normal file
35
defines.h
Normal file
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user