如上圖:
代碼:
else?if?(?centralDiscState?==?BLE_DISC_STATE_CHAR?) ??{ ????//?Characteristic?found,?store?handle ????if?(?pMsg->method?==?ATT_READ_BY_TYPE_RSP?&&? ?????????pMsg->msg.readByTypeRsp.numPairs?>?0?) ????{ ??????centralCharHdl?=?BUILD_UINT16(?pMsg->msg.readByTypeRsp.pDataList[0], ???????????????????????????????????????pMsg->msg.readByTypeRsp.pDataList[1]?); ??????centralProcedureInProgress?=?FALSE; ?????? ??????//?Start?do?read?or?write ??????tmos_start_task(?centralTaskId,?START_READ_OR_WRITE_EVT,?DEFAULT_READ_OR_WRITE_DELAY); ?????? ??????//?Display?Characteristic?1?handle ??????PRINT("Found?Characteristic?4?handle?:?%x?\n",centralCharHdl);???? //?Do?a?write ????????attWriteReq_t?req; ???????? ????????req.cmd?=?FALSE; ????????req.sig?=?FALSE; ????????req.handle?=?centralCharHdl+1; ????????req.len?=?2; //centralConnHandle=0; PRINT(?"222!\n"); ????????req.pValue?=?GATT_bm_alloc(centralConnHandle,ATT_WRITE_REQ,req.len,NULL,0); ????????if?(?req.pValue?!=?NULL?) ????????{ ??????????req.pValue[0]?=?0x01; req.pValue[1]?=?0x00; ??????????PRINT(?"333!\n"); ??????????if(?GATT_WriteCharValue(centralConnHandle,&req,centralTaskId)?==?SUCCESS?) ??????????{?????? ????????????centralProcedureInProgress?=?TRUE; PRINT(?"Open?Notify?ok!\n"); ????????????//centralDoWrite?=?!centralDoWrite; ????????????tmos_start_task(?centralTaskId,?START_READ_OR_WRITE_EVT,?DEFAULT_READ_OR_WRITE_DELAY); ??????????} ??????????else ??????????{ ????????????GATT_bm_free((gattMsg_t?*)&req,?ATT_WRITE_REQ); PRINT(?"Open?Notify?Fail!\n"); ??????????} ????????}?? ????} ????centralDiscState?=?BLE_DISC_STATE_IDLE; ??}
我用CC2541主機(jī)打開CC2541從機(jī)的char4通知使能是可以的。
用沁恒就失敗。
請(qǐng)問高手,哪里有錯(cuò)?謝謝
熱門產(chǎn)品 :
CH32X035: 32位USB+USB PD單片機(jī)