Add command ``Module2``

Add command ``Module2`` to configure fallback module on fast reboot (#8464)
This commit is contained in:
Theo Arends 2020-06-17 14:06:46 +02:00
parent a1d8fa755c
commit 83bbe757db
7 changed files with 46 additions and 20 deletions

View File

@ -52,7 +52,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
## Changelog
### Version 8.3.1.5
### Version 8.3.1.6
- Change IRremoteESP8266 library updated to v2.7.7
- Change Adafruit_SGP30 library from v1.0.3 to v1.2.0 (#8519)
@ -62,6 +62,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- Add command ``Rule0`` to change global rule parameters
- Add command ``Time 4`` to display timestamp using milliseconds (#8537)
- Add command ``SetOption94 0/1`` to select MAX31855 or MAX6675 thermocouple support (#8616)
- Add command ``Module2`` to configure fallback module on fast reboot (#8464)
- Add commands ``LedPwmOn 0..255``, ``LedPwmOff 0..255`` and ``LedPwmMode1 0/1`` to control led brightness by George (#8491)
- Add ESP32 ethernet commands ``EthType 0/1``, ``EthAddress 0..31`` and ``EthClockMode 0..3``
- Add support for unique MQTTClient (and inherited fallback topic) by full Mac address using ``mqttclient DVES_%12X`` (#8300)

View File

@ -1,5 +1,9 @@
## Unreleased (development)
### 8.3.1.6 20200617
- Add command ``Module2`` to configure fallback module on fast reboot (#8464)
### 8.3.1.5 20200616
- Add ESP32 ethernet commands ``EthType 0/1``, ``EthAddress 0..31`` and ``EthClockMode 0..3``

View File

@ -570,8 +570,9 @@ struct {
uint8_t ledpwm_on; // F3F
uint8_t ledpwm_off; // F40
uint8_t tcp_baudrate; // F41
uint8_t fallback_module; // F42
uint8_t free_f42[118]; // F42 - Decrement if adding new Setting variables just above and below
uint8_t free_f43[117]; // F43 - Decrement if adding new Setting variables just above and below
// Only 32 bit boundary variables below
uint16_t pulse_counter_debounce_low; // FB8

View File

@ -768,6 +768,12 @@ void SettingsDefaultSet2(void)
// flag.interlock |= 0;
Settings.interlock[0] = 0xFF; // Legacy support using all relays in one interlock group
Settings.module = MODULE;
#ifdef ESP8266
Settings.fallback_module = SONOFF_BASIC;
#else // ESP32
Settings.fallback_module = WEMOS;
#endif // ESP8266 - ESP32
Settings.fallback_module = MODULE;
ModuleDefault(WEMOS);
// for (uint32_t i = 0; i < ARRAY_SIZE(Settings.my_gp.io); i++) { Settings.my_gp.io[i] = GPIO_NONE; }
SettingsUpdateText(SET_FRIENDLYNAME1, PSTR(FRIENDLY_NAME));
@ -1452,12 +1458,19 @@ void SettingsDelta(void)
Settings.flag4.network_wifi = 1;
Settings.flag4.network_ethernet = 1;
}
if (Settings.version < 0x08030105) {
#ifdef ESP32
if (Settings.version < 0x08030105) {
Settings.eth_type = ETH_TYPE;
Settings.eth_clk_mode = ETH_CLKMODE;
Settings.eth_address = ETH_ADDR;
}
#endif
if (Settings.version < 0x08030106) {
#ifdef ESP8266
Settings.fallback_module = SONOFF_BASIC;
#else // ESP32
Settings.fallback_module = WEMOS;
#endif // ESP8266 - ESP32
}
Settings.version = VERSION;

View File

@ -1018,6 +1018,9 @@ void CmndModule(void)
present = ValidTemplateModule(XdrvMailbox.payload);
}
if (present) {
if (XdrvMailbox.index == 2) {
Settings.fallback_module = XdrvMailbox.payload;
} else {
Settings.last_module = Settings.module;
Settings.module = XdrvMailbox.payload;
SetModuleType();
@ -1029,7 +1032,15 @@ void CmndModule(void)
restart_flag = 2;
}
}
Response_P(S_JSON_COMMAND_NVALUE_SVALUE, XdrvMailbox.command, ModuleNr(), ModuleName().c_str());
}
uint8_t module_real = Settings.module;
uint8_t module_number = ModuleNr();
if (XdrvMailbox.index == 2) {
module_real = Settings.fallback_module;
module_number = (USER_MODULE == Settings.fallback_module) ? 0 : Settings.fallback_module +1;
strcat(XdrvMailbox.command, "2");
}
Response_P(S_JSON_COMMAND_NVALUE_SVALUE, XdrvMailbox.command, module_number, AnyModuleName(module_real).c_str());
}
void CmndModules(void)

View File

@ -278,12 +278,8 @@ void setup(void) {
#endif
}
if (RtcReboot.fast_reboot_count > Settings.param[P_BOOT_LOOP_OFFSET] +4) { // Restarted 6 times
#ifdef ESP8266
Settings.module = SONOFF_BASIC; // Reset module to Sonoff Basic
// Settings.last_module = SONOFF_BASIC;
#else // ESP32
Settings.module = WEMOS; // Reset module to Wemos
#endif // ESP8266 - ESP32
Settings.module = Settings.fallback_module; // Reset module to fallback module
// Settings.last_module = Settings.fallback_module;
}
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_LOG_SOME_SETTINGS_RESET " (%d)"), RtcReboot.fast_reboot_count);
}

View File

@ -20,7 +20,7 @@
#ifndef _TASMOTA_VERSION_H_
#define _TASMOTA_VERSION_H_
const uint32_t VERSION = 0x08030105;
const uint32_t VERSION = 0x08030106;
// Lowest compatible version
const uint32_t VERSION_COMPATIBLE = 0x07010006;