Checking V.BTTN Battery Level


1 comment

  • Official comment
    VSN Mobil Support

    Here’s what you need to do. Keep in mind that reading are instantaneous and levels can dip and raise depending on how much draw the device is putting on the battery at any given time (ie battery will show lower when device is flashing light, beeping, or even transmitting).


    During service discovery, you need to loop thru all the services and get the battery service.


    for (BluetoothGattService service : gatt.getServices()) {

    if (Constants.SERVICE_BATTERY_LEVEL.equal(service.getUuid())) {

    batteryService = service;


    // get other services



    Then you can use the service later to send command to read the battery level (or subscribe for battery notification).




    After sending read command, you will get callback….


    onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {

    // Didn’t include here, but should check to make sure callback is from battery read by checking characteristic Uuid


    batteryLevel = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UNIT8, 0);



    Constants are…

    public static final UUID SERVICE_BATTERY_LEVEL = UUID.fromString(“0000180F-0000-1000-8000-00805f9b34fb”);

    public static final UUID CHAR_BATTERY_LEVEL = UUID.fromString(“00002a19-0000-1000-8000-00805f9b34fb”);

    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk