Zepp OS BTBR: Increase buffer size

This commit is contained in:
José Rebelo
2025-04-27 10:48:39 +01:00
parent 063e022801
commit b6b7ee31f9
2 changed files with 8 additions and 4 deletions
@@ -46,7 +46,7 @@ public final class BtBRQueue {
public static final int HANDLER_SUBJECT_CONNECT = 0;
public static final int HANDLER_SUBJECT_PERFORM_TRANSACTION = 1;
private BluetoothAdapter mBtAdapter = null;
private final BluetoothAdapter mBtAdapter;
private BluetoothSocket mBtSocket = null;
private final GBDevice mGbDevice;
private final SocketCallback mCallback;
@@ -63,7 +63,7 @@ public final class BtBRQueue {
private Thread readThread = new Thread("Read Thread") {
@Override
public void run() {
byte[] buffer = new byte[mBufferSize];
final byte[] buffer = new byte[mBufferSize];
int nRead;
LOG.debug("Read thread started, entering loop");
@@ -215,7 +215,7 @@ public final class BtBRQueue {
return true;
}
protected void onConnectionEstablished() {
private void onConnectionEstablished() {
mCallback.onConnectionEstablished();
}
@@ -61,7 +61,11 @@ import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
public class ZeppOsBtbrSupport extends AbstractBTBRDeviceSupport implements ZeppOsCommunicator {
private static final Logger LOG = LoggerFactory.getLogger(ZeppOsBtbrSupport.class);
private static final int MAX_MTU = 32768;
/**
* The highest MTU we have seen is 32768. However, there is some bug in the BtbrQueue where it
* will lose some bytes if we read less than the available bytes, so we double the buffer size.
*/
private static final int MAX_MTU = 2 * 32768;
private static final byte PACKET_PREAMBLE = 0x55;
private static final byte PACKET_TRAILER = (byte) 0xaa;