1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-24 21:21:24 +01:00

Merge branch 'nanoEvery2' into fastOLED

This commit is contained in:
Neil McKechnie 2021-02-19 10:54:50 +00:00
commit d83e34de39
8 changed files with 77 additions and 62 deletions

View File

@ -69,7 +69,7 @@ void setup()
// Start the WiFi interface on a MEGA, Uno cannot currently handle WiFi // Start the WiFi interface on a MEGA, Uno cannot currently handle WiFi
#if WIFI_ON #if WIFI_ON
WifiInterface::setup(WIFI_SERIAL_LINK_SPEED, F(WIFI_SSID), F(WIFI_PASSWORD), F(WIFI_HOSTNAME), 2560); WifiInterface::setup(WIFI_SERIAL_LINK_SPEED, F(WIFI_SSID), F(WIFI_PASSWORD), F(WIFI_HOSTNAME), IP_PORT, WIFI_CHANNEL);
#endif // WIFI_ON #endif // WIFI_ON
#if ETHERNET_ON #if ETHERNET_ON

View File

@ -83,11 +83,11 @@ EthernetInterface::EthernetInterface()
IPAddress ip = Ethernet.localIP(); // reassign the obtained ip address IPAddress ip = Ethernet.localIP(); // reassign the obtained ip address
server = new EthernetServer(LISTEN_PORT); // Ethernet Server listening on default port LISTEN_PORT server = new EthernetServer(IP_PORT); // Ethernet Server listening on default port IP_PORT
server->begin(); server->begin();
LCD(4,F("IP: %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]); LCD(4,F("IP: %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
LCD(5,F("Port:%d"), LISTEN_PORT); LCD(5,F("Port:%d"), IP_PORT);
outboundRing=new RingStream(OUTBOUND_RING_SIZE); outboundRing=new RingStream(OUTBOUND_RING_SIZE);
} }

View File

@ -39,7 +39,6 @@
* *
*/ */
#define LISTEN_PORT 2560 // standard listen port for the server
#define MAX_ETH_BUFFER 512 #define MAX_ETH_BUFFER 512
#define OUTBOUND_RING_SIZE 2048 #define OUTBOUND_RING_SIZE 2048

View File

@ -1 +1 @@
#define GITHUB_SHA "75ab2ab" #define GITHUB_SHA "0228345"

View File

