1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-29 13:26:50 +01:00

Add support for Casio STB-1000. Limitations of GB-5600B/GB-6900B apply.

This commit is contained in:
Andreas Böhler 2021-10-18 18:23:35 +02:00
parent 2c6907b02b
commit 8a3fc19285
3 changed files with 42 additions and 10 deletions

View File

@ -116,7 +116,8 @@ public final class CasioConstants {
MODEL_CASIO_GENERIC, MODEL_CASIO_GENERIC,
MODEL_CASIO_6900B, MODEL_CASIO_6900B,
MODEL_CASIO_5600B, MODEL_CASIO_5600B,
MODEL_CASIO_GBX100 MODEL_CASIO_GBX100,
MODEL_CASIO_STB1000,
} }
public enum ConfigurationOption { public enum ConfigurationOption {

View File

@ -48,7 +48,8 @@ public class CasioGB6900DeviceCoordinator extends AbstractDeviceCoordinator {
public DeviceType getSupportedType(GBDeviceCandidate candidate) { public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getDevice().getName(); String name = candidate.getDevice().getName();
if (name != null) { if (name != null) {
if (name.startsWith("CASIO") && (name.contains("6900B") || name.contains("5600B"))) { if (name.startsWith("CASIO") && (name.contains("6900B") || name.contains("5600B") ||
name.contains("STB-1000"))) {
return DeviceType.CASIOGB6900; return DeviceType.CASIOGB6900;
} }
} }

View File

@ -153,19 +153,21 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
mModel = CasioConstants.Model.MODEL_CASIO_5600B; mModel = CasioConstants.Model.MODEL_CASIO_5600B;
} else if(name.contains("6900B")) { } else if(name.contains("6900B")) {
mModel = CasioConstants.Model.MODEL_CASIO_6900B; mModel = CasioConstants.Model.MODEL_CASIO_6900B;
} else if(name.contains("STB-1000")) {
mModel = CasioConstants.Model.MODEL_CASIO_STB1000;
} else { } else {
mModel = CasioConstants.Model.MODEL_CASIO_GENERIC; mModel = CasioConstants.Model.MODEL_CASIO_GENERIC;
} }
try { // We skip configuring BLE settings for the STB-1000 since it powers off
new InitOperationGB6900(this, builder).perform(); // BLE on the watch.
} catch (IOException e) { if(mModel != CasioConstants.Model.MODEL_CASIO_STB1000) {
GB.toast(getContext(), "Initializing Casio watch failed", Toast.LENGTH_SHORT, GB.ERROR, e); try {
new InitOperationGB6900(this, builder).perform();
} catch (IOException e) {
GB.toast(getContext(), "Initializing Casio watch failed", Toast.LENGTH_SHORT, GB.ERROR, e);
}
} }
/*
gbDevice.setState(GBDevice.State.INITIALIZING);
gbDevice.sendDeviceUpdateIntent(getContext());
*/
getDevice().setFirmwareVersion("N/A"); getDevice().setFirmwareVersion("N/A");
getDevice().setFirmwareVersion2("N/A"); getDevice().setFirmwareVersion2("N/A");
@ -779,6 +781,31 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
return true; return true;
} }
private GBDeviceEventMusicControl.Event parse5Button(int button) {
GBDeviceEventMusicControl.Event event;
switch(button) {
case 5:
event = GBDeviceEventMusicControl.Event.PLAYPAUSE;
break;
case 4:
event = GBDeviceEventMusicControl.Event.NEXT;
break;
case 3:
event = GBDeviceEventMusicControl.Event.VOLUMEUP;
break;
case 2:
event = GBDeviceEventMusicControl.Event.PREVIOUS;
break;
case 1:
event = GBDeviceEventMusicControl.Event.VOLUMEDOWN;
break;
default:
LOG.warn("Unhandled button received: " + button);
event = GBDeviceEventMusicControl.Event.UNKNOWN;
}
return event;
}
private GBDeviceEventMusicControl.Event parse3Button(int button) { private GBDeviceEventMusicControl.Event parse3Button(int button) {
GBDeviceEventMusicControl.Event event; GBDeviceEventMusicControl.Event event;
switch(button) { switch(button) {
@ -835,6 +862,9 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
case MODEL_CASIO_6900B: case MODEL_CASIO_6900B:
musicCmd.event = parse3Button(button); musicCmd.event = parse3Button(button);
break; break;
case MODEL_CASIO_STB1000:
musicCmd.event = parse5Button(button);
break;
case MODEL_CASIO_GENERIC: case MODEL_CASIO_GENERIC:
musicCmd.event = parse3Button(button); musicCmd.event = parse3Button(button);
break; break;