IanHarvey / bluepy

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

Unable to read whole characteristic value #414

Closed KarolPWr closed 3 years ago

KarolPWr commented 4 years ago

For some reason, bluepy refuses to read whole value of given characteristic. This code:

    print ("Connecting...")
    dev = btle.Peripheral("<MAC>", addrType="random")

    raw = dev.readCharacteristic(0x17)
    print(raw)

Reads only first part of characteristic value - e.g. b'\x0a\n' When I do this via gatttool, I get normal values:

[<MAC>][LE]> connect
Attempting to connect to <MAC>
Connection successful
[<MAC>][LE]> char-read-hnd 0x17
Characteristic value/descriptor: d2 0a 

How can I make this right? Or is this some library limitation?

KarolPWr commented 3 years ago

Solved, additional conversion from bytes to hex was needed to correctly read the response.