1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-27 02:55:50 +01:00

Add support for Sony WF-C700N

This commit is contained in:
Marcel 2024-09-25 21:24:01 +02:00 committed by José Rebelo
parent a923766aa5
commit d182fe58e8
10 changed files with 95 additions and 57 deletions

View File

@ -19,10 +19,11 @@ package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones;
public enum SonyHeadphonesCapabilities { public enum SonyHeadphonesCapabilities {
BatterySingle, BatterySingle,
BatteryDual, BatteryDual,
BatteryDual_NoCase, BatteryDual2,
BatteryCase, BatteryCase,
PowerOffFromPhone, PowerOffFromPhone,
AmbientSoundControl, AmbientSoundControl,
AmbientSoundControl2,
WindNoiseReduction, WindNoiseReduction,
SpeakToChatEnabled, SpeakToChatEnabled,
SpeakToChatConfig, SpeakToChatConfig,

View File

@ -19,8 +19,6 @@ package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import org.apache.commons.lang3.ArrayUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
@ -70,7 +68,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
@Override @Override
public int getBatteryCount() { public int getBatteryCount() {
if (supports(SonyHeadphonesCapabilities.BatterySingle)) { if (supports(SonyHeadphonesCapabilities.BatterySingle)) {
if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual_NoCase)) { if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual2)) {
throw new IllegalStateException("A device can't have both single and dual battery"); throw new IllegalStateException("A device can't have both single and dual battery");
} else if (supports(SonyHeadphonesCapabilities.BatteryCase)) { } else if (supports(SonyHeadphonesCapabilities.BatteryCase)) {
throw new IllegalStateException("Devices with single battery + case are not supported by the protocol"); throw new IllegalStateException("Devices with single battery + case are not supported by the protocol");
@ -87,7 +85,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
batteryCount += 1; batteryCount += 1;
} }
if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual_NoCase)) { if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual2)) {
batteryCount += 2; batteryCount += 2;
} }
@ -106,7 +104,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_tws_case, R.string.battery_case)); batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_tws_case, R.string.battery_case));
} }
if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual_NoCase)) { if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual2)) {
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_l, R.string.left_earbud)); batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_l, R.string.left_earbud));
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_r, R.string.right_earbud)); batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_r, R.string.right_earbud));
} }
@ -118,7 +116,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
public DeviceSpecificSettings getDeviceSpecificSettings(final GBDevice device) { public DeviceSpecificSettings getDeviceSpecificSettings(final GBDevice device) {
final DeviceSpecificSettings deviceSpecificSettings = new DeviceSpecificSettings(); final DeviceSpecificSettings deviceSpecificSettings = new DeviceSpecificSettings();
if (supports(SonyHeadphonesCapabilities.AmbientSoundControl)) { if (supports(SonyHeadphonesCapabilities.AmbientSoundControl) || supports(SonyHeadphonesCapabilities.AmbientSoundControl2)) {
if (supports(SonyHeadphonesCapabilities.WindNoiseReduction)) { if (supports(SonyHeadphonesCapabilities.WindNoiseReduction)) {
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_ambient_sound_control_wind_noise_reduction); deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_ambient_sound_control_wind_noise_reduction);
} else { } else {

View File

@ -23,8 +23,6 @@ import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
public class SonyWFC500Coordinator extends SonyHeadphonesCoordinator { public class SonyWFC500Coordinator extends SonyHeadphonesCoordinator {
@Override @Override
@ -32,18 +30,10 @@ public class SonyWFC500Coordinator extends SonyHeadphonesCoordinator {
return Pattern.compile(".*WF-C500.*"); return Pattern.compile(".*WF-C500.*");
} }
@Override
public BatteryConfig[] getBatteryConfig(final GBDevice device) {
final BatteryConfig battery1 = new BatteryConfig(0, R.drawable.ic_galaxy_buds_l, R.string.left_earbud);
final BatteryConfig battery2 = new BatteryConfig(1, R.drawable.ic_galaxy_buds_r, R.string.right_earbud);
return new BatteryConfig[]{battery1, battery2};
}
@Override @Override
public List<SonyHeadphonesCapabilities> getCapabilities() { public List<SonyHeadphonesCapabilities> getCapabilities() {
return Arrays.asList( return Arrays.asList(
SonyHeadphonesCapabilities.BatteryDual_NoCase, SonyHeadphonesCapabilities.BatteryDual2,
SonyHeadphonesCapabilities.EqualizerSimple, SonyHeadphonesCapabilities.EqualizerSimple,
SonyHeadphonesCapabilities.EqualizerWithCustomBands, SonyHeadphonesCapabilities.EqualizerWithCustomBands,
SonyHeadphonesCapabilities.AudioUpsampling, SonyHeadphonesCapabilities.AudioUpsampling,

View File

@ -0,0 +1,66 @@
/* Copyright (C) 2024 Marcel
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
public class SonyWFC700NCoordinator extends SonyHeadphonesCoordinator {
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile(".*WF-C700N.*");
}
@Override
public List<SonyHeadphonesCapabilities> getCapabilities() {
return Arrays.asList(
SonyHeadphonesCapabilities.BatteryDual2,
SonyHeadphonesCapabilities.BatteryCase,
SonyHeadphonesCapabilities.AmbientSoundControl2,
SonyHeadphonesCapabilities.EqualizerSimple,
SonyHeadphonesCapabilities.EqualizerWithCustomBands,
SonyHeadphonesCapabilities.AudioUpsampling,
SonyHeadphonesCapabilities.ButtonModesLeftRight,
SonyHeadphonesCapabilities.PowerOffFromPhone,
SonyHeadphonesCapabilities.AmbientSoundControlButtonMode
// AutoOff is supported, but current Payload is incorrect.
// Available options in Sony App: 15min, 30min, 1h, 3h, off
// TODO: SonyHeadphonesCapabilities.AutomaticPowerOffByTime
);
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_sony_wf_c700n;
}
@Override
public int getDefaultIconResource() {
return R.drawable.ic_device_galaxy_buds;
}
@Override
public int getDisabledIconResource() {
return R.drawable.ic_device_galaxy_buds_disabled;
}
}

View File

@ -226,6 +226,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWF1000XM4Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWF1000XM4Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWF1000XM5Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWF1000XM5Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWFC500Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWFC500Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWFC700NCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWFSP800NCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWFSP800NCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWH1000XM2Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWH1000XM2Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWH1000XM3Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWH1000XM3Coordinator;
@ -472,6 +473,7 @@ public enum DeviceType {
SONY_WH_1000XM5(SonyWH1000XM5Coordinator.class), SONY_WH_1000XM5(SonyWH1000XM5Coordinator.class),
SONY_WF_1000XM5(SonyWF1000XM5Coordinator.class), SONY_WF_1000XM5(SonyWF1000XM5Coordinator.class),
SONY_WF_C500(SonyWFC500Coordinator.class), SONY_WF_C500(SonyWFC500Coordinator.class),
SONY_WF_C700N(SonyWFC700NCoordinator.class),
SOUNDCORE_LIBERTY3_PRO(SoundcoreLiberty3ProCoordinator.class), SOUNDCORE_LIBERTY3_PRO(SoundcoreLiberty3ProCoordinator.class),
SOUNDCORE_LIBERTY4_NC(SoundcoreLiberty4NCCoordinator.class), SOUNDCORE_LIBERTY4_NC(SoundcoreLiberty4NCCoordinator.class),
SOUNDCORE_MOTION300(SoundcoreMotion300Coordinator.class), SOUNDCORE_MOTION300(SoundcoreMotion300Coordinator.class),

View File

@ -638,9 +638,10 @@ public class SonyProtocolImplV1 extends AbstractSonyProtocolImpl {
final Map<SonyHeadphonesCapabilities, Request> capabilityRequestMap = new LinkedHashMap<SonyHeadphonesCapabilities, Request>() {{ final Map<SonyHeadphonesCapabilities, Request> capabilityRequestMap = new LinkedHashMap<SonyHeadphonesCapabilities, Request>() {{
put(SonyHeadphonesCapabilities.BatterySingle, getBattery(BatteryType.SINGLE)); put(SonyHeadphonesCapabilities.BatterySingle, getBattery(BatteryType.SINGLE));
put(SonyHeadphonesCapabilities.BatteryDual, getBattery(BatteryType.DUAL)); put(SonyHeadphonesCapabilities.BatteryDual, getBattery(BatteryType.DUAL));
put(SonyHeadphonesCapabilities.BatteryDual_NoCase, getBattery(BatteryType.DUAL_NO_CASE)); put(SonyHeadphonesCapabilities.BatteryDual2, getBattery(BatteryType.DUAL2));
put(SonyHeadphonesCapabilities.BatteryCase, getBattery(BatteryType.CASE)); put(SonyHeadphonesCapabilities.BatteryCase, getBattery(BatteryType.CASE));
put(SonyHeadphonesCapabilities.AmbientSoundControl, getAmbientSoundControl()); put(SonyHeadphonesCapabilities.AmbientSoundControl, getAmbientSoundControl());
put(SonyHeadphonesCapabilities.AmbientSoundControl2, getAmbientSoundControl());
put(SonyHeadphonesCapabilities.AncOptimizer, getNoiseCancellingOptimizerState()); put(SonyHeadphonesCapabilities.AncOptimizer, getNoiseCancellingOptimizerState());
put(SonyHeadphonesCapabilities.AudioUpsampling, getAudioUpsampling()); put(SonyHeadphonesCapabilities.AudioUpsampling, getAudioUpsampling());
put(SonyHeadphonesCapabilities.ButtonModesLeftRight, getButtonModes()); put(SonyHeadphonesCapabilities.ButtonModesLeftRight, getButtonModes());
@ -940,14 +941,16 @@ public class SonyProtocolImplV1 extends AbstractSonyProtocolImpl {
singleBatteryInfo.state = payload[3] == 1 ? BatteryState.BATTERY_CHARGING : BatteryState.BATTERY_NORMAL; singleBatteryInfo.state = payload[3] == 1 ? BatteryState.BATTERY_CHARGING : BatteryState.BATTERY_NORMAL;
batteryEvents.add(singleBatteryInfo); batteryEvents.add(singleBatteryInfo);
} else if (BatteryType.DUAL.equals(batteryType)) { } else if (BatteryType.DUAL.equals(batteryType) || BatteryType.DUAL2.equals(batteryType)) {
// Dual Battery (L / R) // Dual Battery (L / R)
LOG.debug("Battery Level: L: {}, R: {}", payload[2], payload[4]); LOG.debug("Battery Level: {}: L: {}, R: {}", batteryType, payload[2], payload[4]);
boolean hasCaseBattery = getCoordinator().supports(SonyHeadphonesCapabilities.BatteryCase);
if (payload[2] != 0) { if (payload[2] != 0) {
final GBDeviceEventBatteryInfo gbDeviceEventBatteryInfoLeft = new GBDeviceEventBatteryInfo(); final GBDeviceEventBatteryInfo gbDeviceEventBatteryInfoLeft = new GBDeviceEventBatteryInfo();
gbDeviceEventBatteryInfoLeft.batteryIndex = 1; gbDeviceEventBatteryInfoLeft.batteryIndex = hasCaseBattery ? 1 : 0;
gbDeviceEventBatteryInfoLeft.level = payload[2]; gbDeviceEventBatteryInfoLeft.level = payload[2];
gbDeviceEventBatteryInfoLeft.state = payload[3] == 1 ? BatteryState.BATTERY_CHARGING : BatteryState.BATTERY_NORMAL; gbDeviceEventBatteryInfoLeft.state = payload[3] == 1 ? BatteryState.BATTERY_CHARGING : BatteryState.BATTERY_NORMAL;
@ -957,30 +960,7 @@ public class SonyProtocolImplV1 extends AbstractSonyProtocolImpl {
if (payload[4] != 0) { if (payload[4] != 0) {
final GBDeviceEventBatteryInfo gbDeviceEventBatteryInfoRight = new GBDeviceEventBatteryInfo(); final GBDeviceEventBatteryInfo gbDeviceEventBatteryInfoRight = new GBDeviceEventBatteryInfo();
gbDeviceEventBatteryInfoRight.batteryIndex = 2; gbDeviceEventBatteryInfoRight.batteryIndex = hasCaseBattery ? 2 : 1;
gbDeviceEventBatteryInfoRight.level = payload[4];
gbDeviceEventBatteryInfoRight.state = payload[5] == 1 ? BatteryState.BATTERY_CHARGING : BatteryState.BATTERY_NORMAL;
batteryEvents.add(gbDeviceEventBatteryInfoRight);
}
} else if (BatteryType.DUAL_NO_CASE.equals(batteryType)) {
// Dual Battery (L / R)
LOG.debug("Battery Level: L: {}, R: {}", payload[2], payload[4]);
if (payload[2] != 0) {
final GBDeviceEventBatteryInfo gbDeviceEventBatteryInfoLeft = new GBDeviceEventBatteryInfo();
gbDeviceEventBatteryInfoLeft.batteryIndex = 0;
gbDeviceEventBatteryInfoLeft.level = payload[2];
gbDeviceEventBatteryInfoLeft.state = payload[3] == 1 ? BatteryState.BATTERY_CHARGING : BatteryState.BATTERY_NORMAL;
batteryEvents.add(gbDeviceEventBatteryInfoLeft);
}
if (payload[4] != 0) {
final GBDeviceEventBatteryInfo gbDeviceEventBatteryInfoRight = new GBDeviceEventBatteryInfo();
gbDeviceEventBatteryInfoRight.batteryIndex = 1;
gbDeviceEventBatteryInfoRight.level = payload[4]; gbDeviceEventBatteryInfoRight.level = payload[4];
gbDeviceEventBatteryInfoRight.state = payload[5] == 1 ? BatteryState.BATTERY_CHARGING : BatteryState.BATTERY_NORMAL; gbDeviceEventBatteryInfoRight.state = payload[5] == 1 ? BatteryState.BATTERY_CHARGING : BatteryState.BATTERY_NORMAL;

View File

@ -19,6 +19,6 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.pro
public enum BatteryType { public enum BatteryType {
SINGLE, SINGLE,
DUAL, DUAL,
DUAL_NO_CASE, DUAL2,
CASE, CASE,
} }

View File

@ -29,6 +29,7 @@ import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSett
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdateDeviceInfo; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdateDeviceInfo;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
@ -68,7 +69,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
PayloadTypeV1.AMBIENT_SOUND_CONTROL_GET.getMessageType(), PayloadTypeV1.AMBIENT_SOUND_CONTROL_GET.getMessageType(),
new byte[]{ new byte[]{
PayloadTypeV1.AMBIENT_SOUND_CONTROL_GET.getCode(), PayloadTypeV1.AMBIENT_SOUND_CONTROL_GET.getCode(),
(byte) (supportsWindNoiseCancelling() ? 0x17 : 0x15) (byte) (supportsWindNoiseCancelling() || getCoordinator().supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x17 : 0x15)
} }
); );
} }
@ -78,7 +79,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
final ByteBuffer buf = ByteBuffer.allocate(supportsWindNoiseCancelling() ? 8 : 7); final ByteBuffer buf = ByteBuffer.allocate(supportsWindNoiseCancelling() ? 8 : 7);
buf.put(PayloadTypeV1.AMBIENT_SOUND_CONTROL_SET.getCode()); buf.put(PayloadTypeV1.AMBIENT_SOUND_CONTROL_SET.getCode());
buf.put((byte) (supportsWindNoiseCancelling() ? 0x17 : 0x15)); buf.put((byte) (supportsWindNoiseCancelling() || getCoordinator().supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x17 : 0x15));
buf.put((byte) 0x01); // 0x00 while dragging the slider? buf.put((byte) 0x01); // 0x00 while dragging the slider?
if (AmbientSoundControl.Mode.OFF.equals(ambientSoundControl.getMode())) { if (AmbientSoundControl.Mode.OFF.equals(ambientSoundControl.getMode())) {
@ -351,7 +352,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
PayloadTypeV2.AMBIENT_SOUND_CONTROL_BUTTON_MODE_SET.getCode(), PayloadTypeV2.AMBIENT_SOUND_CONTROL_BUTTON_MODE_SET.getCode(),
(byte) 0x03, (byte) 0x03,
(byte) 0x01, (byte) 0x01,
(byte) 0x35, (byte) (getCoordinator().supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x00 : 0x35),
(byte) 0x01, (byte) 0x01,
(byte) 0x00, (byte) 0x00,
ambientSoundControlButtonMode.getCode() ambientSoundControlButtonMode.getCode()
@ -554,7 +555,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
return Collections.emptyList(); return Collections.emptyList();
} }
final boolean includesWindNoiseReduction = payload[1] == 0x17; final boolean includesWindNoiseReduction = payload[1] == 0x17 && payload.length > 7;
AmbientSoundControl.Mode mode = null; AmbientSoundControl.Mode mode = null;
@ -798,7 +799,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
return Collections.emptyList(); return Collections.emptyList();
} }
if (payload[1] != 0x03 || payload[2] != 0x01 || payload[3] != 0x35 || payload[4] != 0x01 || payload[5] != 0x00) { if (payload[1] != 0x03 || payload[2] != 0x01 || (payload[3] != 0x00 && payload[3] != 0x35) || payload[4] != 0x01 || payload[5] != 0x00) {
LOG.warn( LOG.warn(
"Unexpected ambient sound control button mode payload bytes {}", "Unexpected ambient sound control button mode payload bytes {}",
String.format("%02x %02x %02x %02x %02x", payload[1], payload[2], payload[3], payload[4], payload[5]) String.format("%02x %02x %02x %02x %02x", payload[1], payload[2], payload[3], payload[4], payload[5])
@ -812,7 +813,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
return Collections.emptyList(); return Collections.emptyList();
} }
LOG.debug("Ambient Sound Control Buton Mode: {}", mode); LOG.debug("Ambient Sound Control Button Mode: {}", mode);
final GBDeviceEventUpdatePreferences event = new GBDeviceEventUpdatePreferences() final GBDeviceEventUpdatePreferences event = new GBDeviceEventUpdatePreferences()
.withPreferences(mode.toPreferences()); .withPreferences(mode.toPreferences());
@ -1028,7 +1029,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
case 0x00: case 0x00:
return BatteryType.SINGLE; return BatteryType.SINGLE;
case 0x01: case 0x01:
return BatteryType.DUAL_NO_CASE; return BatteryType.DUAL2;
case 0x09: case 0x09:
return BatteryType.DUAL; return BatteryType.DUAL;
case 0x0a: case 0x0a:
@ -1043,7 +1044,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
switch (batteryType) { switch (batteryType) {
case SINGLE: case SINGLE:
return 0x00; return 0x00;
case DUAL_NO_CASE: case DUAL2:
return 0x01; return 0x01;
case DUAL: case DUAL:
return 0x09; return 0x09;

View File

@ -1807,6 +1807,7 @@
<string name="devicetype_sony_wf_1000xm4">Sony WF-1000XM4</string> <string name="devicetype_sony_wf_1000xm4">Sony WF-1000XM4</string>
<string name="devicetype_sony_wf_1000xm5">Sony WF-1000XM5</string> <string name="devicetype_sony_wf_1000xm5">Sony WF-1000XM5</string>
<string name="devicetype_sony_wf_c500">Sony WF-C500</string> <string name="devicetype_sony_wf_c500">Sony WF-C500</string>
<string name="devicetype_sony_wf_c700n">Sony WF-C700N</string>
<string name="devicetype_sony_wi_sp600n">Sony WI-SP600N</string> <string name="devicetype_sony_wi_sp600n">Sony WI-SP600N</string>
<string name="devicetype_sony_linkbuds">Sony LinkBuds</string> <string name="devicetype_sony_linkbuds">Sony LinkBuds</string>
<string name="devicetype_sony_linkbuds_s">Sony LinkBuds S</string> <string name="devicetype_sony_linkbuds_s">Sony LinkBuds S</string>

View File

@ -37,7 +37,6 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWF1000XM4Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWF1000XM4Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
@ -104,7 +103,7 @@ public class SonyProtocolImplV2Test {
final Map<BatteryType, String> commands = new LinkedHashMap<BatteryType, String>() {{ final Map<BatteryType, String> commands = new LinkedHashMap<BatteryType, String>() {{
put(BatteryType.SINGLE, "22:00"); put(BatteryType.SINGLE, "22:00");
put(BatteryType.DUAL, "22:09"); put(BatteryType.DUAL, "22:09");
put(BatteryType.DUAL_NO_CASE, "22:01"); put(BatteryType.DUAL2, "22:01");
put(BatteryType.CASE, "22:0a"); put(BatteryType.CASE, "22:0a");
}}; }};