bleak
bleak copied to clipboard
Could not write to characteristics with some exeptions
- bleak version: Latest
- Python version:3.8.10
- Operating System: Linux Mint
- BlueZ version (
bluetoothctl -v
) in case of Linux: 5.50
I think I have got some bug or some weird behavior in writing value to the characteristics. I have a Bleak python code which tries to read/write specific characteristic/s on a device running Nimble stack BLE code. The device has defined characteristic with read/write access property as Nimble defines.
The issue in writing the characteristic is only sometimes when write property is defined after read property. For example, in the following arduino code snippet the error will be with second characteristics just in write operation. Reading characteristic works fine.
BLECharacteristic *first = ser_vis -> createCharacteristic(first_UUID, NIMBLE_PROPERTY::WRITE |NIMBLE_PROPERTY::READ );
BLECharacteristic *second = ser_vis -> createCharacteristic(seconf_UUID, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::WRITE);
BLECharacteristic *third = ser_vis -> createCharacteristic(third_UUID, NIMBLE_PROPERTY::WRITE | NIMBLE_PROPERTY::READ);
I tried the same code with Just Nimble code with ESP-IDF but the issue is there. But there was no issue writing to the characteristic with android applications such as nrfconnect. Hence, I thought that the issue could be with Bleak or something else with my Linux Bluez stack.!
FYI, the error is "Write operation not supported."
- Latest
What is the exact version number or git commit?
FYI, the error is "Write operation not supported."
Are you trying to write to a characteristic that doesn't support writing? Do you need to add the response=True
argument?
- BlueZ version (
bluetoothctl -v
) in case of Linux: 5.50
Does using a newer version of BlueZ fix the problem?
I would have to try the newer version of the BlueZ stack and let you know.
The bleak version is 0.17.0
print(bleak.version) 0.17.0
Are you trying to write to a characteristic that doesn't support writing? Do you need to add the response=True argument?
Not exactly. The characteristic supports write operation. Just what I have noticed is that, if I write something like following in my device code and flash it,
createCharacteristic(seconf_UUID, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::WRITE);
The code does not let me write to the characteristic. But the same thing works if I have the following code on device
createCharacteristic(first_UUID, NIMBLE_PROPERTY::WRITE |NIMBLE_PROPERTY::READ );
This means I have to first define write operation and then do OR( | ) with read operation. But I doubt why??
From my android application the same characteristic can be sent write data and it writes correctly.
The issue is not with Bleak as far as I understood but it should be with BlueZ itself.(I have tried some $bluetoothct
l) commands and there also write operation on not possible on that perticular characteristic.