Skip to content

Commit

Permalink
Fixed incompatibility with BlueZ version >= 5.38
Browse files Browse the repository at this point in the history
  • Loading branch information
donatieng committed Nov 13, 2017
1 parent 15cec50 commit af46b05
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Adafruit_BluefruitLE/bluez_dbus/gatt.py
Expand Up @@ -42,6 +42,8 @@ def __init__(self, dbus_obj):
"""Create an instance of the GATT service from the provided bluez
DBus object.
"""
self._obj = dbus_obj
self._service = dbus.Interface(dbus_obj, _SERVICE_INTERFACE)
self._props = dbus.Interface(dbus_obj, 'org.freedesktop.DBus.Properties')

@property
Expand All @@ -53,9 +55,9 @@ def list_characteristics(self):
"""Return list of GATT characteristics that have been discovered for this
service.
"""
paths = self._props.Get(_SERVICE_INTERFACE, 'Characteristics')
return map(BluezGattCharacteristic,
get_provider()._get_objects_by_path(paths))
return map(BluezGattCharacteristic,
get_provider()._get_objects(_CHARACTERISTIC_INTERFACE,
self._service.object_path))


class BluezGattCharacteristic(GattCharacteristic):
Expand All @@ -75,11 +77,11 @@ def uuid(self):

def read_value(self):
"""Read the value of this characteristic."""
return self._characteristic.ReadValue()
return self._characteristic.ReadValue({})

def write_value(self, value):
"""Write the specified value to this characteristic."""
self._characteristic.WriteValue(value)
self._characteristic.WriteValue(value, {})

def start_notify(self, on_change):
"""Enable notification of changes for this characteristic on the
Expand Down

6 comments on commit af46b05

@stefanix
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix. Solved the issue on Ubuntu 18.04.

@serunis
Copy link

@serunis serunis commented on af46b05 Dec 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
It works great on raspberry pi 4 Linux raspberrypi 4.19.75-v7l+

@JeanJacquesRousseau
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still having an issue after the modification :

sudo python uart_service.py
Using adapter: jjr-acer
Disconnecting any connected UART devices...
Searching for UART device...
Connecting to device...
Discovering services...
Traceback (most recent call last):
File "uart_service.py", line 85, in
ble.run_mainloop_with(main)
File "build/bdist.linux-x86_64/egg/Adafruit_BluefruitLE/bluez_dbus/provider.py", line 105, in run_mainloop_with
File "build/bdist.linux-x86_64/egg/Adafruit_BluefruitLE/bluez_dbus/provider.py", line 120, in _user_thread_main
File "uart_service.py", line 59, in main
uart = UART(device)
File "build/bdist.linux-x86_64/egg/Adafruit_BluefruitLE/services/uart.py", line 50, in init
File "build/bdist.linux-x86_64/egg/Adafruit_BluefruitLE/interfaces/gatt.py", line 48, in find_characteristic
File "build/bdist.linux-x86_64/egg/Adafruit_BluefruitLE/bluez_dbus/gatt.py", line 56, in list_characteristics
File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 147, in call
**keywords)
File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 653, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.InvalidArgs: No such property 'Characteristics'

@eyz
Copy link

@eyz eyz commented on af46b05 May 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the fix for me on a "Bus 003 Device 021: ID 0a5c:21e8 Broadcom Corp. BCM20702A0 Bluetooth 4.0" (https://www.amazon.com/gp/product/B07J5WFPXX/ref=ppx_yo_dt_b_asin_title_o00_s00) adapter to reach the UART service on the example BLE neopixel service for the nrf52 neopixel example on Ubuntu 20.04

@eyz
Copy link

@eyz eyz commented on af46b05 May 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeanJacquesRousseau, it didn't work for me until I re-installed the library again per the docs with sudo python3 setup.py install in the root of Adafruit_Python_BluefruitLE after applying the commit at the top

image
^ the commit in this thread af46b05

image
^ ... was applied against this commit 34fc6f5

My quick test working now -
image

@hotstaff
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. You are my hero.
Works!!
Great job.

Please sign in to comment.