Skip to content
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.BleakDBusError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error) #1075

Closed
ujur007 opened this issue Oct 9, 2022 · 10 comments
Labels
3rd party issue The issue is with the Bluetooth stack, the BLE device, or other 3rd party code not with Bleak itself Backend: BlueZ Issues and PRs relating to the BlueZ backend

Comments

@ujur007
Copy link

ujur007 commented Oct 9, 2022

  • bleak version: latest, installed with pip
  • Python version:Python 3.8.10
  • Operating System: Linux Mint-64bit
  • BlueZ version (bluetoothctl -v) in case of Linux: bluetoothctl: 5.53

Description

I am trying a python script to read & write BLE characteristic values. The issue that I am facing is that while writing to the characteristics. The following output from the terminal.

What I was trying was to write to the specific characteristic with command(write_gatt_char) such as the following. I also tried to change to int:handle instead of string:UUID. I am able to read the characteristic. I am sure that the characteristic is writable, as I have tried it with mobile application.

await client.write_gatt_char("c66f3301-33b3-4687-850a-d52b0d5d1e3e", b'5')

Traceback (most recent call last):
File "testApp.py", line 64, in
asyncio.run(main())
File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "testApp.py", line 46, in main
print(await client.write_gatt_char("c66f3301-33b3-4687-850a-d52b0d5d1e3e", b'5'))
File "/user/.local/lib/python3.8/site-packages/bleak/backends/bluezdbus/client.py", line 720, in write_gatt_char
assert_reply(reply)
File "/user/.local/lib/python3.8/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)

Logs

I am new to Wireshark and update the log in this issue.

@dlech dlech added the Backend: BlueZ Issues and PRs relating to the BlueZ backend label Oct 9, 2022
@ujur007
Copy link
Author

ujur007 commented Oct 11, 2022

I tried to find the solution and what I found was some suggestions.

What I have tried is to downgrade/upgrade the bluez versions but the error still remains the same.
There are some threads also suggesting to increase the packet size on the peripheral device. Which I think should not be an issue, in my case.

@dlech
Copy link
Collaborator

dlech commented Oct 11, 2022

Logging Bluetooth packets is really the best way to understand what is going on.

@ujur007
Copy link
Author

ujur007 commented Oct 11, 2022

The write data seems to be not showing up in the traffic on wireshark itself. Here is the Wireshark log for bluetooth0 interface.
What I try todo is establish the connection with remote device using connect() then read all three of the characteristics and then try to write one of the characteristics.

Log_ble.log

@dlech
Copy link
Collaborator

dlech commented Oct 11, 2022

Everything is from host to controller, so the device is not responding. It appears to be a problem with the device.

@dlech dlech added the 3rd party issue The issue is with the Bluetooth stack, the BLE device, or other 3rd party code not with Bleak itself label Oct 11, 2022
@ujur007
Copy link
Author

ujur007 commented Oct 11, 2022

Ok. I will check with other BLE devices perhaps. Currantly, I have Nimble stack port for esp-idf running on ESP32-pico.

@ujur007
Copy link
Author

ujur007 commented Jan 10, 2023

I have this issue still present in my application. Actually I am simultaneously writing to three characteristics.
What I see happening is that only first write to the characteristic is happening while the latter two are failing.
I have the wireshark log for more information.
wireshark_bluetooth-monitor_20230110174326_mxdjgs.pdf

await self.client.write_gatt_char(first, ([0xFF]))
await self.client.write_gatt_char(second, ([0x00]))
await self.client.write_gatt_char(third, ([0x00]))
        
print(await self.client.read_gatt_char(first))
print(await self.client.read_gatt_char(second))
print(await self.client.read_gatt_char(third))`

@ujur007
Copy link
Author

ujur007 commented Jan 11, 2023

okey, seems the error was in my device code and not with Bleak. So now it works. Thanks..!

@dlech dlech closed this as completed Jan 11, 2023
@smalik007
Copy link

@ujur007, what was the mistake in your code? I am experiencing the same issue when I stress the BLE notification packets too frequently, it suddenly disconnects with device after notifying for few seconds, the issue however is not there when I reduce the messages' frequency. @dlech is there an upper limit in terms of timing we should be aware of, not go beyond to have stable connection?

@dlech
Copy link
Collaborator

dlech commented Dec 8, 2023

is there an upper limit in terms of timing we should be aware of, not go beyond to have stable connection?

Not a hard limit. It will depend on the device you are connecting to and the Bluetooth adapter you are using.

@smalik007
Copy link

smalik007 commented Dec 11, 2023

The exception is thrown from the bleak module, which I am running on a Rasberry Pi 2 board which connects to a low energy embedded BLE chip. I suspect the problem more on the Rasberry Pi2 board.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party issue The issue is with the Bluetooth stack, the BLE device, or other 3rd party code not with Bleak itself Backend: BlueZ Issues and PRs relating to the BlueZ backend
Projects
None yet
Development

No branches or pull requests

3 participants