This commit is contained in:
J. Nick Koston 2025-07-05 16:01:59 -05:00
parent f85dcdca4e
commit 8aac2f525e
No known key found for this signature in database
3 changed files with 6 additions and 7 deletions

View File

@ -48,7 +48,7 @@ void DeepSleepComponent::begin_sleep(bool manual) {
if (this->prevent_ && !manual) {
// Sleep was prevented
this->sleep_state_ = SLEEP_STATE_BLOCKED_BY_PREVENT;
this->sleep_state_ = SLEEP_STATE_BLOCKED;
ESP_LOGD(TAG, "Deep sleep blocked by prevent flag");
return;
}
@ -79,8 +79,8 @@ void DeepSleepComponent::prevent_deep_sleep() { this->prevent_ = true; }
void DeepSleepComponent::allow_deep_sleep() {
this->prevent_ = false;
// If sleep was blocked by prevent flag, try to sleep now
if (this->sleep_state_ == SLEEP_STATE_BLOCKED_BY_PREVENT) {
// If sleep was blocked, try to sleep now
if (this->sleep_state_ == SLEEP_STATE_BLOCKED) {
ESP_LOGD(TAG, "Deep sleep allowed, executing deferred sleep");
this->sleep_state_ = SLEEP_STATE_IDLE;
// Schedule sleep for next loop iteration to avoid potential issues

View File

@ -124,8 +124,7 @@ class DeepSleepComponent : public Component {
#endif
enum SleepState : uint8_t {
SLEEP_STATE_IDLE,
SLEEP_STATE_BLOCKED_BY_PREVENT,
SLEEP_STATE_BLOCKED_BY_WAKEUP_PIN,
SLEEP_STATE_BLOCKED,
SLEEP_STATE_ENTERING_SLEEP,
};

View File

@ -59,8 +59,8 @@ bool DeepSleepComponent::prepare_to_sleep_() {
if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_KEEP_AWAKE && this->wakeup_pin_ != nullptr &&
this->wakeup_pin_->digital_read()) {
// Defer deep sleep until inactive
if (this->sleep_state_ != SLEEP_STATE_BLOCKED_BY_WAKEUP_PIN) {
this->sleep_state_ = SLEEP_STATE_BLOCKED_BY_WAKEUP_PIN;
if (this->sleep_state_ != SLEEP_STATE_BLOCKED) {
this->sleep_state_ = SLEEP_STATE_BLOCKED;
this->status_set_warning();
ESP_LOGW(TAG, "Waiting for wakeup pin state change");
// Set up monitoring - check pin state every 100ms