适用于Linux的电话簿访问(PBAP)客户端(Raspberry Pi)

时间:2016-05-20 12:00:12

标签: linux bluetooth raspberry-pi bluez

我想通过蓝牙访问智能手机的联系人。这应该是我与树莓派的项目的第一步。我读了一些关于手机访问协议(PBAP)的内容。 但我所能做的对我来说并不是很有帮助。大多数例子我找到了旧的地方。

我已经成功配对并连接了我的智能手机(OnePlus One)。我也可以看到支持PBAP。我在版本5.23-2 + rpi1中使用bluez。

我找到了两个PBAP客户端示例,一个来自obexd(http://code.metager.de/source/xref/linux/bluetooth/obexd/test/pbap-client),另一个来自bluez(http://code.metager.de/source/xref/linux/bluetooth/bluez/test/pbap-client)。

如果我在pi上执行obexd示例,我会收到以下错误:

Creating Session
Traceback (most recent call last):
  File "pbap-client-obexd.py", line 110, in <module>
    session_path = client.CreateSession(sys.argv[1], { "Target": "PBAP" })
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.bluez.obex.Error.Failed: No adapter found

如果我执行bluez示例,我会收到以下错误:

Creating Session
Traceback (most recent call last):
  File "pbap-client-bluez.py", line 128, in <module>
    session_path = client.CreateSession(sys.argv[1], { "Target": "PBAP" })
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownObject: Method "CreateSession" with signature "sa{ss}" on interface "org.bluez.obex.Client1" doesn't exist

你们中是否有人有想法修改它,实际教程或其他例子?

谢谢

2 个答案:

答案 0 :(得分:2)

几个小时后搜索,我发现了一个名为PyOBEX的python库。它包含一些例子,例如一个PBAP客户端,一个通过蓝牙下载文件的例子等等。它还包含配对和连接的所有方法。适合我的第一次尝试。

链接: https://bitbucket.org/dboddie/pyobex/overview

答案 1 :(得分:0)

PyOBEX是正确的选择。您还可以查看pypbap,其中包含构建在PyOBEX之上的pbap客户端和服务器。并且有很好的REPL来解决所有pbap功能。