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

What is the equivalent to my usual bash commands #321

Open
dorealex opened this issue Apr 17, 2021 · 3 comments
Open

What is the equivalent to my usual bash commands #321

dorealex opened this issue Apr 17, 2021 · 3 comments

Comments

@dorealex
Copy link

dorealex commented Apr 17, 2021

What would be the pygatt equivalent to running:

sudo gatttool -t random -b D2:C5:26:66:6C:7D --char-write-req -a 0x2f -n 03170101

So far in python I have, I am struggling with the handle and value, I know 0x2f=47, so I passed that (would rather pass 0x2f, no big deal) but I am stumped for the value setting. It doesn't want to accept a string

YOUR_DEVICE_ADDRESS = "D2:C5:26:66:6C:7D"
# Many devices, e.g. Fitbit, use random addressing - this is required to
# connect.
ADDRESS_TYPE = pygatt.BLEAddressType.random

adapter = pygatt.GATTToolBackend()
adapter.start()
device = adapter.connect(YOUR_DEVICE_ADDRESS, address_type=ADDRESS_TYPE)

device.char_write_handle(handle=47, value = '03170101')

I also tried with
device.char_write(characteristic, bytearray([0x2f, 03170101]), wait_for_response=True)
But I just can't seem to pass that value...

@karl0ss
Copy link

karl0ss commented Oct 25, 2021

@dorealex Did you ever work this out? as I am having the same issue...

@dorealex
Copy link
Author

dorealex commented Oct 27, 2021

@karl0ss unfortunately I don't think I ever got around this. I think I ended up just popping the command in a shell script and then running that script from python... This is what I did

@dorealex
Copy link
Author

I forgot to add that bleak may also help you:

https://github.com/hbldh/bleak

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

No branches or pull requests

2 participants