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.

CC2540 BLE中GATT_ReadUsingCharUUID函数使用疑问

Other Parts Discussed in Thread: CC2540

hi,各位大牛!

        由于贵司对CC2540的BLE协议部分代码不开源,在看代码是对相关函数使用不是怎么理解请指导!

        本人在看HostTestApp项目的时,看hci_ext_app.c中的processExMsgATT函数看到对于ATT消息的处理,有如下代码:

case ATT_READ_BY_TYPE_REQ:
        stat = ATT_ParseReadByTypeReq( ATT_SIG_NOT_INCLUDED, FALSE, &pBuf[2], pCmd->len-2, &msg );
        if ( stat == SUCCESS )
        {
                attReadByTypeReq_t *pReq = &msg.readByTypeReq;

                // Find out what's been requested
                if ( gattIncludeType( pReq->type ) )
                {
                        // Find included services
                        stat = GATT_FindIncludedServices( connHandle, pReq->startHandle,
                        pReq->endHandle, hciExtApp_TaskID );
                }
                else if ( gattCharacterType( pReq->type ) )
                {
                        // Discover all characteristics of a service
                        stat = GATT_DiscAllChars( connHandle, pReq->startHandle,
                        pReq->endHandle, hciExtApp_TaskID );
                }
                else
                {
                // Read using characteristic UUID
                        stat = GATT_ReadUsingCharUUID( connHandle, pReq, hciExtApp_TaskID );
                }
        }
        break;

case ATT_READ_BY_TYPE_RSP:
        stat = ATT_ParseReadByTypeRsp( &pBuf[2], pCmd->len-2, &msg );
        if ( stat == SUCCESS )
        {
                stat = ATT_ReadByTypeRsp( connHandle, &msg.readByTypeRsp );
        }
        break;

代码中 stat = GATT_ReadUsingCharUUID( connHandle, pReq, hciExtApp_TaskID );通过UUID获得characteristic value;我的疑问是:该函数需要的UUID是从哪个参数传入的(pReq?);那它获得的characteristic value有时从哪里输出的?该函数调用成功会产生一个ATT_READ_BY_TYPE_RSP消息,是否它的输出characteristic value就是通过ATT_ReadByTypeRsp( connHandle, &msg.readByTypeRsp );获得的?该characteristic value包括在msg中吗?

另外还有类似的函数,如:GATT_DiscAllChars,GATT_DiscPrimaryServiceByUUID,因为贵司没有提供其源码无法深入了解,知道其功能,但是不知道其输入,输出该如何传入?请指教,谢谢!!

  • Hi, 

    关于GATT_ReadUsingCharUUID(), 你的理解是正确的. 关于ATT_READ_BY_TYPE_RSP和ATT_ReadByTypeRsp()的理解你也是正确的.

    processExMsgATT() 负责处理这些从上或者从下传过来的event, 然后做相应反应.

    另外, 对于TI只提供接口的函数, 请参考接口的解释, 应该是比较清楚的.

    GATT_DiscAllChars,GATT_DiscPrimaryServiceByUUID 分别是做查找所有characteristic(应该用的是UUID 0x2803作为参数), 而后者是查找对方虽有的Primary service(应该是用UUID 0x2800作为参数).


  •  

    GATT_DiscPrimaryServiceByUUID( simpleBLEConnHandle,
                                     uuid,
                                     ATT_BT_UUID_SIZE,
                                     simpleBLETaskId );

    这个函数UUID是服务的uuid为 0xFFF0,怎么是你说的0x2800。嗨Yan

  • tatic gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
    {
    //============================================================================//
    // Simple Profile Service 服务特征值声明
    {
    { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
    GATT_PERMIT_READ, /* permissions */
    0, /* handle */
    (uint8 *)&simpleProfileService /* pValue */
    },
    //============================================================================//