Skip to contentSkip to conversation

read phonebook

DISCUSSION Marco Trapanese 3 participants 8 messages Jun 11, 2016 – Jun 12, 2016

lore
Share & tools
lore
#0 lore raw

Hello,
I have this setup:

- RPi3
- Raspbian Jessie Lite
- bluez 5.40
- ofono 1.18

in /etc/bluetooth/main.conf I set this class: 0x640408. Using bluetoothctl I connected my phone to the SBC and I can make a call using the ofono tests.

I wonder how to read the contacts. I launched test-phonebook but I got this error:

Quoted 1 line

Method "Import" with signature "" on interface "org.ofono.Phonebook" doesn't exist

Do I need to enable something other before?
Thanks
Marco

#1 lore raw
Quoted 15 lines · Marco Trapanese

Hello,
I have this setup:

- RPi3
- Raspbian Jessie Lite
- bluez 5.40
- ofono 1.18

in /etc/bluetooth/main.conf I set this class: 0x640408. Using bluetoothctl I connected my phone to the SBC and I can make a call using the ofono tests.

I wonder how to read the contacts. I launched test-phonebook but I got this error:

Quoted 6 lines
Quoted 2 lines

Method "Import" with signature "" on interface "org.ofono.Phonebook" doesn't exist

Do I need to enable something other before?
Thanks
Marco

Hi Marco,

see attached python script for how to get the phone book from a bluetooth device.
I think you need obexd for this, although I am not quite sure because I programmed
it long ago.

Regards
Georg

#!/usr/bin/python
# -*- coding: utf-8 -*-

import gtk, gobject, os, dbus, dbus.service, logging

class Phonebook_Phone:

bus = None
session_p = None
session = None
pbap_object = None
transfer_path = None
transfer_file = None
phone_book = []
cb_done = None

def __init__(self, phone, done_cb):
self.cb_done = done_cb
self.bus = dbus.SessionBus()
client = dbus.Interface(self.bus.get_object("org.bluez.obex", "/org/bluez/obex"), "org.bluez.obex.Client1") self.session_p = client.CreateSession(phone, { "Target": "PBAP" })
obj = self.bus.get_object("org.bluez.obex", self.session_p)
self.session = dbus.Interface(obj, "org.bluez.obex.Session1")
self.pbap_object = dbus.Interface(obj, "org.bluez.obex.PhonebookAccess1") self.bus.add_signal_receiver(self.properties_changed,
dbus_interface="org.freedesktop.DBus.Properties", signal_name="PropertiesChanged",
path_keyword="path")
self.pbap_object.Select("int", "PB")
self.get_book()

def properties_changed(self, interface, properties, invalidated, path):

      if self.transfer_file == None:
         return
      if "Transferred" in properties:
         return
      if properties['Status'] == 'complete':
         self.transfer_complete(path)
         return
      if properties['Status'] == 'error':
         self.error(path)
         return

def get_book(self):
params = dbus.Dictionary({ "Format" : "vcard30",
"Fields" : ["PHOTO"] })
self.pbap_object.PullAll("", params,
reply_handler=self.register, error_handler=self.error)

def register(self, path, properties):
self.transfer_path = path
self.transfer_file = properties["Filename"]

def error(self, err):
logging.error("Error while retrieving the Phonebook: %s", err)

def transfer_complete(self, path):
if self.transfer_file == None:
return
try:
f = open(self.transfer_file, "r")
lines = f.readlines()
f.close()
os.remove(self.transfer_file)
self.result_cb(lines)
except:
pass

def result_cb(self, lines):

       for line in lines:
           line = line.strip()
           if line[:3] == "FN:":
              my_name = line[3:]
              my_numbers = []
           elif line[:4] == "TEL;":
              my_numbers.append(line[line.find(":") + 1:])
           elif line == "END:VCARD" and len(my_numbers) != 0:
              for i in range(0, len(my_numbers)):
                 my_name_1 = my_name
                 if i != 0:
                    my_name_1 = my_name_1 + " " + str(i)
                 self.phone_book.append([my_name_1, my_numbers[i]])
       if self.cb_done:
          self.cb_done()
