2 * Copyright (c) 2010-2023 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.eclipse.jdt.annotation.Nullable;
17 import org.openhab.core.common.registry.Identifiable;
18 import org.openhab.core.thing.ThingUID;
21 * The {@link BluetoothAdapter} class defines the standard adapter API that must be implemented by bridge handlers,
22 * which are then required to be registered as a BluetoothAdapter OSGi service.
25 * The API assumes that the adapter is "always" scanning to enable beacons to be received.
26 * The bridge must decide to enable and disable scanning as it needs. This design choice avoids interaction between
27 * higher layers where a binding may want to enable scanning while another needs to disable scanning for a specific
28 * function (e.g. to connect to a device). The bridge should disable scanning only for the period that is needed.
30 * @author Chris Jackson - Initial contribution
31 * @author Kai Kreuzer - renamed it, made it identifiable and added listener support
34 public interface BluetoothAdapter extends Identifiable<ThingUID> {
37 * Adds a {@link BluetoothDiscoveryListener} to the adapter
39 * @param listener the listener to add
41 void addDiscoveryListener(BluetoothDiscoveryListener listener);
44 * Removes a {@link BluetoothDiscoveryListener} from the adapter
46 * @param listener the listener to remove
48 void removeDiscoveryListener(@Nullable BluetoothDiscoveryListener listener);
51 * Starts an active scan on the Bluetooth interface.
56 * Stops an active scan on the Bluetooth interface
61 * Gets the {@link BluetoothAddress} of the adapter
63 * @return the {@link BluetoothAddress} of the adapter
64 * @throws IllegalStateException if the adapter is not initialized
67 BluetoothAddress getAddress();
70 * Gets the {@link BluetoothDevice} given the {@link BluetoothAddress}.
71 * A {@link BluetoothDevice} will always be returned for a valid hardware address, even if this adapter has never
74 * @param address the {@link BluetoothAddress} to retrieve
75 * @return the {@link BluetoothDevice}
77 BluetoothDevice getDevice(BluetoothAddress address);
80 * Gets the location of this adapter, as specified in Thing.getLocation()
82 * @return the location of this adapter
88 * Gets the label for this adapter, as specified in Thing.getLabel()
90 * @return the location of this adapter
96 * Checks if this adapter has a device with the given {@link BluetoothAddress}.
98 * @param address the {@link BluetoothAddress} to check for
99 * @return true if this adapter has a {@link BluetoothDevice} with that address
101 boolean hasHandlerForDevice(BluetoothAddress address);