This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我使用的例程是simple_peripheral_oad_offchip,如何获取RSSI呢?
是否使用这个API?
hciStatus_t HCI_ReadRssiCmd( uint16 connHandle );
应该在哪个函数里使用呢?
我尝试用如下方式获取RSSI,但是pReport->lastRssi打印为0,不知如何操作。求教!
您好,
调用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 for switch (pMsg->cmdOpcode) { case HCI_READ_RSSI: { int8 rssi = (int8)pMsg->pReturnParam[3]; // Display RSSI value, if RSSI is higher than threshold, change to faster PHY if (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;
希望可以帮助到您。
您好,
RSSI127意思是 LL_RSSI_NOT_AVAILABLE。您在调用 HCI_ReadRssiCmd 时,BLE是否是在主动连接中(active BLE connection)?