mirror of
https://github.com/esphome/esphome.git
synced 2025-10-28 21:53:48 +00:00
Add Factory Reset button and switch (#3724)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
790280ace9
commit
9a5f865eea
@@ -243,17 +243,34 @@ class ESP8266Preferences : public ESPPreferences {
|
||||
}
|
||||
}
|
||||
if (erase_res != SPI_FLASH_RESULT_OK) {
|
||||
ESP_LOGV(TAG, "Erase ESP8266 flash failed!");
|
||||
ESP_LOGE(TAG, "Erase ESP8266 flash failed!");
|
||||
return false;
|
||||
}
|
||||
if (write_res != SPI_FLASH_RESULT_OK) {
|
||||
ESP_LOGV(TAG, "Write ESP8266 flash failed!");
|
||||
ESP_LOGE(TAG, "Write ESP8266 flash failed!");
|
||||
return false;
|
||||
}
|
||||
|
||||
s_flash_dirty = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool reset() override {
|
||||
ESP_LOGD(TAG, "Cleaning up preferences in flash...");
|
||||
SpiFlashOpResult erase_res;
|
||||
{
|
||||
InterruptLock lock;
|
||||
erase_res = spi_flash_erase_sector(get_esp8266_flash_sector());
|
||||
}
|
||||
if (erase_res != SPI_FLASH_RESULT_OK) {
|
||||
ESP_LOGE(TAG, "Erase ESP8266 flash failed!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Protect flash from writing till restart
|
||||
s_prevent_write = true;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void setup_preferences() {
|
||||
|
||||
Reference in New Issue
Block a user