【发布时间】:2021-10-02 18:43:41
【问题描述】:
我正在使用 BlueZ-obexd 和 pydbus 创建一个用于 opp 文件传输的 python obex 客户端。到目前为止,我已经能够使文件传输正常工作,并且我正在尝试从 API 实现 RemoveSession 以仅在传输完成或失败后触发。我知道 API 中也有一个 status 属性,但我完全不知道如何使用它。我对 dbus 或 pydbus 没有太多经验,所以任何帮助都会很棒。我的代码如下。
import pydbus
import time
import subprocess
# Setup of device specific values
address = subprocess.check_output("bluetoothctl paired-devices", shell=True)
dev_id = str(address)[9:26]
TRANSFER_IFACE = 'org.bluez.obex.Transfer1'
ses = pydbus.SessionBus()
obex = ses.get('org.bluez.obex', '/org/bluez/obex')
ses1 = obex.CreateSession(dev_id, {'Target': pydbus.Variant('s', 'OPP')})
ses1_dbus = ses.get('org.bluez.obex', ses1)
props = ses1_dbus.SendFile('/home/pi/Desktop/image.jpg')
obex.RemoveSession(ses1)
【问题讨论】:
标签: python-3.x bluez obex