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.

  • The BPS example is sending an initial indication on the custom BLE_BPS_EVT_INDICATION_ENABLED event, and then an additional indication for every button press (if no indications are pending).

    The Bluetooth Spec will tell you more about indications, but in short, indications are very much like notifications. The notable difference is that indications must be ACKed, where notifications can be sent as fast as the peer can receive. Indications are good for when receiving a value is expensive, or when you need extra time before getting the rest of the data. Maybe you need to boot up a display to display it. Notifications are good when you want to send an update whenever you have something to send, or if you want to send data very fast.

    It is possible to have characteristics that are both notifiable and indicatable, and the peer decides by writing to the CCCD.

Reply
  • The BPS example is sending an initial indication on the custom BLE_BPS_EVT_INDICATION_ENABLED event, and then an additional indication for every button press (if no indications are pending).

    The Bluetooth Spec will tell you more about indications, but in short, indications are very much like notifications. The notable difference is that indications must be ACKed, where notifications can be sent as fast as the peer can receive. Indications are good for when receiving a value is expensive, or when you need extra time before getting the rest of the data. Maybe you need to boot up a display to display it. Notifications are good when you want to send an update whenever you have something to send, or if you want to send data very fast.

    It is possible to have characteristics that are both notifiable and indicatable, and the peer decides by writing to the CCCD.

Children
No Data
Related