Interface BluetoothDevice

All Known Implementing Classes:
AbstractBluetoothDevice, LinuxBluetoothDevice, MacBluetoothDevice

@PublicApi @Immutable public interface BluetoothDevice
Represents a Bluetooth device (paired or connected) known to the system, analogous to UsbDevice for USB peripherals.

Bluetooth devices are enumerated per adapter. Each device reports its name, MAC address, major device class, connection/pairing state, and battery level when available.

Example usage:

for (BluetoothDevice device : hal.getBluetoothDevices()) {
    System.out.printf("%s [%s] %s%s (battery: %s)%n", device.getName(), device.getAddress(),
            device.getMajorDeviceClass(), device.isConnected() ? " *connected*" : "",
            device.getBatteryLevel() >= 0 ? device.getBatteryLevel() + "%" : "N/A");
}
  • Method Summary

    Modifier and Type
    Method
    Description
    The name of the adapter (e.g., hci0) through which this device is known.
    The MAC address of the Bluetooth device in colon-separated format (e.g., AA:BB:CC:DD:EE:FF).
    int
    The battery level of the device as a percentage (0–100).
    The major Bluetooth device class (e.g., "Audio", "Phone", "Computer", "Peripheral", "Networking").
    The user-visible name of the Bluetooth device.
    boolean
    Whether the device is currently connected to this system.
    boolean
    Whether the device is paired (bonded) with this system.
  • Method Details

    • getName

      String getName()
      The user-visible name of the Bluetooth device.
      Returns:
      The device name, or an empty string if unknown.
    • getAddress

      String getAddress()
      The MAC address of the Bluetooth device in colon-separated format (e.g., AA:BB:CC:DD:EE:FF).
      Returns:
      The device MAC address.
    • getMajorDeviceClass

      String getMajorDeviceClass()
      The major Bluetooth device class (e.g., "Audio", "Phone", "Computer", "Peripheral", "Networking").

      Derived from the Class of Device (CoD) field when available.

      Returns:
      The major device class string, or an empty string if unknown.
    • isConnected

      boolean isConnected()
      Whether the device is currently connected to this system.
      Returns:
      true if connected, false otherwise.
    • isPaired

      boolean isPaired()
      Whether the device is paired (bonded) with this system.
      Returns:
      true if paired, false otherwise.
    • getBatteryLevel

      int getBatteryLevel()
      The battery level of the device as a percentage (0–100).
      Returns:
      The battery percentage, or -1 if not available.
    • getAdapterName

      String getAdapterName()
      The name of the adapter (e.g., hci0) through which this device is known.
      Returns:
      The adapter name.