1

I am developing an Android BLE application for connecting with a BLE peripheral device. The BLE peripheral device has strong energy constraints and therefore the connection interval should be kept high when establishing the connection.

To increase the connection interval, I am calling

requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER)

in the callback onConnectionStateChange, once the connection is established. The connection interval is then changed to 96 ms as expected. However, I observe that when establishing the connection, before the callback is called, the connection interval is much shorter during 300 ms.

 D  connect() - device: D1:79:4F:0F:F2:D0, auto: false, eattSupport: false
 D  registerApp()
 D  registerApp() - UUID=d02dd9c1-6ca6-4d9f-9037-ec41fc4ea29c
 D  onClientRegistered() - status=0 clientIf=9
 D  isLeEnabled(): ON
 D  onClientConnectionState() - status=0 clientIf=9 device=D1:79:4F:0F:F2:D0
 D  requestConnectionPriority() - params: 2
 D  onConfigureMTU() - Device=D1:79:4F:0F:F2:D0 mtu=247 status=0
 D  onConnectionUpdated() - Device=D1:79:4F:0F:F2:D0 interval=6 latency=0 timeout=500 status=0
 D  onConnectionUpdated() - Device=D1:79:4F:0F:F2:D0 interval=96 latency=2 timeout=500 status=0

I have also tried to call requestConnectionPriority right after the call to connectGatt to change the connection interval as early as possible. This had no effect. Tests were done with a Sony Xperia 1 III with code from https://github.com/android/platform-samples/tree/main/samples/connectivity/bluetooth/ble.

Is there a way to control the connection interval from the very start of establishing the BLE connection?

New contributor
Titouan Gaborit is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1 Answer 1

1

On Android, there is no API for changing the default connection interval parameters. If you have control of the peripheral code, you can set the default connection parameters on the peripheral to be as desired. This way, when the Android device establishes the connection with the peripheral device, the connection parameters will change during the connection interval negotiation process. Your second best option is as you said, have requestConnectionPriority be called right after connectGatt or onConnectionStateChange. Have a look at the links below for more information:-

Not the answer you're looking for? Browse other questions tagged or ask your own question.