Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IndexError in bluez client #66

Merged
merged 1 commit into from
Jun 30, 2019
Merged

Fix IndexError in bluez client #66

merged 1 commit into from
Jun 30, 2019

Conversation

5frank
Copy link

@5frank 5frank commented May 21, 2019

There seems to be no guarantee that services are listed before
characteristics in bluez dbus API. This caused (sometimes) a IndexError
in get_services() as adding a characteristic to a service that did not
exist yet failed.
Not sure if it's the same with descriptors, could possible be in the same
loop as characteristics?

There seems to be no guarantee that services are listed before
charachteristics in bluez dbus API. This caused (sometimes) a IndexError
in get_services() as adding a charachteristic to a service that did not
exist yet failed.
@5frank
Copy link
Author

5frank commented May 21, 2019

Traceback on the issue (line numbers might be off):

Traceback (most recent call last):
  [...]
    async with BleakClient(address, loop=loop) as client:
  File "bleak/bleak/backends/client.py", line 41, in __aenter__
    await self.connect()
  File "bleak/bleak/backends/bluezdbus/client.py", line 107, in connect
    await self.get_services()
  File "bleak/bleak/backends/bluezdbus/client.py", line 199, in get_services
    char, object_path, _service[0].uuid
IndexError: list index out of range

API usage example from bluez that iterate twice on the same objects but without a explanation on why: https://github.com/hadess/bluez/blob/master/test/example-gatt-client

hbldh added a commit that referenced this pull request May 25, 2019
@hbldh
Copy link
Owner

hbldh commented May 25, 2019

Merged this to develop and rewrote it slightly. Will be merging this to master during next week after I have tried it a bit more. Thank you!

@hbldh hbldh merged commit f67cf43 into hbldh:master Jun 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants