Reputation: 107
i want to access the contacts of my smartphone over bluetooth. This should be made as first step of a project of my with a raspberry pi. I read something about the phone bok access protocol (PBAP). But all i could was not very helpful for me. The most examples i found where to old.
I already managed to pair and connect my smart phone (OnePlus One). I also can see that is support PBAP. I use bluez in version 5.23-2+rpi1.
I found two examples of an PBAP client, one from 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).
If i execute the obexd example on the pi i get the following error:
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
If i execute the bluez example i get the following error:
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
Does anyone of you have an idea to fix it, an actual tutorial or an other example?
Thank you
Upvotes: 0
Views: 4515
Reputation: 1
PyOBEX is the right choice. you can also have a look into pypbap which has both pbap client and server built on top of PyOBEX. And has nice REPL to playaround with all pbap functionalities.
Upvotes: 0
Reputation: 107
After searching a few hours later, i found a python library called PyOBEX. It contains some examples, e.g. a PBAP-Client, a example to download files over bluetooth and much more. It also contains all methods for pairing and connecting. Works on first try for me.
Link: https://bitbucket.org/dboddie/pyobex/overview
Upvotes: 3