使用 PyBluez 和 PyOBEX 通过蓝牙发送文件

问题描述

我正在尝试通过蓝牙将文件从我的笔记本电脑 (win10) 发送到我的手机 (android)。我跟着 this answer 并且我对 python 3.6 做同样的事情

我正在使用 PyOBEX Python 3 Package,这是我尝试过的。

import sys
from PyOBEX.client import Client
from bluetooth import *

addr = '60:7E:DD:A7:42:43' 


print("Searching for OBEX service on {}".format(addr))
services = find_service(address=addr,name=b'OBEX Object Push\x00')
if len(services) == 0:
    sys.exit()


first_match = services[0]
port = first_match["port"]

client = Client(addr,port)
client.connect()
client.put("test.txt","Hello world\n")
client.disconnect()

当我运行它时,设备被发现,但它没有建立连接或发送文件。这是它给出的错误

enter image description here

我尝试通过将 socket_.recv 返回的数据类型更改为 str 来处理 PyOBEX 包,但它给了我另一个错误

enter image description here

我被卡住了,我以前从未使用过蓝牙或套接字。任何帮助表示赞赏

解决方法

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

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

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