fix BatteryInfoProfile NPE, show battery level for Vibratissimo

This commit is contained in:
Andreas Shimokawa 2016-09-19 16:37:45 +02:00
parent b2669d6fd7
commit da01a76594
2 changed files with 3 additions and 1 deletions

View File

@ -27,7 +27,7 @@ public class BatteryInfoProfile<T extends AbstractBTLEDeviceSupport> extends Abs
public static final UUID SERVICE_UUID = GattService.UUID_SERVICE_BATTERY_SERVICE; public static final UUID SERVICE_UUID = GattService.UUID_SERVICE_BATTERY_SERVICE;
public static final UUID UUID_CHARACTERISTIC_BATTERY_LEVEL = GattCharacteristic.UUID_CHARACTERISTIC_BATTERY_LEVEL; public static final UUID UUID_CHARACTERISTIC_BATTERY_LEVEL = GattCharacteristic.UUID_CHARACTERISTIC_BATTERY_LEVEL;
private BatteryInfo batteryInfo; private final BatteryInfo batteryInfo = new BatteryInfo();
public BatteryInfoProfile(T support) { public BatteryInfoProfile(T support) {
super(support); super(support);

View File

@ -57,6 +57,7 @@ public class VibratissimoSupport extends AbstractBTLEDeviceSupport {
addSupportedService(GattService.UUID_SERVICE_GENERIC_ACCESS); addSupportedService(GattService.UUID_SERVICE_GENERIC_ACCESS);
addSupportedService(GattService.UUID_SERVICE_GENERIC_ATTRIBUTE); addSupportedService(GattService.UUID_SERVICE_GENERIC_ATTRIBUTE);
addSupportedService(GattService.UUID_SERVICE_DEVICE_INFORMATION); addSupportedService(GattService.UUID_SERVICE_DEVICE_INFORMATION);
addSupportedService(GattService.UUID_SERVICE_BATTERY_SERVICE);
addSupportedService(UUID.fromString("00001523-1212-efde-1523-785feabcd123")); addSupportedService(UUID.fromString("00001523-1212-efde-1523-785feabcd123"));
deviceInfoProfile = new DeviceInfoProfile<>(this); deviceInfoProfile = new DeviceInfoProfile<>(this);
@ -88,6 +89,7 @@ public class VibratissimoSupport extends AbstractBTLEDeviceSupport {
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext())); builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext()));
requestDeviceInfo(builder); requestDeviceInfo(builder);
setInitialized(builder); setInitialized(builder);
batteryInfoProfile.requestBatteryInfo(builder);
return builder; return builder;
} }