BlueNRG Bluetooth: how to receive data via chateractic

1.1k views Asked by At

Currently I implement code bluetooth low engine (BLE) for STM32L476 + X-NUCLEO-IDB04A1 base on example "sensor demo".

In "Sensor Demo" example, it only code to send data to smart phone. And don't have receive data.

I think can use function below to read data:

tBleStatus aci_gatt_read_charac_val(uint16_t conn_handle, uint16_t attr_handle)

enter image description here

And can read data from HCI_Event_CB(hciReadPacket->dataBuff);

However I don't know how to get parameter "uint16_t attr_handle" for function

tBleStatus aci_gatt_read_charac_val(uint16_t conn_handle, uint16_t attr_handle)

Could you explain for me about this problem?

1

There are 1 answers

1
Winfred On BEST ANSWER

That would be the value of the handle for this connection.

When IDB04A1 successfully connects to the smart phone, it shall send a HCI_LE_META_EVENT with information for this connection. Connection_Handle can be found in the event, to be specific, a 16-byte value: (offset 6 | offset 5)