#2 lore raw

I've done some work with this. Here are a few points I've learned about dealing with PBAP.
Yes, it definitely requires obexd. Obexd uses dbus, in session mode.
This implies that the user that runs obex must access the data in the same session. If you want to run obexd in one shell, and access the information from another shell, or application, you'll want to use the system bus like so:

export DBUS_SESSION_BUS_ADDRESS="unix:path=/var/run/dbus/system_bus_socket" You can validate that with "qdbus --system" in another session. If you see orf.bluez.obex that you've connected it to the system dbus.

You'll also need to add dbus permissions to access via dbus, or a non-root user won't even be able to start it.

to /etc/dbus-1/system.d/bluetooth.conf
add:
<policy user="user">

       <allow own="org.bluez.obex"/>
       <allow send_destination="org.bluez.obex"/>

</policy>

oh, also, the files downloaded are in vcard format. I would highly recommend python's vobject module, or similar for ease of managing the data.

The device needs to be paired and trusted, but it does not have to be connected to pull PBAP information. I don't think this is important, but I always found it interesting. All of my code written depends on the device currently being connected though.

This isn't ofono specific stuff, so if you have any questions you can email me off list. I also have a git repo out there with some pbap handling.

I'd like to do more with MAP, and other obex based protocols, but time is limited.

Jason

Quoted 42 lines · Georg Chini
Quoted 16 lines · Marco Trapanese

Hello,
I have this setup:

- RPi3
- Raspbian Jessie Lite
- bluez 5.40
- ofono 1.18

in /etc/bluetooth/main.conf I set this class: 0x640408. Using bluetoothctl I connected my phone to the SBC and I can make a call using the ofono tests.

I wonder how to read the contacts. I launched test-phonebook but I got this error:

Quoted 7 lines
Quoted 2 lines

Method "Import" with signature "" on interface "org.ofono.Phonebook" doesn't exist

Do I need to enable something other before?
Thanks
Marco

Hi Marco,

see attached python script for how to get the phone book from a bluetooth device.
I think you need obexd for this, although I am not quite sure because I programmed
it long ago.

Regards
Georg

_______________________________________________
ofono mailing list
ofono(a)ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

#3 lore raw

Hello Georg, hello Jason!
Thank you both for your interesting answers.
As far as I understand obex is now integrated in bluez5:

Quoted 3 lines

https://packages.debian.org/jessie/bluez-obexd

http://www.bluez.org/page/7/

(see Release of BlueZ 5.0)

Quoted 1 line

http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/obex-api.txt

Thus my confusion about the test script in ofono!
So, if I'm running off-topic, I will move to the bluez mailing-list.

