Is there a way in the main application to detect when a characteristic read is occurring.
In my application, I need to generate the characteristic data dynamically as it is requested. Ideally I would like a callback so that I can update the characteristic value before it is sent.
Solved! Go to Solution.
That worked! I am getting that event.
There is still a small problem, I update the GATT database in the event handler, but the previous value is sent to the client. The next time the client reads the value, it reads the value that I had set so the read value is always delayed by one request.
Is this event triggered AFTER the response is sent to the client ?
and is there any way to update the data BEFORE it is sent to the client ?
I think the BLE component/code prohibits you from doing this. Maybe this is some constraint made by Cypress; maybe it is required by Bluetooth specification. I don't know.
You could create your own Characteristic with Write and Indicate properties. Use write to send your own "read command" to the server, and then let the server do an Indication back.