[bluetooth] Changed characteristic read/write to use CompletableFutures (#8970)

Signed-off-by: Connor Petty <mistercpp2000+gitsignoff@gmail.com>
This commit is contained in:
Connor Petty
2021-04-09 13:23:28 -07:00
committed by GitHub
parent 1822f77b07
commit 89d735bb0f
24 changed files with 1207 additions and 1562 deletions

View File

@@ -25,7 +25,6 @@ import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.bluetooth.BluetoothAdapter;
import org.openhab.binding.bluetooth.BluetoothAddress;
import org.openhab.binding.bluetooth.BluetoothCharacteristic;
import org.openhab.binding.bluetooth.BluetoothCompletionStatus;
import org.openhab.binding.bluetooth.BluetoothDescriptor;
import org.openhab.binding.bluetooth.BluetoothDevice;
import org.openhab.binding.bluetooth.BluetoothDeviceListener;
@@ -135,32 +134,16 @@ public class RoamingBluetoothDevice extends DelegateBluetoothDevice {
}
@Override
public void onCharacteristicReadComplete(BluetoothCharacteristic characteristic,
BluetoothCompletionStatus status) {
public void onCharacteristicUpdate(BluetoothCharacteristic characteristic, byte[] value) {
if (device == getDelegate()) {
notifyListeners(BluetoothEventType.CHARACTERISTIC_READ_COMPLETE, characteristic, status);
notifyListeners(BluetoothEventType.CHARACTERISTIC_UPDATED, characteristic, value);
}
}
@Override
public void onCharacteristicWriteComplete(BluetoothCharacteristic characteristic,
BluetoothCompletionStatus status) {
public void onDescriptorUpdate(BluetoothDescriptor bluetoothDescriptor, byte[] value) {
if (device == getDelegate()) {
notifyListeners(BluetoothEventType.CHARACTERISTIC_WRITE_COMPLETE, characteristic);
}
}
@Override
public void onCharacteristicUpdate(BluetoothCharacteristic characteristic) {
if (device == getDelegate()) {
notifyListeners(BluetoothEventType.CHARACTERISTIC_UPDATED, characteristic);
}
}
@Override
public void onDescriptorUpdate(BluetoothDescriptor bluetoothDescriptor) {
if (device == getDelegate()) {
notifyListeners(BluetoothEventType.DESCRIPTOR_UPDATED, bluetoothDescriptor);
notifyListeners(BluetoothEventType.DESCRIPTOR_UPDATED, bluetoothDescriptor, value);
}
}