Anyway, following the hints of Jason I exported the dbus session address (because I don't use X) and set the dbus policies in bluetooth.conf. I paired and trusted my phone.

Running the bluez/test/pbap-client script or the Georg's code leads to:

Quoted 1 line

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.bluez.obex was not provided by any .service files

while the ofono/test/test-phonebook returns:

Quoted 1 line

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "Import" with signature "" on interface "org.ofono.Phonebook" doesn't exist

Because obex is under org.bluez I don't think I need the obexd-client Debian package, do I?

Thanks!
Marco

--

Il 11/06/2016 23:54, Jason Gauthier ha scritto:

Quoted 89 lines

I've done some work with this. Here are a few points I've learned about dealing with PBAP.
Yes, it definitely requires obexd. Obexd uses dbus, in session mode.
This implies that the user that runs obex must access the data in the same session. If you want to run obexd in one shell, and access the information from another shell, or application, you'll want to use the system bus like so:

export DBUS_SESSION_BUS_ADDRESS="unix:path=/var/run/dbus/system_bus_socket" You can validate that with "qdbus --system" in another session. If you see orf.bluez.obex that you've connected it to the system dbus.

You'll also need to add dbus permissions to access via dbus, or a non-root user won't even be able to start it.

to /etc/dbus-1/system.d/bluetooth.conf
add:
<policy user="user">

       <allow own="org.bluez.obex"/>
       <allow send_destination="org.bluez.obex"/>

</policy>

oh, also, the files downloaded are in vcard format. I would highly recommend python's vobject module, or similar for ease of managing the data.

The device needs to be paired and trusted, but it does not have to be connected to pull PBAP information. I don't think this is important, but I always found it interesting. All of my code written depends on the device currently being connected though.

This isn't ofono specific stuff, so if you have any questions you can email me off list. I also have a git repo out there with some pbap handling.

I'd like to do more with MAP, and other obex based protocols, but time is limited.

Jason

Quoted 34 lines · Georg Chini
Quoted 16 lines · Marco Trapanese

Hello,
I have this setup:

- RPi3
- Raspbian Jessie Lite
- bluez 5.40
- ofono 1.18

in /etc/bluetooth/main.conf I set this class: 0x640408. Using bluetoothctl I connected my phone to the SBC and I can make a call using the ofono tests.

I wonder how to read the contacts. I launched test-phonebook but I got this error:

Quoted 7 lines
Quoted 2 lines

Method "Import" with signature "" on interface "org.ofono.Phonebook" doesn't exist

Do I need to enable something other before?
Thanks
Marco

Hi Marco,

see attached python script for how to get the phone book from a bluetooth device.
I think you need obexd for this, although I am not quite sure because I programmed
it long ago.

Quoted 8 lines

Regards
Georg

_______________________________________________
ofono mailing list
ofono(a)ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

_______________________________________________
ofono mailing list
ofono(a)ofono.org
https://lists.ofono.org/mailman/listinfo/ofono

#4 lore raw
Quoted 27 lines · Marco Trapanese

Hello Georg, hello Jason!
Thank you both for your interesting answers.
As far as I understand obex is now integrated in bluez5:

Quoted 3 lines

https://packages.debian.org/jessie/bluez-obexd

http://www.bluez.org/page/7/

(see Release of BlueZ 5.0)

Quoted 1 line

http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/obex-api.txt

Thus my confusion about the test script in ofono!
So, if I'm running off-topic, I will move to the bluez mailing-list.

Anyway, following the hints of Jason I exported the dbus session address (because I don't use X) and set the dbus policies in bluetooth.conf. I paired and trusted my phone.

Running the bluez/test/pbap-client script or the Georg's code leads to:

Quoted 3 lines

dbus.exceptions.DBusException:
org.freedesktop.DBus.Error.ServiceUnknown: The name org.bluez.obex was not provided by any .service files

Quoted 8 lines

while the ofono/test/test-phonebook returns:

Quoted 3 lines

dbus.exceptions.DBusException:
org.freedesktop.DBus.Error.UnknownMethod: Method "Import" with signature "" on interface "org.ofono.Phonebook" doesn't exist

Because obex is under org.bluez I don't think I need the obexd-client Debian package, do I?

I have bluez-obexd installed.

#6 lore raw
Quoted 10 lines · Marco Trapanese

Il 12/06/2016 11:56, Georg Chini ha scritto:

Quoted 1 line

I have bluez-obexd installed.

I'm trying right now but it would be weird because:

https://packages.debian.org/en/jessie/bluez-obexd

"This was the software that is independent as obexd, but this has been integrated into BlueZ from BlueZ 5.0."

I think it just means that once it was independent and now it is part of bluez
but nevertheless is still delivered as an extra package.
BTW, I also have obexfs and obexftp installed, not sure if they are needed.

#7 lore raw

Il 12/06/2016 12:03, Georg Chini ha scritto:

Quoted 3 lines

I think it just means that once it was independent and now it is part of bluez
but nevertheless is still delivered as an extra package.

Yeah it works!
I apologize, but my understanding of English misled me.
I understood that the bluez-obexd package was integrated into bluez5!

Thanks a lot!
Marco