Read Only Characteristic

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

This is a basic question...  I have a custom service with multiple custom characteristics.  The characteristics have various read/write permissions, some notify some do not.  I am having trouble with one characteristic.  It is read-only and it notifies.  I am using a phone app (LightBlue) as a client.

The idea is to have the BLE peripheral provide a status to the client via this characteristic, the app can read the characteristic and receives updates via notification.

In the GeneralEventHandler I update this characteristic on the "stack on" event.  When I connect the update is not there, I see the default value of the characteristic as entered in the GUI dialog.

I does not work when set to read only, but it does work when set to read/write.  What am I missing?

Thanks

Rich

0 Likes
1 Solution
Anonymous
Not applicable

I think I may have answered my own question.

I was updating the GATT with CyBle_GattsWriteAttributeValue, sending the CYBLE_GATT_DB_PEER_INITIATED parameter.  This assumes a connection.

To update the database only, I use the CYBLE_GATT_DB_LOCALLY_INITIATED parameter and I get the results I expect.

I welcome any comments.

Thanks

Rich

View solution in original post

2 Replies
Anonymous
Not applicable

I think I am misunderstand what it means for the characteristic to be "read only"  I interpret this as meaning that my BLE firmware will "set" the characteristic by writing to it but to a client (Phone) it will be read only.

Buuuut, when I try to write to this read-only characteristic using CyBle_GattsWriteAttributeValue I get the error "CYBLE_GATT_ERR_WRITE_NOT_PERMITTED"

So clearly I am misunderstand how this works.

Thanks

Rich

0 Likes
Anonymous
Not applicable

I think I may have answered my own question.

I was updating the GATT with CyBle_GattsWriteAttributeValue, sending the CYBLE_GATT_DB_PEER_INITIATED parameter.  This assumes a connection.

To update the database only, I use the CYBLE_GATT_DB_LOCALLY_INITIATED parameter and I get the results I expect.

I welcome any comments.

Thanks

Rich