NordicSemiconductor / Android-BLE-Library

A library that makes working with Bluetooth LE on Android a pleasure. Seriously.
BSD 3-Clause "New" or "Revised" License
1.98k stars 413 forks source link

Samsung Tab S6 Lite: Connection Parameter Negotiation #537

Closed LimeSlice closed 6 months ago

LimeSlice commented 9 months ago

Currently developing BLE peripheral using an RSL10, while developing a BLE Central on a Samsung Tab S6 Lite using this library. Having some trouble with the connection parameters being set high. Before service discovery, the connection is initialized with interval=6, latency=0, timeout=500. After service discovery, they get updated to interval=36, latency=0, timeout=500.

Currently, the RSL10 is accepting whatever parameters are being received, but this needs to change as this is meant to be an ultra-low power device where the preferred connection parameters are: min_intv=15 max_intv=60 latency=30 timeout=6000

My main concern is the latency. I need to be able to change this latency between 5 and 30 at different points in the code, but it seems sending out a GAPC_UPDATE_PARAMS_IND isn't being received by any listener. Any advice or recommendations?

philips77 commented 8 months ago

Before service discovery, the connection is initialized with interval=6, latency=0, timeout=500. After service discovery, they get updated to interval=36, latency=0, timeout=500.

Android uses short connection interal for service discovery. When complete, it changes to default ones. You may request other from Android using requestConnectionPriority(...) or from the device side.

My main concern is the latency. I need to be able to change this latency between 5 and 30 at different points in the code, but it seems sending out a GAPC_UPDATE_PARAMS_IND isn't being received by any listener. Any advice or recommendations?

There's a setConnectionParametersListener method in BleManager: https://github.com/NordicSemiconductor/Android-BLE-Library/blob/3112b52021cb1e91a5f693fdd7ebca9777de6f6d/ble/src/main/java/no/nordicsemi/android/ble/BleManager.java#L2057-L2070 (Android 8+)