BLE - How to set read value of a Characteristic

Hi all,

I am a bit confused as of how to set the read value of a read-only ble.Characteristic.

For example let’s say I create the following characteristic:

c = ble.Characteristic(0x1525,ble.READ,1,"LED",ble.NUMBER) 

As far as I understand from the documentation:

  • the function set_value is only used when the characteristic has a notify permission. I did try it and didn’t receive any value when read.
  • the function set_callback is used for write permissions

So, how to set the value for reading? I haven’t found something in the documentation.

I forgot to mention that I work with an ESP32 board.

Hi @nickagian
I tested the BLE Alerts example
, you have to enable notifications and the data will be updated every 5 seconds as in the code.
The code set_value for the characteristic and updates the value every 5 seconds if the notifications are enabled.

Also the set_callback is used to enable and disable notifications from the app, with calls the callback fucntion.
Let me know if you have further questions.

Hi @karimhamdy1,

Thank you for your time. What you’re describing is exactly what I am experiencing. We agree in that! :slightly_smiling_face:

But this exactly is my problem. What about characteristics with only read permissions (without notifications). What happens if you press on the button next to the one you have put in circle (single arrow). Then nothing comes back, because I suppose it is not implemented from the fw running on the esp32.

I am not sure, I have to check with ESP-IDF.
If this feature is not implemented, I will pass this as a feature suggestion.

If you have more questions, Let me know :slight_smile: