GATT_DiscPrimaryServiceByUUID 这个执行后,event里回的ATT_FindByTypeValueRsp这个结构体包含了哪些信息?和static 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 */
},
这个结构体有关么?有关的话这个对应关系是咋样的呢?看了很久代码,没想明白,先谢谢了
Yan:
跟这个关系不大.
GATT_DiscPrimaryServiceByUUID 通过你指定的UUID去发现一个Primary service.
ATT_FindByTypeValueRsp 里面 的结构体 attFindByTypeValueRsp_t, 内容是根据你需要的UUID, 返回的primary service的attribute handle的个数, 以及以这个primary service的attribute handle值开始, 到这个primary service 所有属性定义结束为一个group的最有一个属性的attribute handle值.
总而言之, 返回的是总共有几个这个UUID的primary service, 以及这几个primary service, 每一个primary service的attribute handle, 最后一个属性的attribute handle.
看这两个:
/** * Handles Infomation format. */typedef struct{ uint16 handle; //!< Found attribute handle uint16 grpEndHandle; //!< Group end handle} attHandlesInfo_t;
/** * Find By Type Value Response format. */typedef struct{ uint8 numInfo; //!< Number of handles information found attHandlesInfo_t handlesInfo[ATT_MAX_NUM_HANDLES_INFO]; //!< List of 1 or more handles information} attFindByTypeValueRsp_t;
feng qian2:
回复 Yan:
那这个primary service的attribute handle的个数,primary service的attribute handle的开始值是在哪边定义的呢?
Yan:
回复 feng qian2:
Hi Feng,
在每个示例程序里面的init函数里面, 都会有一系列Add service之类的函数.
通过你之前看到的那些定义好的service结构体, 通过调用add service函数, 底层的协议栈会自动分配好Handle.
feng qian2:
回复 Yan:
这个handle代码啥意思呢?和init注册的结构体的关系是怎么样的呢?
feng qian2:
回复 Yan:
GATT_DiscPrimaryServiceByUUID传入的UUID就是simpleProfileAttrTbl结构体中primaryServiceUUID的UUID么?
Yan:
回复 feng qian2:
没错, 在simple peripheral 这个例子里面, 就是SIMPLEPROFILE_SERV_UUID
Jack Lee2:
这里面的数据的传输,好像完全是借鉴网络数据传输的那种概念,和网络传输的协议和封装的都很相似
feng qian2:
回复 Jack Lee2:
在问两个问题
1.这张表的开头是佛必须以开始?
// Simple Profile Service { { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */ GATT_PERMIT_READ, /* permissions */ 0, /* handle */ (uint8 *)&simpleProfileService /* pValue */ },
2. characteristic declaration 和value分别是做什么用的呢?这两个有关系么
// Characteristic 1 Declaration { { ATT_BT_UUID_SIZE, characterUUID }, GATT_PERMIT_READ, 0, &simpleProfileChar1Props }, // Characteristic Value 1 { { ATT_BT_UUID_SIZE, simpleProfilechar1UUID }, GATT_PERMIT_READ | GATT_PERMIT_WRITE, 0, &simpleProfileChar1 },
TI中文支持网
