IanHarvey / bluepy

Python interface to Bluetooth LE on Linux
Other
1.6k stars 491 forks source link

Any example of writing 2 bytes? #435

Closed AK51 closed 3 years ago

AK51 commented 3 years ago

Hi, I am new to the bluepy and still reading the document. I typed "sudo python3 btle.py XX:XX:XX:XX:XX:XX" and I can see my BLE device, but the btle.py is long, do I just type my code in the main? Is there any example of writing 2 bytes?

Thanks, Andy

AK51 commented 3 years ago

For my particular BLE device chName = AssignedNumbers.getCommonName(ch,uuid) For "Battery Level", I can see chName is "Battery Level" However, for the data I want to change, chName is None... How can I write the data inside? Thx

AK51 commented 3 years ago

I can get the search working by if (str(ch) == "Characteristic "): but how to write two bytes? p_data = "0001" ch.write(p_data.encode('utf-8'),True) but there is error....

Thanks.

AK51 commented 3 years ago

ch.write(b'\x04\x00') I got it. :>