mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 18:15:49 +01:00
Reordered a few functions, constructor to be more sensible
This commit is contained in:
parent
d892e8d963
commit
48abd91e72
@ -68,21 +68,28 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport {
|
|||||||
*/
|
*/
|
||||||
String lastAlbum;
|
String lastAlbum;
|
||||||
String lastTrack;
|
String lastTrack;
|
||||||
|
String lastArtist;
|
||||||
|
|
||||||
private void setInitialized(TransactionBuilder builder) {
|
public PineTimeJFSupport() {
|
||||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZED, getContext()));
|
super(LOG);
|
||||||
}
|
addSupportedService(GattService.UUID_SERVICE_ALERT_NOTIFICATION);
|
||||||
|
addSupportedService(GattService.UUID_SERVICE_CURRENT_TIME);
|
||||||
private void requestDeviceInfo(TransactionBuilder builder) {
|
addSupportedService(GattService.UUID_SERVICE_DEVICE_INFORMATION);
|
||||||
LOG.debug("Requesting Device Info!");
|
addSupportedService(PineTimeJFConstants.UUID_SERVICE_MUSIC_CONTROL);
|
||||||
deviceInfoProfile.requestDeviceInfo(builder);
|
deviceInfoProfile = new DeviceInfoProfile<>(this);
|
||||||
}
|
IntentListener mListener = new IntentListener() {
|
||||||
|
@Override
|
||||||
private void handleDeviceInfo(nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.deviceinfo.DeviceInfo info) {
|
public void notify(Intent intent) {
|
||||||
LOG.warn("Device info: " + info);
|
String action = intent.getAction();
|
||||||
versionCmd.hwVersion = info.getHardwareRevision();
|
if (DeviceInfoProfile.ACTION_DEVICE_INFO.equals(action)) {
|
||||||
versionCmd.fwVersion = info.getFirmwareRevision();
|
handleDeviceInfo((nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.deviceinfo.DeviceInfo) intent.getParcelableExtra(DeviceInfoProfile.EXTRA_DEVICE_INFO));
|
||||||
handleGBDeviceEvent(versionCmd);
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
deviceInfoProfile.addListener(mListener);
|
||||||
|
AlertNotificationProfile<PineTimeJFSupport> alertNotificationProfile = new AlertNotificationProfile<>(this);
|
||||||
|
addSupportedProfile(alertNotificationProfile);
|
||||||
|
addSupportedProfile(deviceInfoProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -221,37 +228,6 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String lastArtist;
|
|
||||||
|
|
||||||
public PineTimeJFSupport() {
|
|
||||||
super(LOG);
|
|
||||||
addSupportedService(GattService.UUID_SERVICE_ALERT_NOTIFICATION);
|
|
||||||
addSupportedService(GattService.UUID_SERVICE_CURRENT_TIME);
|
|
||||||
addSupportedService(GattService.UUID_SERVICE_DEVICE_INFORMATION);
|
|
||||||
addSupportedService(PineTimeJFConstants.UUID_SERVICE_MUSIC_CONTROL);
|
|
||||||
deviceInfoProfile = new DeviceInfoProfile<>(this);
|
|
||||||
IntentListener mListener = new IntentListener() {
|
|
||||||
@Override
|
|
||||||
public void notify(Intent intent) {
|
|
||||||
String action = intent.getAction();
|
|
||||||
if (DeviceInfoProfile.ACTION_DEVICE_INFO.equals(action)) {
|
|
||||||
handleDeviceInfo((nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.deviceinfo.DeviceInfo) intent.getParcelableExtra(DeviceInfoProfile.EXTRA_DEVICE_INFO));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
deviceInfoProfile.addListener(mListener);
|
|
||||||
AlertNotificationProfile<PineTimeJFSupport> alertNotificationProfile = new AlertNotificationProfile<>(this);
|
|
||||||
addSupportedProfile(alertNotificationProfile);
|
|
||||||
addSupportedProfile(deviceInfoProfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function that ust converts an integer into a byte array
|
|
||||||
*/
|
|
||||||
private static byte[] intToBytes(int source) {
|
|
||||||
return ByteBuffer.allocate(4).putInt(source).array();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
|
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
|
||||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext()));
|
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext()));
|
||||||
@ -406,6 +382,13 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function that just converts an integer into a byte array
|
||||||
|
*/
|
||||||
|
private static byte[] intToBytes(int source) {
|
||||||
|
return ByteBuffer.allocate(4).putInt(source).array();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will check if the characteristic exists and can be written
|
* This will check if the characteristic exists and can be written
|
||||||
* <p>
|
* <p>
|
||||||
@ -418,4 +401,20 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport {
|
|||||||
builder.write(characteristic, data);
|
builder.write(characteristic, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setInitialized(TransactionBuilder builder) {
|
||||||
|
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZED, getContext()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requestDeviceInfo(TransactionBuilder builder) {
|
||||||
|
LOG.debug("Requesting Device Info!");
|
||||||
|
deviceInfoProfile.requestDeviceInfo(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleDeviceInfo(nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.deviceinfo.DeviceInfo info) {
|
||||||
|
LOG.warn("Device info: " + info);
|
||||||
|
versionCmd.hwVersion = info.getHardwareRevision();
|
||||||
|
versionCmd.fwVersion = info.getFirmwareRevision();
|
||||||
|
handleGBDeviceEvent(versionCmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user