use of nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.deviceevents.SonyHeadphonesEnqueueRequestEvent in project Gadgetbridge by Freeyourgadget.
the class SonyProtocolImplV1 method handleInitResponse.
public List<? extends GBDeviceEvent> handleInitResponse(final byte[] payload) {
if (payload.length != 4) {
LOG.warn("Unexpected payload length {}", payload.length);
return Collections.emptyList();
}
final DeviceType deviceType = getDevice().getType();
final List<Request> capabilityRequests = new ArrayList<>();
// TODO: We should be determine which of these we need from the device...
switch(deviceType) {
case SONY_WH_1000XM3:
capabilityRequests.add(getFirmwareVersion());
capabilityRequests.add(getBattery(BatteryType.SINGLE));
capabilityRequests.add(getAudioCodec());
capabilityRequests.add(getAmbientSoundControl());
capabilityRequests.add(getNoiseCancellingOptimizerState());
capabilityRequests.add(getAudioUpsampling());
capabilityRequests.add(getVoiceNotifications());
capabilityRequests.add(getAutomaticPowerOff());
capabilityRequests.add(getTouchSensor());
capabilityRequests.add(getSurroundMode());
capabilityRequests.add(getSoundPosition());
capabilityRequests.add(getEqualizer());
break;
case SONY_WH_1000XM4:
capabilityRequests.add(getFirmwareVersion());
capabilityRequests.add(getBattery(BatteryType.SINGLE));
capabilityRequests.add(getAudioCodec());
capabilityRequests.add(getAmbientSoundControl());
capabilityRequests.add(getNoiseCancellingOptimizerState());
capabilityRequests.add(getAudioUpsampling());
capabilityRequests.add(getVoiceNotifications());
capabilityRequests.add(getAutomaticPowerOff());
capabilityRequests.add(getTouchSensor());
capabilityRequests.add(getEqualizer());
capabilityRequests.add(getPauseWhenTakenOff());
break;
case SONY_WF_SP800N:
capabilityRequests.add(getFirmwareVersion());
capabilityRequests.add(getBattery(BatteryType.DUAL));
capabilityRequests.add(getBattery(BatteryType.CASE));
capabilityRequests.add(getAudioCodec());
capabilityRequests.add(getAmbientSoundControl());
capabilityRequests.add(getVoiceNotifications());
capabilityRequests.add(getAutomaticPowerOff());
capabilityRequests.add(getEqualizer());
capabilityRequests.add(getButtonModes());
capabilityRequests.add(getPauseWhenTakenOff());
break;
default:
LOG.error("Unsupported Sony device type '{}' with key '{}'", deviceType, deviceType.getKey());
return null;
}
return Collections.singletonList(new SonyHeadphonesEnqueueRequestEvent(capabilityRequests));
}
use of nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.deviceevents.SonyHeadphonesEnqueueRequestEvent in project Gadgetbridge by Freeyourgadget.
the class SonyHeadphonesSupport method evaluateGBDeviceEvent.
@Override
public void evaluateGBDeviceEvent(GBDeviceEvent deviceEvent) {
final SonyHeadphonesProtocol sonyProtocol = (SonyHeadphonesProtocol) getDeviceProtocol();
if (deviceEvent instanceof SonyHeadphonesEnqueueRequestEvent) {
final SonyHeadphonesEnqueueRequestEvent enqueueRequestEvent = (SonyHeadphonesEnqueueRequestEvent) deviceEvent;
sonyProtocol.enqueueRequests(enqueueRequestEvent.getRequests());
if (sonyProtocol.getPendingAcks() == 0) {
// There are no pending acks, send one request from the queue
// TODO: A more elegant way of scheduling these?
SonyHeadphonesIoThread deviceIOThread = getDeviceIOThread();
deviceIOThread.write(sonyProtocol.getFromQueue());
}
}
super.evaluateGBDeviceEvent(deviceEvent);
}
Aggregations