Pybluez库python中的OSError

问题描述

我想使用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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)