Void Sentry
An AI-driven, real-time Sentry Turret platform leveraging asynchronous I/O and computer vision to deliver high-precision autonomous motion tracking on resource-constrained embedded hardware.
Loading...
Searching...
No Matches
wifi_plan.h
Go to the documentation of this file.
1
6#pragma once
7
8#include "prov_types.h"
9
10namespace prov
11{
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 };
16
17struct Action {
18 ActionKind kind = ActionKind::None;
19 uint8_t network = 0; // Join: index into NetworkList
20};
21
27{
28public:
29 static constexpr uint32_t kJoinTimeoutMs = 15000;
30 static constexpr uint32_t kLostToSetupMs = 120000;
31 static constexpr uint32_t kSetupRescanMs = 30000;
33 static constexpr uint32_t kSetupFirstRescanMs = 5000;
35 static constexpr uint8_t kTransientRetries = 2;
36
38 Action start(bool have_saved, uint32_t now_ms);
40 Action on_scan_done(const Candidates& c, uint32_t now_ms);
42 Action on_joined(uint32_t now_ms);
49 Action on_join_failed(JoinFail why, uint32_t now_ms);
51 Action on_disconnected(uint32_t now_ms);
56 Action on_network_added(uint32_t now_ms);
58 Action tick(uint32_t now_ms);
59
60 PlanState state() const;
61 bool hotspot_up() const;
62 JoinFail last_failure() const;
63
64private:
65 Action fail_over(uint32_t now_ms);
66 Action join_next(uint32_t now_ms);
67
68 PlanState _state = PlanState::Boot;
69 bool _hotspot = false;
70 JoinFail _last_fail = JoinFail::None;
71 bool _added_scan = false; // the pending scan was triggered by an added network
72 Candidates _cand;
73 size_t _next = 0;
74 uint32_t _join_ms = 0;
75 uint8_t _retries = 0; // Transient retries used on the current candidate
76 uint32_t _lost_ms = 0;
77 uint32_t _scan_ms = 0;
78};
79} // namespace prov
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