12enum class PlanState { Boot, Scanning, Joining, Connected, Lost, Setup };
13enum class ActionKind {
None, StartScan, Join, StartHotspot, StopHotspot };
15enum class JoinFail {
None, Timeout, WrongPassword, NotFound, Other, Transient };
18 ActionKind kind = ActionKind::None;
29 static constexpr uint32_t kJoinTimeoutMs = 15000;
30 static constexpr uint32_t kLostToSetupMs = 120000;
31 static constexpr uint32_t kSetupRescanMs = 30000;
60 PlanState state()
const;
61 bool hotspot_up()
const;
65 Action fail_over(uint32_t now_ms);
66 Action join_next(uint32_t now_ms);
68 PlanState _state = PlanState::Boot;
69 bool _hotspot =
false;
70 JoinFail _last_fail = JoinFail::None;
71 bool _added_scan =
false;
74 uint32_t _join_ms = 0;
76 uint32_t _lost_ms = 0;
77 uint32_t _scan_ms = 0;
Decides what the WiFi glue should do next. Events that do not apply to the current state return Actio...
Definition wifi_plan.h:27
Action tick(uint32_t now_ms)
Timers: join timeout, Lost -> Setup, Setup rescan.
Definition wifi_plan.cpp:148
static constexpr uint8_t kTransientRetries
Same-candidate retries of a Transient failure within kJoinTimeoutMs.
Definition wifi_plan.h:35
Action on_join_failed(JoinFail why, uint32_t now_ms)
Joining only: next remembered candidate, else Setup (+ StartHotspot if not up). A Transient failure f...
Definition wifi_plan.cpp:106
Action on_network_added(uint32_t now_ms)
Setup or Lost -> StartScan (and the last failure is cleared; a scan that then finds no candidate reco...
Definition wifi_plan.cpp:133
static constexpr uint32_t kSetupFirstRescanMs
First Setup rescan after the join attempts of a boot or lost-network cycle all failed.
Definition wifi_plan.h:33
Action on_joined(uint32_t now_ms)
Joining, Lost or Setup -> Connected; StopHotspot if the hotspot is up.
Definition wifi_plan.cpp:72
Action on_disconnected(uint32_t now_ms)
Connected -> Lost (auto-reconnect retries; nothing issued).
Definition wifi_plan.cpp:122
Action start(bool have_saved, uint32_t now_ms)
Boot only: saved networks -> Scanning + StartScan; none -> Setup + StartHotspot.
Definition wifi_plan.cpp:16
Action on_scan_done(const Candidates &c, uint32_t now_ms)
Scan finished (Scanning, Setup or Lost). Candidates -> Joining; none -> Setup (Scanning only).
Definition wifi_plan.cpp:41
Plain value types shared by the WiFi provisioning logic (pure C++20, no heap).
Definition wifi_plan.h:17
Saved networks present in a scan, strongest first.
Definition prov_types.h:52
JoinFail
Transient: a failure that usually clears on an immediate retry (e.g. AUTH_EXPIRE right after boot).
Definition wifi_plan.h:15