cancel
Showing results for 
Search instead for 
Did you mean: 

BlueNRG-MS attribute handle in received event

Amila Perera
Associate II
Posted on April 23, 2018 at 07:03

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.

#bluenrg-stack #irq-bluenrg-ms #stm32-l4 #bluenrg #bluenrg-ms
1 REPLY 1
Amila Perera
Associate II
Posted on April 24, 2018 at 02:39

Hi All,

I think I was somehow managed to decipher the logic carried out in the Read-Eevent callback. I don't find this information anywhere neither in the BlueNRG-SDK(UM1865) nor in Programming Manual(PM0237).

But, fortunately I came across some useful information on a tool-tip-baloon on BlueNRG-GUI Desktop application.

0690X0000060Ak8QAE.png

The words ''next handle'' explains why the increment was done before the comparison.

I'm pretty sure that this is not something particular to Bluetooth Core specification. This should be something unique to BlueNRG-SDK. It will be really good if the documentation is updated with the relevant information as well.

Thanks.