Skip to content

BluetoothDeviceDiscoveryAgent

Qt Base Class: QBluetoothDeviceDiscoveryAgent

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

Base classes

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

⋔ Inheritance diagram

graph TD
  1473367567808["bluetooth.BluetoothDeviceDiscoveryAgent"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473367259984["QtBluetooth.QBluetoothDeviceDiscoveryAgent"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473299815024 --> 1473367567808
  140713234304496 --> 1473299815024
  1473367259984 --> 1473367567808
  1473288842240 --> 1473367259984
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: ObjectMixin, QBluetoothDeviceDiscoveryAgent

Discovers the Bluetooth devices nearby.

Source code in prettyqt\bluetooth\bluetoothdevicediscoveryagent.py
class BluetoothDeviceDiscoveryAgent(
    core.ObjectMixin, bluetooth.QBluetoothDeviceDiscoveryAgent
):
    """Discovers the Bluetooth devices nearby."""

    device_discovered = core.Signal(object)  # bluetooth.BluetoothDeviceInfo casts signal.

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.deviceDiscovered.connect(self._on_device_discovered)

    def _on_device_discovered(self, info):
        info = bluetooth.BluetoothDeviceInfo(info)
        self.device_discovered.emit(info)

    # def set_inquiry_type(self, typ: InquiryTypeStr):
    #     """Set inquiry type.

    #     Args:
    #         typ: inquiry type
    #     """
    #     self.setInquiryType(INQUIRY_TYPES.get_enum_value(typ))

    # def get_inquiry_type(self) -> InquiryTypeStr:
    #     """Get the current inquiry type.

    #     Returns:
    #         inquiry type
    #     """
    #     return INQUIRY_TYPES.inverse[self.inquiryType()]

    def start_discovery(self, classic: bool = True, low_energy: bool = True):
        """Start discovery of bluetooth devices.

        Arguments:
            classic: use classic method
            low_energy: use BLE mode
        """
        flag = bluetooth.QBluetoothDeviceDiscoveryAgent.NoMethod
        if classic:
            flag |= bluetooth.QBluetoothDeviceDiscoveryAgent.ClassicMethod
        if low_energy:
            flag |= bluetooth.QBluetoothDeviceDiscoveryAgent.LowEnergyMethod
        self.start(flag)

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

    def get_supported_discovery_methods(self) -> list[DiscoveryMethodStr]:
        """Return a list of supported discovery methods."""
        return DISCOVERY_METHODS.get_list(self.supportedDiscoveryMethods())

get_error() -> ErrorStr

Get error type if available.

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

get_supported_discovery_methods() -> list[DiscoveryMethodStr]

Return a list of supported discovery methods.

Source code in prettyqt\bluetooth\bluetoothdevicediscoveryagent.py
def get_supported_discovery_methods(self) -> list[DiscoveryMethodStr]:
    """Return a list of supported discovery methods."""
    return DISCOVERY_METHODS.get_list(self.supportedDiscoveryMethods())

start_discovery(classic: bool = True, low_energy: bool = True)

Start discovery of bluetooth devices.

Parameters:

Name Type Description Default
classic bool

use classic method

True
low_energy bool

use BLE mode

True
Source code in prettyqt\bluetooth\bluetoothdevicediscoveryagent.py
def start_discovery(self, classic: bool = True, low_energy: bool = True):
    """Start discovery of bluetooth devices.

    Arguments:
        classic: use classic method
        low_energy: use BLE mode
    """
    flag = bluetooth.QBluetoothDeviceDiscoveryAgent.NoMethod
    if classic:
        flag |= bluetooth.QBluetoothDeviceDiscoveryAgent.ClassicMethod
    if low_energy:
        flag |= bluetooth.QBluetoothDeviceDiscoveryAgent.LowEnergyMethod
    self.start(flag)

⌗ Property table

Qt Property Type Doc
objectName QString