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

How to enable indication for a characteristic

Hello Everyone

Is there any example code which uses indication property. Application nAn-36 uses notification property and as far as i read and understood about indication property it will indicate any change in the characteristic of service made by client to the Server.

Enabling the GATT characteristic to indicate state, what other things i need to do. such as

char_md.char_props.indicate = 1;

So that whenever a value changes it will be indicated automatically.

Thanks & Regards Asma

Parents
  • Doing a quick search in the SDK, I see that multiple profiles are using the indications. This includes BPS, CGM, GLS, HTS and the DFU example to mention a few.

    In general, it is enough to set the indicate bit and a writable CCCD for the characteristic in question. This will add an indicatable characteristic.

    However, before you are able to send an indication with sd_ble_gatts_hvx() and hvx_params.type = BLE_GATT_HVX_INDICATION, the peer you have connected to must write to the CCCD of the characteristic, enabling indications. The CCCD value is a bitfield, and indications are the second bit. So any value like 0x02 (indications only) and 0x03 (indications and notifications) should enable indication.

    You are also not allowed to send a new indication until the previous one is confirmed. This is signaled by the reception of a BLE_GATTS_EVT_HVC (handle value confirmation) event.

    For more information, refer to the API documentation for sd_ble_gatts_hvx.

Reply Children
No Data
Related