从机CC2640使能notify问题
时间:10-02
整理:3721RD
点击:
我使用主机CC2541发送使能notify消息给从机CC2640,但是在从机CC2640上没办法进入这个部分
case GATT_CLIENT_CHAR_CFG_UUID: status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len, offset, GATT_CLIENT_CFG_NOTIFY );
我用手机试验过CC2640能正常的接收和处理使能notify消息
以下是我的CC2541查找及连接的部分
查找服务:GATT_DiscPrimaryServiceByUUID( simpleBLEConnHandle, uuid, ATT_BT_UUID_SIZE, simpleBLETaskId );
获取句柄
static void simpleBLEGATTDiscoveryEvent( gattMsgEvent_t *pMsg ) { if( simpleBLEDiscState == BLE_DISC_STATE_SVC ) { // Service found, store handles if(( pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP) && (pMsg->msg.findByTypeValueRsp.numInfo > 0)) {simpleBLESvcStartHdl = pMsg->msg.findByTypeValueRsp.handlesInfo[0].handle;simpleBLESvcEndHdl = pMsg->msg.findByTypeValueRsp.handlesInfo[0].grpEndHandle; } // If procedure complete if(( pMsg->method == ATT_FIND_BY_TYPE_VALUE_RSP && pMsg->hdr.status == bleProcedureComplete )||( pMsg->method == ATT_ERROR_RSP ) ) { // if ( simpleBLESvcStartHdl != 0 ){ simpleBLEDiscState = BLE_DISC_STATE_CHAR; GATT_DiscAllChars(simpleBLEConnHandle,simpleBLESvcStartHdl,simpleBLESvcEndHdl,simpleBLETaskId); } } } else if( simpleBLEDiscState == BLE_DISC_STATE_CHAR ) { // Characteristic found, store handle if ( pMsg->method == ATT_READ_BY_TYPE_RSP && pMsg->msg.readByTypeRsp.numPairs > 0 ) { //find all simpleBLECharHdl[0] = BUILD_UINT16( pMsg->msg.readByTypeRsp.dataList[3],pMsg->msg.readByTypeRsp.dataList[4]); simpleBLECharHdl[1] = BUILD_UINT16( pMsg->msg.readByTypeRsp.dataList[10],pMsg->msg.readByTypeRsp.dataList[11]); CentralConfig(); osal_set_event( simpleBLETaskId, CEN_DATA_SEND_EVT ); HalUARTWrite( 0, pMsg->msg.readByTypeRsp.dataList,ATT_MTU_SIZE-2); } else { osal_start_timerEx( simpleBLETaskId, CEN_START_DISCOVERY_EVT, DEFAULT_SVC_DISCOVERY_DELAY ); } simpleBLEDiscState = BLE_DISC_STATE_IDLE; }
其中simpleBLECharHdl[1]为从机2640通道2的句柄(对应notify通道)
CentralConfig()为发送notify使能消息
static uint8 CentralConfig(void) { attWriteReq_t writeReq; uint8 state; writeReq.len = 2; writeReq.value[0] = LO_UINT16(GATT_CLIENT_CFG_NOTIFY); writeReq.value[1] = HI_UINT16(GATT_CLIENT_CFG_NOTIFY); writeReq.sig = 0; writeReq.cmd = 0; writeReq.handle = simpleBLECharHdl[1]; state = GATT_WriteCharValue(simpleBLEConnHandle, &writeReq, simpleBLETaskId); return(state); }
麻烦TI的大神们帮我看看哪里有问题,为什么无法使能CC2640的notify功能?谢谢