Search in sources :

Example 6 with GBDeviceEventUpdatePreferences

use of nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences 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)

Example 7 with GBDeviceEventUpdatePreferences

use of nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences in project Gadgetbridge by Freeyourgadget.

the class SonyProtocolImplV1 method handleNoiseCancellingOptimizerState.

public List<? extends GBDeviceEvent> handleNoiseCancellingOptimizerState(final byte[] payload) {
    // 89 01 01 01 01 0A
    if (payload.length != 6) {
        LOG.warn("Unexpected payload length {}", payload.length);
        return Collections.emptyList();
    }
    final float pressure = payload[5] / 10.0f;
    if (pressure <= 0 || pressure > 1.0f) {
        LOG.warn("Invalid Noise Cancelling Optimizer pressure: {} atm, ignoring", pressure);
        return Collections.emptyList();
    }
    LOG.info("Noise Cancelling Optimizer pressure: {} atm", pressure);
    final GBDeviceEventUpdatePreferences event = new GBDeviceEventUpdatePreferences().withPreference(PREF_SONY_NOISE_OPTIMIZER_STATE_PRESSURE, String.format(Locale.getDefault(), "%.2f atm", pressure));
    return Collections.singletonList(event);
}
Also used : GBDeviceEventUpdatePreferences(nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences)

Example 8 with GBDeviceEventUpdatePreferences

use of nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences in project Gadgetbridge by Freeyourgadget.

the class SonyProtocolImplV1 method handleNoiseCancellingOptimizerStatus.

public List<? extends GBDeviceEvent> handleNoiseCancellingOptimizerStatus(final byte[] payload) {
    if (payload.length != 4) {
        LOG.warn("Unexpected payload length {}", payload.length);
        return Collections.emptyList();
    }
    final NoiseCancellingOptimizerStatus status = NoiseCancellingOptimizerStatus.fromCode(payload[3]);
    if (status == null) {
        LOG.warn("Unable to determine noise cancelling opptimizer status from {}", GB.hexdump(payload));
        return Collections.emptyList();
    }
    LOG.info("Noise Cancelling Optimizer status: {}", status);
    final GBDeviceEventUpdatePreferences event = new GBDeviceEventUpdatePreferences().withPreference(PREF_SONY_NOISE_OPTIMIZER_STATUS, status.name().toLowerCase(Locale.ROOT));
    return Collections.singletonList(event);
}
Also used : GBDeviceEventUpdatePreferences(nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences) NoiseCancellingOptimizerStatus(nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.v1.params.NoiseCancellingOptimizerStatus)

Example 9 with GBDeviceEventUpdatePreferences

use of nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences in project Gadgetbridge by Freeyourgadget.

the class SonyProtocolImplV1 method handleSurroundMode.

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

Example 10 with GBDeviceEventUpdatePreferences

use of nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences in project Gadgetbridge by Freeyourgadget.

the class SonyProtocolImplV1 method handleVoiceNotifications.

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

Aggregations

GBDeviceEventUpdatePreferences (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences)13 ArrayList (java.util.ArrayList)1 GBDeviceEventUpdateDeviceInfo (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdateDeviceInfo)1 AmbientSoundControl (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl)1 AudioUpsampling (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling)1 AutomaticPowerOff (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff)1 ButtonModes (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonModes)1 EqualizerCustomBands (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands)1 EqualizerPreset (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset)1 PauseWhenTakenOff (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.PauseWhenTakenOff)1 SoundPosition (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.SoundPosition)1 SurroundMode (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.SurroundMode)1 TouchSensor (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.TouchSensor)1 VoiceNotifications (nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.VoiceNotifications)1 AudioCodec (nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.v1.params.AudioCodec)1 NoiseCancellingOptimizerStatus (nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl.v1.params.NoiseCancellingOptimizerStatus)1