mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-27 11:05:49 +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:
parent
090e0c7b33
commit
cbadb9c7ae
@ -54,7 +54,7 @@ public abstract class AbstractMiBandFWHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try (InputStream in = new BufferedInputStream(uriHelper.openInputStream())) {
|
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);
|
determineFirmwareInfo(fw);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw ex; // pass through
|
throw ex; // pass through
|
||||||
|
@ -28,14 +28,36 @@ import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
|
|||||||
|
|
||||||
public class MiBand6FirmwareInfo extends HuamiFirmwareInfo {
|
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<>();
|
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) {
|
public MiBand6FirmwareInfo(byte[] bytes) {
|
||||||
super(bytes);
|
super(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HuamiFirmwareType determineFirmwareType(byte[] bytes) {
|
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)) {
|
if (ArrayUtils.startsWith(bytes, UIHH_HEADER) && (bytes[4] == 1 || bytes[4] == 2)) {
|
||||||
return HuamiFirmwareType.WATCHFACE;
|
return HuamiFirmwareType.WATCHFACE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user