Add Safe Mode Restart Switch (#2437)

This commit is contained in:
Paul Monigatti
2021-10-06 20:44:48 +13:00
committed by GitHub
parent 54a173dbf1
commit 955c96731e
9 changed files with 135 additions and 5 deletions
+7
View File
@@ -48,6 +48,10 @@ class OTAComponent : public Component {
bool should_enter_safe_mode(uint8_t num_attempts, uint32_t enable_time);
/// Set to true if the next startup will enter safe mode
void set_safe_mode_pending(const bool &pending);
bool get_safe_mode_pending();
#ifdef USE_OTA_STATE_CALLBACK
void add_on_state_callback(std::function<void(OTAState, float, uint8_t)> &&callback);
#endif
@@ -89,6 +93,9 @@ class OTAComponent : public Component {
uint8_t safe_mode_num_attempts_;
ESPPreferenceObject rtc_;
static const uint32_t ENTER_SAFE_MODE_MAGIC =
0x5afe5afe; ///< a magic number to indicate that safe mode should be entered on next boot
#ifdef USE_OTA_STATE_CALLBACK
CallbackManager<void(OTAState, float, uint8_t)> state_callback_{};
#endif