OSError in Pybluez library python

691 views Asked by At

I would like to make a bluetooth communication using python3 (pyBluez0.23 module)

I found on internet some tutorials which use the Pybluez library but this doesn't work for me. Find below the code for the server part :

import bluetooth

def setupServer():
    server_socket=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
    print("Socket Created.")
    port = 0
    server_socket.bind("",port)
    server_socket.listen(1)
    print("Socket bind complete")

    uuid = "xxx-xxx-xxxx-xxxx"
        
    bluetooth.advertise_service(server_sock, "Wifi config",
                      service_id=uuid,
                      service_classes=[uuid, bluetooth.SERIAL_PORT_CLASS],
                      profiles=[bluetooth.SERIAL_PORT_PROFILE])
        
    client_sock, client_info = server_sock.accept()
        
    self.handle_client(client_sock)
        
    client_sock.close()
    server_sock.close()

This is the output :

<bluetooth.msbt.BluetoothSocket object at 0x000002736C4BB610>
    bluetooth socket created.
    Traceback (most recent call last):
      File "ROS.py", line 99, in <module>
        main()
      File "ROS.py", line 96, in main
        BluetoothServerNode().start()
      File "ROS.py", line 67, in start
        server_sock.bind(("", blt.PORT_ANY))
      File "c:\opt\ros\noetic\x64\lib\site-packages\bluetooth\msbt.py", line 84, in bind
        bt.bind (self._sockfd, addr, port)
    OSError: A
0

There are 0 answers