How can I identify the transmission completion of a packet when using NCS?

Hi Nordic team,

I'm using the bt_gatt_notify_cb function to send notifications about data.

In the SDK, I can ascertain that the data has been successfully sent through the "BLE_GATTS_EVT_HVN_TX_COMPLETE" event. However, in NCS, which event or function can provide me with this information?

I want to find out how many packets are waiting in the queue.


Thank you.

Parents
  • Hello,

    I am not aware of any way to find how many packets are waiting in the queue no, but if you are using the notify with callback function, isn't the callback being called to indicate that the packet is sent? Ref for instance from nus.c service where on_sent() is called:

    int bt_nus_send(struct bt_conn *conn, const uint8_t *data, uint16_t len)
    {
    	struct bt_gatt_notify_params params = {0};
    	const struct bt_gatt_attr *attr = &nus_svc.attrs[2];
    
    	params.attr = attr;
    	params.data = data;
    	params.len = len;
    	params.func = on_sent;
    
    	if (!conn) {
    		LOG_DBG("Notification send to all connected peers");
    		return bt_gatt_notify_cb(NULL, &params);
    	} else if (bt_gatt_is_subscribed(conn, attr, BT_GATT_CCC_NOTIFY)) {
    		return bt_gatt_notify_cb(conn, &params);
    	} else {
    		return -EINVAL;
    	}
    }

    Kenneth

Reply
  • Hello,

    I am not aware of any way to find how many packets are waiting in the queue no, but if you are using the notify with callback function, isn't the callback being called to indicate that the packet is sent? Ref for instance from nus.c service where on_sent() is called:

    int bt_nus_send(struct bt_conn *conn, const uint8_t *data, uint16_t len)
    {
    	struct bt_gatt_notify_params params = {0};
    	const struct bt_gatt_attr *attr = &nus_svc.attrs[2];
    
    	params.attr = attr;
    	params.data = data;
    	params.len = len;
    	params.func = on_sent;
    
    	if (!conn) {
    		LOG_DBG("Notification send to all connected peers");
    		return bt_gatt_notify_cb(NULL, &params);
    	} else if (bt_gatt_is_subscribed(conn, attr, BT_GATT_CCC_NOTIFY)) {
    		return bt_gatt_notify_cb(conn, &params);
    	} else {
    		return -EINVAL;
    	}
    }

    Kenneth

Children
Related