@ -26,11 +26,9 @@
#include "WifiInboundHandler.h" #include "WifiInboundHandler.h"
const char FLASH READY_SEARCH[] = "\r\nready\r\n";
const char FLASH OK_SEARCH[] = "\r\nOK\r\n";
const char FLASH END_DETAIL_SEARCH[] = "@ 1000";
const char FLASH SEND_OK_SEARCH[] = "\r\nSEND OK\r\n";
const char FLASH IPD_SEARCH[] = "+IPD";
const unsigned long LOOP_TIMEOUT = 2000; const unsigned long LOOP_TIMEOUT = 2000;
bool WifiInterface::connected = false; bool WifiInterface::connected = false;
Stream * WifiInterface::wifiStream; Stream * WifiInterface::wifiStream;
@ -60,7 +58,8 @@ bool WifiInterface::setup(long serial_link_speed,
const FSH *wifiESSID, const FSH *wifiESSID,
const FSH *wifiPassword, const FSH *wifiPassword,
const FSH *hostname, const FSH *hostname,
const int port) { const int port,
const byte channel) {
wifiSerialState wifiUp = WIFI_NOAT; wifiSerialState wifiUp = WIFI_NOAT;
@ -75,7 +74,7 @@ bool WifiInterface::setup(long serial_link_speed,
#if NUM_SERIAL > 0 #if NUM_SERIAL > 0
Serial1.begin(serial_link_speed); Serial1.begin(serial_link_speed);
wifiUp = setup(Serial1, wifiESSID, wifiPassword, hostname, port); wifiUp = setup(Serial1, wifiESSID, wifiPassword, hostname, port, channel);
#endif #endif
// Other serials are tried, depending on hardware. // Other serials are tried, depending on hardware.
@ -83,7 +82,7 @@ bool WifiInterface::setup(long serial_link_speed,
if (wifiUp == WIFI_NOAT) if (wifiUp == WIFI_NOAT)
{ {
Serial2.begin(serial_link_speed); Serial2.begin(serial_link_speed);
wifiUp = setup(Serial2, wifiESSID, wifiPassword, hostname, port); wifiUp = setup(Serial2, wifiESSID, wifiPassword, hostname, port, channel);
} }
#endif #endif
@ -91,7 +90,7 @@ bool WifiInterface::setup(long serial_link_speed,
if (wifiUp == WIFI_NOAT) if (wifiUp == WIFI_NOAT)
{ {
Serial3.begin(serial_link_speed); Serial3.begin(serial_link_speed);
wifiUp = setup(Serial3, wifiESSID, wifiPassword, hostname, port); wifiUp = setup(Serial3, wifiESSID, wifiPassword, hostname, port, channel);
} }
#endif #endif
@ -109,7 +108,7 @@ bool WifiInterface::setup(long serial_link_speed,
} }
wifiSerialState WifiInterface::setup(Stream & setupStream, const FSH* SSid, const FSH* password, wifiSerialState WifiInterface::setup(Stream & setupStream, const FSH* SSid, const FSH* password,
const FSH* hostname, int port) { const FSH* hostname, int port, byte channel) {
wifiSerialState wifiState; wifiSerialState wifiState;
static uint8_t ntry = 0; static uint8_t ntry = 0;
ntry++; ntry++;
@ -118,7 +117,7 @@ wifiSerialState WifiInterface::setup(Stream & setupStream, const FSH* SSid, con
DIAG(F("\n++ Wifi Setup Try %d ++\n"), ntry); DIAG(F("\n++ Wifi Setup Try %d ++\n"), ntry);
wifiState = setup2( SSid, password, hostname, port); wifiState = setup2( SSid, password, hostname, port, channel);
if (wifiState == WIFI_NOAT) { if (wifiState == WIFI_NOAT) {
DIAG(F("\n++ Wifi Setup NO AT ++\n")); DIAG(F("\n++ Wifi Setup NO AT ++\n"));
@ -127,7 +126,7 @@ wifiSerialState WifiInterface::setup(Stream & setupStream, const FSH* SSid, con
if (wifiState == WIFI_CONNECTED) { if (wifiState == WIFI_CONNECTED) {
StringFormatter::send(wifiStream, F("ATE0\r\n")); // turn off the echo StringFormatter::send(wifiStream, F("ATE0\r\n")); // turn off the echo
checkForOK(200, OK_SEARCH, true); checkForOK(200, true);
} }
@ -141,41 +140,40 @@ wifiSerialState WifiInterface::setup(Stream & setupStream, const FSH* SSid, con
#pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-parameter"
#endif #endif
wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password, wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password,
const FSH* hostname, int port) { const FSH* hostname, int port, byte channel) {
bool ipOK = false; bool ipOK = false;
bool oldCmd = false; bool oldCmd = false;
char macAddress[17]; // mac address extraction char macAddress[17]; // mac address extraction
// First check... Restarting the Arduino does not restart the ES. // First check... Restarting the Arduino does not restart the ES.
// There may alrerady be a connection with data in the pipeline. // There may alrerady be a connection with data in the pipeline.
// If there is, just shortcut the setup and continue to read the data as normal. // If there is, just shortcut the setup and continue to read the data as normal.
if (checkForOK(200,IPD_SEARCH, true)) { if (checkForOK(200,F("+IPD"), true)) {
DIAG(F("\nPreconfigured Wifi already running with data waiting\n")); DIAG(F("\nPreconfigured Wifi already running with data waiting\n"));
// loopstate=4; // carry on from correct place... or not as the case may be
return WIFI_CONNECTED; return WIFI_CONNECTED;
} }
StringFormatter::send(wifiStream, F("AT\r\n")); // Is something here that understands AT? StringFormatter::send(wifiStream, F("AT\r\n")); // Is something here that understands AT?
if(!checkForOK(200, OK_SEARCH, true)) if(!checkForOK(200, true))
return WIFI_NOAT; // No AT compatible WiFi module here return WIFI_NOAT; // No AT compatible WiFi module here
StringFormatter::send(wifiStream, F("ATE1\r\n")); // Turn on the echo, se we can see what's happening StringFormatter::send(wifiStream, F("ATE1\r\n")); // Turn on the echo, se we can see what's happening
checkForOK(2000, OK_SEARCH, true); // Makes this visible on the console checkForOK(2000, true); // Makes this visible on the console
// Display the AT version information // Display the AT version information
StringFormatter::send(wifiStream, F("AT+GMR\r\n")); StringFormatter::send(wifiStream, F("AT+GMR\r\n"));
checkForOK(2000, OK_SEARCH, true, false); // Makes this visible on the console checkForOK(2000, true, false); // Makes this visible on the console
#ifdef DONT_TOUCH_WIFI_CONF #ifdef DONT_TOUCH_WIFI_CONF
DIAG(F("\nDONT_TOUCH_WIFI_CONF was set: Using existing config\n")); DIAG(F("\nDONT_TOUCH_WIFI_CONF was set: Using existing config\n"));
#else #else
StringFormatter::send(wifiStream, F("AT+CWMODE=1\r\n")); // configure as "station" = WiFi client 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" checkForOK(1000, true); // Not always OK, sometimes "no change"
// Older ES versions have AT+CWJAP, newer ones have AT+CWJAP_CUR and AT+CWHOSTNAME // Older ES versions have AT+CWJAP, newer ones have AT+CWJAP_CUR and AT+CWHOSTNAME
StringFormatter::send(wifiStream, F("AT+CWJAP?\r\n")); StringFormatter::send(wifiStream, F("AT+CWJAP?\r\n"));
if (checkForOK(2000, OK_SEARCH, true)) { if (checkForOK(2000, true)) {
oldCmd=true; oldCmd=true;
while (wifiStream->available()) StringFormatter::printEscape( wifiStream->read()); /// THIS IS A DIAG IN DISGUISE while (wifiStream->available()) StringFormatter::printEscape( wifiStream->read()); /// THIS IS A DIAG IN DISGUISE
} }
@ -191,8 +189,8 @@ wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password,
// typical connect time approx 7 seconds // typical connect time approx 7 seconds
delay(8000); delay(8000);
StringFormatter::send(wifiStream, F("AT+CIFSR\r\n")); StringFormatter::send(wifiStream, F("AT+CIFSR\r\n"));
if (checkForOK(5000, (const char*) F("+CIFSR:STAIP"), true,false)) if (checkForOK(5000, F("+CIFSR:STAIP"), true,false))
if (!checkForOK(1000, (const char*) F("0.0.0.0"), true,false)) if (!checkForOK(1000, F("0.0.0.0"), true,false))
ipOK = true; ipOK = true;
} }
} else { } else {
@ -200,14 +198,14 @@ wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password,
if (oldCmd) { if (oldCmd) {
// AT command early version supports CWJAP/CWSAP // AT command early version supports CWJAP/CWSAP
StringFormatter::send(wifiStream, F("AT+CWJAP=\"%S\",\"%S\"\r\n"), SSid, password); StringFormatter::send(wifiStream, F("AT+CWJAP=\"%S\",\"%S\"\r\n"), SSid, password);
ipOK = checkForOK(WIFI_CONNECT_TIMEOUT, OK_SEARCH, true); ipOK = checkForOK(WIFI_CONNECT_TIMEOUT, true);
} else { } else {
// later version supports CWJAP_CUR // later version supports CWJAP_CUR
StringFormatter::send(wifiStream, F("AT+CWHOSTNAME=\"%S\"\r\n"), hostname); // Set Host name for Wifi Client StringFormatter::send(wifiStream, F("AT+CWHOSTNAME=\"%S\"\r\n"), hostname); // Set Host name for Wifi Client
checkForOK(2000, OK_SEARCH, true); // dont care if not supported checkForOK(2000, true); // dont care if not supported
StringFormatter::send(wifiStream, F("AT+CWJAP_CUR=\"%S\",\"%S\"\r\n"), SSid, password); StringFormatter::send(wifiStream, F("AT+CWJAP_CUR=\"%S\",\"%S\"\r\n"), SSid, password);
ipOK = checkForOK(WIFI_CONNECT_TIMEOUT, OK_SEARCH, true); ipOK = checkForOK(WIFI_CONNECT_TIMEOUT, true);
} }
if (ipOK) { if (ipOK) {
@ -215,8 +213,8 @@ wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password,
// Let's check for IP (via DHCP) // Let's check for IP (via DHCP)
ipOK = false; ipOK = false;
StringFormatter::send(wifiStream, F("AT+CIFSR\r\n")); StringFormatter::send(wifiStream, F("AT+CIFSR\r\n"));
if (checkForOK(5000, (const char*) F("+CIFSR:STAIP"), true,false)) if (checkForOK(5000, F("+CIFSR:STAIP"), true,false))
if (!checkForOK(1000, (const char*) F("0.0.0.0"), true,false)) if (!checkForOK(1000, F("0.0.0.0"), true,false))
ipOK = true; ipOK = true;
} }
} }
@ -225,21 +223,21 @@ wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password,
// If we have not managed to get this going in station mode, go for AP mode // If we have not managed to get this going in station mode, go for AP mode
// StringFormatter::send(wifiStream, F("AT+RST\r\n")); // StringFormatter::send(wifiStream, F("AT+RST\r\n"));
// checkForOK(1000, OK_SEARCH, true); // Not always OK, sometimes "no change" // checkForOK(1000, true); // Not always OK, sometimes "no change"
int i=0; int i=0;
do { do {
// configure as AccessPoint. Try really hard as this is the // configure as AccessPoint. Try really hard as this is the
// last way out to get any Wifi connectivity. // last way out to get any Wifi connectivity.
StringFormatter::send(wifiStream, F("AT+CWMODE=2\r\n")); StringFormatter::send(wifiStream, F("AT+CWMODE=2\r\n"));
} while (!checkForOK(1000+i*500, OK_SEARCH, true) && i++<10); } while (!checkForOK(1000+i*500, true) && i++<10);
while (wifiStream->available()) StringFormatter::printEscape( wifiStream->read()); /// THIS IS A DIAG IN DISGUISE while (wifiStream->available()) StringFormatter::printEscape( wifiStream->read()); /// THIS IS A DIAG IN DISGUISE
// Figure out MAC addr // Figure out MAC addr
StringFormatter::send(wifiStream, F("AT+CIFSR\r\n")); // not TOMATO StringFormatter::send(wifiStream, F("AT+CIFSR\r\n")); // not TOMATO
// looking fpr mac addr eg +CIFSR:APMAC,"be:dd:c2:5c:6b:b7" // looking fpr mac addr eg +CIFSR:APMAC,"be:dd:c2:5c:6b:b7"
if (checkForOK(5000, (const char*) F("+CIFSR:APMAC,\""), true,false)) { if (checkForOK(5000, F("+CIFSR:APMAC,\""), true,false)) {
// Copy 17 byte mac address // Copy 17 byte mac address
for (int i=0; i<17;i++) { for (int i=0; i<17;i++) {
while(!wifiStream->available()); while(!wifiStream->available());
@ -251,39 +249,41 @@ wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password,
} }
char macTail[]={macAddress[9],macAddress[10],macAddress[12],macAddress[13],macAddress[15],macAddress[16],'\0'}; char macTail[]={macAddress[9],macAddress[10],macAddress[12],macAddress[13],macAddress[15],macAddress[16],'\0'};
while (wifiStream->available()) StringFormatter::printEscape( wifiStream->read()); /// THIS IS A DIAG IN DISGUISE checkForOK(1000, true, false); // suck up remainder of AT+CIFSR
i=0; i=0;
do { do {
if (strncmp_P(yourNetwork, (const char*)password, 13) == 0) { if (strncmp_P(yourNetwork, (const char*)password, 13) == 0) {
// unconfigured // unconfigured
StringFormatter::send(wifiStream, F("AT+CWSAP%s=\"DCCEX_%s\",\"PASS_%s\",1,4\r\n"), oldCmd ? "" : "_CUR", macTail, macTail); StringFormatter::send(wifiStream, F("AT+CWSAP%s=\"DCCEX_%s\",\"PASS_%s\",%d,4\r\n"),
oldCmd ? "" : "_CUR", macTail, macTail, channel);
} else { } else {
// password configured by user // password configured by user
StringFormatter::send(wifiStream, F("AT+CWSAP%s=\"DCCEX_%s\",\"%S\",1,4\r\n"), oldCmd ? "" : "_CUR", macTail, password); StringFormatter::send(wifiStream, F("AT+CWSAP%s=\"DCCEX_%s\",\"%S\",%d,4\r\n"), oldCmd ? "" : "_CUR",
macTail, password, channel);
} }
} while (!checkForOK(WIFI_CONNECT_TIMEOUT, OK_SEARCH, true) && i++<2); // do twice if necessary but ignore failure as AP mode may still be ok } while (!checkForOK(WIFI_CONNECT_TIMEOUT, true) && i++<2); // do twice if necessary but ignore failure as AP mode may still be ok
if (i >= 2) if (i >= 2)
DIAG(F("\nWarning: Setting AP SSID and password failed\n")); // but issue warning DIAG(F("\nWarning: Setting AP SSID and password failed\n")); // but issue warning
if (!oldCmd) { if (!oldCmd) {
StringFormatter::send(wifiStream, F("AT+CIPRECVMODE=0\r\n"), port); // make sure transfer mode is correct StringFormatter::send(wifiStream, F("AT+CIPRECVMODE=0\r\n"), port); // make sure transfer mode is correct
checkForOK(2000, OK_SEARCH, true); checkForOK(2000, true);
} }
} }
StringFormatter::send(wifiStream, F("AT+CIPSERVER=0\r\n")); // turn off tcp server (to clean connections before CIPMUX=1) StringFormatter::send(wifiStream, F("AT+CIPSERVER=0\r\n")); // turn off tcp server (to clean connections before CIPMUX=1)
checkForOK(1000, OK_SEARCH, true); // ignore result in case it already was off checkForOK(1000, true); // ignore result in case it already was off
StringFormatter::send(wifiStream, F("AT+CIPMUX=1\r\n")); // configure for multiple connections StringFormatter::send(wifiStream, F("AT+CIPMUX=1\r\n")); // configure for multiple connections
if (!checkForOK(1000, OK_SEARCH, true)) return WIFI_DISCONNECTED; if (!checkForOK(1000, true)) return WIFI_DISCONNECTED;
StringFormatter::send(wifiStream, F("AT+CIPSERVER=1,%d\r\n"), port); // turn on server on port StringFormatter::send(wifiStream, F("AT+CIPSERVER=1,%d\r\n"), port); // turn on server on port
if (!checkForOK(1000, OK_SEARCH, true)) return WIFI_DISCONNECTED; if (!checkForOK(1000, true)) return WIFI_DISCONNECTED;
#endif //DONT_TOUCH_WIFI_CONF #endif //DONT_TOUCH_WIFI_CONF
StringFormatter::send(wifiStream, F("AT+CIFSR\r\n")); // Display ip addresses to the DIAG StringFormatter::send(wifiStream, F("AT+CIFSR\r\n")); // Display ip addresses to the DIAG
if (!checkForOK(1000, (const char *)F("IP,\"") , true, false)) return WIFI_DISCONNECTED; if (!checkForOK(1000, F("IP,\"") , true, false)) return WIFI_DISCONNECTED;
// Copy the IP address // Copy the IP address
{ {
const byte MAX_IP_LENGTH=15; const byte MAX_IP_LENGTH=15;
@ -302,7 +302,7 @@ wifiSerialState WifiInterface::setup2(const FSH* SSid, const FSH* password,
LCD(4,F("%s"),ipString); // There is not enough room on some LCDs to put a title to this LCD(4,F("%s"),ipString); // There is not enough room on some LCDs to put a title to this
} }
// suck up anything after the IP. // suck up anything after the IP.
if (!checkForOK(1000, OK_SEARCH, true, false)) return WIFI_DISCONNECTED; if (!checkForOK(1000, true, false)) return WIFI_DISCONNECTED;
LCD(5,F("PORT=%d\n"),port); LCD(5,F("PORT=%d\n"),port);
return WIFI_CONNECTED; return WIFI_CONNECTED;
@ -325,15 +325,19 @@ void WifiInterface::ATCommand(const byte * command) {
} }
else { else {
StringFormatter:: send(wifiStream, F("AT+%s\r\n"), command); StringFormatter:: send(wifiStream, F("AT+%s\r\n"), command);
checkForOK(10000, OK_SEARCH, true); checkForOK(10000, true);
} }
} }
bool WifiInterface::checkForOK( const unsigned int timeout, const char * waitfor, bool echo, bool escapeEcho) { bool WifiInterface::checkForOK( const unsigned int timeout, bool echo, bool escapeEcho) {
return checkForOK(timeout,F("\r\nOK\r\n"),echo,escapeEcho);
}
bool WifiInterface::checkForOK( const unsigned int timeout, const FSH * waitfor, bool echo, bool escapeEcho) {
unsigned long startTime = millis(); unsigned long startTime = millis();
char const *locator = waitfor; char *locator = (char *)waitfor;
DIAG(F("\nWifi Check: [%E]"), waitfor); DIAG(F("\nWifi Check: [%E]"), waitfor);
while ( millis() - startTime < timeout) { while ( millis() - startTime < timeout) {
while (wifiStream->available()) { while (wifiStream->available()) {
@ -342,7 +346,7 @@ bool WifiInterface::checkForOK( const unsigned int timeout, const char * waitfor
if (escapeEcho) StringFormatter::printEscape( ch); /// THIS IS A DIAG IN DISGUISE if (escapeEcho) StringFormatter::printEscape( ch); /// THIS IS A DIAG IN DISGUISE
else DIAG(F("%c"), ch); else DIAG(F("%c"), ch);
} }
if (ch != GETFLASH(locator)) locator = waitfor; if (ch != GETFLASH(locator)) locator = (char *)waitfor;
if (ch == GETFLASH(locator)) { if (ch == GETFLASH(locator)) {
locator++; locator++;
if (!GETFLASH(locator)) { if (!GETFLASH(locator)) {

View File

@ -34,23 +34,20 @@ public:
const FSH *wifiESSID, const FSH *wifiESSID,
const FSH *wifiPassword, const FSH *wifiPassword,
const FSH *hostname, const FSH *hostname,
const int port = 2560); const int port,
const byte channel);
static void loop(); static void loop();
static void ATCommand(const byte *command); static void ATCommand(const byte *command);
private: private:
static wifiSerialState setup(Stream &setupStream, const FSH *SSSid, const FSH *password, static wifiSerialState setup(Stream &setupStream, const FSH *SSSid, const FSH *password,
const FSH *hostname, int port); const FSH *hostname, int port, byte channel);
static Stream *wifiStream; static Stream *wifiStream;
static DCCEXParser parser; static DCCEXParser parser;
static wifiSerialState setup2(const FSH *SSSid, const FSH *password, static wifiSerialState setup2(const FSH *SSSid, const FSH *password,
const FSH *hostname, int port); const FSH *hostname, int port, byte channel);
static bool checkForOK(const unsigned int timeout, const char *waitfor, bool echo, bool escapeEcho = true); static bool checkForOK(const unsigned int timeout, bool echo, bool escapeEcho = true);
static bool checkForOK(const unsigned int timeout, const FSH *waitfor, bool echo, bool escapeEcho = true);
static bool connected; static bool connected;
static bool closeAfter;
static byte loopstate;
static int datalength;
static int connectionId;
static unsigned long loopTimeoutStart;
}; };
#endif #endif

View File

@ -26,6 +26,12 @@ The configuration file for DCC-EX Command Station
// //
#define MOTOR_SHIELD_TYPE STANDARD_MOTOR_SHIELD #define MOTOR_SHIELD_TYPE STANDARD_MOTOR_SHIELD
/////////////////////////////////////////////////////////////////////////////////////
//
// The IP port to talk to a WIFI or Ethernet shield.
//
#define IP_PORT 2560
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
// //
// NOTE: Only supported on Arduino Mega // NOTE: Only supported on Arduino Mega
@ -66,6 +72,12 @@ The configuration file for DCC-EX Command Station
// WIFI_HOSTNAME: You probably don't need to change this // WIFI_HOSTNAME: You probably don't need to change this
#define WIFI_HOSTNAME "dccex" #define WIFI_HOSTNAME "dccex"
// //
// WIFI_CHANNEL: If the line "#define ENABLE_WIFI true" is uncommented,
// WiFi will be enabled (Mega only). The default channel is set to "1" whether
// this line exists or not. If you need to use an alternate channel (we recommend
// using only 1,6, or 11) you may change it here.
#define WIFI_CHANNEL 1
//
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
// //
// Wifi connect timeout in milliseconds. Default is 14000 (14 seconds). You only need // Wifi connect timeout in milliseconds. Default is 14000 (14 seconds). You only need

View File

@ -21,10 +21,13 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// //
// WIFI_ON: All prereqs for running with WIFI are met // WIFI_ON: All prereqs for running with WIFI are met
// // Note: WIFI_CHANNEL may not exist in early config.h files so is added here if needed.
#if ENABLE_WIFI && (defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_SAMD_ZERO)) #if ENABLE_WIFI && (defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560) || defined(ARDUINO_SAMD_ZERO))
#define WIFI_ON true #define WIFI_ON true
#ifndef WIFI_CHANNEL
#define WIFI_CHANNEL 1
#endif
#else #else
#define WIFI_ON false #define WIFI_ON false
#endif #endif