用Util_constructClock设置了周期性地Read Rssi,在SimplePeripheral_clockHandler中调用HCI_ReadRssiCmd且返回SUCCESS,但是却无法在SimplePeripheral_processCmdCompleteEvt中收到HCI_READ_RSSI完成的消息。
如果换成在收到GAP_LINK_ESTABLISHED_EVENT事件时发送HCI_ReadRssiCmd,能够正常响应,但是在SimplePeripheral_clockHandler中发送(此时链路已经连接完成)就无响应了,这是为什么?
Alvin Chen:
The RSSI notification event is sent after the connection event closes.
shuangcheng tu:
回复 Alvin Chen:
我一在SimplePeripheral_clockHandler中调用HCI_ReadRssiCmd,BLE就会断开,是为什么?
Alvin Chen:
回复 shuangcheng tu:
/********************************************************************** @fnSimplePeripheral_connEvtCB** @briefConnection event callback.** @param pReport pointer to connection event report*/ static void SimplePeripheral_connEvtCB(Gap_ConnEventRpt_t *pReport) {// Enqueue the event for processing in the app context.if(SimplePeripheral_enqueueMsg(SP_CONN_EVT, pReport) != SUCCESS){ICall_free(pReport);} }static void SimplePeripheral_processConnEvt(Gap_ConnEventRpt_t *pReport) {// Get index from handleuint8_t connIndex = SimplePeripheral_getConnIndex(pReport->handle);SIMPLEPERIPHERAL_ASSERT(connIndex < MAX_NUM_BLE_CONNS);// If auto phy change is enabledif (connList[connIndex].isAutoPHYEnable == TRUE){// Read the RSSIHCI_ReadRssiCmd(pReport->handle);} }static void SimplePeripheral_processCmdCompleteEvt(hciEvt_CmdComplete_t *pMsg) {uint8_t status = pMsg->pReturnParam[0];//Find which command this command complete is forswitch (pMsg->cmdOpcode){case HCI_READ_RSSI:{int8 rssi = (int8)pMsg->pReturnParam[3];// Display RSSI value, if RSSI is higher than threshold, change to faster PHYif (status == SUCCESS){你什么版本SDK?
在simplelink_cc2640r2_sdk_2_40_00_32 里面,你可以发现上面code:
你为什么要在SimplePeripheral_clockHandler 里面去调用,正常是应该在SimplePeripheral_processAppMsg处理你的定时器任务然后去发送RSSI命令。你最好参考一下上面的code。