]> git.basschouten.com Git - openhab-addons.git/blob
858ac0ef2c77ce4d88dc08836bed497cd0732d85
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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 read request completes
51      *
52      * @param characteristic the {@link BluetoothCharacteristic} that has completed the read request
53      * @param status the {@link BluetoothCompletionStatus} of the read request
54      */
55     void onCharacteristicReadComplete(BluetoothCharacteristic characteristic, BluetoothCompletionStatus status);
56
57     /**
58      * Called when a write request completes
59      *
60      * @param characteristic the {@link BluetoothCharacteristic} that has completed the write request
61      * @param status the {@link BluetoothCompletionStatus} of the write request
62      */
63     void onCharacteristicWriteComplete(BluetoothCharacteristic characteristic, BluetoothCompletionStatus status);
64
65     /**
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.
68      *
69      * @param characteristic the updated {@link BluetoothCharacteristic}
70      */
71     void onCharacteristicUpdate(BluetoothCharacteristic characteristic);
72
73     /**
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.
76      *
77      * @param characteristic the updated {@link BluetoothCharacteristic}
78      */
79     void onDescriptorUpdate(BluetoothDescriptor bluetoothDescriptor);
80
81     /**
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
85      *
86      * @param adapter the new {@link BluetoothAdapter} used by this device
87      */
88     void onAdapterChanged(BluetoothAdapter adapter);
89 }