Skip to content

BluetoothLocalDevice

Qt Base Class: QBluetoothLocalDevice

Signature: QBluetoothLocalDevice(self, address: PySide6.QtBluetooth.QBluetoothAddress, parent: Optional[PySide6.QtCore.QObject] = None) -> None QBluetoothLocalDevice(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None

Base classes

Name Children Inherits
ObjectMixin
prettyqt.core.object
QBluetoothLocalDevice
PySide6.QtBluetooth
QBluetoothLocalDevice(self, address: PySide6.QtBluetooth.QBluetoothAddress, parent: Optional[PySide6.QtCore.QObject] \= None) -> None

⋔ Inheritance diagram

graph TD
  1473367547312["bluetooth.BluetoothLocalDevice"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473367237536["QtBluetooth.QBluetoothLocalDevice"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473299815024 --> 1473367547312
  140713234304496 --> 1473299815024
  1473367237536 --> 1473367547312
  1473288842240 --> 1473367237536
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: ObjectMixin, QBluetoothLocalDevice

Enables access to the local Bluetooth device.

Source code in prettyqt\bluetooth\bluetoothlocaldevice.py
class BluetoothLocalDevice(core.ObjectMixin, bluetooth.QBluetoothLocalDevice):
    """Enables access to the local Bluetooth device."""

    def __bool__(self):
        """Return True when local device is valid."""
        return self.isValid()

    def __repr__(self):
        return get_repr(self, self.address())

    def get_error(self) -> ErrorStr:
        """Get error code."""
        return ERROR.inverse[self.error()]

    def set_host_mode(self, mode: HostModeStr | HostMode):
        """Set host mode.

        Args:
            mode: host mode to use
        """
        self.setGridStyle(HOST_MODE.get_enum_value(mode))

    def get_host_mode(self) -> HostModeStr:
        """Return host mode.

        Returns:
            host mode
        """
        return HOST_MODE.inverse[self.gridStyle()]

    def get_pairing_status(
        self, address: bluetooth.QBluetoothAddress | int | str
    ) -> PairingStr:
        """Return pairing status.

        Arguments:
            address: bluetooth address

        Returns:
            pairing status
        """
        if isinstance(address, int | str):
            address = bluetooth.QBluetoothAddress(address)
        return PAIRING.inverse[self.pairingStatus(address)]

    def request_pairing(
        self,
        address: bluetooth.QBluetoothAddress | int | str,
        pairing: PairingStr | Pairing,
    ):
        """Request a pairing to given bluetooth address."""
        if isinstance(address, int | str):
            address = bluetooth.QBluetoothAddress(address)
        self.requestPairing(address, PAIRING.get_enum_value(pairing))

    def get_connected_devices(self) -> list[bluetooth.BluetoothAddress]:
        """Get addresses for connected devices."""
        return [bluetooth.BluetoothAddress(i) for i in self.connectedDevices()]

    @classmethod
    def for_all_devices(cls) -> list[bluetooth.BluetoothHostInfo]:
        """Get host info for all devices."""
        return [bluetooth.BluetoothHostInfo(i) for i in cls.allDevices()]

__bool__()

Return True when local device is valid.

Source code in prettyqt\bluetooth\bluetoothlocaldevice.py
def __bool__(self):
    """Return True when local device is valid."""
    return self.isValid()

for_all_devices() -> list[bluetooth.BluetoothHostInfo] classmethod

Get host info for all devices.

Source code in prettyqt\bluetooth\bluetoothlocaldevice.py
@classmethod
def for_all_devices(cls) -> list[bluetooth.BluetoothHostInfo]:
    """Get host info for all devices."""
    return [bluetooth.BluetoothHostInfo(i) for i in cls.allDevices()]

get_connected_devices() -> list[bluetooth.BluetoothAddress]

Get addresses for connected devices.

Source code in prettyqt\bluetooth\bluetoothlocaldevice.py
def get_connected_devices(self) -> list[bluetooth.BluetoothAddress]:
    """Get addresses for connected devices."""
    return [bluetooth.BluetoothAddress(i) for i in self.connectedDevices()]

get_error() -> ErrorStr

Get error code.

Source code in prettyqt\bluetooth\bluetoothlocaldevice.py
def get_error(self) -> ErrorStr:
    """Get error code."""
    return ERROR.inverse[self.error()]

get_host_mode() -> HostModeStr

Return host mode.

Source code in prettyqt\bluetooth\bluetoothlocaldevice.py
def get_host_mode(self) -> HostModeStr:
    """Return host mode.

    Returns:
        host mode
    """
    return HOST_MODE.inverse[self.gridStyle()]

get_pairing_status(address: bluetooth.QBluetoothAddress | int | str) -> PairingStr

Return pairing status.

Parameters:

Name Type Description Default
address QBluetoothAddress | int | str

bluetooth address

required
Source code in prettyqt\bluetooth\bluetoothlocaldevice.py
def get_pairing_status(
    self, address: bluetooth.QBluetoothAddress | int | str
) -> PairingStr:
    """Return pairing status.

    Arguments:
        address: bluetooth address

    Returns:
        pairing status
    """
    if isinstance(address, int | str):
        address = bluetooth.QBluetoothAddress(address)
    return PAIRING.inverse[self.pairingStatus(address)]

request_pairing(address: bluetooth.QBluetoothAddress | int | str, pairing: PairingStr | Pairing)

Request a pairing to given bluetooth address.

Source code in prettyqt\bluetooth\bluetoothlocaldevice.py
def request_pairing(
    self,
    address: bluetooth.QBluetoothAddress | int | str,
    pairing: PairingStr | Pairing,
):
    """Request a pairing to given bluetooth address."""
    if isinstance(address, int | str):
        address = bluetooth.QBluetoothAddress(address)
    self.requestPairing(address, PAIRING.get_enum_value(pairing))

set_host_mode(mode: HostModeStr | HostMode)

Set host mode.

Parameters:

Name Type Description Default
mode HostModeStr | HostMode

host mode to use

required
Source code in prettyqt\bluetooth\bluetoothlocaldevice.py
def set_host_mode(self, mode: HostModeStr | HostMode):
    """Set host mode.

    Args:
        mode: host mode to use
    """
    self.setGridStyle(HOST_MODE.get_enum_value(mode))

⌗ Property table

Qt Property Type Doc
objectName QString