From ae97e961b9924e08ce2848aba8eddc179109c797 Mon Sep 17 00:00:00 2001 From: MrYoranimo Date: Fri, 5 Jan 2024 17:42:54 +0100 Subject: [PATCH] Xiaomi: add potential service and characteristic UUIDs --- .../service/btle/BleNamesResolver.java | 7 +++++- .../devices/xiaomi/XiaomiBleSupport.java | 25 ++++++++++++------- .../service/devices/xiaomi/XiaomiUuids.java | 22 +++++++++++++++- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BleNamesResolver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BleNamesResolver.java index 31c623b7b..98f7164c6 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BleNamesResolver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BleNamesResolver.java @@ -99,10 +99,15 @@ public class BleNamesResolver { mServices.put("00001814-0000-1000-8000-00805f9b34fb", "Running Speed and Cadence"); mServices.put("00001813-0000-1000-8000-00805f9b34fb", "Scan Parameters"); mServices.put("00001804-0000-1000-8000-00805f9b34fb", "Tx Power"); + mServices.put("0000fdab-0000-1000-8000-00805f9b34fb", "(Propr: Xiaomi Proximity Unlock Service)"); + mServices.put("0000fe95-0000-1000-8000-00805f9b34fb", "(Propr: Xiaomi Wear Service)"); mServices.put("0000fee0-0000-3512-2118-0009af100700", "(Propr: Xiaomi MiLi Service)"); mServices.put("00001530-0000-3512-2118-0009af100700", "(Propr: Xiaomi Weight Service)"); mServices.put("14701820-620a-3973-7c78-9cfff0876abd", "(Propr: HPLUS Service)"); - + mServices.put("16186f00-0000-1000-8000-00807f9b34fb", "(Propr: Xiaomi Wear Service - Mi Watch Lite/Redmi Watch)"); + mServices.put("16187f00-0000-1000-8000-00807f9b34fb", "(Propr: Xiaomi Wear Service - Mi Smart Watch 4C/Redmi Band)"); + mServices.put("1314f000-1000-9000-7000-301291e21220", "(Propr: Xiaomi Wear Service - Mi Watch/Mi Watch Color/Mi Watch Color Sport)"); + mServices.put("7495fe00-a7f3-424b-92dd-4a006a3aef56", "(Propr: Xiaomi Wear Service - Mi Watch CN)"); mCharacteristics.put("00002a43-0000-1000-8000-00805f9b34fb", "Alert AlertCategory ID"); mCharacteristics.put("00002a42-0000-1000-8000-00805f9b34fb", "Alert AlertCategory ID Bit Mask"); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/XiaomiBleSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/XiaomiBleSupport.java index 757fae5bb..268db4805 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/XiaomiBleSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/XiaomiBleSupport.java @@ -75,23 +75,30 @@ public class XiaomiBleSupport extends XiaomiConnectionSupport { if (getSupportedServices().contains(xiaomiUuid.getKey())) { LOG.debug("Found Xiaomi service: {}", xiaomiUuid.getKey()); uuidSet = xiaomiUuid.getValue(); + UUID currentChar; - btCharacteristicCommandRead = getCharacteristic(uuidSet.getCharacteristicCommandRead()); - btCharacteristicCommandWrite = getCharacteristic(uuidSet.getCharacteristicCommandWrite()); - btCharacteristicActivityData = getCharacteristic(uuidSet.getCharacteristicActivityData()); - btCharacteristicDataUpload = getCharacteristic(uuidSet.getCharacteristicDataUpload()); - if (btCharacteristicCommandRead == null) { + if ((currentChar = uuidSet.getCharacteristicCommandRead()) == null || + (btCharacteristicCommandRead = getCharacteristic(currentChar)) == null) { LOG.warn("btCharacteristicCommandRead characteristicc is null"); continue; - } else if (btCharacteristicCommandWrite == null) { + } + + if ((currentChar = uuidSet.getCharacteristicCommandWrite()) == null || + (btCharacteristicCommandWrite = getCharacteristic(currentChar)) == null) { LOG.warn("btCharacteristicCommandWrite characteristicc is null"); continue; - } else if (btCharacteristicActivityData == null) { + } + + if ((currentChar = uuidSet.getCharacteristicActivityData()) == null || + (btCharacteristicActivityData= getCharacteristic(currentChar)) == null) { LOG.warn("btCharacteristicActivityData characteristicc is null"); continue; - } else if (btCharacteristicDataUpload == null) { + } + + if ((currentChar = uuidSet.getCharacteristicDataUpload()) == null || + (btCharacteristicDataUpload= getCharacteristic(currentChar)) == null) { LOG.warn("btCharacteristicDataUpload characteristicc is null"); - continue; + // this characteristic may not be supported by all models } break; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/XiaomiUuids.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/XiaomiUuids.java index faa2e132c..62534d70a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/XiaomiUuids.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/XiaomiUuids.java @@ -40,6 +40,7 @@ public class XiaomiUuids { )); // Mi Watch Lite + // Redmi Watch put(UUID.fromString("16186f00-0000-1000-8000-00807f9b34fb"), new XiaomiBleUuidSet( false, UUID.fromString("16186f01-0000-1000-8000-00807f9b34fb"), @@ -48,7 +49,17 @@ public class XiaomiUuids { UUID.fromString("16186f04-0000-1000-8000-00807f9b34fb") )); - // Mi Watch Color Sport + // Mi Smart Watch 4C + // Redmi Band + put(UUID.fromString("16187f00-0000-1000-8000-00807f9b34fb"), new XiaomiBleUuidSet( + false, // FIXME check + UUID.fromString("16187f02-0000-1000-8000-00807f9b34fb"), + UUID.fromString("16187f01-0000-1000-8000-00807f9b34fb"), + UUID.fromString("16187f03-0000-1000-8000-00807f9b34fb"), + UUID.fromString("16187f04-0000-1000-8000-00807f9b34fb") + )); + + // Mi Watch (Color (Sport)) put(UUID.fromString("1314f000-1000-9000-7000-301291e21220"), new XiaomiBleUuidSet( false, UUID.fromString("1314f005-1000-9000-7000-301291e21220"), @@ -56,6 +67,15 @@ public class XiaomiUuids { UUID.fromString("1314f002-1000-9000-7000-301291e21220"), UUID.fromString("1314f007-1000-9000-7000-301291e21220") )); + + // Mi Watch CN + put(UUID.fromString("7495fe00-a7f3-424b-92dd-4a006a3aef56"), new XiaomiBleUuidSet( + false, // FIXME check + UUID.fromString("74950002-a7f3-424b-92dd-4a006a3aef56"), + UUID.fromString("74950001-a7f3-424b-92dd-4a006a3aef56"), + UUID.fromString("74950003-a7f3-424b-92dd-4a006a3aef56"), + null + )); }}; public static class XiaomiBleUuidSet {