mirror of
https://github.com/esphome/esphome.git
synced 2026-09-11 15:27:33 +00:00
Only dial immediately at boot for deep sleep devices
This commit is contained in:
@@ -46,8 +46,7 @@ void OutgoingConnectionManager::loop(APIServer *server) {
|
||||
switch (this->state_) {
|
||||
case DialState::DIAL_STATE_IDLE:
|
||||
// The connected target went away; give it the configured delay to
|
||||
// reconnect on its own before dialing. (Boot skips this state so a
|
||||
// device whose client never reached it dials right away.)
|
||||
// reconnect on its own before dialing.
|
||||
this->state_ = DialState::DIAL_STATE_WAITING;
|
||||
this->state_ts_ = now;
|
||||
this->wait_ = API_OUTGOING_CONNECTION_DELAY;
|
||||
|
||||
@@ -91,12 +91,17 @@ class OutgoingConnectionManager {
|
||||
SavedOutgoingTarget saved_{};
|
||||
#endif
|
||||
uint32_t backoff_{BACKOFF_MIN_MS};
|
||||
// Boot starts in WAITING, measured from boot: normally the client is
|
||||
// expected to connect in first, so the full delay applies. A deep sleep
|
||||
// device wakes for a short window where connecting out IS the wake state,
|
||||
// so it dials as soon as the network is up.
|
||||
#ifdef USE_DEEP_SLEEP
|
||||
uint32_t wait_{0};
|
||||
#else
|
||||
uint32_t wait_{API_OUTGOING_CONNECTION_DELAY};
|
||||
#endif
|
||||
uint32_t state_ts_{0};
|
||||
uint32_t last_poll_{0};
|
||||
// Boot starts in WAITING with wait_ 0: when no dial-back client has ever
|
||||
// connected (a device its client could never reach), dial immediately.
|
||||
// The configured delay only applies after a connected target goes away.
|
||||
DialState state_{DialState::DIAL_STATE_WAITING};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user