]> git.basschouten.com Git - openhab-addons.git/blob
dfe7ccc7b9e2223625e0d714515271b2555e86ee
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.bluetooth;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.bluetooth.notification.BluetoothConnectionStatusNotification;
17 import org.openhab.binding.bluetooth.notification.BluetoothScanNotification;
18
19 /**
20  * The {@link BluetoothDeviceListener} class defines the a callback interface where devices are notified of updates to a
21  * BLE device
22  *
23  * @author Chris Jackson - Initial contribution
24  * @author Kai Kreuzer - Added descriptor updates
25  */
26 @NonNullByDefault
27 public interface BluetoothDeviceListener {
28
29     /**
30      * Called when a scan record is received for the device
31      *
32      * @param scanNotification the {@link BluetoothScanNotification} providing the scan packet information
33      */
34     void onScanRecordReceived(BluetoothScanNotification scanNotification);
35
36     /**
37      * Called when the connection status changes
38      *
39      * @param connectionNotification the {@link BluetoothConnectionStatusNotification} providing the updated connection
40      *            information
41      */
42     void onConnectionStateChange(BluetoothConnectionStatusNotification connectionNotification);
43
44     /**
45      * Called when a devices services and characteristics have been completely read
46      */
47     void onServicesDiscovered();
48
49     /**
50      * Called when a characteristic value is received. Implementations should call this whenever a value
51      * is received from the BLE device even if there is no change to the value.
52      *
53      * @param characteristic the updated {@link BluetoothCharacteristic}
54      * @param value the update value
55      */
56     void onCharacteristicUpdate(BluetoothCharacteristic characteristic, byte[] value);
57
58     /**
59      * Called when a descriptor value is received. Implementations should call this whenever a value
60      * is received from the BLE device even if there is no change to the value.
61      *
62      * @param bluetoothDescriptor the updated {@link BluetoothDescriptor}
63      * @param value the update value
64      */
65     void onDescriptorUpdate(BluetoothDescriptor bluetoothDescriptor, byte[] value);
66
67     /**
68      * Called when the BluetoothAdapter for this BluetoothDevice changes.
69      * Implementations should call this whenever they change the adapter used by this device.
70      * Note: In general this is only called by a RoamingBluetoothDevice
71      *
72      * @param adapter the new {@link BluetoothAdapter} used by this device
73      */
74     void onAdapterChanged(BluetoothAdapter adapter);
75 }