AnsweredAssumed Answered

BlueNRG-MS attribute handle in received event

Question asked by Amila Perera on Apr 23, 2018
Latest reply on Apr 24, 2018 by Amila Perera

Hi all,

I was able to port Environmental Sensor Service program to an STM32L4 MCU and the program seems to work fine with BlueNRG-MS application on smart phone.

While going through the code, I came across that when the GATT server receives a read event from the client it checks the relevant handle of the characteristic in the following way.

 

void Read_Request_CB(uint16_t handle)

  if(handle == accCharHandle + 1){
    Acc_Update((AxesRaw_t*)&axes_data);
 
  else if(handle == tempCharHandle + 1){
    int16_t data;
    data = 270 + ((uint64_t)rand()*15)/RAND_MAX; //sensor emulation       
    Acc_Update((AxesRaw_t*)&axes_data); //FIXME: to overcome issue on Android App
                                        // If the user button is not pressed within
                                        // a short time after the connection,
                                        // a pop-up reports a "No valid characteristics found" error.
    Temp_Update(data);
  }
  else if(handle == pressCharHandle + 1){
    int32_t data;
    struct timer t
    Timer_Set(&t, CLOCK_SECOND/10);
    data = 100000 + ((uint64_t)rand()*1000)/RAND_MAX;
    Press_Update(data);
  }
  else if(handle == humidityCharHandle + 1){
    uint16_t data;
   
    data = 450 + ((uint64_t)rand()*100)/RAND_MAX;
   
    Humidity_Update(data);
 
 
  //EXIT:
  if(connection_handle != 0)
    aci_gatt_allow_read(connection_handle);
}

 

One thing I can not understand is why the received attribute handle is compared with the (characteristic handle + 1) instead of just the (characteristic handle).

What is this relationship between attribute handle of the received event and the characteristic handle.

Where is this logic related to in the API documentation of the SDK ?

 

 

Thank you in advance.

Outcomes