2021-10-31 16:01:50 +01:00
|
|
|
/* Copyright (C) 2021 José Rebelo
|
|
|
|
|
|
|
|
This file is part of Gadgetbridge.
|
|
|
|
|
|
|
|
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Gadgetbridge is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2021-11-18 22:33:07 +01:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones;
|
2021-10-31 16:01:50 +01:00
|
|
|
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Queue;
|
2021-10-31 16:01:50 +01:00
|
|
|
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
2021-11-16 23:17:44 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
2021-12-12 19:48:14 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdateDeviceState;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
2022-12-30 19:07:18 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
2021-12-12 19:48:14 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
|
2021-12-24 15:20:57 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonModes;
|
2021-12-12 19:48:14 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset;
|
2021-12-24 15:20:57 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.PauseWhenTakenOff;
|
2022-12-30 19:07:18 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.QuickAccess;
|
2023-03-24 01:03:54 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.SpeakToChatConfig;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.SpeakToChatEnabled;
|
2021-12-12 19:48:14 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.VoiceNotifications;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.SoundPosition;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.SurroundMode;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.TouchSensor;
|
2021-10-31 16:01:50 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
2021-12-12 19:48:14 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.Request;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.Message;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.MessageType;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.AbstractSonyProtocolImpl;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.v1.SonyProtocolImplV1;
|
2022-10-22 14:14:50 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.v2.SonyProtocolImplV2;
|
2022-12-30 19:07:18 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.v3.SonyProtocolImplV3;
|
2021-10-31 16:01:50 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
public class SonyHeadphonesProtocol extends GBDeviceProtocol {
|
2021-11-18 22:33:07 +01:00
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(SonyHeadphonesProtocol.class);
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-11-16 23:17:44 +01:00
|
|
|
private byte sequenceNumber = 0;
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
// Request queue, sent every ACK, as we can't send them all at once
|
|
|
|
// Initially, it should contain all the init requests
|
|
|
|
private final Queue<Request> requestQueue = new LinkedList<>();
|
|
|
|
private int pendingAcks = 0;
|
|
|
|
|
|
|
|
private AbstractSonyProtocolImpl protocolImpl = null;
|
|
|
|
|
2021-11-18 22:33:07 +01:00
|
|
|
public SonyHeadphonesProtocol(GBDevice device) {
|
2021-10-31 16:01:50 +01:00
|
|
|
super(device);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public GBDeviceEvent[] decodeResponse(byte[] res) {
|
2021-12-12 19:48:14 +01:00
|
|
|
final Message message = Message.fromBytes(res);
|
|
|
|
if (message == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
LOG.info("Received {}", message);
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
final MessageType messageType = message.getType();
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
if (messageType == MessageType.ACK) {
|
|
|
|
if (sequenceNumber == message.getSequenceNumber()) {
|
|
|
|
LOG.warn("Unexpected ACK sequence number {}", message.getSequenceNumber());
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
sequenceNumber = message.getSequenceNumber();
|
|
|
|
|
|
|
|
return new GBDeviceEvent[]{handleAck()};
|
2021-10-31 16:01:50 +01:00
|
|
|
}
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
if (message.getPayload().length == 0) {
|
|
|
|
LOG.warn("Empty message: {}", message);
|
2021-10-31 16:01:50 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
final List<Object> events = new ArrayList<>();
|
|
|
|
|
|
|
|
if (protocolImpl == null) {
|
|
|
|
// Check if we got an init response, which should indicate the protocol version
|
|
|
|
if (MessageType.COMMAND_1.equals(messageType) && message.getPayload()[0] == 0x01) {
|
|
|
|
// Init reply, set the protocol version
|
|
|
|
if (message.getPayload().length == 4) {
|
2022-12-30 19:07:18 +01:00
|
|
|
// WH-1000XM3: 01:00:40:10
|
|
|
|
// WF-SP800N 1.0.1: 01:00:70:00
|
2021-12-12 19:48:14 +01:00
|
|
|
protocolImpl = new SonyProtocolImplV1(getDevice());
|
2022-10-22 14:14:50 +02:00
|
|
|
} else if (message.getPayload().length == 8) {
|
2022-12-30 19:07:18 +01:00
|
|
|
switch (message.getPayload()[2]) {
|
|
|
|
case 0x01:
|
|
|
|
// WF-1000XM4 1.1.5: 01:00:01:00:00:00:00:00
|
|
|
|
protocolImpl = new SonyProtocolImplV2(getDevice());
|
|
|
|
break;
|
|
|
|
case 0x03:
|
|
|
|
// LinkBuds S 2.0.2: 01:00:03:00:00:07:00:00
|
|
|
|
default:
|
|
|
|
protocolImpl = new SonyProtocolImplV3(getDevice());
|
|
|
|
return null;
|
|
|
|
}
|
2022-01-10 20:03:09 +01:00
|
|
|
} else {
|
|
|
|
LOG.error("Unexpected init response payload length: {}", message.getPayload().length);
|
|
|
|
return null;
|
2021-12-12 19:48:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (protocolImpl == null) {
|
|
|
|
LOG.error("No protocol implementation, ignoring message");
|
|
|
|
return null;
|
2021-10-31 16:01:50 +01:00
|
|
|
}
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
try {
|
|
|
|
switch (messageType) {
|
|
|
|
case COMMAND_1:
|
|
|
|
case COMMAND_2:
|
|
|
|
events.add(new GBDeviceEventSendBytes(encodeAck(message.getSequenceNumber())));
|
|
|
|
events.addAll(protocolImpl.handlePayload(messageType, message.getPayload()));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
LOG.warn("Unknown message type for {}", message);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
} catch (final Exception e) {
|
|
|
|
// Don't crash the app if we somehow fail to handle the payload
|
|
|
|
LOG.error("Error handling payload", e);
|
|
|
|
}
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
return events.toArray(new GBDeviceEvent[0]);
|
2021-10-31 16:01:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public byte[] encodeSendConfiguration(String config) {
|
2021-12-12 19:48:14 +01:00
|
|
|
if (protocolImpl == null) {
|
|
|
|
LOG.error("No protocol implementation, ignoring config {}", config);
|
|
|
|
return super.encodeSendConfiguration(config);
|
|
|
|
}
|
|
|
|
|
2021-10-31 16:01:50 +01:00
|
|
|
final SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
|
2021-12-12 19:48:14 +01:00
|
|
|
|
|
|
|
final Request configRequest;
|
2021-10-31 16:01:50 +01:00
|
|
|
|
|
|
|
switch (config) {
|
2021-11-18 22:33:07 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_AMBIENT_SOUND_CONTROL:
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_FOCUS_VOICE:
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_AMBIENT_SOUND_LEVEL:
|
2021-12-12 19:48:14 +01:00
|
|
|
configRequest = protocolImpl.setAmbientSoundControl(AmbientSoundControl.fromPreferences(prefs));
|
|
|
|
break;
|
2022-12-30 19:07:18 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_AMBIENT_SOUND_CONTROL_BUTTON_MODE:
|
|
|
|
configRequest = protocolImpl.setAmbientSoundControlButtonMode(AmbientSoundControlButtonMode.fromPreferences(prefs));
|
|
|
|
break;
|
2022-01-15 00:50:00 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_NOISE_OPTIMIZER_START:
|
|
|
|
configRequest = protocolImpl.startNoiseCancellingOptimizer(true);
|
|
|
|
break;
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_NOISE_OPTIMIZER_CANCEL:
|
|
|
|
configRequest = protocolImpl.startNoiseCancellingOptimizer(false);
|
|
|
|
break;
|
2021-11-18 22:33:07 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_SOUND_POSITION:
|
2021-12-12 19:48:14 +01:00
|
|
|
configRequest = protocolImpl.setSoundPosition(SoundPosition.fromPreferences(prefs));
|
|
|
|
break;
|
2021-11-18 22:33:07 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_SURROUND_MODE:
|
2021-12-12 19:48:14 +01:00
|
|
|
configRequest = protocolImpl.setSurroundMode(SurroundMode.fromPreferences(prefs));
|
|
|
|
break;
|
2021-11-18 22:33:07 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_MODE:
|
2021-12-12 19:48:14 +01:00
|
|
|
configRequest = protocolImpl.setEqualizerPreset(EqualizerPreset.fromPreferences(prefs));
|
|
|
|
break;
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BAND_400:
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BAND_1000:
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BAND_2500:
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BAND_6300:
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BAND_16000:
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BASS:
|
|
|
|
configRequest = protocolImpl.setEqualizerCustomBands(EqualizerCustomBands.fromPreferences(prefs));
|
|
|
|
break;
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_AUDIO_UPSAMPLING:
|
|
|
|
configRequest = protocolImpl.setAudioUpsampling(AudioUpsampling.fromPreferences(prefs));
|
|
|
|
break;
|
2021-11-18 22:33:07 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_TOUCH_SENSOR:
|
2021-12-12 19:48:14 +01:00
|
|
|
configRequest = protocolImpl.setTouchSensor(TouchSensor.fromPreferences(prefs));
|
|
|
|
break;
|
2021-11-18 22:33:07 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_AUTOMATIC_POWER_OFF:
|
2021-12-12 19:48:14 +01:00
|
|
|
configRequest = protocolImpl.setAutomaticPowerOff(AutomaticPowerOff.fromPreferences(prefs));
|
|
|
|
break;
|
2021-12-24 15:20:57 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_BUTTON_MODE_LEFT:
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_BUTTON_MODE_RIGHT:
|
|
|
|
configRequest = protocolImpl.setButtonModes(ButtonModes.fromPreferences(prefs));
|
|
|
|
break;
|
2022-12-30 19:07:18 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_QUICK_ACCESS_DOUBLE_TAP:
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_QUICK_ACCESS_TRIPLE_TAP:
|
|
|
|
configRequest = protocolImpl.setQuickAccess(QuickAccess.fromPreferences(prefs));
|
|
|
|
break;
|
2021-12-24 15:20:57 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_PAUSE_WHEN_TAKEN_OFF:
|
|
|
|
configRequest = protocolImpl.setPauseWhenTakenOff(PauseWhenTakenOff.fromPreferences(prefs));
|
|
|
|
break;
|
2021-11-18 22:33:07 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_NOTIFICATION_VOICE_GUIDE:
|
2021-12-12 19:48:14 +01:00
|
|
|
configRequest = protocolImpl.setVoiceNotifications(VoiceNotifications.fromPreferences(prefs));
|
|
|
|
break;
|
2022-01-09 12:56:29 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_CONNECT_TWO_DEVICES:
|
|
|
|
LOG.warn("Connection to two devices not implemented ('{}')", config);
|
|
|
|
return super.encodeSendConfiguration(config);
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_SPEAK_TO_CHAT:
|
2023-03-24 01:03:54 +01:00
|
|
|
configRequest = protocolImpl.setSpeakToChatEnabled(SpeakToChatEnabled.fromPreferences(prefs));
|
|
|
|
break;
|
2022-01-09 12:56:29 +01:00
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_SPEAK_TO_CHAT_SENSITIVITY:
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_SPEAK_TO_CHAT_FOCUS_ON_VOICE:
|
|
|
|
case DeviceSettingsPreferenceConst.PREF_SONY_SPEAK_TO_CHAT_TIMEOUT:
|
2023-03-24 01:03:54 +01:00
|
|
|
configRequest = protocolImpl.setSpeakToChatConfig(SpeakToChatConfig.fromPreferences(prefs));
|
2023-03-23 22:50:40 +01:00
|
|
|
break;
|
2021-10-31 16:01:50 +01:00
|
|
|
default:
|
|
|
|
LOG.warn("Unknown config '{}'", config);
|
2021-12-12 19:48:14 +01:00
|
|
|
return super.encodeSendConfiguration(config);
|
2021-10-31 16:01:50 +01:00
|
|
|
}
|
|
|
|
|
2022-10-19 21:50:39 +02:00
|
|
|
if (configRequest == null) {
|
|
|
|
LOG.warn("Failed to encode config request for {}", config);
|
|
|
|
return super.encodeSendConfiguration(config);
|
|
|
|
}
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
pendingAcks++;
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
return configRequest.encode(sequenceNumber);
|
2021-11-16 23:17:44 +01:00
|
|
|
}
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
@Override
|
|
|
|
public byte[] encodeTestNewFunction() {
|
|
|
|
//return Request.fromHex(MessageType.COMMAND_1, "c40100").encode(sequenceNumber);
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
return null;
|
2021-10-31 16:01:50 +01:00
|
|
|
}
|
|
|
|
|
2021-12-24 15:20:57 +01:00
|
|
|
@Override
|
|
|
|
public byte[] encodePowerOff() {
|
|
|
|
if (protocolImpl != null) {
|
|
|
|
return protocolImpl.powerOff().encode(sequenceNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
return super.encodePowerOff();
|
|
|
|
}
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
public byte[] encodeAck(byte sequenceNumber) {
|
|
|
|
return new Message(MessageType.ACK, (byte) (1 - sequenceNumber), new byte[0]).encode();
|
2021-10-31 16:01:50 +01:00
|
|
|
}
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
public byte[] encodeInit() {
|
|
|
|
pendingAcks++;
|
|
|
|
return new Message(
|
|
|
|
MessageType.COMMAND_1,
|
|
|
|
sequenceNumber,
|
|
|
|
new byte[]{
|
|
|
|
(byte) 0x00,
|
|
|
|
(byte) 0x00
|
|
|
|
}
|
|
|
|
).encode();
|
2021-10-31 16:01:50 +01:00
|
|
|
}
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
public void enqueueRequests(final List<Request> requests) {
|
|
|
|
LOG.debug("Enqueueing {} requests", requests.size());
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
requestQueue.addAll(requests);
|
2021-10-31 16:01:50 +01:00
|
|
|
}
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
public int getPendingAcks() {
|
|
|
|
return pendingAcks;
|
2021-11-16 23:17:44 +01:00
|
|
|
}
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-12-24 15:20:57 +01:00
|
|
|
public void decreasePendingAcks() {
|
|
|
|
pendingAcks--;
|
|
|
|
}
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
public byte[] getFromQueue() {
|
|
|
|
return requestQueue.remove().encode(sequenceNumber);
|
2021-10-31 16:01:50 +01:00
|
|
|
}
|
|
|
|
|
2022-01-10 20:03:09 +01:00
|
|
|
public boolean hasProtocolImplementation() {
|
|
|
|
return protocolImpl != null;
|
|
|
|
}
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
private GBDeviceEvent handleAck() {
|
|
|
|
pendingAcks--;
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
if (!requestQueue.isEmpty()) {
|
|
|
|
LOG.debug("Outstanding requests in queue: {}", requestQueue.size());
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
final Request request = requestQueue.remove();
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
return new GBDeviceEventSendBytes(request.encode(sequenceNumber));
|
2021-10-31 16:01:50 +01:00
|
|
|
}
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
if (GBDevice.State.INITIALIZING.equals(getDevice().getState())) {
|
|
|
|
// The queue is now empty, so we have got all the information from the device
|
|
|
|
// Mark it as initialized
|
2021-10-31 16:01:50 +01:00
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
return new GBDeviceEventUpdateDeviceState(GBDevice.State.INITIALIZED);
|
2021-10-31 16:01:50 +01:00
|
|
|
}
|
|
|
|
|
2021-12-12 19:48:14 +01:00
|
|
|
return null;
|
2021-10-31 16:01:50 +01:00
|
|
|
}
|
|
|
|
}
|