1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-29 05:16:51 +01:00

added firmware check on connect

This commit is contained in:
Daniel Dakhno 2019-10-01 16:05:47 +02:00
parent b20963348d
commit ebab69a063

View File

@ -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()) {