mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-27 18:16:13 +01:00
Compare commits
2 Commits
f3cdd17c3a
...
6bfd19dc54
Author | SHA1 | Date | |
---|---|---|---|
|
6bfd19dc54 | ||
|
60616bb395 |
|
@ -52,9 +52,9 @@
|
||||||
#include "DCCEX.h"
|
#include "DCCEX.h"
|
||||||
#include "Display_Implementation.h"
|
#include "Display_Implementation.h"
|
||||||
|
|
||||||
#ifdef OTA_ENABLED
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
#endif // OTA_ENABLED
|
#endif // ARDUINO_ARCH_ESP32
|
||||||
|
|
||||||
#ifdef CPU_TYPE_ERROR
|
#ifdef CPU_TYPE_ERROR
|
||||||
#error CANNOT COMPILE - DCC++ EX ONLY WORKS WITH THE ARCHITECTURES LISTED IN defines.h
|
#error CANNOT COMPILE - DCC++ EX ONLY WORKS WITH THE ARCHITECTURES LISTED IN defines.h
|
||||||
|
@ -105,16 +105,9 @@ void setup()
|
||||||
#else
|
#else
|
||||||
// ESP32 needs wifi on always
|
// ESP32 needs wifi on always
|
||||||
WifiESP::setup(WIFI_SSID, WIFI_PASSWORD, WIFI_HOSTNAME, IP_PORT, WIFI_CHANNEL, WIFI_FORCE_AP);
|
WifiESP::setup(WIFI_SSID, WIFI_PASSWORD, WIFI_HOSTNAME, IP_PORT, WIFI_CHANNEL, WIFI_FORCE_AP);
|
||||||
|
#if OTA_AUTO_INIT
|
||||||
// Start OTA if enabled
|
Diag::OTA = true;
|
||||||
#ifdef OTA_ENABLED
|
#endif // OTA_AUTO_INIT
|
||||||
ArduinoOTA.setHostname(WIFI_HOSTNAME);
|
|
||||||
#ifdef OTA_AUTH
|
|
||||||
ArduinoOTA.setPassword(OTA_AUTH);
|
|
||||||
#endif // OTA_AUTH
|
|
||||||
ArduinoOTA.begin();
|
|
||||||
#endif // OTA_ENABLED
|
|
||||||
|
|
||||||
#endif // ARDUINO_ARCH_ESP32
|
#endif // ARDUINO_ARCH_ESP32
|
||||||
|
|
||||||
#if ETHERNET_ON
|
#if ETHERNET_ON
|
||||||
|
@ -164,9 +157,24 @@ void loop()
|
||||||
#ifndef WIFI_TASK_ON_CORE0
|
#ifndef WIFI_TASK_ON_CORE0
|
||||||
WifiESP::loop();
|
WifiESP::loop();
|
||||||
#endif
|
#endif
|
||||||
#ifdef OTA_ENABLED
|
// Responsibility 4: Optionally handle Arduino OTA updates
|
||||||
|
if (Diag::OTA) {
|
||||||
|
static bool otaInitialised = false;
|
||||||
|
// Initialise OTA if not already done
|
||||||
|
if (!otaInitialised) {
|
||||||
|
ArduinoOTA.setHostname(WIFI_HOSTNAME);
|
||||||
|
// Set OTA password if defined
|
||||||
|
#ifdef OTA_AUTH
|
||||||
|
ArduinoOTA.setPassword(OTA_AUTH);
|
||||||
|
#endif // OTA_AUTH
|
||||||
|
ArduinoOTA.begin();
|
||||||
|
otaInitialised = true;
|
||||||
|
}
|
||||||
|
// Handle OTA if initialised
|
||||||
|
else {
|
||||||
ArduinoOTA.handle();
|
ArduinoOTA.handle();
|
||||||
#endif // OTA_ENABLED
|
}
|
||||||
|
}
|
||||||
#endif //ARDUINO_ARCH_ESP32
|
#endif //ARDUINO_ARCH_ESP32
|
||||||
#if ETHERNET_ON
|
#if ETHERNET_ON
|
||||||
EthernetInterface::loop();
|
EthernetInterface::loop();
|
||||||
|
|
|
@ -168,6 +168,7 @@ const int16_t HASH_KEYWORD_ANOUT = -26399;
|
||||||
const int16_t HASH_KEYWORD_WIFI = -5583;
|
const int16_t HASH_KEYWORD_WIFI = -5583;
|
||||||
const int16_t HASH_KEYWORD_ETHERNET = -30767;
|
const int16_t HASH_KEYWORD_ETHERNET = -30767;
|
||||||
const int16_t HASH_KEYWORD_WIT = 31594;
|
const int16_t HASH_KEYWORD_WIT = 31594;
|
||||||
|
const int16_t HASH_KEYWORD_OTA = 22938;
|
||||||
|
|
||||||
int16_t DCCEXParser::stashP[MAX_COMMAND_PARAMS];
|
int16_t DCCEXParser::stashP[MAX_COMMAND_PARAMS];
|
||||||
bool DCCEXParser::stashBusy;
|
bool DCCEXParser::stashBusy;
|
||||||
|
@ -1084,6 +1085,11 @@ bool DCCEXParser::parseD(Print *stream, int16_t params, int16_t p[])
|
||||||
IODevice::writeAnalogue(p[1], p[2], params>3 ? p[3] : 0);
|
IODevice::writeAnalogue(p[1], p[2], params>3 ? p[3] : 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HASH_KEYWORD_OTA: // <D OTA ON/OFF>
|
||||||
|
Diag::OTA = onOff;
|
||||||
|
DIAG(F("OTA=%S"), onOff ? F("ON") : F("OFF"));
|
||||||
|
return true;
|
||||||
|
|
||||||
default: // invalid/unknown
|
default: // invalid/unknown
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ bool Diag::WIFI=false;
|
||||||
bool Diag::WITHROTTLE=false;
|
bool Diag::WITHROTTLE=false;
|
||||||
bool Diag::ETHERNET=false;
|
bool Diag::ETHERNET=false;
|
||||||
bool Diag::LCN=false;
|
bool Diag::LCN=false;
|
||||||
|
bool Diag::OTA=false;
|
||||||
|
|
||||||
|
|
||||||
void StringFormatter::diag( const FSH* input...) {
|
void StringFormatter::diag( const FSH* input...) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ class Diag {
|
||||||
static bool WITHROTTLE;
|
static bool WITHROTTLE;
|
||||||
static bool ETHERNET;
|
static bool ETHERNET;
|
||||||
static bool LCN;
|
static bool LCN;
|
||||||
|
static bool OTA;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StringFormatter
|
class StringFormatter
|
||||||
|
|
|
@ -133,15 +133,19 @@ The configuration file for DCC-EX Command Station
|
||||||
// with that SSID.
|
// with that SSID.
|
||||||
#define WIFI_FORCE_AP false
|
#define WIFI_FORCE_AP false
|
||||||
//
|
//
|
||||||
// OTA_ENABLED: If you'd like to enable OTA updates, set this to true. Otherwise,
|
// OTA_AUTO_INIT: Set this to true if you want OTA updates to be initialized
|
||||||
// OTA updates will not be available.
|
// automatically upon startup. If set to false, OTA updates will remain
|
||||||
#define OTA_ENABLED true
|
// unavailable until the "<C OTA 1>" command is executed.
|
||||||
|
// Please note that this feature requires the use of ARDUINO_ARCH_ESP32 as your board.
|
||||||
|
#define OTA_AUTO_INIT false
|
||||||
//
|
//
|
||||||
// OTA_AUTH: If you'd like to change the OTA password, set this to the password
|
// OTA_AUTH: Set this to your desired password if you wish to secure OTA updates.
|
||||||
// you'd like to use. Otherwise, the default password will be "dccex-ota".
|
// If not set, OTA updates will be password-free.
|
||||||
// Note: After changing the OTA password, you must update the "upload_flags → --auth"
|
// Note: Upon modifying the OTA password, ensure to update the "upload_flags → --auth"
|
||||||
// in the corresponding environment within the platformio.ini file.
|
// in the relevant environment within the platformio.ini file.
|
||||||
#define OTA_AUTH "dccex-ota"
|
// To deactivate OTA authorization, comment out the line below and comment out
|
||||||
|
// the "upload_flags" line in the platformio.ini file.
|
||||||
|
// #define OTA_AUTH "dccex-ota"
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue
Block a user