1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-29 11:10:35 +02:00

Log exception for #159

This commit is contained in:
Erik Johansson
2018-07-04 13:10:24 +02:00
parent a2543afe02
commit 69312b83ad

View File

@@ -290,16 +290,21 @@ public abstract class BluetoothCommunication {
protected void setIndicationOn(UUID service, UUID characteristic, UUID descriptor) { protected void setIndicationOn(UUID service, UUID characteristic, UUID descriptor) {
Timber.d("Set indication on for %s", characteristic); Timber.d("Set indication on for %s", characteristic);
BluetoothGattCharacteristic gattCharacteristic = try {
bluetoothGatt.getService(service).getCharacteristic(characteristic); BluetoothGattCharacteristic gattCharacteristic =
bluetoothGatt.setCharacteristicNotification(gattCharacteristic, true); bluetoothGatt.getService(service).getCharacteristic(characteristic);
bluetoothGatt.setCharacteristicNotification(gattCharacteristic, true);
synchronized (lock) { synchronized (lock) {
descriptorRequestQueue.add( descriptorRequestQueue.add(
new GattObjectValue<>( new GattObjectValue<>(
gattCharacteristic.getDescriptor(descriptor), gattCharacteristic.getDescriptor(descriptor),
BluetoothGattDescriptor.ENABLE_INDICATION_VALUE)); BluetoothGattDescriptor.ENABLE_INDICATION_VALUE));
handleRequests(); handleRequests();
}
}
catch (Exception e) {
Timber.e(e);
} }
} }
@@ -312,16 +317,21 @@ public abstract class BluetoothCommunication {
protected void setNotificationOn(UUID service, UUID characteristic, UUID descriptor) { protected void setNotificationOn(UUID service, UUID characteristic, UUID descriptor) {
Timber.d("Set notification on for %s", characteristic); Timber.d("Set notification on for %s", characteristic);
BluetoothGattCharacteristic gattCharacteristic = try {
bluetoothGatt.getService(service).getCharacteristic(characteristic); BluetoothGattCharacteristic gattCharacteristic =
bluetoothGatt.setCharacteristicNotification(gattCharacteristic, true); bluetoothGatt.getService(service).getCharacteristic(characteristic);
bluetoothGatt.setCharacteristicNotification(gattCharacteristic, true);
synchronized (lock) { synchronized (lock) {
descriptorRequestQueue.add( descriptorRequestQueue.add(
new GattObjectValue<>( new GattObjectValue<>(
gattCharacteristic.getDescriptor(descriptor), gattCharacteristic.getDescriptor(descriptor),
BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE)); BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE));
handleRequests(); handleRequests();
}
}
catch (Exception e) {
Timber.e(e);
} }
} }