mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-12 10:55:49 +01:00
Rearranged the code in PineTime support a bit
This commit is contained in:
parent
2cd783feca
commit
c41fda5072
@ -18,7 +18,6 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.pinetime;
|
|||||||
|
|
||||||
import android.bluetooth.BluetoothGatt;
|
import android.bluetooth.BluetoothGatt;
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -45,6 +44,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicContr
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.pinetime.PineTimeDFUService;
|
import nodomain.freeyourgadget.gadgetbridge.devices.pinetime.PineTimeDFUService;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.pinetime.PineTimeInstallHandler;
|
import nodomain.freeyourgadget.gadgetbridge.devices.pinetime.PineTimeInstallHandler;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.pinetime.PineTimeJFConstants;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||||
@ -65,13 +65,13 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotificat
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertNotificationProfile;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertNotificationProfile;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.NewAlert;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.NewAlert;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.OverflowStrategy;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.OverflowStrategy;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.deviceinfo.DeviceInfo;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.deviceinfo.DeviceInfoProfile;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.deviceinfo.DeviceInfoProfile;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
|
|
||||||
public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuLogListener {
|
public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuLogListener {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(PineTimeJFSupport.class);
|
private static final Logger LOG = LoggerFactory.getLogger(PineTimeJFSupport.class);
|
||||||
|
private final GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo();
|
||||||
|
private final DeviceInfoProfile<PineTimeJFSupport> deviceInfoProfile;
|
||||||
/**
|
/**
|
||||||
* These are used to keep track when long strings haven't changed,
|
* These are used to keep track when long strings haven't changed,
|
||||||
* thus avoiding unnecessary transfers that are (potentially) very slow.
|
* thus avoiding unnecessary transfers that are (potentially) very slow.
|
||||||
@ -81,11 +81,6 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuL
|
|||||||
String lastAlbum;
|
String lastAlbum;
|
||||||
String lastTrack;
|
String lastTrack;
|
||||||
String lastArtist;
|
String lastArtist;
|
||||||
|
|
||||||
private final GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo();
|
|
||||||
|
|
||||||
private final DeviceInfoProfile<PineTimeJFSupport> deviceInfoProfile;
|
|
||||||
|
|
||||||
PineTimeInstallHandler handler;
|
PineTimeInstallHandler handler;
|
||||||
DfuServiceController controller;
|
DfuServiceController controller;
|
||||||
|
|
||||||
@ -224,32 +219,6 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuL
|
|||||||
addSupportedProfile(deviceInfoProfile);
|
addSupportedProfile(deviceInfoProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
|
|
||||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext()));
|
|
||||||
requestDeviceInfo(builder);
|
|
||||||
onSetTime();
|
|
||||||
builder.notify(getCharacteristic(UUID_CHARACTERISTICS_MUSIC_EVENT), true);
|
|
||||||
setInitialized(builder);
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
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(DeviceInfo info) {
|
|
||||||
LOG.warn("Device info: " + info);
|
|
||||||
versionCmd.hwVersion = info.getHardwareRevision();
|
|
||||||
versionCmd.fwVersion = info.getFirmwareRevision();
|
|
||||||
handleGBDeviceEvent(versionCmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean useAutoConnect() {
|
public boolean useAutoConnect() {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user