2 * Copyright (c) 2010-2020 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.bluetooth;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.bluetooth.notification.BluetoothConnectionStatusNotification;
17 import org.openhab.binding.bluetooth.notification.BluetoothScanNotification;
20 * The {@link BluetoothDeviceListener} class defines the a callback interface where devices are notified of updates to a
23 * @author Chris Jackson - Initial contribution
24 * @author Kai Kreuzer - Added descriptor updates
27 public interface BluetoothDeviceListener {
30 * Called when a scan record is received for the device
32 * @param scanNotification the {@link BluetoothScanNotification} providing the scan packet information
34 void onScanRecordReceived(BluetoothScanNotification scanNotification);
37 * Called when the connection status changes
39 * @param connectionNotification the {@link BluetoothConnectionStatusNotification} providing the updated connection
42 void onConnectionStateChange(BluetoothConnectionStatusNotification connectionNotification);
45 * Called when a devices services and characteristics have been completely read
47 void onServicesDiscovered();
50 * Called when a read request completes
52 * @param characteristic the {@link BluetoothCharacteristic} that has completed the read request
53 * @param status the {@link BluetoothCompletionStatus} of the read request
55 void onCharacteristicReadComplete(BluetoothCharacteristic characteristic, BluetoothCompletionStatus status);
58 * Called when a write request completes
60 * @param characteristic the {@link BluetoothCharacteristic} that has completed the write request
61 * @param status the {@link BluetoothCompletionStatus} of the write request
63 void onCharacteristicWriteComplete(BluetoothCharacteristic characteristic, BluetoothCompletionStatus status);
66 * Called when a characteristic value is received. Implementations should call this whenever a value
67 * is received from the BLE device even if there is no change to the value.
69 * @param characteristic the updated {@link BluetoothCharacteristic}
71 void onCharacteristicUpdate(BluetoothCharacteristic characteristic);
74 * Called when a descriptor value is received. Implementations should call this whenever a value
75 * is received from the BLE device even if there is no change to the value.
77 * @param characteristic the updated {@link BluetoothCharacteristic}
79 void onDescriptorUpdate(BluetoothDescriptor bluetoothDescriptor);
82 * Called when the BluetoothAdapter for this BluetoothDevice changes.
83 * Implementations should call this whenever they change the adapter used by this device.
84 * Note: In general this is only called by a RoamingBluetoothDevice
86 * @param adapter the new {@link BluetoothAdapter} used by this device
88 void onAdapterChanged(BluetoothAdapter adapter);