From e809a460cce4ec58a87dd8a2b1a812136361c238 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sat, 14 Nov 2020 13:17:47 +0100 Subject: [PATCH] DONT_TOUCH_WIFI_CONFIG feature --- WifiInterface.cpp | 6 +++++- WifiInterface.h | 1 + config.example.h | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/WifiInterface.cpp b/WifiInterface.cpp index 422af7a..459bd09 100644 --- a/WifiInterface.cpp +++ b/WifiInterface.cpp @@ -18,7 +18,7 @@ along with CommandStation. If not, see . */ -#include "WifiInterface.h" /* config.h and defines.h included here */ +#include "WifiInterface.h" /* config.h included there */ #include #include "DIAG.h" #include "StringFormatter.h" @@ -157,6 +157,9 @@ wifiSerialState WifiInterface::setup2(const __FlashStringHelper* SSid, const __F StringFormatter::send(wifiStream, F("AT+GMR\r\n")); checkForOK(2000, OK_SEARCH, true, false); // Makes this visible on the console +#ifdef DONT_TOUCH_WIFI_CONF + DIAG(F("\nDONT_TOUCH_WIFI_CONF was set: Using existing config\n")); +#else StringFormatter::send(wifiStream, F("AT+CWMODE=1\r\n")); // configure as "station" = WiFi client checkForOK(1000, OK_SEARCH, true); // Not always OK, sometimes "no change" @@ -256,6 +259,7 @@ wifiSerialState WifiInterface::setup2(const __FlashStringHelper* SSid, const __F StringFormatter::send(wifiStream, F("AT+CIPSERVER=1,%d\r\n"), port); // turn on server on port if (!checkForOK(10000, OK_SEARCH, true)) return WIFI_DISCONNECTED; +#endif //DONT_TOUCH_WIFI_CONF StringFormatter::send(wifiStream, F("AT+CIFSR\r\n")); // Display ip addresses to the DIAG if (!checkForOK(10000, OK_SEARCH, true, false)) return WIFI_DISCONNECTED; diff --git a/WifiInterface.h b/WifiInterface.h index 6411f6c..390a85f 100644 --- a/WifiInterface.h +++ b/WifiInterface.h @@ -19,6 +19,7 @@ */ #ifndef WifiInterface_h #define WifiInterface_h +#include "config.h" #include "DCCEXParser.h" #include #include diff --git a/config.example.h b/config.example.h index d0be16a..3ceb675 100644 --- a/config.example.h +++ b/config.example.h @@ -44,6 +44,12 @@ The configuration file for DCC++ EX Command Station // // DEFINE WiFi Parameters (only in effect if WIFI is on) // +//#define DONT_TOUCH_WIFI_CONF +// +// if DONT_TOUCH_WIFI_CONF is set, all WIFI config will be done with +// the <+> commands and this sketch will not change anything over +// AT commands and the WIFI_* defines below do not have any effect. +// #define WIFI_SSID "Your network name" #define WIFI_PASSWORD "Your network passwd" #define WIFI_HOSTNAME "dccex"