mirror of https://github.com/arendst/Tasmota.git
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
|
||||
}
|
||||
|
||||
#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
|
||||
\*********************************************************************************************/
|
||||
|
|
|
@ -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) {
|
||||
if (!TasmotaGlobal.enable_logging) { return; }
|
||||
// Store log_data in buffer
|
||||
// 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()
|
||||
|
|
|
@ -141,6 +141,7 @@ struct {
|
|||
bool module_changed; // Indicate module changed since last restart
|
||||
bool wifi_stay_asleep; // Allow sleep only incase of ESP32 BLE
|
||||
bool no_autoexec; // Disable autoexec
|
||||
bool enable_logging; // Enable logging
|
||||
|
||||
StateBitfield global_state; // Global states (currently Wifi and Mqtt) (8 bits)
|
||||
uint8_t spi_enabled; // SPI configured
|
||||
|
@ -224,6 +225,10 @@ void setup(void) {
|
|||
RtcPreInit();
|
||||
SettingsInit();
|
||||
|
||||
#ifdef USE_EMERGENCY_RESET
|
||||
EmergencyReset();
|
||||
#endif // USE_EMERGENCY_RESET
|
||||
|
||||
memset(&TasmotaGlobal, 0, sizeof(TasmotaGlobal));
|
||||
TasmotaGlobal.baudrate = APP_BAUDRATE;
|
||||
TasmotaGlobal.seriallog_timer = SERIALLOG_TIMER;
|
||||
|
@ -233,6 +238,7 @@ void setup(void) {
|
|||
TasmotaGlobal.tele_period = 9999;
|
||||
TasmotaGlobal.active_device = 1;
|
||||
TasmotaGlobal.global_state.data = 0xF; // Init global state (wifi_down, mqtt_down) to solve possible network issues
|
||||
TasmotaGlobal.enable_logging = 1;
|
||||
|
||||
RtcRebootLoad();
|
||||
if (!RtcRebootValid()) {
|
||||
|
|
Loading…
Reference in New Issue