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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations