Skip to content

Add function to check if a characteristic is subscribed - #296

Merged
fotiDim merged 4 commits into
mainfrom
Add-function-to-check-if-a-characteristic-is-subscribed
Sep 7, 2026
Merged

fotiDim merged 4 commits into
mainfrom
Add-function-to-check-if-a-characteristic-is-subscribed

Conversation

@fotiDim

@fotiDim fotiDim commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 CacheHandler and clear them on disconnect.
  • Expose subscription queries via UniversalBle.isSubscribed(...), UniversalBle.getSubscribedCharacteristics(...), plus convenience getters on BleCharacteristic/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.

Comment thread test/ble_characteristic_test.dart
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@rohitsangwan01 rohitsangwan01 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

@fotiDim
fotiDim force-pushed the Add-function-to-check-if-a-characteristic-is-subscribed branch from e9129b1 to 7ce034a Compare September 7, 2026 11:46
@fotiDim
fotiDim force-pushed the Add-function-to-check-if-a-characteristic-is-subscribed branch from 7089e18 to 6a3295e Compare September 7, 2026 11:47
@fotiDim

fotiDim commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@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

I am working on #301 for hot reload support. Let's merge that for now.

@fotiDim
fotiDim merged commit 06d8181 into main Sep 7, 2026
3 checks passed
@fotiDim
fotiDim deleted the Add-function-to-check-if-a-characteristic-is-subscribed branch September 7, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants