I am developing an application using Nordic nRF_SDK_15.0.0, in which I need to make my BLE peripheral device as a peer device which will get/set data from/to the other micro-controller (Host device) through UART communication through set of command and response frames. I will be developing a set of custom characteristics with read / write / notify permissions.
For reference, I am using 'ble_app_uart' example and performing modifications in same to obtain my application. Through this example I am clear about how to write data into characteristic (through BLE_GATTS_EVT_WRITE event) and how to generate data for notifications, at peripheral side. But I am not able to get that how to read from characteristic? In other words, what event will be generated at peripheral side so that my peripheral device will come to know that central device need to read from characteristic? This event will make my BLE peripheral device to send corresponding command on UART to my Host device to get the required parameter value in response frame and display that value through characteristic.
Thanks in advance for your help.
I got some hints in this link. Some more information will be great.
Yes, you can achieve the behavior you are looking for by using Read requests with authorization, see the S132 SoftDevice v6.0.0: GATTS Read Request with Authorization Message Sequence Chart for the event handling flow. You basically have to handle the BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event, which in your case will be to query the host device over UART and then call sd_ble_gatts_rw_authorize_reply with the value received from the host.
Thanks a lot Bjorn for your response. I will evaluate the use of same for my development.
Is there any example code or implemented service source code in Nordic SDK which uses GATTS Read Request with Authorization?
Read Requests are used in the QWR module which is included in most of the BLE peripheral examples.
Thanks a lot. :-)
I will go through it.