bmwcarit / pypbap

Python implementation of Phone Book Access Profile (PBAP) is a profile that allows exchange of Phone Book Objects between devices
GNU General Public License v3.0
15 stars 10 forks source link

Not Acceptable #5

Open benbucksch opened 4 years ago

benbucksch commented 4 years ago

Device

Reproduction steps

  1. python pbapclient.py
  2. connect 20:20:0F:32:D3:29
  3. pull_phonebook telecom/pb.vcf (vCard 2.1)
  4. pull_phonebook --format=1 telecom/pb.vcf (vCard 3.0)
  5. pull_vcard_listing telecom/pb
  6. set_phonebook telecom/pb
  7. pull_vcard_entry 2.vcf

Actual result

pbap> connect 20:20:0F:32:D3:29
2020-06-19 05:15:12,406 __main__ INFO     Finding PBAP service ...
2020-06-19 05:15:13,099 __main__ INFO     PBAP service found!
2020-06-19 05:15:13,099 __main__ INFO     Connecting to pbap server = (20:20:0F:32:D3:29, 19)
2020-06-19 05:15:13,530 __main__ INFO     Connect success
pbap> pull_phonebook telecom/pb.vcf
2020-06-19 05:15:18,272 __main__ INFO     Requesting pull_phonebook for pbobject 'telecom/pb.vcf' with appl parameters {'self': <__main__.PBAPClient object at 0xb5b317d0>, 'name': 'telecom/pb.vcf', 'filter_': 0, 'format_': 0, 'max_list_count': 65535, 'list_startoffset': 0}
2020-06-19 05:15:18,334 __main__ ERROR    pull_phonebook failed for pbobject 'telecom/pb.vcf'. reason = <pbapresponses.Not_Acceptable object at 0xb5a7c890>
pbap> pull_phonebook --format=1 telecom/pb.vcf
2020-06-19 05:15:34,038 __main__ INFO     Requesting pull_phonebook for pbobject 'telecom/pb.vcf' with appl parameters {'self': <__main__.PBAPClient object at 0xb5b317d0>, 'name': 'telecom/pb.vcf', 'filter_': 0, 'format_': 1, 'max_list_count': 65535, 'list_startoffset': 0}
2020-06-19 05:15:34,287 __main__ ERROR    pull_phonebook failed for pbobject 'telecom/pb.vcf'. reason = <pbapresponses.Not_Acceptable object at 0xb5a7c970>
pbap> pull_vcard_listing telecom/pb
2020-06-19 05:16:20,901 __main__ INFO     Requesting pull_vcard_listing with parameters {'self': <__main__.PBAPClient object at 0xb5b317d0>, 'name': 'telecom/pb', 'order': 0, 'search_value': None, 'search_attribute': 0, 'max_list_count': 65535, 'list_startoffset': 0}
2020-06-19 05:16:21,673 __main__ ERROR    pull_vcard_listing failed for pbobject 'telecom/pb'. reason = <pbapresponses.Not_Acceptable object at 0xb58ec390>
pbap> set_phonebook telecom/pb
2020-06-19 05:16:28,972 __main__ INFO     Setting current folder with params '{'self': <__main__.PBAPClient object at 0xb5b317d0>, 'name': 'telecom/pb', 'to_root': False, 'to_parent': False}'
2020-06-19 05:16:29,166 __main__ INFO     Result of set_phonebook:
<PyOBEX.responses.Success object at 0xb58ec2f0>
pbap> pull_vcard_entry 2.vcf
2020-06-19 05:16:35,837 __main__ INFO     Requesting pull_vcard_entry for pbobject with parameters {'self': <__main__.PBAPClient object at 0xb5b317d0>, 'name': '2.vcf', 'filter_': 0, 'format_': 0}
2020-06-19 05:16:35,898 __main__ ERROR    pull_vcard_entry failed for pbobject '2.vcf'. reason = <PyOBEX.responses.Not_Found object at 0xb58ec7d0>

Expected result

Getting phonebook entries from smartphone, as README says.

Additional device info

[bluetooth]# info 20:20:0F:32:D3:29
Device 20:20:0F:32:D3:29 (public)
    Name: ...
    Alias: ...
    Class: 0x005a020c
    Icon: phone
    Paired: yes
    Trusted: no
    Blocked: no
    Connected: no
    LegacyPairing: no
    UUID: OBEX Object Push          (00001105-0000-1000-8000-00805f9b34fb)
    UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
    UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
    UUID: Headset AG                (00001112-0000-1000-8000-00805f9b34fb)
    UUID: PANU                      (00001115-0000-1000-8000-00805f9b34fb)
    UUID: NAP                       (00001116-0000-1000-8000-00805f9b34fb)
    UUID: Handsfree Audio Gateway   (0000111f-0000-1000-8000-00805f9b34fb)
    UUID: Phonebook Access Server   (0000112f-0000-1000-8000-00805f9b34fb)
    UUID: Message Access Server     (00001132-0000-1000-8000-00805f9b34fb)
    UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
    UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
    UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
    Modalias: bluetooth:v038Fp1200d1436

The device shows that it's connected to my computer. It is paired, and during pairing, I specifically allowed phone book / contacts access. On the smartphone, Settings, in the device properties for my computer, it also shows that Contacts access is allowed.

bethewind commented 2 years ago

diff --git a/pbapheaders.py b/pbapheaders.py index 52227b7..5055d26 100644 --- a/pbapheaders.py +++ b/pbapheaders.py @@ -72,7 +72,7 @@ class VariableLengthProperty(AppParamProperty): return struct.unpack(self.fmt.format(len=length), data)[0]

-class PBAPType(UnicodeHeader): +class PBAPType(Type): code = 0x42

// try to do the following change if build fail, on ubuntu 18.04 diff --git a/setup.py b/setup.py index ba24cb4..5f97f08 100644 --- a/setup.py +++ b/setup.py @@ -22,8 +22,7 @@ setup( dependency_links=["https://bitbucket.org/dboddie/pyobex/get/tip.zip#egg=pyobex-0.26"], install_requires=[ "pybluez==0.22", -"pyobex>=0.26", -"pymongo", +"pymongo==3.6.1", "cmd2==0.8.8" ], )

sudo apt-get install libbluetooth-dev
pip install pyparsing
cd pyobex-0.26/ ; //https://gitlab.com/dboddie/pyobex/-/tree/0.26
sudo python setup.py install