Update Characteristic on read request

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

cross mob
Anonymous
Not applicable

Hi,

is there any way to update the data of a Characteristic during a read request?

I want to update the data by writing a new value to the Characteristic when I receive a read request. The client should read the updated data then.

Hope you can help.

0 Likes
1 Solution
Anonymous
Not applicable

This is not currently possible in the latest official BLE stack component. There is a CYBLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ event which can be enabled on a per-attribute basis that tells the application code that a read has been requested, but the data is pre-loaded for transfer to the client before this event is triggered, and so it is not possible to actually modify the value before it is delivered back to the client. I am unsure whether this is going to change in the near future.

   

As an alternative (though perhaps not as clean as the modify-on-read scenario), you could make the characteristic support both write and notify or indicate, then have the server notify/indicate the immediate new value to the client after the client writes a simple value to the same characteristic. At a protocol level, this is not all that different from what actually happens with a read request.

View solution in original post

0 Likes
3 Replies
Anonymous
Not applicable

This is not currently possible in the latest official BLE stack component. There is a CYBLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ event which can be enabled on a per-attribute basis that tells the application code that a read has been requested, but the data is pre-loaded for transfer to the client before this event is triggered, and so it is not possible to actually modify the value before it is delivered back to the client. I am unsure whether this is going to change in the near future.

   

As an alternative (though perhaps not as clean as the modify-on-read scenario), you could make the characteristic support both write and notify or indicate, then have the server notify/indicate the immediate new value to the client after the client writes a simple value to the same characteristic. At a protocol level, this is not all that different from what actually happens with a read request.

0 Likes
Anonymous
Not applicable

That might be possible for custom services. I also need this for predefined services, such as "Device Information". I couldn't understand why Cypress doesn't give the possibility to do this. I'm sure not the only one who might need this.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

As jrow said "This is not currently possible in the latest official BLE stack component." The BLE stack is given by the Bluetooth association and so ensures that all "official" versions can interact with each other on all iso layers.

   

 

   

Bob