Skip to content

Commit

Permalink
Add command Module2
Browse files Browse the repository at this point in the history
Add command ``Module2`` to configure fallback module on fast reboot (#8464)
  • Loading branch information
arendst committed Jun 17, 2020
1 parent a1d8fa7 commit 83bbe75
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 20 deletions.
3 changes: 2 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions tasmota/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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``
Expand Down
7 changes: 4 additions & 3 deletions tasmota/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,12 @@ struct {
uint16_t windmeter_pulse_debounce; // F3A
int16_t windmeter_speed_factor; // F3C
uint8_t windmeter_tele_pchange; // F3E
uint8_t ledpwm_on; // F3F
uint8_t ledpwm_off; // F40
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
Expand Down
15 changes: 14 additions & 1 deletion tasmota/settings.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
27 changes: 19 additions & 8 deletions tasmota/support_command.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1018,18 +1018,29 @@ void CmndModule(void)
present = ValidTemplateModule(XdrvMailbox.payload);
}
if (present) {
Settings.last_module = Settings.module;
Settings.module = XdrvMailbox.payload;
SetModuleType();
if (Settings.last_module != XdrvMailbox.payload) {
for (uint32_t i = 0; i < ARRAY_SIZE(Settings.my_gp.io); i++) {
Settings.my_gp.io[i] = GPIO_NONE;
if (XdrvMailbox.index == 2) {
Settings.fallback_module = XdrvMailbox.payload;
} else {
Settings.last_module = Settings.module;
Settings.module = XdrvMailbox.payload;
SetModuleType();
if (Settings.last_module != XdrvMailbox.payload) {
for (uint32_t i = 0; i < ARRAY_SIZE(Settings.my_gp.io); i++) {
Settings.my_gp.io[i] = GPIO_NONE;
}
}
restart_flag = 2;
}
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)
Expand Down
8 changes: 2 additions & 6 deletions tasmota/tasmota.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion tasmota/tasmota_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 83bbe75

Please sign in to comment.