-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bleak.exc.BleakError: Characteristic was not found! #359
Comments
Try |
Thanks! Unfortunately, the same error with |
@mrdc Could you please run the |
@hbldh
It outputs nothing, but Connected: True |
It might. Regardless, the script should print something more at least? Or throw an error? Otherwise BlueZ just didn't detect any services on your peripheral. BlueZ does its own handling of services, e.g. the Battery Service is not available in BlueZ as it is in Windows. Maybe it disregards services with non-standard uuids? Have you written the peripheral code yourself? |
Unfortunately, no output: it just says
Yes, it's homemade :) Had no issues with BLE part - it connects from macOS, Win10, iOS, but not from RPi3b+ |
Do you have any non-RPi Linux system to try connecting from? |
I can try to install Ubuntu, I hope it will work with CSR 4.0 dongle. |
ubuntu-20.04.1-desktop-amd64@LiveMode and CSR 4.0 dongle. Here you go:
and my initial script:
So, looks like it's RPi related issue. |
Have you tried the suggestions in #332? Otherwise, do that in this case! |
Yes, I’ve updated the firmware. |
Which version of the firmware did you update to? |
BCM4345C0_003.001.025.0171.0339.hcd (https://drive.google.com/file/d/1DVOtBjrsoR2NhwEBVn3ei0sv-xTIBCxR/view?usp=sharing) According to the firmware change log (https://github.com/RPi-Distro/bluez-firmware/blob/master/debian/changelog), it fixes the connection issue, in my case RPi3 connects to BLE device. |
Any updates with this one? Facing similar issue. |
We're getting ready to do a release (probably tomorrow) that includes some troubleshooting tips on making sure the problem isn't cached device info. Also, there are major changes to the BlueZ backend, so if anything else, it should at least provide better debugging info. |
@aayushsingla The new version 0.11.0 has new been released to PyPI. Install that as see if that improves your situation. |
@hbldh Hello, I've checked with the latest bleak (0.11.0) - the same issue :( |
Did you try removing the device using |
In case I've paired my device? Or you mean something else? |
Even if it is not paired, BlueZ still caches information about the device. Removing the device will clear all of the cached info so that you can start fresh. |
I've tried it: |
Does it still raise a |
Hi, yes, it's the same error: |
Same problem 😢 |
If you are using a Raspberry Pi, then try to follow the advice here: #332 (comment) If the characteristic you want to use isn't printed when running |
Yes, in my case there are no characteristics found when I use
Thanks, I'll test it and provide feedback. |
The same issue :( |
@mrdc I honestly have no idea what might be causing this, Does it happen on other RPis, if you happen to have more to try the code on? |
Actually, it's not a big deal - I don't depend on it. I'll buy RPi4 late for tests - will update the issue. |
I recently found a bug in BlueZ where the cache was not entirely cleared when the device is removed. Here is the workaround:
...where Does this resolve the issue? |
im getting the same issue bleak.exc.BleakError: Characteristic UUID was not found! while trying to connect to a ble device from a linux PC, i tried all the above things. i tried with both uuid's which i got from client.get_services() |
This sounds like you are trying to use service UUIDs when you should be using characteristic UUIDs. |
i tried with this code and the same uuids im getting in metadata as well |
Those are not characteristic UUIDs, those are service UUIDs. You can use the |
i tried this i got the uuids but not for reading, i tried with the uuids which i got but for that the read is not permitted, what does it mean, i cant read the data from it? |
Some characteristics require authorization/authentication in order to read, which means the device needs to be paired first. Some characteristics may not support reading. These properties should be reported by the service explorer. |
hello maybe I'm in the right place, something strange happen when I try to use service_explorer.py on a raspberry and on a Mac these are the results:
macOS:
it seems that not all services are recognized by the mac |
The "Generic Attribute Profile" is used internally by the Bluetooth stack so may not be exposed on all OSes. |
mmm and 11 and 13? |
Those are children of the service, so if the service is not available, then the characteristics of that service (and their descriptors) will not be available either. |
Ah ok thank you! |
i tried the following code to pair and get the uuids ADDRESS = (
"EE:3B:19:4B:E3:E6"
)
async def main(address):
async with BleakClient(address) as client:
logger.info(f"Connected: {client.is_connected}")
paired = await client.pair(protection_level=2)
print(f"Paired: {paired}")
for service in client.services:
logger.info(f"[Service] {service}")
for char in service.characteristics:
if "read" in char.properties:
print("trueee")
try:
print("read")
value = bytes(await client.read_gatt_char(char.uuid))
logger.info(
f"\t[Characteristic] {char} ({','.join(char.properties)}), Valueread: {value}"
)
except Exception as e:
logger.error(
f"\t[Characteristic] {char} ({','.join(char.properties)}), Value: {e}"
)
else:
value = None
logger.info(
f"\t[Characteristic] {char} ({','.join(char.properties)}), Value: {value}"
)
for descriptor in char.descriptors:
try:
value = bytes(
await client.read_gatt_descriptor(descriptor.handle)
)
logger.info(f"\t\t[Descriptor] {descriptor}) | Value: {value}")
except Exception as e:
logger.error(f"\t\t[Descriptor] {descriptor}) | Value: {e}")
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
asyncio.run(main(ADDRESS)) got the following response:
did i do the pairing correctly, if yes then i dint get read uuid.. how can i get it |
There are no readable characteristics, but you could enable notifications on the characteristic with UUID 569a2000-b87f-490c-92cb-11ba5ea5167c to receive information from the remote device. |
Hi everyone, I'm having a somewhat similar issue but in my case, using service_explorer.py does show the readable characteristics:
This is how I'm setting up my service/characteristics on the peripheral side:
and on the central side:
... and trying to read centrally using:
My custom script allows my central device (Mac) to originally establish a connection with the peripheral (nRF52DK), but it gets disconnected in about 2 seconds, after the await line above fails to run successfully. Any clues to fix this? I've been trying to figure it out to no avail for the past couple of weeks... Thanks in advance! |
The value should be two bytes, so there appears to be a problem with the remote device itself. |
Thanks for your reply. Why should the value be two bytes? Especially since I'm not writing to the remote device... |
|
So the descriptor is also something I need to set up for the peripheral in my Arduino code? How do I set it to be |
Yes.
This happens behind the scenes already when you call:
|
I think I'm not understanding something critical. The function:
Gets called in my Python script, which is used to talk to the remote device, but does not get flashed. I don't have the descriptor set up in my Arduino code (which I'm flashing onto the remote device) so far. Could you please point me to how to find the line of code that I need to add on the Arduino end? Thanks again! |
Closing since the BlueZ backend in Bleak has significantly changed since the issue was opened. Hopefully the original issue could be solved by upgrading BlueZ and/or ensuring that the device is sending the correct information about the attribute database to BlueZ in the first place. |
Hi guys, i faced the same problem with my esp32.
My code: $ python3 esp32_ble.py
Traceback (most recent call last):
File "/home/merino/Documents/M2_Data_Science/PT/Car_project/esp32_ble.py", line 31, in <module>
asyncio.run(run())
File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/merino/Documents/M2_Data_Science/PT/Car_project/esp32_ble.py", line 18, in run
await client.write_gatt_char(UUID3, int_parameter.to_bytes(4, byteorder='little'))
File "/home/merino/.local/lib/python3.11/site-packages/bleak/__init__.py", line 769, in write_gatt_char
raise BleakError("Characteristic {char_specifier} was not found!")
bleak.exc.BleakError: Characteristic {char_specifier} was not found! |
What is |
May be your UUID(write property) is mistake? I met this mistake too. After I modified the UUID, the problem was solved. |
Description
I'm trying to connect to a BLE device via
bleak
- it works fine when I use my script on Windows 10, but the same script fails on Linux:What I Did
My code:
The difference I see is a different bleak version on Win and on Linux. On Linux
pip3 install bleak
returns only bleak 0,8.0:The text was updated successfully, but these errors were encountered: