This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2652R:在发送 GATT_Notification 之前读取 GATT 队列中的可用空间

Guru**** 2347060 points
Other Parts Discussed in Thread: SYSCONFIG
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1432130/cc2652r-read-available-space-in-gatt-queue-before-sending-gatt_notification

器件型号:CC2652R
主题中讨论的其他器件:SysConfig

工具与软件:

你(们)好

我正在使用 GATT_Notification ()将大文件从设备发送到移动应用。 为了做到这一点,我已经注册了连接事件回调使用 Gap_Register 387EventCb ()。 每次回调时、我可以(根据文档)发送4个通知。 只要传输过程中没有丢失数据包、这就可以正常工作。 如果数据包丢失,堆栈将从我理解的内容重新传输它们,因此 GATT TX 队列将满,调用 GATT_Notification ()将失败,并显示0x16。 我认为这是到目前为止的预期行为。

我的问题是:在调用 GATT_Notification ()之前,如果队列中有足够的空间发送另一个通知,是否有办法知道? 或者,我是否只需要 在后续连接事件回调中再次使用相同的数据调用 GATT_Notification (),直到它被栈接受?

谢谢

参考

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Reto:

    通过监控 ICall 堆或 ble 任务大小、您或许可以对此有所了解、但最稳定的解决方案可能是在数据包正在传输时使其排队。 我会在 "通知已发送"事件中添加一个复选标记、以便您继续排队。 这样、在给定时间内、您的数据包排队数量不会超过您发送的数量。 还可以增加 PDU 的大小和数量(可以通过 SysConfig 完成)。

    此致、

    1月

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    这没有太大意义、无论如何我现在让它运行得非常好、下面的代码显示了我实现的逻辑:

    static uint8* buffer=null;
    static uint16 buffer_len=0;
    
    void on_connection_event()
    {
    	int32_t packets=4;
    	while (packets-- > 0)        //we can send 4 frames per connection event
    	{
    		if (buffer==null)
    		{
    			buffer=(uint8*)GATT_bm_alloc(..)
    
    			//fill data into buffer and set buffer_len
    
    		}
    	 
    		attHandleValueNoti_t noti;
    		noti.handle=get_attr_handle();
    		noti.len=buffer_len;
    		noti.pValue=buffer;
    		bStatus_t status = GATT_Notification( connHandle, &noti, false );
    
    		if (status==SUCCESS)
    		{
    			//success
    
    			//the stack will free the buffer...
    			buffer=NULL;  // so we allocate a new buffer next tiem
    			buffer_len=0;
    
    			Log_info2("FS %d %d", log_data_rx_frame_idx, debug);
    		}
    		else if (status==blePending)
    		{
    			//we can't send right now as the gatt queue is full
    			//Keep the buffer and send it later
    			
    			//There's no point trying again in this connection event, so let's just return and on next connection event we will send the buffer again...
    			return;
    		}
    		else
    		{
    			//Something else gone wrong
    			//Free the buffer
    
    			ATT_bm_free( (gattMsg_t *)buffer, ATT_HANDLE_VALUE_NOTI );
    			buffer=NULL;  // so we allocate a new buffer next tiem
    			buffer_len=0;
    		}
    	}
    }