1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-20 20:10:15 +02:00

Mi Watch Lite: Attempt to fix plaintext support

This commit is contained in:
José Rebelo 2023-10-17 13:14:35 +01:00
parent d953fd5b5b
commit 1920968fba

View File

@ -242,11 +242,13 @@ public class XiaomiCharacteristic {
}
if (shouldWriteChunked(currentSending)) {
// Prepend encrypted index
currentSending = ByteBuffer.allocate(2 + currentSending.length).order(ByteOrder.LITTLE_ENDIAN)
.putShort(encryptedIndex++)
.put(currentSending)
.array();
if (isEncrypted) {
// Prepend encrypted index for the nonce
currentSending = ByteBuffer.allocate(2 + currentSending.length).order(ByteOrder.LITTLE_ENDIAN)
.putShort(encryptedIndex++)
.put(currentSending)
.array();
}
LOG.debug("Sending next - chunked");
@ -255,7 +257,7 @@ public class XiaomiCharacteristic {
final ByteBuffer buf = ByteBuffer.allocate(6).order(ByteOrder.LITTLE_ENDIAN);
buf.putShort((short) 0);
buf.put((byte) 0);
buf.put((byte) 1);
buf.put((byte) (isEncrypted ? 1 : 0));
buf.putShort((short) Math.round(currentSending.length / 247.0));
final TransactionBuilder builder = mSupport.createTransactionBuilder("send chunked start");