Phone Linux (Raspberry Pi) 的 Book Access (PBAP) 客户端

Phone Book Access (PBAP) client for Linux (Raspberry Pi)

我想通过蓝牙访问我的 smartphone 的联系人。这应该作为我 raspberry pi 项目的第一步。我阅读了一些关于 phone bok 访问协议 (PBAP) 的内容。 但是我所能做的对我来说并不是很有帮助。我发现的最多的例子是旧的。

我已经成功配对并连接了我的智能 phone (OnePlus One)。我还可以看到支持 PBAP。我用的bluez版本是5.23-2+rpi1.

我找到了两个 PBAP 客户端示例,一个来自 obexd (http://code.metager.de/source/xref/linux/bluetooth/obexd/test/pbap-client) and one from 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

你们有没有人有修复它的想法,一个实际的教程或其他示例?

谢谢

经过几个小时的搜索,我找到了一个名为 PyOBEX 的 python 库。它包含一些示例,例如PBAP-Client,一个通过蓝牙下载文件的例子等等。它还包含用于配对和连接的所有方法。对我来说第一次尝试就可以了。

Link: https://bitbucket.org/dboddie/pyobex/overview

PyOBEX 是正确的选择。您还可以查看 pypbap,它同时具有基于 PyOBEX 构建的 pbap 客户端和服务器。并且有很好的 REPL 来玩弄所有 pbap 功能。