Search in sources :

Example 1 with TouchSensor

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

the class SonyProtocolImplV1 method handleTouchSensor.

public List<? extends GBDeviceEvent> handleTouchSensor(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 touch sensor code {}", String.format("%02x", payload[3]));
            return Collections.emptyList();
    }
    LOG.debug("Touch Sensor: {}", enabled);
    final GBDeviceEventUpdatePreferences event = new GBDeviceEventUpdatePreferences().withPreferences(new TouchSensor(enabled).toPreferences());
    return Collections.singletonList(event);
}
Also used : TouchSensor(nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.TouchSensor) GBDeviceEventUpdatePreferences(nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences)

Aggregations

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