yanshouwang / bluetooth_low_energy

A Flutter plugin for controlling the bluetooth low energy.
https://pub.dev/packages/bluetooth_low_energy
MIT License
46 stars 15 forks source link

[Question] How to Notify Characteristics Change from Peripheral to All Connected Central? #90

Open zoomkoding opened 1 month ago

zoomkoding commented 1 month ago

First, thank you so much for implementing this essential library and maintaining it diligently.

In my project, I need to continuously notify all connected central devices of changes from a peripheral device. Among the peripheral manager functions, instead of directly taking central or request as an argument, I want to propagate the changed characteristics to all subscribed central devices. Could you please guide me on how to implement this?

Thank you in advance for your help!

yanshouwang commented 1 month ago

You have to listen the characteristicNotifyStateChanged stream and cache the notified centrals by yourself. Then notify the centrals one bye one in this version.

I know it's better to make the central argument as optional and notify all centrals when this argument is null. This feature is available on all platforms except Android. To implemnet this feature I have to notify the centrals one by one on Android. And how to returns the notify result is another thing to be considered since each notify maybe failed.

Maybe I can implement this in the 7.0.0 version, but now you have to notify the centrals one by one.

zoomkoding commented 1 month ago

Thank you for the detailed explanation and quick response.

So, it means that I should manage the state of the centrals separately and call notifyCharacteristic for each central whenever there is a change. It would be really great if, as you mentioned, the library could manage the information of the subscribed centrals and take centrals as an optional parameter.

I'm looking forward to version 7.0.0! Thank you once again for implementing such a great library!

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open for 30 days with no activity.