python - 通过 OBEX 发送文件(浅蓝色/OBEXFTP)

标签 python bluetooth

我正在拼命尝试使用 python 通过 OBEX 发送文件。我有两个功能代码,第一个使用 lightblue,另一个使用 obexftp。我们这里有两部 Android 手机,第一部是三星 Galaxy S,第二部是 HTC Desire HD(运行 CyanogenMod 7.1)。我正在尝试从运行 Ubuntu(natty 和 lucid)的计算机将文件发送到这些手机。

问题是,每个代码仅适用于一部手机。而且只是有时。

第一个是:

import lightblue
client=lightblue.obex.OBEXClient('MACADDR',CHANNEL)
client.connect()
client.put({'name':'file.png'},file('file.png',"rb"))
client.disconnect()

此产品仅适用于 Galaxy s。 如果我尝试将文件发送到所需的高清,我会得到:

<OBEXRespnse reason='Internal Server Error' code=0x50 (0xd0) headers={}>

第二个代码是:

import obexftp
cli=obexftp.client(obexftp.BLUETOOTH)
channel=obexftp.browsebt('MACADDR',obexftp.PUSH)
print channel #it is the correct channel, I've doubled checked
cli.connect ('MACADDR',channel)
cli.put_file("./file.png") #I also noticed you need to wait a second before this
cli.disconnect()

此功能仅适用于desire hd(有时)。

所有设备均使用 bluez-simple-agent 脚本进行配对,该脚本在 Ubuntu 中可用。

我试图找出导致这种不一致的原因,但没有成功。如果有人指出我做错了什么或向我展示实际有效的代码,我会很高兴。

最佳答案

OBEX 可能是出了名的错误,有很多耳机/免提制造商投入大量资金来测试 OBEX 和其他 BT 协议(protocol)...... 也许这就是问题所在!您可以尝试更多手机来测试吗?!

关于python - 通过 OBEX 发送文件(浅蓝色/OBEXFTP),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7784781/

相关文章:

c# - 无法使用 32feet.Net C# 库通过蓝牙将文件从 Windows 传输到 Linux

python - 在某个类的 python 中获取 __init__ def 中的变量

java - 蓝牙 HID 配置文件位于何处?

python - for 循环中的百分比变化

python - 如何在 Python 中将双反斜杠替换为单个字节字符串

android - 是什么让 QBluetoothDeviceDiscoveryAgent::finished() 被调用?

android - Android 蓝牙 Gatt 服务器/客户端同时连接的问题

javascript - 如何从缓冲区渲染数据? react native Javascript

python - 使用 Python 快速搜索驱动器

python - 无法在单个连接中发送多个请求数据 — 套接字错误