Add function to check if a characteristic is subscribed - #296
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new disconnect test starts a periodic notifier Timer via the mock subscribe path but doesn’t reliably tear it down, which can leak timers and make the test suite flaky.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds an in-memory mechanism to track whether the app is currently subscribed to a given characteristic’s notifications/indications, exposes that state via UniversalBle and BleCharacteristic APIs, and documents/tests the new behavior.
Changes:
- Track per-device subscribed characteristic UUIDs in
CacheHandlerand clear them on disconnect. - Expose subscription queries via
UniversalBle.isSubscribed(...),UniversalBle.getSubscribedCharacteristics(...), plus convenience getters onBleCharacteristic/CharacteristicSubscription. - Add README + CHANGELOG documentation and extend tests for subscribe/unsubscribe/disconnect behavior.
File summaries
| File | Description |
|---|---|
| test/ble_characteristic_test.dart | Adds assertions for subscription state before/after subscribe/unsubscribe and after disconnect. |
| README.md | Documents the new subscription status/query APIs with usage examples. |
| lib/src/utils/cache_handler.dart | Introduces a subscriptions cache and related query/update/reset helpers. |
| lib/src/universal_ble.dart | Adds isSubscribed / getSubscribedCharacteristics APIs and updates subscription state after notifiable changes. |
| lib/src/extensions/ble_characteristic_extension.dart | Adds isSubscribed getters on BleCharacteristic and CharacteristicSubscription. |
| CHANGELOG.md | Notes the addition of the subscription status APIs. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
rohitsangwan01
left a comment
There was a problem hiding this comment.
@fotiDim good for a quick implementation, but this state will be invalid on hot restart, so i think better solution will be to implement this on Native side to always get the actual state from native by original source of truth
e9129b1 to
7ce034a
Compare
7089e18 to
6a3295e
Compare
No description provided.