mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-26 01:27:33 +01:00
Add support for displaying music info
This commit is contained in:
parent
81df586fbd
commit
76aebd4e20
@ -35,6 +35,12 @@ public final class CasioGB6900Constants {
|
||||
public static final UUID ALERT_CHARACTERISTIC_UUID = UUID.fromString("00002a46-0000-1000-8000-00805f9b34fb");
|
||||
public static final UUID ALERT_NOTIFICATION_CONTROL_POINT = UUID.fromString("00002a44-0000-1000-8000-00805f9b34fb");
|
||||
|
||||
// More Alert
|
||||
|
||||
public static final UUID MORE_ALERT_SERVICE_UUID = UUID.fromString("26eb001a-b012-49a8-b1f8-394fb2032b0f");
|
||||
public static final UUID MORE_ALERT_UUID = UUID.fromString("26eb001b-b012-49a8-b1f8-394fb2032b0f");
|
||||
public static final UUID MORE_ALERT_FOR_LONG_UUID = UUID.fromString("26eb001c-b012-49a8-b1f8-394fb2032b0f");
|
||||
|
||||
// Phone Alert
|
||||
public static final UUID CASIO_PHONE_ALERT_STATUS_SERVICE = UUID.fromString("26eb0001-b012-49a8-b1f8-394fb2032b0f");
|
||||
public static final UUID RINGER_CONTROL_POINT = UUID.fromString("00002a40-0000-1000-8000-00805f9b34fb");
|
||||
|
@ -57,6 +57,8 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
public BluetoothGattCharacteristic mCasioCharact4 = null;
|
||||
public BluetoothGattCharacteristic mCasioCharact5 = null;
|
||||
private CasioGATTThread mThread = null;
|
||||
private MusicSpec mBufferMusicSpec = null;
|
||||
private MusicStateSpec mBufferMusicStateSpec = null;
|
||||
|
||||
public CasioGB6900DeviceSupport() {
|
||||
super(LOG);
|
||||
@ -67,6 +69,7 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
addSupportedService(CasioGB6900Constants.WATCH_CTRL_SERVICE_UUID);
|
||||
addSupportedService(CasioGB6900Constants.WATCH_FEATURES_SERVICE_UUID);
|
||||
addSupportedService(CasioGB6900Constants.CASIO_PHONE_ALERT_STATUS_SERVICE);
|
||||
addSupportedService(CasioGB6900Constants.MORE_ALERT_SERVICE_UUID);
|
||||
mThread = new CasioGATTThread(getContext(), this);
|
||||
}
|
||||
|
||||
@ -364,12 +367,53 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
@Override
|
||||
public void onSetMusicState(MusicStateSpec stateSpec) {
|
||||
LOG.info("onSetMusicState");
|
||||
if(stateSpec != mBufferMusicStateSpec)
|
||||
{
|
||||
mBufferMusicStateSpec = stateSpec;
|
||||
sendMusicInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMusicInfo()
|
||||
{
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("sendMusicInfo");
|
||||
String info = "";
|
||||
if (mBufferMusicSpec.track != null && mBufferMusicSpec.track.length() > 0) {
|
||||
info += mBufferMusicSpec.track;
|
||||
}
|
||||
if (mBufferMusicSpec.album != null && mBufferMusicSpec.album.length() > 0) {
|
||||
info += mBufferMusicSpec.album;
|
||||
}
|
||||
if (mBufferMusicSpec.artist != null && mBufferMusicSpec.artist.length() > 0) {
|
||||
info += mBufferMusicSpec.artist;
|
||||
}
|
||||
byte[] bInfo = info.getBytes(StandardCharsets.US_ASCII);
|
||||
int len = bInfo.length > 17 ? 17 : bInfo.length;
|
||||
byte[] arr = new byte[len + 3];
|
||||
arr[0] = 0;
|
||||
arr[1] = 10;
|
||||
arr[2] = 1;
|
||||
for(int i=0; i<len; i++)
|
||||
{
|
||||
arr[i+3] = bInfo[i];
|
||||
}
|
||||
builder.write(getCharacteristic(CasioGB6900Constants.MORE_ALERT_FOR_LONG_UUID), arr);
|
||||
performConnected(builder.getTransaction());
|
||||
} catch (IOException e) {
|
||||
LOG.warn(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetMusicInfo(MusicSpec musicSpec) {
|
||||
|
||||
LOG.info("onSetMusicInfo");
|
||||
if(musicSpec != mBufferMusicSpec)
|
||||
{
|
||||
mBufferMusicSpec = musicSpec;
|
||||
sendMusicInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user