mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-06-05 21:49:48 +02:00
Mi Watch 3 Lite: Fix firmware update
(not enabled yet)
This commit is contained in:
@@ -50,6 +50,8 @@ public class XiaomiDataUploadService extends AbstractXiaomiService {
|
|||||||
private byte currentType;
|
private byte currentType;
|
||||||
private byte[] currentBytes;
|
private byte[] currentBytes;
|
||||||
|
|
||||||
|
private int chunkSize;
|
||||||
|
|
||||||
public XiaomiDataUploadService(final XiaomiSupport support) {
|
public XiaomiDataUploadService(final XiaomiSupport support) {
|
||||||
super(support);
|
super(support);
|
||||||
}
|
}
|
||||||
@@ -59,14 +61,21 @@ public class XiaomiDataUploadService extends AbstractXiaomiService {
|
|||||||
switch (cmd.getSubtype()) {
|
switch (cmd.getSubtype()) {
|
||||||
case CMD_UPLOAD_START:
|
case CMD_UPLOAD_START:
|
||||||
final XiaomiProto.DataUploadAck dataUploadAck = cmd.getDataUpload().getDataUploadAck();
|
final XiaomiProto.DataUploadAck dataUploadAck = cmd.getDataUpload().getDataUploadAck();
|
||||||
LOG.debug("Got upload start, unknown2={}, unknown4={}", dataUploadAck.getUnknown2(), dataUploadAck.getUnknown4());
|
LOG.debug("Got upload start, unknown2={}, resumePosition={}", dataUploadAck.getUnknown2(), dataUploadAck.getResumePosition());
|
||||||
|
|
||||||
if (dataUploadAck.getUnknown2() != 0 || dataUploadAck.getUnknown4() != 0) {
|
if (dataUploadAck.getUnknown2() != 0 || dataUploadAck.getResumePosition() != 0) {
|
||||||
LOG.warn("Unexpected response");
|
LOG.warn("Unexpected response");
|
||||||
this.currentType = 0;
|
this.currentType = 0;
|
||||||
this.currentBytes = null;
|
this.currentBytes = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dataUploadAck.hasChunkSize()) {
|
||||||
|
chunkSize = dataUploadAck.getChunkSize();
|
||||||
|
} else {
|
||||||
|
chunkSize = 2048;
|
||||||
|
}
|
||||||
|
|
||||||
doUpload(currentType, currentBytes);
|
doUpload(currentType, currentBytes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -131,7 +140,7 @@ public class XiaomiDataUploadService extends AbstractXiaomiService {
|
|||||||
buf2.putInt(CheckSums.getCRC32(buf1.array()));
|
buf2.putInt(CheckSums.getCRC32(buf1.array()));
|
||||||
|
|
||||||
final byte[] payload = buf2.array();
|
final byte[] payload = buf2.array();
|
||||||
final int partSize = 2044; // 2 + 2 at beginning of each for total and progress
|
final int partSize = chunkSize - 4; // 2 + 2 at beginning of each for total and progress
|
||||||
final int totalParts = (int) Math.ceil(payload.length / (float) partSize);
|
final int totalParts = (int) Math.ceil(payload.length / (float) partSize);
|
||||||
|
|
||||||
characteristic.setCallback(remainingParts -> {
|
characteristic.setCallback(remainingParts -> {
|
||||||
|
@@ -869,5 +869,6 @@ message DataUploadRequest {
|
|||||||
message DataUploadAck {
|
message DataUploadAck {
|
||||||
optional bytes md5sum = 1;
|
optional bytes md5sum = 1;
|
||||||
optional uint32 unknown2 = 2; // 0
|
optional uint32 unknown2 = 2; // 0
|
||||||
optional uint32 unknown4 = 4; // 0
|
optional uint32 resumePosition = 4;
|
||||||
|
optional uint32 chunkSize = 5; // 4096 on Redmi Watch 3 Active, Nonexistent on Mi Band 8
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user