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

manage two characteristics indications simultaneously

I have one characteristic which send data with indications, for each frame sent I wait for acknowledgement on case BLE_GATTS_EVT_HVC: before sending the next data

but now I have two characteristics performing the same task, how can I differentiate between them? I mean how can I know that the event received on BLE_GATTS_EVT_HVC is related to characteristic one or two

  • Hi,

    In the structure of your characteristics, you shall have a .value_handle somewhere. Let's take the ble_app_uart as an example. The value handles are populated by the service itself, and stored in the global struct:

    m_nus.rx_handles.value_handle
    m_nus.tx_handles.value_handle
    

    When you then get the event BLE_GATTS_EVT_HVC, you can check the handle in the BLE evt:

    if (p_ble_evt->evt.gatts_evt.params.hvc.handle == m_myservice1.my_handle.value_handle) {service1_do_something();}
    

    Cheers, Håkon

Related