mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-27 10:15:00 +02:00
BluetoothCommunication: Stop state machine only if setNotification operation was enqueued;
This commit is contained in:
@@ -308,14 +308,20 @@ public abstract class BluetoothCommunication {
|
|||||||
* Set notification flag on for the Bluetooth device.
|
* Set notification flag on for the Bluetooth device.
|
||||||
*
|
*
|
||||||
* @param characteristic the Bluetooth UUID characteristic
|
* @param characteristic the Bluetooth UUID characteristic
|
||||||
|
* @return true if the operation was enqueued, false if the characteristic doesn't support notification or indications or
|
||||||
*/
|
*/
|
||||||
protected void setNotificationOn(UUID service, UUID characteristic) {
|
protected boolean setNotificationOn(UUID service, UUID characteristic) {
|
||||||
Timber.d("Invoke set notification on " + BluetoothGattUuid.prettyPrint(characteristic));
|
Timber.d("Invoke set notification on " + BluetoothGattUuid.prettyPrint(characteristic));
|
||||||
if(btPeripheral.getService(service) != null) {
|
if(btPeripheral.getService(service) != null) {
|
||||||
stopMachineState();
|
|
||||||
BluetoothGattCharacteristic currentTimeCharacteristic = btPeripheral.getCharacteristic(service, characteristic);
|
BluetoothGattCharacteristic currentTimeCharacteristic = btPeripheral.getCharacteristic(service, characteristic);
|
||||||
btPeripheral.setNotify(currentTimeCharacteristic, true);
|
if (currentTimeCharacteristic != null) {
|
||||||
|
if (btPeripheral.setNotify(currentTimeCharacteristic, true)) {
|
||||||
|
stopMachineState();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user