mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 02:36:35 +00:00
Add optional emergency reset
Add optional emergency reset when Rx is connected to Tx at restart
This commit is contained in:
parent
c9761665e3
commit
c47307bd5e
@ -276,6 +276,32 @@ void UpdateQuickPowerCycle(bool update) {
|
|||||||
#endif // FIRMWARE_MINIMAL
|
#endif // FIRMWARE_MINIMAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_EMERGENCY_RESET
|
||||||
|
/*********************************************************************************************\
|
||||||
|
* Emergency reset if Rx and Tx are tied together
|
||||||
|
\*********************************************************************************************/
|
||||||
|
|
||||||
|
void EmergencyReset(void) {
|
||||||
|
Serial.begin(115200);
|
||||||
|
Serial.write(0xAA);
|
||||||
|
Serial.write(0x55);
|
||||||
|
delay(1);
|
||||||
|
if (Serial.available() == 2) {
|
||||||
|
if ((Serial.read() == 0xAA) && (Serial.read() == 0x55)) {
|
||||||
|
SettingsErase(3); // Reset all settings including QuickPowerCycle flag
|
||||||
|
|
||||||
|
do { // Wait for user to remove Rx Tx jumper and power cycle
|
||||||
|
Serial.write(0xA5);
|
||||||
|
delay(1000); // Satisfy SDK
|
||||||
|
} while (Serial.read() == 0xA5); // Poll for removal of jumper
|
||||||
|
|
||||||
|
ESP_Restart(); // Restart to init default settings
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (Serial.available()) { Serial.read(); } // Flush input buffer
|
||||||
|
}
|
||||||
|
#endif // USE_EMERGENCY_RESET
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Settings services
|
* Settings services
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
@ -2368,6 +2368,7 @@ bool GetLog(uint32_t req_loglevel, uint32_t* index_p, char** entry_pp, size_t* l
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AddLogData(uint32_t loglevel, const char* log_data, const char* log_data_payload = nullptr, const char* log_data_retained = nullptr) {
|
void AddLogData(uint32_t loglevel, const char* log_data, const char* log_data_payload = nullptr, const char* log_data_retained = nullptr) {
|
||||||
|
if (!TasmotaGlobal.enable_logging) { return; }
|
||||||
// Store log_data in buffer
|
// Store log_data in buffer
|
||||||
// To lower heap usage log_data_payload may contain the payload data from MqttPublishPayload()
|
// To lower heap usage log_data_payload may contain the payload data from MqttPublishPayload()
|
||||||
// and log_data_retained may contain optional retained message from MqttPublishPayload()
|
// and log_data_retained may contain optional retained message from MqttPublishPayload()
|
||||||
|
@ -133,7 +133,7 @@ struct {
|
|||||||
bool pwm_present; // Any PWM channel configured with SetOption15 0
|
bool pwm_present; // Any PWM channel configured with SetOption15 0
|
||||||
bool i2c_enabled; // I2C configured
|
bool i2c_enabled; // I2C configured
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
bool i2c_enabled_2; // I2C configured, second controller on ESP32, Wire1
|
bool i2c_enabled_2; // I2C configured, second controller on ESP32, Wire1
|
||||||
#endif
|
#endif
|
||||||
bool ntp_force_sync; // Force NTP sync
|
bool ntp_force_sync; // Force NTP sync
|
||||||
bool skip_light_fade; // Temporarily skip light fading
|
bool skip_light_fade; // Temporarily skip light fading
|
||||||
@ -141,6 +141,7 @@ struct {
|
|||||||
bool module_changed; // Indicate module changed since last restart
|
bool module_changed; // Indicate module changed since last restart
|
||||||
bool wifi_stay_asleep; // Allow sleep only incase of ESP32 BLE
|
bool wifi_stay_asleep; // Allow sleep only incase of ESP32 BLE
|
||||||
bool no_autoexec; // Disable autoexec
|
bool no_autoexec; // Disable autoexec
|
||||||
|
bool enable_logging; // Enable logging
|
||||||
|
|
||||||
StateBitfield global_state; // Global states (currently Wifi and Mqtt) (8 bits)
|
StateBitfield global_state; // Global states (currently Wifi and Mqtt) (8 bits)
|
||||||
uint8_t spi_enabled; // SPI configured
|
uint8_t spi_enabled; // SPI configured
|
||||||
@ -224,6 +225,10 @@ void setup(void) {
|
|||||||
RtcPreInit();
|
RtcPreInit();
|
||||||
SettingsInit();
|
SettingsInit();
|
||||||
|
|
||||||
|
#ifdef USE_EMERGENCY_RESET
|
||||||
|
EmergencyReset();
|
||||||
|
#endif // USE_EMERGENCY_RESET
|
||||||
|
|
||||||
memset(&TasmotaGlobal, 0, sizeof(TasmotaGlobal));
|
memset(&TasmotaGlobal, 0, sizeof(TasmotaGlobal));
|
||||||
TasmotaGlobal.baudrate = APP_BAUDRATE;
|
TasmotaGlobal.baudrate = APP_BAUDRATE;
|
||||||
TasmotaGlobal.seriallog_timer = SERIALLOG_TIMER;
|
TasmotaGlobal.seriallog_timer = SERIALLOG_TIMER;
|
||||||
@ -233,6 +238,7 @@ void setup(void) {
|
|||||||
TasmotaGlobal.tele_period = 9999;
|
TasmotaGlobal.tele_period = 9999;
|
||||||
TasmotaGlobal.active_device = 1;
|
TasmotaGlobal.active_device = 1;
|
||||||
TasmotaGlobal.global_state.data = 0xF; // Init global state (wifi_down, mqtt_down) to solve possible network issues
|
TasmotaGlobal.global_state.data = 0xF; // Init global state (wifi_down, mqtt_down) to solve possible network issues
|
||||||
|
TasmotaGlobal.enable_logging = 1;
|
||||||
|
|
||||||
RtcRebootLoad();
|
RtcRebootLoad();
|
||||||
if (!RtcRebootValid()) {
|
if (!RtcRebootValid()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user