mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-12 01:51:58 +01:00
replaced BatteryLevelRequest with native characteristic
This commit is contained in:
parent
f912ae28a2
commit
5ce5b5d8a4
@ -111,7 +111,6 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
|
|
||||||
private Queue<Request> requestQueue = new ArrayDeque<>();
|
private Queue<Request> requestQueue = new ArrayDeque<>();
|
||||||
|
|
||||||
|
|
||||||
private String modelNumber;
|
private String modelNumber;
|
||||||
|
|
||||||
public QHybridSupport() {
|
public QHybridSupport() {
|
||||||
@ -119,6 +118,7 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
addSupportedService(UUID.fromString("3dda0001-957f-7d4a-34a6-74696673696d"));
|
addSupportedService(UUID.fromString("3dda0001-957f-7d4a-34a6-74696673696d"));
|
||||||
addSupportedService(UUID.fromString("0000180a-0000-1000-8000-00805f9b34fb"));
|
addSupportedService(UUID.fromString("0000180a-0000-1000-8000-00805f9b34fb"));
|
||||||
addSupportedService(UUID.fromString("00001800-0000-1000-8000-00805f9b34fb"));
|
addSupportedService(UUID.fromString("00001800-0000-1000-8000-00805f9b34fb"));
|
||||||
|
addSupportedService(UUID.fromString("0000180f-0000-1000-8000-00805f9b34fb"));
|
||||||
IntentFilter commandFilter = new IntentFilter(QHYBRID_COMMAND_CONTROL);
|
IntentFilter commandFilter = new IntentFilter(QHYBRID_COMMAND_CONTROL);
|
||||||
commandFilter.addAction(QHYBRID_COMMAND_UNCONTROL);
|
commandFilter.addAction(QHYBRID_COMMAND_UNCONTROL);
|
||||||
commandFilter.addAction(QHYBRID_COMMAND_SET);
|
commandFilter.addAction(QHYBRID_COMMAND_SET);
|
||||||
@ -133,8 +133,10 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
|
|
||||||
private boolean supportsExtendedVibration() {
|
private boolean supportsExtendedVibration() {
|
||||||
switch (modelNumber) {
|
switch (modelNumber) {
|
||||||
case "HL.0.0": return false;
|
case "HL.0.0":
|
||||||
case "HW.0.0": return true;
|
return false;
|
||||||
|
case "HW.0.0":
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
@ -186,14 +188,15 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
requestQueue.add(new GetCurrentStepCountRequest());
|
requestQueue.add(new GetCurrentStepCountRequest());
|
||||||
requestQueue.add(new GetVibrationStrengthRequest());
|
requestQueue.add(new GetVibrationStrengthRequest());
|
||||||
requestQueue.add(new ActivityPointGetRequest());
|
requestQueue.add(new ActivityPointGetRequest());
|
||||||
requestQueue.add(new AnimationRequest());
|
|
||||||
|
|
||||||
Request initialRequest = new BatteryLevelRequest();
|
Request initialRequest = new AnimationRequest();
|
||||||
|
|
||||||
builder.read(getCharacteristic(UUID.fromString("00002a00-0000-1000-8000-00805f9b34fb")))
|
builder.read(getCharacteristic(UUID.fromString("00002a00-0000-1000-8000-00805f9b34fb")))
|
||||||
.read(getCharacteristic(UUID.fromString("00002a24-0000-1000-8000-00805f9b34fb")))
|
.read(getCharacteristic(UUID.fromString("00002a24-0000-1000-8000-00805f9b34fb")))
|
||||||
.read(getCharacteristic(UUID.fromString("00002a26-0000-1000-8000-00805f9b34fb")))
|
.read(getCharacteristic(UUID.fromString("00002a26-0000-1000-8000-00805f9b34fb")))
|
||||||
.write(getCharacteristic(initialRequest.getRequestUUID()), initialRequest.getRequestData());
|
.read(getCharacteristic(UUID.fromString("00002a19-0000-1000-8000-00805f9b34fb")))
|
||||||
|
.write(getCharacteristic(initialRequest.getRequestUUID()), initialRequest.getRequestData())
|
||||||
|
;
|
||||||
|
|
||||||
helper = new PackageConfigHelper(getContext());
|
helper = new PackageConfigHelper(getContext());
|
||||||
getTimeOffset();
|
getTimeOffset();
|
||||||
@ -293,8 +296,10 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
// queueWrite(new ActivityPointGetRequest());
|
// queueWrite(new ActivityPointGetRequest());
|
||||||
long millis = System.currentTimeMillis();
|
long millis = System.currentTimeMillis();
|
||||||
int secs = (int) (millis / 1000 * 60);
|
int secs = (int) (millis / 1000 * 60);
|
||||||
queueWrite(new SetCountdownSettings(secs, secs + 10, (short) 120));
|
//queueWrite(new SetCountdownSettings(secs, secs + 10, (short) 120));
|
||||||
queueWrite(new GetCountdownSettingsRequest());
|
//queueWrite(new GetCountdownSettingsRequest());
|
||||||
|
|
||||||
|
queueWrite(new AnimationRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void overwriteButtons() {
|
private void overwriteButtons() {
|
||||||
@ -362,6 +367,18 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
gbDevice.setFirmwareVersion(firmwareVersion);
|
gbDevice.setFirmwareVersion(firmwareVersion);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "00002a19-0000-1000-8000-00805f9b34fb": {
|
||||||
|
short level = characteristic.getValue()[0];
|
||||||
|
gbDevice.setBatteryLevel(level);
|
||||||
|
|
||||||
|
gbDevice.setBatteryThresholdPercent((short) 2);
|
||||||
|
|
||||||
|
GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo();
|
||||||
|
batteryInfo.level = gbDevice.getBatteryLevel();
|
||||||
|
batteryInfo.state = BatteryState.BATTERY_NORMAL;
|
||||||
|
handleGBDeviceEvent(batteryInfo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -477,16 +494,7 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
Log.d("Service", "response: " + request.getClass().getSimpleName());
|
Log.d("Service", "response: " + request.getClass().getSimpleName());
|
||||||
request.handleResponse(characteristic);
|
request.handleResponse(characteristic);
|
||||||
|
|
||||||
if (request instanceof BatteryLevelRequest) {
|
if (request instanceof GetStepGoalRequest) {
|
||||||
gbDevice.setBatteryLevel(((BatteryLevelRequest) request).level);
|
|
||||||
|
|
||||||
gbDevice.setBatteryThresholdPercent((short) 2);
|
|
||||||
|
|
||||||
GBDeviceEventBatteryInfo batteryInfo = new GBDeviceEventBatteryInfo();
|
|
||||||
batteryInfo.level = gbDevice.getBatteryLevel();
|
|
||||||
batteryInfo.state = BatteryState.BATTERY_NORMAL;
|
|
||||||
handleGBDeviceEvent(batteryInfo);
|
|
||||||
} else if (request instanceof GetStepGoalRequest) {
|
|
||||||
gbDevice.addDeviceInfo(new GenericItem(ITEM_STEP_GOAL, String.valueOf(((GetStepGoalRequest) request).stepGoal)));
|
gbDevice.addDeviceInfo(new GenericItem(ITEM_STEP_GOAL, String.valueOf(((GetStepGoalRequest) request).stepGoal)));
|
||||||
} else if (request instanceof GetVibrationStrengthRequest) {
|
} else if (request instanceof GetVibrationStrengthRequest) {
|
||||||
int strength = ((GetVibrationStrengthRequest) request).strength;
|
int strength = ((GetVibrationStrengthRequest) request).strength;
|
||||||
|
Loading…
Reference in New Issue
Block a user