This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

There are a way to clean queued data on tx buffer?

Hi everyone,

I am using nrfConnect 3.9.3, And SDK v1.7.0.

I am working on a project based on uart example.

My question is if there are some way for clean/discard all the data that a peer have buffered on nus tx characteristic through bt_nus_send().

The main reason is that i want to send only one packet per connection with the less delay possible, for that I turn on the Radio Notifications with MPSL_RADIO_NOTIFICATION_DISTANCE_5500US, and when is triggered i refresh the packet with the data of my sensors.

On add if there are some way to make longer this time MPSL_RADIO_NOTIFICATION_DISTANCE_5500US could be great.

Thank you Nordic Team,

regards

Parents
  • Hi another time, I was trying to find a function to clean (&att->tx_queue), due to  this buffer is filled when bt_nus_send() -> gatt_notify() -> bt_att_send()

    On the last function is filled the buffer with the function

    net_buf_put(&att->tx_queue, buf);

    So makes sense that att_reset() clean all the att->tx_queue

    static void att_reset(struct bt_att *att)
    {
    	struct bt_att_req *req, *tmp;
    	struct net_buf *buf;
    
    #if CONFIG_BT_ATT_PREPARE_COUNT > 0
    	/* Discard queued buffers */
    	while ((buf = net_buf_get(&att->prep_queue, K_NO_WAIT))) {
    		net_buf_unref(buf);
    	}
    #endif /* CONFIG_BT_ATT_PREPARE_COUNT > 0 */
    
    	while ((buf = net_buf_get(&att->tx_queue, K_NO_WAIT))) {
    		net_buf_unref(buf);
    	}
    
    	att->conn = NULL;
    
    	/* Notify pending requests */
    	SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&att->reqs, req, tmp, node) {
    		if (req->func) {
    			req->func(NULL, BT_ATT_ERR_UNLIKELY, NULL, 0,
    				  req->user_data);
    		}
    
    		bt_att_req_free(req);
    	}
    
    	k_mem_slab_free(&att_slab, (void **)&att);
    }

    Unfortunatelly isn't work, data queued keeps beeing sended.

    My question is if there are some way for clean/discard all the data that a peer have buffered on nus tx characteristic through bt_nus_send().

    Any suggestion is welcome, i think that what i am asking mustn't be an impossibble thing, no?

    Thank you

Reply
  • Hi another time, I was trying to find a function to clean (&att->tx_queue), due to  this buffer is filled when bt_nus_send() -> gatt_notify() -> bt_att_send()

    On the last function is filled the buffer with the function

    net_buf_put(&att->tx_queue, buf);

    So makes sense that att_reset() clean all the att->tx_queue

    static void att_reset(struct bt_att *att)
    {
    	struct bt_att_req *req, *tmp;
    	struct net_buf *buf;
    
    #if CONFIG_BT_ATT_PREPARE_COUNT > 0
    	/* Discard queued buffers */
    	while ((buf = net_buf_get(&att->prep_queue, K_NO_WAIT))) {
    		net_buf_unref(buf);
    	}
    #endif /* CONFIG_BT_ATT_PREPARE_COUNT > 0 */
    
    	while ((buf = net_buf_get(&att->tx_queue, K_NO_WAIT))) {
    		net_buf_unref(buf);
    	}
    
    	att->conn = NULL;
    
    	/* Notify pending requests */
    	SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&att->reqs, req, tmp, node) {
    		if (req->func) {
    			req->func(NULL, BT_ATT_ERR_UNLIKELY, NULL, 0,
    				  req->user_data);
    		}
    
    		bt_att_req_free(req);
    	}
    
    	k_mem_slab_free(&att_slab, (void **)&att);
    }

    Unfortunatelly isn't work, data queued keeps beeing sended.

    My question is if there are some way for clean/discard all the data that a peer have buffered on nus tx characteristic through bt_nus_send().

    Any suggestion is welcome, i think that what i am asking mustn't be an impossibble thing, no?

    Thank you

Children
Related