Python 3.x Pybluez库python中的OSError

Python 3.x Pybluez库python中的OSError,python-3.x,bluetooth,pybluez,Python 3.x,Bluetooth,Pybluez,我想使用python3(pyBluez0.23模块)进行蓝牙通信 我在网上找到了一些使用Pybluez库的教程,但这对我来说并不适用。 在下面找到服务器部件的代码: import bluetooth def setupServer(): server_socket=bluetooth.BluetoothSocket( bluetooth.RFCOMM ) print("Socket Created.") port = 0 server_soc

我想使用python3(pyBluez0.23模块)进行蓝牙通信

我在网上找到了一些使用Pybluez库的教程,但这对我来说并不适用。 在下面找到服务器部件的代码:

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()
这是输出:

<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

蓝牙套接字已创建。
回溯(最近一次呼叫最后一次):
文件“ROS.py”,第99行,在
main()
文件“ROS.py”,第96行,主
BluetoothServerNode().start()
文件“ROS.py”,第67行,开头
服务器\u sock.bind((“”,blt.PORT\u ANY))
文件“c:\opt\ros\noetic\x64\lib\site packages\bluetooth\msbt.py”,第84行,在bind中
bt.bind(self.\u sockfd,addr,port)
错误:A

您似乎没有在bind语句中输入电脑上蓝牙适配器的地址。更多信息请访问:感谢您的回复。我也尝试过,但出现了相同的错误。您似乎没有在bind语句中输入电脑上蓝牙适配器的地址。更多信息请访问:谢谢您的回复。我也尝试过这样做,但也出现了相同的错误。