Part Number:CC2642R
我使用的例程是simple_peripheral_oad_offchip,如何获取RSSI呢?
是否使用这个API?
hciStatus_t HCI_ReadRssiCmd( uint16 connHandle );
应该在哪个函数里使用呢?
我尝试用如下方式获取RSSI,但是pReport->lastRssi打印为0,不知如何操作。求教!
Nick Sun:
您好,
收到您的问题了,我们升级到英文论坛给工程师看下,有答复尽快给到您。
,
Nick Sun:
您好,
调用HCI_ReadRssiCmd API 不会立即返回请求的数据。API 将触发一个 HCI 命令,该命令将由堆栈处理并注册返回( registered callback)应用层。
simple_peripheral 示例为我们设置了这一点,请参阅下面的代码,在 case HCI_READ_RSSI 里找到相关RSSI内容。
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){uint16_t handle = BUILD_UINT16(pMsg->pReturnParam[1], pMsg->pReturnParam[2]);uint8_t index = SimplePeripheral_getConnIndex(handle);if (index >= MAX_NUM_BLE_CONNS){Display_printf(dispHandle, SP_ROW_STATUS_1, 0, "Connection handle is not in the connList !!!");return;}if (rssi != LL_RSSI_NOT_AVAILABLE){connList[index].rssiArr[connList[index].rssiCntr++] = rssi;connList[index].rssiCntr %= SP_MAX_RSSI_STORE_DEPTH;希望可以帮助到您。
,
zhenhua He:
我参照simple_peripheral 示例改了程序。但获取到的RSSI是127,这个值正常吗?总感觉不对啊。一般区间是多少呢?
,
Nick Sun:
您好,
RSSI127意思是 LL_RSSI_NOT_AVAILABLE。您在调用 HCI_ReadRssiCmd 时,BLE是否是在主动连接中(active BLE connection)?