M1 step 2: Wi-Fi Service, Saved Networks, NTP, Settings page

- lib/wifi (host-tested): SavedNetworks (up to 8, validated, hidden
  flag, persisted) and WifiController (joins the strongest Saved
  Network, tries hidden ones in turn, backoff 10/30/60 s, connect
  timeout, Monitoring override, radio off without Saved Networks)
- WifiService carries out the controller's actions, sets the EU
  country code, and syncs the Clock over SNTP without touching the TZ
- Wi-Fi On/Off setting; Settings > Wi-Fi page: status, add from a scan
  or a hidden network, forget
- Status Bar: W + signal bars, W? while searching, MON while monitoring
- Serial: wifi add / wifi status (replaces the step 1 heap probe)

Verified on the device: joins the test network ~5 s after boot, clock
set over NTP, ~129 KB free heap while connected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
2026-10-02 14:46:07 +02:00
co-authored by Claude Opus 5.5
parent d8fe676c65
commit 1a0baf4ac7
22 changed files with 1108 additions and 48 deletions
+53
View File
@@ -0,0 +1,53 @@
#pragma once
#include <memory>
#include <string>
#include "dialog_model.h"
#include "event_bus.h"
#include "key_event.h"
#include "line_editor.h"
#include "list_model.h"
#include "saved_networks.h"
#include "services/wifi_service.h"
#include "settings.h"
#include "ui/canvas.h"
#include "ui/theme.h"
namespace roro {
// Settings → Wi-Fi: the On/Off switch, current connection, Saved Networks, and adding networks
// from a scan or by name (hidden). Owned by the Settings App.
class WifiSettingsPage {
public:
WifiSettingsPage(Settings& settings, SavedNetworks& saved, WifiService& wifi, EventBus& bus)
: settings_(settings), saved_(saved), wifi_(wifi), bus_(bus) {}
void enter();
bool onKey(const KeyEvent& e); // false: leave the page
bool textEntryActive() const { return view_ == View::Ssid || view_ == View::Password; }
bool live() const { return view_ == View::Main || view_ == View::Scan; } // redraw periodically
void draw(Canvas& c);
private:
enum class View { Main, Scan, Ssid, Password };
enum Fixed { kToggle, kStatus, kAddScanned, kAddHidden, kFixedRows };
void refreshMain();
void warn(const std::string& text, NotificationLevel level = NotificationLevel::Warning);
std::string statusText() const;
Settings& settings_;
SavedNetworks& saved_;
WifiService& wifi_;
EventBus& bus_;
View view_ = View::Main;
ListModel main_{theme::kContent.h / theme::kLineHeight};
ListModel scan_{theme::kContent.h / theme::kLineHeight};
LineEditor editor_{63};
std::string newSsid_;
bool newHidden_ = false;
std::unique_ptr<DialogModel> forgetDialog_;
};
} // namespace roro