1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-08-24 16:21:16 +02:00

Zepp OS: Fix Alexa initial connection

This commit is contained in:
José Rebelo 2023-09-10 22:57:23 +01:00
parent 43d02b9661
commit 7359186cee

View File

@ -19,6 +19,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.servic
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_VOICE_SERVICE_LANGUAGE;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WATCHFACE;
import android.os.Handler;
import android.widget.Toast;
import org.slf4j.Logger;
@ -75,6 +76,8 @@ public class ZeppOsAlexaService extends AbstractZeppOsService {
public static final String PREF_VERSION = "zepp_os_alexa_version";
private final Handler handler = new Handler();
final ByteArrayOutputStream voiceBuffer = new ByteArrayOutputStream();
public ZeppOsAlexaService(final Huami2021Support support) {
@ -348,7 +351,10 @@ public class ZeppOsAlexaService extends AbstractZeppOsService {
LOG.info("Alexa starting: var1={}, var2={}, var3={}, var4={}, params={}", var1, var2, var3, var4, params);
sendStartAck();
// Send the start ack with a slight delay, to give enough time for the connection to switch to fast mode
// I can't seem to get the callback for onConnectionUpdated working, and if we reply too soon the watch
// will just stay stuck "Connecting...". It seems like it takes ~350ms to switch to fast connection.
handler.postDelayed(this::sendStartAck, 700);
}
private void handleEnd(final byte[] payload) {