Closed coderjoe closed 5 months ago
Updated to reference the correct other issue, meant #250 not 150
You can probably read the device name characteristic. Also see https://github.com/hbldh/bleak/issues/849#issuecomment-1255370264 about a proposed enhancement for a name
property on the BleakClient
object.
Thank you @dlech I appreciate the suggestion, but I could not figure out how to query the Device Name characteristic from within bleak. Attempts to reference it by UUID give me problems as the Generic Access Service (0x1800) does not seem listed as an available service.
Is there some other way to query it without being able to find the service via bleak
?
Ok no - the problem was on my end, the format of the UUID I was passing was valid for the UUID library, but a typo in my code had it being interpreted as a string. As a result the error
bleak.exc.BleakError: Characteristic with UUID {00002a00-0000-1000-8000-00805f9b34fb} could not be found!
Had me believing that I could not read that characteristic. That was wrongminded - it works fine when I create my UUID properly.
My mistake - thank you for your suggestion as it eventually lead me to the correct solution!
bluetoothctl -v
) in case of Linux: 5.64Description
I am working with a device that advertises under one device name, but upon successful connection and protocol negotiation it changes its device name to another name.
The mobile app I'm trying to emulate appears to make a second request to the Generic Access Service (0x1800) for Device Name (0x2a00). Unfortunately bleak does not appear to expose that service so I cannot make my own requests.
Per closed issue #250 I believe it was said that this data was wrapped up in the BLEDevice, but I am not sure how to get the updated device name once I have connected.
My debug logs show that DBus picks up the property change, but I do not know how to fetch the updated property.
What I Did
I am emulating the android application by performing a bluetooth device scan and looking for advertised devices by either a known address or product name.
Once connected, I listen for device updates on its RX characteristic, and perform a connection negotiation by sending a vendor specific command over its TX characteristic.
However the device name never gets updated even though bluez reports the correct change.
At timestamp
2023-12-25 15:18:28
thedevice.name
output isHPA250B
which is the advertised device name At timestamp2023-12-25 15:18:28,936
output in the logs bluez reports the property change to the new name ofHEPA 250 JB
But I cannot figure out how to reference this updated name in bleak.
Logs
See above program output for debug logs.
In particular timestamp
2023-12-25 15:18:28
for the advertised device name and timestamp2023-12-25 15:18:28,936
for the bluez property update debug log.