协议栈里的例程都是通过SIMPLEPROFILE_CHAR1_UUID去获得handle
req.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR1_UUID);
req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR1_UUID);
为什么通过SIMPLEPROFILE_CHAR4_UUID去获取handle会失败,我的从机SIMPLEPROFILE_CHAR4_UUID是Notify,还请大神告知.
chao xie:
通过SIMPLEPROFILE_CHAR2_UUID也是可以获得handle的,是不是notify对应的UUID要特殊处理才能获取handle?
chao xie:
回复 chao xie:
目前测试下来通过,CHAR3,CHAR4,CHAR5,均无法获取handle,是不是从机那边需要进行设置?
Barbara Wu:
回复 chao xie:
有点不明白您的意思,您这边是主机?获取handle的代码是?
chao xie:
回复 Barbara Wu:
就是Ti的主机例子啊,
static void SimpleBLECentral_processGATTDiscEvent(gattMsgEvent_t *pMsg){ if (pMsg->method == ATT_MTU_UPDATED_EVENT) { // MTU size updated LCD_WRITE_STRING_VALUE("MTU Size:", pMsg->msg.mtuEvt.MTU, 10, LCD_PAGE4); } else if (discState == BLE_DISC_STATE_MTU) { // MTU size response received, discover simple BLE service if (pMsg->method == ATT_EXCHANGE_MTU_RSP) { uint8_t uuid[ATT_BT_UUID_SIZE] = { LO_UINT16(SIMPLEPROFILE_SERV_UUID), HI_UINT16(SIMPLEPROFILE_SERV_UUID) }; // Just in case we're using the default MTU size (23 octets) LCD_WRITE_STRING_VALUE("MTU Size:", ATT_MTU_SIZE, 10, LCD_PAGE4); discState = BLE_DISC_STATE_SVC;
// Discovery simple BLE service VOID GATT_DiscPrimaryServiceByUUID(connHandle[connHandleIdx], uuid, ATT_BT_UUID_SIZE, selfEntity); } } else if (discState == BLE_DISC_STATE_SVC) { // Service found, store handles if (pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP && pMsg->msg.findByTypeValueRsp.numInfo > 0) { svcStartHdl = ATT_ATTR_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0); svcEndHdl = ATT_GRP_END_HANDLE(pMsg->msg.findByTypeValueRsp.pHandlesInfo, 0); } // If procedure complete if (((pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP) && (pMsg->hdr.status == bleProcedureComplete)) || (pMsg->method == ATT_ERROR_RSP)) { if (svcStartHdl != 0) { attReadByTypeReq_t req; // Discover characteristic discState = BLE_DISC_STATE_CHAR; req.startHandle = svcStartHdl; req.endHandle = svcEndHdl; req.type.len = ATT_BT_UUID_SIZE; req.type.uuid[0] = LO_UINT16(SIMPLEPROFILE_CHAR1_UUID); req.type.uuid[1] = HI_UINT16(SIMPLEPROFILE_CHAR1_UUID);
VOID GATT_ReadUsingCharUUID(connHandle[connHandleIdx], &req, selfEntity); } } } else if (discState == BLE_DISC_STATE_CHAR) { // Characteristic found, store handle if ((pMsg->method == ATT_READ_BY_TYPE_RSP) && (pMsg->msg.readByTypeRsp.numPairs > 0)) { charHdl[connHandleIdx] = BUILD_UINT16(pMsg->msg.readByTypeRsp.pDataList[0], pMsg->msg.readByTypeRsp.pDataList[1]); print_string("Simple Svc Found\r\n"); LCD_WRITE_STRING("Simple Svc Found", LCD_PAGE2); procedureInProgress = FALSE; } discState = BLE_DISC_STATE_IDLE; } }
Devil Sunny:
回复 chao xie:
你好,请问你的问题解决了么?我在修改主机例程时也遇到了同样的问题。
另外,我修改了CHAR1的特征值大小为20个字节,在主机读取CHAR1的特征值的时候发现只有第一个字符是对的(从机广播的CHAR1也相应修改了),请问这是什么原因?