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

gattlib not working #4

Closed
JorgePe opened this issue Aug 13, 2017 · 3 comments
Closed

gattlib not working #4

JorgePe opened this issue Aug 13, 2017 · 3 comments
Assignees
Labels

Comments

@JorgePe
Copy link
Owner

JorgePe commented Aug 13, 2017

This works from Ubuntu 17.04 shell:

gatttool -b 00:16:53:A4:CD:7E --char-write-req --handle=0x0e --value=0c018139110a00069B9B647f03

This doesn't:

#!/usr/bin/env python3
from gattlib import GATTRequester, GATTResponse
from time import sleep

req = GATTRequester("00:16:53:A4:CD:7E",True,"hci0")
response = GATTResponse()
req.write_by_handle_async(0x0e, "\x0C\x01\x81\x39\x11\x0A\x00\x06\x9B\x9B\x64\x7F\x03", response)
while not response.received():
    sleep(0.1)
    print(response.received())
print(req.read_by_handle(0x0e))

Output:

['\x13']
['\x0c\x01\x819\x11\n\x00\x06\x9b\x9bd\x7f\x03']

Also replacing with a shorter command like changing LED color

gatttool -b 00:16:53:A4:CD:7E --char-write-req --handle=0x0e --value=080081321151000A

returns

['\x13']
['\x08\x00\x812\x11Q\x00\n']

Something is wrong after 3rd byte ?!?

@JorgePe JorgePe self-assigned this Aug 13, 2017
@JorgePe JorgePe added the bug label Aug 13, 2017
@JorgePe
Copy link
Owner Author

JorgePe commented Aug 14, 2017

\x81 is > 127, converting to string in python3 works different than python2
think I figured the proper way, have to try

@JorgePe
Copy link
Owner Author

JorgePe commented Aug 14, 2017

Writing
bytes(bytearray(b'\x08\x00\x81\x32\x11\x51\x00\x0A'))
instead of
str(bytearray(b'\x08\x00\x81\x32\x11\x51\x00\x0A'))
works.

@JorgePe
Copy link
Owner Author

JorgePe commented Aug 14, 2017

As also just
b'\x08\x00\x81\x32\x11\x51\x00\x0A'

@JorgePe JorgePe closed this as completed Aug 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant