Search in sources :

Example 1 with SoundPosition

use of nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.SoundPosition in project Gadgetbridge by Freeyourgadget.

the class SonyProtocolImplV1 method handleSoundPosition.

public List<? extends GBDeviceEvent> handleSoundPosition(final byte[] payload) {
    if (payload.length != 3) {
        LOG.warn("Unexpected payload length {}", payload.length);
        return Collections.emptyList();
    }
    SoundPosition mode = null;
    for (SoundPosition value : SoundPosition.values()) {
        if (value.getCode() == payload[2]) {
            mode = value;
            break;
        }
    }
    if (mode == null) {
        LOG.warn("Unknown sound position code {}", String.format("%02x", payload[2]));
        return Collections.emptyList();
    }
    LOG.debug("Sound Position: {}", mode);
    final GBDeviceEventUpdatePreferences event = new GBDeviceEventUpdatePreferences().withPreferences(mode.toPreferences());
    return Collections.singletonList(event);
}
Also used : SoundPosition(nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.SoundPosition) GBDeviceEventUpdatePreferences(nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences)

Aggregations

GBDeviceEventUpdatePreferences (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences)1 SoundPosition (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.SoundPosition)1