mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Pebble 2 Duo: Fix getting inital battery level (for the rest still rely on datalog
This commit is contained in:
+3
@@ -481,6 +481,9 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
write(mPebbleProtocol.encodeEnableAppLogs(devicePrefs.getBoolean("pebble_enable_applogs", false)));
|
||||
write(mPebbleProtocol.encodeReportDataLogSessions());
|
||||
gbDevice.setState(GBDevice.State.INITIALIZED);
|
||||
if (mPebbleLESupport != null) {
|
||||
mPebbleLESupport.readBatteryCharacteristic();
|
||||
}
|
||||
return false;
|
||||
} else if (deviceEvent instanceof GBDeviceEventAppManagement) {
|
||||
GBDeviceEventAppManagement appMgmt = (GBDeviceEventAppManagement) deviceEvent;
|
||||
|
||||
+6
-5
@@ -245,12 +245,13 @@ class PebbleGATTClient extends BluetoothGattCallback {
|
||||
if (status == BluetoothGatt.GATT_SUCCESS) {
|
||||
LOG.info("MTU changed to {}", mtu);
|
||||
mPebbleLESupport.setMTU(mtu);
|
||||
}
|
||||
}
|
||||
|
||||
// read battery
|
||||
BluetoothGattCharacteristic characteristic = gatt.getService(GattService.UUID_SERVICE_BATTERY_SERVICE).getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_BATTERY_LEVEL);
|
||||
if (characteristic != null) {
|
||||
gatt.readCharacteristic(characteristic);
|
||||
}
|
||||
public void readBatteryCharacteristic() {
|
||||
BluetoothGattCharacteristic characteristic = mBluetoothGatt.getService(GattService.UUID_SERVICE_BATTERY_SERVICE).getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_BATTERY_LEVEL);
|
||||
if (characteristic != null) {
|
||||
mBluetoothGatt.readCharacteristic(characteristic);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -154,6 +154,10 @@ public class PebbleLESupport {
|
||||
mMTU = Math.min(mtu, mMTULimit);
|
||||
}
|
||||
|
||||
public void readBatteryCharacteristic() {
|
||||
mPebbleGATTClient.readBatteryCharacteristic();
|
||||
}
|
||||
|
||||
public void handlePPoGATTPacket(byte[] value) {
|
||||
if (!mIsConnected) {
|
||||
mIsConnected = true;
|
||||
|
||||
Reference in New Issue
Block a user