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

BLE_EVT_TX_COMPLETE and which characteristic sent a notifiation

Hi all! It`s possible to know in event BLE_EVT_TX_COMPLETE which characteristic sent a notifiation? I have 2 characteristic and depending on which one of them sent notification, it is necessary to produce different action. This is a pseudocode:

static void on_ble_evt(ble_evt_t *p_ble_evt)
{
...
   case BLE_EVT_TX_COMPLETE:
   {
   if (characterictic1_sent)
     do_sums1();
   else if (characterictic2_sent)
    do_sums2();
   }
...
}

Thanks!

Parents
  • I don't think it is possible to cleanly find out what characteristic was sent in your use case of notification. But instead of notification you can use indication then the peer will send you confirmation of receiving it. Then your app will receive BLE_GATTS_EVT_HVC and you can do something like this

    static void on_ble_evt(ble_evt_t *p_ble_evt)
    {
    ...
       case BLE_GATTS_EVT_HVC:
       {
       if (characterictic1.value_handle == p_ble_evt->evt.gatts_evt.params.hvc.handle)
         do_sums1();
       else if (characterictic2.value_handle == p_ble_evt->evt.gatts_evt.params.hvc.handle)
        do_sums2();
       }
    ...
    }
    
Reply
  • I don't think it is possible to cleanly find out what characteristic was sent in your use case of notification. But instead of notification you can use indication then the peer will send you confirmation of receiving it. Then your app will receive BLE_GATTS_EVT_HVC and you can do something like this

    static void on_ble_evt(ble_evt_t *p_ble_evt)
    {
    ...
       case BLE_GATTS_EVT_HVC:
       {
       if (characterictic1.value_handle == p_ble_evt->evt.gatts_evt.params.hvc.handle)
         do_sums1();
       else if (characterictic2.value_handle == p_ble_evt->evt.gatts_evt.params.hvc.handle)
        do_sums2();
       }
    ...
    }
    
Children
Related