Plugin BLE binding and Sensor discovery checkpoint - #820
Conversation
ff4efc3 to
071294c
Compare
tadelv
left a comment
There was a problem hiding this comment.
The implementation direction looks consistent with #749/#809, and the existing coverage is strong, but I think two central ownership cases still need explicit contract tests before this checkpoint lands:
-
Do not hot-swap an already-connected native owner. #809 explicitly says an occupied device keeps its current owner and enabling a matching plugin must not replace an active native connection. The current
plugin-first ownership fences old native candidatetest covers a discovered/unconnected native candidate: it loads the plugin first, then verifies the stale native candidate cannot connect. Please add the complementary case where the native candidate connects and owns the physical ID first, then a matching plugin is loaded. Assert the native connection remains untouched/no plugin transport is created while it is occupied, and that plugin ownership can only be selected after normal native teardown plus subsequent discovery/reconciliation. -
A loaded BLE declaration without a runtime
bindDrivermust remain native-eligible. This is another explicit fallback condition in #809 and is materially different from the plugin being absent or failing to load. Please cover a successfully loaded plugin whose manifest declares the matching BLE driver but whose runtime never binds it, and verify the existing native candidate is still selected.
These are both first-order ownership rules rather than timing/fuzz/edge cases, and they protect the main #749 boundary: Decaid owns arbitration/lifecycle and a plugin only participates once it has a valid runtime driver binding.
Non-blocking cleanup while touching this: the PR is currently marked ready for review, but its description/archive plan still say This PR remains draft / Status: draft checkpoint and describe later stack slices as remaining merge-readiness work. It would be clearer to update that wording so #820's actual merge boundary is explicit.
Summary
host.devices.bindDriver()and host-owned BLE bindings with synchronous factories, session-scoped GATT/publication, and bounded teardown.This is the review-ready BLE binding and Sensor checkpoint after merged #813, not completion of #809. Its merge boundary is host-owned BLE arbitration/lifecycle and Sensor integration through existing controllers and APIs, verified with a fake BLE edge.
Linked Issue
Refs #809. Keep the issue open.
Verification
flutter analyze --no-pub: no issues.flutter test --no-pub --machine: 3,992 passing tests, one skip. The 20-second per-suite active-time gate passes.lib/main.dart, simulate=1) passed using CMake 3.28 and Visual Studio 2022 in a separate build directory. Flutter's default VS2019 toolchain failed on native dependencies; no global toolchain settings or dependency sources were changed.{"status":"ok","result":{"humidity":52}}; a fresh WebSocket notification returned{"humidity":57}. Runtime exited after teardown. No real BLE/USB devices or saved user data were used. This is not full application UI/hardware acceptance.Subsequent #809 checkpoints cover Bookoo protocol, Scale measurement timing, automatic optional Scale operations, and sleep policy. Exhaustive reload/discovery interleavings and physical hardware acceptance remain broader #809 acceptance work; they are not claimed by this checkpoint. #809 remains open.
Latest ownership-contract verification at
75e8ec6e: all 10 discovery-policy tests pass, including occupied native ownership through plugin load and loaded-but-unbound declaration fallback. Full suite: 3,992 passed, one skipped; analysis clean; formatter and 20-second suite timing gate pass. No production code changed in this follow-up. Native build/runtime smoke above are prior checkpoint evidence, not rerun for this test/doc-only change.Impact
Contributor Responsibility
AI-assisted development is allowed. The submitter remains responsible for the submitted work.