From bb710bae92637de2b5c4835e1e3590b99eda3260 Mon Sep 17 00:00:00 2001 From: Thomas Kuehne Date: Sun, 10 Aug 2025 00:00:00 +0200 Subject: [PATCH] fix: BatteryInfoProfile complaining about unexpected characteristics --- .../btle/profiles/battery/BatteryInfoProfile.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/battery/BatteryInfoProfile.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/battery/BatteryInfoProfile.java index d9df042723..a5f84fafec 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/battery/BatteryInfoProfile.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/profiles/battery/BatteryInfoProfile.java @@ -60,16 +60,15 @@ public class BatteryInfoProfile exten @Override public boolean onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, byte[] value, int status) { - if (status == BluetoothGatt.GATT_SUCCESS) { - UUID charUuid = characteristic.getUuid(); - if (charUuid.equals(UUID_CHARACTERISTIC_BATTERY_LEVEL)) { + UUID charUuid = characteristic.getUuid(); + if (charUuid.equals(UUID_CHARACTERISTIC_BATTERY_LEVEL)) { + if (status == BluetoothGatt.GATT_SUCCESS) { handleBatteryLevel(gatt, characteristic, value); return true; } else { - LOG.info("Unexpected onCharacteristicRead: " + GattCharacteristic.toString(characteristic)); + LOG.warn("error reading characteristic: {}", GattCharacteristic.toString(characteristic)); + return false; } - } else { - LOG.warn("error reading from characteristic:" + GattCharacteristic.toString(characteristic)); } return false; }