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.

[参考译文] CC2340R5:Central 如何知道 DATA_STREAM 示例代码中的通知和写入句柄?

Guru**** 2835775 points

Other Parts Discussed in Thread: CC2340R5

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

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1625377/cc2340r5-how-does-the-central-know-the-notification-and-write-handles-in-the-data_stream-sample-code

器件型号: CC2340R5

尊敬的 TI 专家:
使用两个 CC2340R5 板以及 DATA_STREAM 示例(中央器件和外设角色)、中央侧如何找到用于启用通知或发送数据的正确 Requ.handle? 是否有用于句柄发现的 API?

(SDK 9.14.2.16)

void EnableNotification(char *index){
    
	attWriteReq_t req;

    bStatus_t status;

    uint8 configData[2] = {0x01,0x00};
    req.pValue = GATT_bm_alloc(app_connection_handle, ATT_WRITE_REQ, 2, NULL);

    // Enable notify for outgoing data
    if (req.pValue != NULL)
    {
        req.handle = 47;//????
        req.len = 2;
        memcpy(req.pValue, configData, 2);
        req.cmd = TRUE;
        req.sig = FALSE;
        status = GATT_WriteNoRsp(app_connection_handle, &req);
        if ( status != SUCCESS )
        {
            GATT_bm_free((gattMsg_t *)&req, ATT_WRITE_REQ);
        }

    }
	
}
static gattAttribute_t dss_attrTbl[] =
{
 /*--------------------type-------------------*/ /*------------permissions-------------*/ /*------------------pValue--------------------*/
   // Data Stream Service
   GATT_BT_ATT( primaryServiceUUID,                 GATT_PERMIT_READ,                        (uint8 *) &dss_service ),

   // DataIn Characteristic Properties
   GATT_BT_ATT( characterUUID,                      GATT_PERMIT_READ,                        &dss_dataIn_props ),
   // DataIn Characteristic Value
   GATT_ATT( dss_dataIn_UUID,                       GATT_PERMIT_WRITE,                       &dss_dataIn_val ),
   // DataIn Characteristic User Description
   GATT_BT_ATT( charUserDescUUID,                   GATT_PERMIT_READ,                        dss_dataIn_userDesp ),

   // DataOut Characteristic Properties
   GATT_BT_ATT( characterUUID,                      GATT_PERMIT_READ,                        &dss_dataOut_props ),
   // DataOut Characteristic Value
   GATT_ATT( dss_dataOut_UUID,                      0,                                       &dss_dataOut_val ),
   // DataOut Characteristic configuration
   GATT_BT_ATT( clientCharCfgUUID,                  GATT_PERMIT_READ | GATT_PERMIT_WRITE,    (uint8 *) &dss_dataOut_config ),
   // DataOut Characteristic User Description
   GATT_BT_ATT( charUserDescUUID,                   GATT_PERMIT_READ,                        dss_dataOut_userDesp ),
};
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Anthony:

    感谢您发送编修。  让我看看 ,并报告我的发现,只要我有.

    此致、

    Ging

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

    你好 Ging

    对此有任何更新? 重新连接后、中央器件无法重新启用通知 (GATT_WriteNoRsp 期间出现错误 0x16)。 我怀疑在断开链路后把手(之前的 47)可能是错误的。 是否有任何 API 可动态查找特定属性句柄?

    此致、

    Anthony

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

    对延迟深表歉意。 为属性启用通知的推荐方法如下:

    1.使用“GATT_DiscAllPrimaryServices"发现“发现 GATT 表的服务
    2.使用“GATT_DiscAllChars"了解“了解您感兴趣的服务的特性
    3.此时,您将有权访问每个属性的句柄。 然后、您可以获得
    CCCD 处理所需的信息、并调用“GATT_WriteNoRsp"以“以启用通知。

    您可以使用此示例作为参考: github.com/.../README.md

    如需更多信息、此主题也可能很有用: e2e.ti.com/.../cc2340r5-service-discovery

    此致、
    Ging