1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 10:35:50 +01:00

Mi Band 6: allow firmware update

Also whitelist FW 1.0.1.36 which I just flashed though Gadgetbridge

Tracking Issue: #2263
This commit is contained in:
Andreas Shimokawa 2021-05-24 16:50:24 +02:00
parent 090e0c7b33
commit cbadb9c7ae
2 changed files with 23 additions and 1 deletions

View File

@ -54,7 +54,7 @@ public abstract class AbstractMiBandFWHelper {
}
try (InputStream in = new BufferedInputStream(uriHelper.openInputStream())) {
this.fw = FileUtils.readAll(in, 1024 * 2048); // 2.0 MB
this.fw = FileUtils.readAll(in, 1024 * 3048); // 3.0 MB
determineFirmwareInfo(fw);
} catch (IOException ex) {
throw ex; // pass through

View File

@ -28,14 +28,36 @@ import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
public class MiBand6FirmwareInfo extends HuamiFirmwareInfo {
public static final byte[] FW_HEADER = new byte[]{
0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x9c, (byte) 0xe3, 0x7d, 0x5c, 0x00, 0x04
};
public static final int FW_HEADER_OFFSET = 16;
private static final Map<Integer, String> crcToVersion = new HashMap<>();
static {
// firmware
crcToVersion.put(47447, "1.0.1.36");
// resources
crcToVersion.put(54803, "1.0.1.36");
}
public MiBand6FirmwareInfo(byte[] bytes) {
super(bytes);
}
@Override
protected HuamiFirmwareType determineFirmwareType(byte[] bytes) {
if (ArrayUtils.equals(bytes, NEWRES_HEADER, COMPRESSED_RES_HEADER_OFFSET_NEW) || ArrayUtils.equals(bytes, NEWRES_HEADER, COMPRESSED_RES_HEADER_OFFSET)) {
return HuamiFirmwareType.RES_COMPRESSED;
}
if (ArrayUtils.equals(bytes, FW_HEADER, FW_HEADER_OFFSET)) {
if (searchString32BitAligned(bytes, "Mi Smart Band 6")) {
return HuamiFirmwareType.FIRMWARE;
}
return HuamiFirmwareType.INVALID;
}
if (ArrayUtils.startsWith(bytes, UIHH_HEADER) && (bytes[4] == 1 || bytes[4] == 2)) {
return HuamiFirmwareType.WATCHFACE;
}