What is the equivalent to my usual bash commands
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...
@dorealex Did you ever work this out? as I am having the same issue...
@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
I forgot to add that bleak may also help you:
https://github.com/hbldh/bleak