IanHarvey / bluepy

Python interface to Bluetooth LE on Linux
Other
1.58k stars 490 forks source link

How to use writeCharateristic() method by UUID? #466

Open Lance-Tin opened 2 years ago

Lance-Tin commented 2 years ago

Thank you for your sharing of this respository. I know that the peripheral class have the method of writeCharateristic() and readCharateristic(), But the two methods only can use handle to communicate with the peripherals, sometimes the handle is not useful and I can't get the True handle and UUID whith the method of getCharateristic() .

doug-holtsinger commented 2 years ago

Hello, You should be able to use the getHandle() method of the Characteristic() class to retrieve the Value Handle. Alternatively you can simply use the write() and read() methods of the Characteristic() class directly and not use a handle. Use the getServiceByUUID() method of the Peripheral() class, followed by the 'forUUID' parameter in the getCharacteristics() method of the Service() class to obtain the characteristic object for a specific UUID. http://ianharvey.github.io/bluepy-doc/characteristic.html

Lance-Tin commented 2 years ago

Thank you for your answer, It's really a easy way to use "UUID" to communicate with the BLE peripheral, I will try again.

At 2021-12-17 04:02:56, "Doug Holtsinger" @.***> wrote:

Hello, You should be able to use the getHandle() method of the Characteristic() class to retrieve the Value Handle. Alternatively you can simply use the write() and read() methods of the Characteristic() class directly and not use a handle. http://ianharvey.github.io/bluepy-doc/characteristic.html

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>