Skip to content

BluetoothSocket

Base classes

Name Children Inherits
IODeviceMixin
prettyqt.core.iodevice
QBluetoothSocket
PySide6.QtBluetooth
QBluetoothSocket(self, socketType: PySide6.QtBluetooth.QBluetoothServiceInfo.Protocol, /, parent: PySide6.QtCore.QObject | None \= None) -> None

⋔ Inheritance diagram

graph TD
  2578597756["bluetooth.BluetoothSocket"]
  1351663398["core.IODeviceMixin"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  1884040527["QtBluetooth.QBluetoothSocket"]
  3657792459["QtCore.QIODevice"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  2183098470["QtCore.QIODeviceBase"]
  1351663398 --> 2578597756
  3227531497 --> 1351663398
  2751680898 --> 3227531497
  2751680898 --> 1351663398
  1884040527 --> 2578597756
  3657792459 --> 1884040527
  3984060476 --> 3657792459
  37984305 --> 3984060476
  2751680898 --> 37984305
  2183098470 --> 3657792459
  37984305 --> 2183098470

🛈 DocStrings

Bases: IODeviceMixin, QBluetoothSocket

Enables connection to a Bluetooth device running a bluetooth server.

Source code in prettyqt/bluetooth/bluetoothsocket.py
class BluetoothSocket(core.IODeviceMixin, bluetooth.QBluetoothSocket):
    """Enables connection to a Bluetooth device running a bluetooth server."""

    def __init__(
        self,
        protocol: bluetooth.bluetoothserviceinfo.ProtocolStr
        | bluetooth.QBluetoothServiceInfo.Protocol
        | None = None,
        parent: core.QObject | None = None,
    ):
        if protocol is None:
            super().__init__(parent)
        else:
            proto = bluetooth.bluetoothserviceinfo.PROTOCOL.get_enum_value(protocol)
            super().__init__(proto, parent)

    def get_error(self) -> SocketErrorStr:
        return SOCKET_ERROR.inverse[self.error()]

    def get_state(self) -> SocketStateStr:
        return SOCKET_STATE.inverse[self.state()]

    def get_local_address(self) -> bluetooth.BluetoothAddress:
        return bluetooth.BluetoothAddress(self.localAddress())

    def get_peer_address(self) -> bluetooth.BluetoothAddress:
        return bluetooth.BluetoothAddress(self.peerAddress())

    def get_socket_type(self) -> bluetooth.bluetoothserviceinfo.ProtocolStr:
        return bluetooth.bluetoothserviceinfo.PROTOCOL.inverse[self.socketType()]

:fa-brands-github: Show source on GitHub