Improve Wi-Fi onboarding and BLE provisioning#46
Draft
Funkelfetisch wants to merge 4 commits into
Draft
Conversation
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@esp32/sdkconfig.defaults.ble-provisioning`:
- Around line 9-11: Update makeIdentity() in the ESP32 BLE provisioning
implementation so Security 1 uses a unique, non-public per-device secret rather
than the MAC suffix mac[3..5]. Preserve the existing BLE service-name identity
separately, and ensure the generated secret is delivered through the established
out-of-band provisioning mechanism.
In `@src/core/NetworkModule.h`:
- Around line 325-338: Update the empty-SSID branch in onUpdate() to ensure AP
mode is actually started, reusing the existing behavior from
maybeApplyPendingWifiCredentials(): transition via startAP() when state_ is not
already State::AP, then report the status. Preserve clearing
wifiCredentialApplyPending_ and avoid restarting AP when it is already active.
In `@src/platform/esp32/platform_esp32_ble_provisioning.cpp`:
- Around line 23-37: Make the BleProvisioningState fields started and
initialized atomic, then update all accesses in bleProvEventCb,
bleProvisioningInit, and bleProvisioningStop to use atomic-safe reads and
writes. Preserve the existing branching and lifecycle behavior while ensuring
concurrent provisioning callbacks and main-thread teardown cannot race.
- Around line 66-75: Update makeIdentity so g_bleProv.pop is derived from a
private per-device secret or another non-advertised provisioning source, rather
than mac[3..5] used in serviceName. Keep the BLE service name generation
unchanged, and ensure the PoP remains available through the intended secure
channel or device labeling without being recoverable from the advertised name.
In `@test/unit/core/unit_NetworkModule.cpp`:
- Around line 66-117: Extend the NetworkModule regression coverage with a test
that sets a non-empty SSID, connects, then clears the SSID through
scheduler.setControl and verifies the module enters AP state using its state/API
assertion rather than only checking status text. Keep the test clock setup and
ClockGuard cleanup pattern, and ensure the assertion matches the specification
in docs/moonmodules/.
🪄 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: bb426d11-8e5c-4171-9181-387836ea56c6
⛔ Files ignored due to path filters (1)
moondeck/build/build_esp32.pyis excluded by!**/build/**
📒 Files selected for processing (15)
docs/moonmodules/core/services.mdesp32/main/CMakeLists.txtesp32/main/Kconfig.projbuildesp32/main/idf_component.ymlesp32/sdkconfig.defaults.ble-provisioningsrc/core/BleProvisioningModule.hsrc/core/NetworkModule.hsrc/main.cppsrc/platform/desktop/platform_config.hsrc/platform/desktop/platform_desktop.cppsrc/platform/esp32/platform_config.hsrc/platform/esp32/platform_esp32.cppsrc/platform/esp32/platform_esp32_ble_provisioning.cppsrc/platform/platform.htest/unit/core/unit_NetworkModule.cpp
Drops the public MAC-derived proof-of-possession path, uses security 0 instead of pretending to have a secret, makes BLE provisioning state atomic, and restores AP mode when an empty SSID is applied through web controls. Checks: check_specs.py; git diff --check; build_esp32.py --firmware esp32s3-n16r8 (projectMM.bin 0x1cd630, total image 1889720 bytes). Notes: This PR is BLE Wi-Fi provisioning only; it does not add BLE firmware OTA.
Keep unauthenticated BLE onboarding available only while Network is in AP fallback, inject platform calls at runtime, and add lifecycle and credential tests. KPI: 16384lights | tick:673/159/152/705/1656/637/9/526/197/119/12/734/1622/104us(FPS:1485/6289/6578/1418/603/1569/111111/1901/5076/8403/83333/1362/616/9615) | src:192(37213) | test:128(19441) - Core: inject a platform-neutral BLE runtime and stop advertising once the network is configured. - Tests: add BLE startup, retry, credential publication, password clearing, and release coverage; refresh required desktop scenario observations. - Validation: 24 focused C++ tests, 20 scenarios, 55 Python tests, specs, platform boundary, firmware catalog, and BLE-enabled ESP32-S3 build pass. - Gate note: full ctest is blocked by the existing x86 Zig unused-function warning in test/unit/core/unit_moonlive_ir.cpp; the focused BLE and Network suite passes.
c1d403e to
feb712e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
main.cppso core stays platform-neutral and desktop tests can exercise lifecycle behaviorReview follow-up
Validation
git diff --checkesp32s3-n8r8build: 1,893,036-byte image, 40% app partition freeRemaining hardware validation
Known external gate
ctestexecutable is blocked by the existing unusedplacehelper warning intest/unit/core/unit_moonlive_ir.cpp; the focused BLE/Network executable passes