This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Event related to read request on characteristic

Hi,

imagine that I have a proprietary characteristic that allows only READ operation (from a smartphone for example) that expose an internal value in my application. I see that there isn't an event raised when a READ request arrives to the BLE layer (it exists for a WRITE request, ex. BLE_GATTS_EVT_WRITE event). It means that I need to update periodically (with a timer) the characteristic value (using sd_ble_gatts_value_set) even if I don't receive READ request to keep update the value for future requests. Why there isn't an event model on this ?

Thanks, Paolo.

Parents
  • Hello.

    You must turn on read authorization on your characteristic. This is done during the characteristic_add() function, probably called from services_init(). (The function names may vary depending on the service)

    Configure this value inside metadata structure(with type ble_gatts_attr_md_t).

    attr_md.rd_auth = 1;

    After setting this, you will receive BLE_GATTTS_RW_AUTHORIZE_REQUEST events when someone want to read the characteristic. See the message sequence chart.

    The problem and solution is also described here. Let me know if anything is unclear, or if you run into any problems.

  • As you mentioned, you can copy the service files to somewhere you can edit them. Optionally, you can use the zip version of our SDK instead of Keil Packs. As for your last question: Normally the application does not need to know about the battery level being read. Therefore it is not implemented in this service. You are free to create any custom service you would like, with properties customized to your application. You can read about that here.

Reply Children
No Data
Related