Search in sources :

Example 1 with PauseWhenTakenOff

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

the class SonyProtocolImplV1 method handlePauseWhenTakenOff.

public List<? extends GBDeviceEvent> handlePauseWhenTakenOff(final byte[] payload) {
    if (payload.length != 4) {
        LOG.warn("Unexpected payload length {}", payload.length);
        return Collections.emptyList();
    }
    boolean enabled;
    switch(payload[3]) {
        case 0x00:
            enabled = false;
            break;
        case 0x01:
            enabled = true;
            break;
        default:
            LOG.warn("Unknown pause when taken off code {}", String.format("%02x", payload[3]));
            return Collections.emptyList();
    }
    LOG.debug("Touch Sensor: {}", enabled);
    final GBDeviceEventUpdatePreferences event = new GBDeviceEventUpdatePreferences().withPreferences(new PauseWhenTakenOff(enabled).toPreferences());
    return Collections.singletonList(event);
}
Also used : GBDeviceEventUpdatePreferences(nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences) PauseWhenTakenOff(nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.PauseWhenTakenOff)

Aggregations

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