mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-13 19:27:33 +01:00
Add explicit support for GB-6900B, GB-X6900B and GB-5600B
This commit is contained in:
parent
df6547c287
commit
fc17dec87b
@ -88,5 +88,9 @@ public final class CasioGB6900Constants {
|
|||||||
public static final byte SNS_NOTIFICATION_ID = 13;
|
public static final byte SNS_NOTIFICATION_ID = 13;
|
||||||
public static final byte SMS_NOTIFICATION_ID = 5;
|
public static final byte SMS_NOTIFICATION_ID = 5;
|
||||||
|
|
||||||
|
public enum Model {
|
||||||
|
MODEL_CASIO_GENERIC,
|
||||||
|
MODEL_CASIO_6900B,
|
||||||
|
MODEL_CASIO_5600B
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,40 @@ class CasioGATTServer extends BluetoothGattServerCallback {
|
|||||||
LOG.warn("error sending response");
|
LOG.warn("error sending response");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private GBDeviceEventMusicControl.Event parse3Button(int button) {
|
||||||
|
GBDeviceEventMusicControl.Event event;
|
||||||
|
switch(button) {
|
||||||
|
case 3:
|
||||||
|
event = GBDeviceEventMusicControl.Event.NEXT;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
event = GBDeviceEventMusicControl.Event.PREVIOUS;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
event = GBDeviceEventMusicControl.Event.PLAYPAUSE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOG.warn("Unhandled button received: " + button);
|
||||||
|
event = GBDeviceEventMusicControl.Event.UNKNOWN;
|
||||||
|
}
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GBDeviceEventMusicControl.Event parse2Button(int button) {
|
||||||
|
GBDeviceEventMusicControl.Event event;
|
||||||
|
switch(button) {
|
||||||
|
case 2:
|
||||||
|
event = GBDeviceEventMusicControl.Event.PLAYPAUSE;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
event = GBDeviceEventMusicControl.Event.NEXT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOG.warn("Unhandled button received: " + button);
|
||||||
|
event = GBDeviceEventMusicControl.Event.UNKNOWN;
|
||||||
|
}
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic,
|
public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic,
|
||||||
@ -119,21 +153,23 @@ class CasioGATTServer extends BluetoothGattServerCallback {
|
|||||||
if((value[0] & 0x03) == 0) {
|
if((value[0] & 0x03) == 0) {
|
||||||
int button = value[1] & 0x0f;
|
int button = value[1] & 0x0f;
|
||||||
LOG.info("Button pressed: " + button);
|
LOG.info("Button pressed: " + button);
|
||||||
switch(button) {
|
switch(mDeviceSupport.getModel())
|
||||||
case 3:
|
{
|
||||||
musicCmd.event = GBDeviceEventMusicControl.Event.NEXT;
|
case MODEL_CASIO_5600B:
|
||||||
|
musicCmd.event = parse2Button(button);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case MODEL_CASIO_6900B:
|
||||||
musicCmd.event = GBDeviceEventMusicControl.Event.PREVIOUS;
|
musicCmd.event = parse3Button(button);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case MODEL_CASIO_GENERIC:
|
||||||
musicCmd.event = GBDeviceEventMusicControl.Event.PLAYPAUSE;
|
musicCmd.event = parse3Button(button);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG.warn("Unhandled button received: " + button);
|
LOG.warn("Unhandled device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mDeviceSupport.evaluateGBDeviceEvent(musicCmd);
|
mDeviceSupport.evaluateGBDeviceEvent(musicCmd);
|
||||||
|
mDeviceSupport.evaluateGBDeviceEvent(musicCmd);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG.info("received from device: " + value.toString());
|
LOG.info("received from device: " + value.toString());
|
||||||
@ -145,7 +181,7 @@ class CasioGATTServer extends BluetoothGattServerCallback {
|
|||||||
|
|
||||||
LOG.info("Connection state change for device: " + device.getAddress() + " status = " + status + " newState = " + newState);
|
LOG.info("Connection state change for device: " + device.getAddress() + " status = " + status + " newState = " + newState);
|
||||||
if (newState == BluetoothGattServer.STATE_DISCONNECTED) {
|
if (newState == BluetoothGattServer.STATE_DISCONNECTED) {
|
||||||
|
LOG.info("CASIO GATT server noticed disconnect.");
|
||||||
}
|
}
|
||||||
if (newState == BluetoothGattServer.STATE_CONNECTED) {
|
if (newState == BluetoothGattServer.STATE_CONNECTED) {
|
||||||
GBDevice.State devState = mDeviceSupport.getDevice().getState();
|
GBDevice.State devState = mDeviceSupport.getDevice().getState();
|
||||||
|
@ -60,6 +60,7 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
private MusicSpec mBufferMusicSpec = null;
|
private MusicSpec mBufferMusicSpec = null;
|
||||||
private MusicStateSpec mBufferMusicStateSpec = null;
|
private MusicStateSpec mBufferMusicStateSpec = null;
|
||||||
private BluetoothGatt mBtGatt = null;
|
private BluetoothGatt mBtGatt = null;
|
||||||
|
private CasioGB6900Constants.Model mModel = CasioGB6900Constants.Model.MODEL_CASIO_GENERIC;
|
||||||
|
|
||||||
public CasioGB6900DeviceSupport() {
|
public CasioGB6900DeviceSupport() {
|
||||||
super(LOG);
|
super(LOG);
|
||||||
@ -117,6 +118,16 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
|
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
|
||||||
LOG.info("Initializing");
|
LOG.info("Initializing");
|
||||||
|
|
||||||
|
String name = gbDevice.getName();
|
||||||
|
|
||||||
|
if(name.contains("5600B")) {
|
||||||
|
mModel = CasioGB6900Constants.Model.MODEL_CASIO_5600B;
|
||||||
|
} else if(name.contains("6900B")) {
|
||||||
|
mModel = CasioGB6900Constants.Model.MODEL_CASIO_6900B;
|
||||||
|
} else {
|
||||||
|
mModel = CasioGB6900Constants.Model.MODEL_CASIO_GENERIC;
|
||||||
|
}
|
||||||
|
|
||||||
gbDevice.setState(GBDevice.State.INITIALIZING);
|
gbDevice.setState(GBDevice.State.INITIALIZING);
|
||||||
gbDevice.sendDeviceUpdateIntent(getContext());
|
gbDevice.sendDeviceUpdateIntent(getContext());
|
||||||
|
|
||||||
@ -133,6 +144,10 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
|
|||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CasioGB6900Constants.Model getModel() {
|
||||||
|
return mModel;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: Replace hardcoded values by configuration
|
// FIXME: Replace hardcoded values by configuration
|
||||||
private void configureWatch(TransactionBuilder builder) {
|
private void configureWatch(TransactionBuilder builder) {
|
||||||
if (mBtGatt == null)
|
if (mBtGatt == null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user