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

Indication of Read request at application level

Hello,

 

I am using nRF52832, SDK_15.3.0, S132 SoftDevice and Segger for flashing the image. I am using ‘ble_app_blinky’.

 

I was going to “Batter Service”. Battery level is a read & notify option. In this example, a timer handler is triggered periodically, read battery level and update the value using sd_ble_gatts_value_set(). So when read request is initiated, device will send recent read value.

 

But I have a requirement, when there is a read request from Client, Server application will receive the request indication and then only do battery measurement and send read response with latest battery level with timestamp.

In below link, I see only read request till "SoftDevice" and SD will send read response.

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v6.1.1%2Fmodules.html

Scenario (For better understanding):

1) Battery is read and updated Characteristic value using sd_ble_gatts_value_set() periodically every 30 minutes.

2) As of now whenever there is a read request from Client, Server will send last updated value.

3) Whereas in my scenario, in-between, say at 25th minutes, client can request battery level. For this request, servers should read battery level immediately and send latest value rather than last updated value which is 25 minutes old.

How to achieve this ? Is there any indication for read operation (Similar to write, cccd).

 

Thanks & Regards

Vishnu Beema

Parents Reply Children
  • Andy thank you for your inputs and different approach.

    Sigurd thank you for your inputs.

     

    Just I gave battery as example. But in our case, on read request I need to read Sensor at that instance, timestamp the value and send to Client. So time stamp will be at the instance when read request is received by server.

    Already Client is developed and we don’t want to change (Because of this I said not to implement write command).

     

    With respect to “GATTS Read Request without Authorization”, periodically server will read sensor data, timestamp the data and update ‘Characteristic value’ by calling sd_ble_gatts_value_set(). So when there is a read request from Client, shared structure at Server is read and transmitted. So the data read is last but not latest.

     

    To get better understanding, my further queries are:

    1) As of now I did not enable any security (read_access = SEC_OPEN). With “GATTS Read Request with Authorization”, do I need to enable any security.

    2) To enable ‘rd_auth’ I need to set ‘is_defered_read’ to 1. But as per comments “Indicate if deferred read operations are supported”, please give more inputs on this variable.

     

    Thanks & Regards

    Vishnu Beema

  • 1) No you don't need to enable security in order to use authorization.

    2) If you are using the function characteristic_add() to add the characteristic, then you need to set this to 1, since this is then used to set the value of attr_md.rd_auth. But if this is for the characteristic user descriptor, then it's optional to use.

Related