1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-27 12:26:48 +01:00

Amazfit Bip S: Support flashing firmware and res

This commit is contained in:
Andreas Shimokawa 2020-06-11 19:24:45 +02:00
parent 25c749bab9
commit 99b7764709
2 changed files with 15 additions and 3 deletions

View File

@ -23,6 +23,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareInfo;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband4.MiBand4FirmwareInfo;
import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
public class AmazfitBipSFirmwareInfo extends HuamiFirmwareInfo {
@ -35,6 +36,17 @@ public class AmazfitBipSFirmwareInfo extends HuamiFirmwareInfo {
@Override
protected HuamiFirmwareType determineFirmwareType(byte[] bytes) {
//FW "header" looks like Mi Band 4
if (ArrayUtils.equals(bytes, MiBand4FirmwareInfo.FW_HEADER, MiBand4FirmwareInfo.FW_HEADER_OFFSET)) {
if (searchString32BitAligned(bytes, "Amazfit Bip S")) {
return HuamiFirmwareType.FIRMWARE;
}
return HuamiFirmwareType.INVALID;
}
if (ArrayUtils.equals(bytes, NEWRES_HEADER, COMPRESSED_RES_HEADER_OFFSET)) {
return HuamiFirmwareType.RES_COMPRESSED;
}
if (ArrayUtils.startsWith(bytes, WATCHFACE_HEADER)) {
return HuamiFirmwareType.WATCHFACE;
}
@ -45,7 +57,7 @@ public class AmazfitBipSFirmwareInfo extends HuamiFirmwareInfo {
return HuamiFirmwareType.GPS_CEP;
}
if (ArrayUtils.startsWith(bytes, NEWFT_HEADER)) {
if (bytes[10] == 0x01) {
if (bytes[10] == 0x01 || bytes[10] == 0x06) {
return HuamiFirmwareType.FONT;
} else if (bytes[10] == 0x02 || bytes[10] == 0x0A) {
return HuamiFirmwareType.FONT_LATIN;

View File

@ -27,11 +27,11 @@ import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
public class MiBand4FirmwareInfo extends HuamiFirmwareInfo {
private static final byte[] FW_HEADER = new byte[]{
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
};
private static final int FW_HEADER_OFFSET = 16;
public static final int FW_HEADER_OFFSET = 16;
private static Map<Integer, String> crcToVersion = new HashMap<>();