@@ -0,0 +1,2249 @@
+package nl.littlerobots.bean.internal.battery;%0A%0Aimport android.bluetooth.BluetoothGattCharacteristic;%0Aimport android.bluetooth.BluetoothGattService;%0A%0Aimport java.util.List;%0A%0Aimport nl.littlerobots.bean.internal.ble.BaseProfile;%0Aimport nl.littlerobots.bean.internal.ble.GattClient;%0A%0Apublic class BatteryProfile extends BaseProfile %7B%0A%0A    private static final int BATTERY_SERVICE_UID = 0x180F;%0A    private static final int BATTERY_CHARACTERISTIC_UID = 0x2A19;%0A%0A    private BluetoothGattService mBatteryService;%0A    private BatteryLevelCallback mCallback;%0A%0A    public BatteryProfile(GattClient client) %7B%0A        super(client);%0A    %7D%0A%0A    @Override%0A    public void onConnected() %7B%0A        mGattClient.discoverServices();%0A    %7D%0A%0A    @Override%0A    public void onServicesDiscovered(GattClient client) %7B%0A        List%3CBluetoothGattService%3E services = client.getServices();%0A        for (BluetoothGattService service : services) %7B%0A            if ((service.getUuid().getMostSignificantBits() %3E%3E 32) == BATTERY_SERVICE_UID) %7B%0A                mBatteryService = service;%0A            %7D%0A        %7D%0A    %7D%0A%0A    public void getBatteryLevel(BatteryLevelCallback callback) %7B%0A        mCallback = callback;%0A        for (BluetoothGattCharacteristic characteristic : mBatteryService.getCharacteristics()) %7B%0A            if ((characteristic.getUuid().getMostSignificantBits() %3E%3E 32) == BATTERY_CHARACTERISTIC_UID) %7B%0A                mGattClient.readCharacteristic(characteristic);%0A            %7D%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void onCharacteristicRead(GattClient client, BluetoothGattCharacteristic characteristic) %7B%0A        if ((characteristic.getUuid().getMostSignificantBits() %3E%3E 32) == BATTERY_CHARACTERISTIC_UID) %7B%0A            byte%5B%5D value = characteristic.getValue();%0A            if (mCallback != null) %7B%0A                int percentage = value%5B0%5D & 0xff;%0A                if (percentage %3E 100) %7B%0A                    percentage = 100;%0A                %7D else if (percentage %3C 0) %7B%0A                    percentage = 0;%0A                %7D%0A                mCallback.onBatteryLevel(percentage);%0A                mCallback = null;%0A            %7D%0A        %7D%0A    %7D%0A%0A    public static interface BatteryLevelCallback %7B%0A        public void onBatteryLevel(int percentage);%0A    %7D%0A%7D%0A

Add the profile