mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 21:06:50 +01:00
Xiaomi: Improve service auto-detection
Some watches have the encrypted service, even though they're plaintext, but are missing the characteristics.
This commit is contained in:
parent
1c68252255
commit
4de7cb3591
@ -114,9 +114,31 @@ public class XiaomiSupport extends AbstractBTLEDeviceSupport {
|
||||
@Override
|
||||
protected final TransactionBuilder initializeDevice(final TransactionBuilder builder) {
|
||||
XiaomiBleUuids.XiaomiBleUuidSet uuidSet = null;
|
||||
BluetoothGattCharacteristic btCharacteristicCommandRead = null;
|
||||
BluetoothGattCharacteristic btCharacteristicCommandWrite = null;
|
||||
BluetoothGattCharacteristic btCharacteristicActivityData = null;
|
||||
BluetoothGattCharacteristic btCharacteristicDataUpload = null;
|
||||
for (Map.Entry<UUID, XiaomiBleUuids.XiaomiBleUuidSet> xiaomiUuid : XiaomiBleUuids.UUIDS.entrySet()) {
|
||||
if (getSupportedServices().contains(xiaomiUuid.getKey())) {
|
||||
LOG.debug("Found Xiaomi service: {}", xiaomiUuid.getKey());
|
||||
btCharacteristicCommandRead = getCharacteristic(xiaomiUuid.getValue().getCharacteristicCommandRead());
|
||||
btCharacteristicCommandWrite = getCharacteristic(xiaomiUuid.getValue().getCharacteristicCommandWrite());
|
||||
btCharacteristicActivityData = getCharacteristic(xiaomiUuid.getValue().getCharacteristicActivityData());
|
||||
btCharacteristicDataUpload = getCharacteristic(xiaomiUuid.getValue().getCharacteristicDataUpload());
|
||||
if (btCharacteristicCommandRead == null) {
|
||||
LOG.warn("btCharacteristicCommandRead characteristicc is null");
|
||||
continue;
|
||||
} else if (btCharacteristicCommandWrite == null) {
|
||||
LOG.warn("btCharacteristicCommandWrite characteristicc is null");
|
||||
continue;
|
||||
} else if (btCharacteristicActivityData == null) {
|
||||
LOG.warn("btCharacteristicActivityData characteristicc is null");
|
||||
continue;
|
||||
} else if (btCharacteristicDataUpload == null) {
|
||||
LOG.warn("btCharacteristicDataUpload characteristicc is null");
|
||||
continue;
|
||||
}
|
||||
|
||||
uuidSet = xiaomiUuid.getValue();
|
||||
break;
|
||||
}
|
||||
@ -129,11 +151,6 @@ public class XiaomiSupport extends AbstractBTLEDeviceSupport {
|
||||
return builder;
|
||||
}
|
||||
|
||||
final BluetoothGattCharacteristic btCharacteristicCommandRead = getCharacteristic(uuidSet.getCharacteristicCommandRead());
|
||||
final BluetoothGattCharacteristic btCharacteristicCommandWrite = getCharacteristic(uuidSet.getCharacteristicCommandWrite());
|
||||
final BluetoothGattCharacteristic btCharacteristicActivityData = getCharacteristic(uuidSet.getCharacteristicActivityData());
|
||||
final BluetoothGattCharacteristic btCharacteristicDataUpload = getCharacteristic(uuidSet.getCharacteristicDataUpload());
|
||||
|
||||
// FIXME unsetDynamicState unsets the fw version, which causes problems..
|
||||
if (getDevice().getFirmwareVersion() == null && mFirmwareVersion != null) {
|
||||
getDevice().setFirmwareVersion(mFirmwareVersion);
|
||||
|
Loading…
Reference in New Issue
Block a user