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.
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.
1 of 1 people found this helpful
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.