I want some way to read the connection parameters programatically in Android BLE.
Android's BluetoothGatt
class, as of API 21, provides these three modes to set up connection parameters.
CONNECTION_PRIORITY_BALANCED Connection paramter update - Use the connection paramters recommended by the Bluetooth SIG.
CONNECTION_PRIORITY_HIGH Connection paramter update - Request a high priority, low latency connection.
CONNECTION_PRIORITY_LOW_POWER Connection paramter update - Request low power, reduced data rate connection parameters.
These have been discussed in detail here, and here.
Since none of these give me the connection interval that I want, so tried performing a connection update from the side of my peripheral. Luckily, that seems to work. After I send the connection update I can see in Logcat:
D/BluetoothGattServer: onConnectionUpdated() - Device=XX:XX:XX:XX:XX:XX interval=1596 latency=0 timeout=512 status=0
D/BluetoothGatt: onConnectionUpdated() - Device=XX:XX:XX:XX:XX:XX interval=1596 latency=0 timeout=512 status=0
I don't care what interval the Android devices chooses, so long as it is between 1000ms and 2000ms. While it is easy to see this change occurring in the logs, I have yet to find a way to read the interval value programatically. I would like to make sure this update occurred so that I am not wasting battery life on my peripheral.