1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-29 13:26:50 +01:00

Mi Band 6: Write to chunked2021 for old chunked types on new firmware (fixes music, weather and setting menu items)

This commit is contained in:
Andreas Shimokawa 2021-09-01 15:25:39 +02:00
parent 4a27825931
commit 4242f5ccd4

View File

@ -1792,7 +1792,6 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
* *
* @param alarm * @param alarm
* @param builder * @param builder
* @param characteristic
*/ */
private void queueAlarm(Alarm alarm, TransactionBuilder builder) { private void queueAlarm(Alarm alarm, TransactionBuilder builder) {
Calendar calendar = AlarmUtils.toCalendar(alarm); Calendar calendar = AlarmUtils.toCalendar(alarm);
@ -2547,6 +2546,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
command[pos++] = id.byteValue(); command[pos++] = id.byteValue();
} }
} }
writeToChunked(builder, 2, command); writeToChunked(builder, 2, command);
return this; return this;
@ -2818,6 +2818,15 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
} }
protected void writeToChunked(TransactionBuilder builder, int type, byte[] data) { protected void writeToChunked(TransactionBuilder builder, int type, byte[] data) {
if (force2021Protocol && type > 0) {
byte[] command = ArrayUtils.addAll(new byte[]{0x00, 0x00, (byte) (0xc0 | type), 0x00}, data);
writeToChunked2021(builder, HuamiService.CHUNKED2021_ENDPOINT_COMPAT, getNextHandle(), command, type != 1);
} else {
writeToChunkedOld(builder, type, data);
}
}
protected void writeToChunkedOld(TransactionBuilder builder, int type, byte[] data) {
final int MAX_CHUNKLENGTH = mMTU - 6; final int MAX_CHUNKLENGTH = mMTU - 6;
int remaining = data.length; int remaining = data.length;
byte count = 0; byte count = 0;