<div dir="ltr">I have been trying to connect to a Bluetooth device (regular, not low energy - an HC-06) using PyQt5 but with no success. I can connect to the same device using standard python calls. I am running Python 3.7 on MacOS 10.15.4. When I run the below code, I get the error: 'unknown error', I'd be happy to know what I am doing wrong, or a pointer to a python example (I could not find any online). I have managed to get the scanning for Bluetooth devices working using PyQt. My code is below:<div><br></div><div>**************<br>import sys<br>import bluetooth<br>import os<br><br>from PyQt5.QtWidgets import QApplication, QWidget<br>from PyQt5.QtCore import Qt<br>from PyQt5 import QtBluetooth<br><br>class bluetoothTest(QWidget):<br><br>    def __init__(self, parent = None):<br><br>        super(bluetoothTest, self).__init__(parent)<br><br>        self.connectToRobot()<br><br>        self.app = QApplication(sys.argv)<br>        self.win = QWidget()<br>        self.win.show()<br>        sys.exit(self.app.exec_())<br><br>    def connectToRobot(self):<br>        self.sock = QtBluetooth.QBluetoothSocket(bluetooth.RFCOMM)<br><br>        self.sock.connected.connect(self.connectedToBluetooth)<br>        self.sock.readyRead.connect(self.receivedBluetoothMessage)<br>        self.sock.disconnected.connect(self.disconnectedFromBluetooth)<br>        self.sock.error.connect(self.socketError)<br>        port = 1<br>        self.sock.connectToService(QtBluetooth.QBluetoothAddress("98:D3:C1:FD:2C:46"),port)<br><br>    def socketError(self,error):<br>        print(self.sock.errorString())<br><br>    def connectedToBluetooth(self):<br>        self.sock.write('A'.encode())<br><br>    def disconnectedFromBluetooth(self):<br>        self.print('Disconnected from bluetooth')<br><br>    def receivedBluetoothMessage(self):<br>        while sock.canReadLine():<br>            line = sock.readLine()<br>            print(line)<br><br>def main():<br>    # deal with a bluetooth bug on mac<br>    if sys.platform == 'darwin':<br>        os.environ['QT_EVENT_DISPATCHER_CORE_FOUNDATION'] = '1'<br><br>    app = QApplication(sys.argv)<br>    ex = bluetoothTest()<br>    ex.show()<br>    sys.exit(app.exec_())<br><br>if __name__ == '__main__':<br>        main()<font color="#888888"><br></font></div><div><br></div><div>**************<br></div><div><br></div><div>Thanks,</div><div><br></div><div>Jason</div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Jason Friedman, PhD<div>Senior Lecturer<br><div>Department of Physical Therapy</div><div>Tel Aviv University</div><div>email: <a href="mailto:write.to.jason@gmail.com" target="_blank">write.to.jason@gmail.com</a></div><div>web: <a href="http://curiousjason.com" target="_blank">http://curiousjason.com</a></div></div></div></div></div>