Zepp OS: Reset MTU before initialization

Fixes regression introduced by 732cbd9b1, which partially reverted #3219
by accident.
This commit is contained in:
José Rebelo
2025-04-13 18:38:36 +01:00
parent c539fe50ba
commit f567d963d3
2 changed files with 6 additions and 3 deletions
@@ -336,7 +336,7 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
protected MediaManager mediaManager;
private boolean heartRateNotifyEnabled;
protected static final int MIN_MTU = 23;
private int mMTU = MIN_MTU;
protected int mMTU = MIN_MTU;
// Keep track of the previous MTU before reconnection, so that we can request it after reconnection
private int previousMtu = -1;
protected int mActivitySampleSize = 4;
@@ -80,11 +80,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.SleepAsAndroidSender;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Service;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsAgpsInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsGpxRouteInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandCoordinator;
import nodomain.freeyourgadget.gadgetbridge.externalevents.CalendarReceiver;
import nodomain.freeyourgadget.gadgetbridge.externalevents.sleepasandroid.SleepAsAndroidAction;
@@ -283,6 +281,11 @@ public class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTransferSer
@Override
protected TransactionBuilder initializeDevice(final TransactionBuilder builder) {
if (getMTU() != MIN_MTU) {
// #3219 - Reset the MTU before re-initializing the device, otherwise initialization will sometimes fail
setMtu(MIN_MTU);
}
characteristicChunked2021Read = getCharacteristic(HuamiService.UUID_CHARACTERISTIC_CHUNKEDTRANSFER_2021_READ);
if (characteristicChunked2021Read != null && huami2021ChunkedDecoder == null) {
huami2021ChunkedDecoder = new Huami2021ChunkedDecoder(this, force2021Protocol());