From ebab69a0637e82ba1ec16d2712ef1d43e0bf6763 Mon Sep 17 00:00:00 2001 From: Daniel Dakhno Date: Tue, 1 Oct 2019 16:05:47 +0200 Subject: [PATCH] added firmware check on connect --- .../service/devices/qhybrid/QHybridSupport.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/QHybridSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/QHybridSupport.java index 13c6c2a18..3e59bd202 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/QHybridSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/QHybridSupport.java @@ -365,6 +365,9 @@ public class QHybridSupport extends QHybridBaseSupport { case "00002a26-0000-1000-8000-00805f9b34fb": { String firmwareVersion = characteristic.getStringValue(0); gbDevice.setFirmwareVersion(firmwareVersion); + + checkFirmwareVersion(firmwareVersion); + break; } case "00002a19-0000-1000-8000-00805f9b34fb": { @@ -384,6 +387,19 @@ public class QHybridSupport extends QHybridBaseSupport { return true; } + private void checkFirmwareVersion(String firmwareVersion){ + if(!isFirmwareCompatible(firmwareVersion)){ + GB.toast("Firmware " + firmwareVersion + " not compatible", Toast.LENGTH_LONG, GB.ERROR); + getDevice().setName("incopatible firmware"); + } + } + + private boolean isFirmwareCompatible(String firmwareVersion){ + int major = Integer.parseInt(firmwareVersion.substring(6, 7)); + + return major == 1; + } + @Override public boolean onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { switch (characteristic.getUuid().toString()) {