boskokg / flutter_blue_plus

Flutter plugin for connecting and communicationg with Bluetooth Low Energy devices, on Android and iOS
Other
681 stars 427 forks source link

[Feature]: Android: Get connection parameters #746

Open savvn001 opened 7 months ago

savvn001 commented 7 months ago

FlutterBluePlus Version

1.31.2

Flutter Version

3.16.5

What OS?

All

OS Version

macOS

Bluetooth Module

.

What is your feature request?

It would be nice to have an API to be able to get some other current connection parameters other than MTU for the connected device, for example, connection interval, without having to dig down into the platform APIs. Would this be a fairly straightforward addition?

Logs

.
chipweinberger commented 7 months ago

not possible. android and ios don't expose this.

please link me the docs if i'm wrong.

savvn001 commented 7 months ago

Oh that's interesting. I just assumed they did. Have you used Nordic's nRF connect app for android? It seems to be able to log when connection parameters are changed, and show information like that. So it's maybe hooking on somehow. But I don't believe that particular app is open sourced.

savvn001 commented 5 months ago

On Android, I think is some kind of callback whenever the connection is updated:

I saw from my logs whilst debugging my app:

D/BluetoothGatt(13462): onConnectionUpdated() - Device=F0:0D:BE:EF:BB:11 interval=144 latency=0 timeout=400 status=0

There seems to be this onConnectionUpdated method in BluetoothGatt.java. See this https://stackoverflow.com/a/52757948

chipweinberger commented 5 months ago

interesting. never saw that before!

it's not in the documentation: https://developer.android.com/reference/android/bluetooth/BluetoothGattCallback

feel free to open a PR

savvn001 commented 5 months ago

Yeah sure. If I get some time I can try to contribute that feature

chipweinberger commented 5 months ago

I mean, only if you need this feature.

otherwise we shouldn't add it if no one wants it.

elethiame commented 2 days ago

Modifying the connection interval is crucial for our app. Currently, we aim to transmit 100+kb data to the Bluetooth device. However, with a small MTU and an unadjustable connection interval, the user experience is poor.

chipweinberger commented 2 days ago

modification is not possible