ESPHome  2024.4.2
safe_mode_button.cpp
Go to the documentation of this file.
1 #include "safe_mode_button.h"
2 #include "esphome/core/hal.h"
3 #include "esphome/core/log.h"
5 
6 namespace esphome {
7 namespace safe_mode {
8 
9 static const char *const TAG = "safe_mode.button";
10 
11 void SafeModeButton::set_ota(ota::OTAComponent *ota) { this->ota_ = ota; }
12 
14  ESP_LOGI(TAG, "Restarting device in safe mode...");
15  this->ota_->set_safe_mode_pending(true);
16 
17  // Let MQTT settle a bit
18  delay(100); // NOLINT
19  App.safe_reboot();
20 }
21 
22 void SafeModeButton::dump_config() { LOG_BUTTON("", "Safe Mode Button", this); }
23 
24 } // namespace safe_mode
25 } // namespace esphome
void set_ota(ota::OTAComponent *ota)
Application App
Global storage of Application pointer - only one Application can exist.
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
void set_safe_mode_pending(const bool &pending)
Set to true if the next startup will enter safe mode.
OTAComponent provides a simple way to integrate Over-the-Air updates into your app using ArduinoOTA...
Definition: ota_component.h:44
void IRAM_ATTR HOT delay(uint32_t ms)
Definition: core.cpp:26