feat(wifi): keep-awake toggle to disable modem sleep#163
Conversation
Arduino-ESP32 defaults WiFi to WIFI_PS_MIN_MODEM, which can drop reported RSSI ~10 dB vs ESPHome on identical hardware. New NVS-backed config toggle (wifi_keep_awake, default off) calls WiFi.setSleep(false) after WiFi.begin so users on weak networks can opt into full-power operation. Plumbing mirrors the bambu_dashboard pattern: ConfigUpdate struct field, NVS key "wifi_awake", getter, /api/config GET/POST, web form toggle in the WiFi section.
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 28 minutes and 3 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughA new WiFi modem sleep behavior configuration feature is added across the firmware stack. The feature includes a UI checkbox toggle, persistent NVS storage via the ConfigurationManager, REST API exposure, and runtime control via Changes
Sequence DiagramsequenceDiagram
participant User as User/Browser
participant UI as Web UI
participant API as WebServerManager
participant Config as ConfigurationManager
participant NVS as NVS Storage
participant WiFi as WiFi Driver
rect rgba(100, 150, 255, 0.5)
Note over User,WiFi: Configuration Update Flow
User->>UI: Toggle "Keep WiFi awake"
UI->>API: POST /api/config with wifi_keep_awake: 1
API->>Config: parseUpdate() sets update.wifi_keep_awake
Config->>Config: saveToNVS(update)
Config->>NVS: Write NVS_KEY_WIFI_AWAKE = 1
NVS-->>Config: Stored
API-->>UI: Config updated
UI-->>User: Confirm change
end
rect rgba(150, 200, 100, 0.5)
Note over User,WiFi: Runtime Application Flow
User->>WiFi: Device restarts/reinitializes
WiFi->>Config: initWiFi() calls isWifiKeepAwakeEnabled()
Config->>Config: Returns _wifiKeepAwake value
Config-->>WiFi: Returns setting state
WiFi->>WiFi: setSleep(!enabled) applies modem sleep policy
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/ConfigHTML.h`:
- Around line 99-108: The checkbox input with id "wifi_keep_awake" has no
accessible label; either move the visible text (the element with class
"toggle-label") inside the same <label> as the input or give that text an id
(e.g., add id "wifi_keep_awake_label" to the span with class "toggle-label") and
set aria-labelledby="wifi_keep_awake_label" on the input element; ensure the
input retains id "wifi_keep_awake" so references in JS remain valid and update
any related CSS/JS if you change element nesting.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: b3a372c7-10be-412f-a889-acaf52395900
📒 Files selected for processing (5)
src/ConfigHTML.hsrc/ConfigurationManager.cppsrc/ConfigurationManager.hsrc/WebServerManager.cppsrc/main.cpp
Addresses CodeRabbit finding on #163. Toggle rows rendered the visible caption as a <span class="toggle-label"> sibling to the <input>, so screen readers announced the checkbox with no accessible name. Adds an id to each caption span and points the input/select at it via aria-labelledby. Covers the new wifi_keep_awake toggle plus the pre-existing spoolman_on, prusalink_on, lcd_enabled, led_enabled, keypad_enabled, tft_enabled, bambu_dashboard toggles and the tft_driver, nfc_reader selects. Fixes WCAG 1.3.1 (Info and Relationships) and 4.1.2 (Name, Role, Value). No visual or behavioral change.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Bumps FIRMWARE_VERSION from 1.7.2 → 1.7.3. CHANGELOG.md: - Adds [1.7.3] entry documenting SpoolSense#163 WiFi keep-awake, SpoolSense#165 case files, SpoolSense#164/SpoolSense#13 TigerTag partial writes, SpoolSense#159/SpoolSense#162 openprinttag rename. - Backfills missing [1.7.2] entry (Bambu MIFARE Classic reading, SpoolSense#24). - Backfills missing [1.7.1] entry (writer enrichment + bug fixes, SpoolSense#130/SpoolSense#101/SpoolSense#128/SpoolSense#151 and platform pin).
Summary
WiFi.setSleep(false)afterWiFi.begin()to disableWIFI_PS_MIN_MODEM.Changes
ConfigurationManager.h/.cppwifi_keep_awakestruct field,NVS_KEY_WIFI_AWAKE = "wifi_awake",isWifiKeepAwakeEnabled()getter, load/save wiringConfigHTML.hWebServerManager.cpp/api/configGET exposes it, POST parses itmain.cppWiFi.setSleep(!config.isWifiKeepAwakeEnabled())afterWiFi.begin()Plumbing mirrors the existing
bambu_dashboardpattern.Test plan
esp32dev,esp32s3devkitc,esp32s3zero(espressif32@6.10.0)Summary by CodeRabbit