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.

[参考译文] LAUNCHXL-CC2650:CC2650:如何获取 RSSI 值。

Guru**** 1647120 points
Other Parts Discussed in Thread: CC2650
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1287584/launchxl-cc2650-cc2650-how-can-get-rssi-values

器件型号:LAUNCHXL-CC2650
主题中讨论的其他器件:CC2650

大家好、我正在创建一个程序来使用 CC2650读取 RSSI 值。

我有两个问题。

首先、如何读取 RSSI 值?

我通常使用"EasyLink_receiveAsync"中的"lastRssi"来获得该值、但我认为我必须收到一些东西才能使用它。

如果没有收到任何数据、我就无法获取 RSSI 值、我是否必须等到收到任何数据?

其次、如果没有收到任何消息、我要终止"EasyLink_receiveASYNC"。

我该怎么办?

我使用了"EasyLink_cmdPropRxAdv.EndTime"和"EasyLink_cmdPropRxAdv.endTrigger"、但未执行下一步。

有人能告诉我吗?

达木市

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Tatsuki:

    RSSI 表示"接收信号强度指示器"、表示必须在测量该值之前接收信号。  可以在信标上挂起并调用 EasyLink_abort、以在经过预定的时间后取消异步操作。  我将使用 tirtos_cc13xx_cc26xx_2_21_01_08\examples\TI\CC2650_LAUNCHXL\rfEasyLinkRx\rfEasyLinkRx.c 作为示例:

            EasyLink_receiveAsync(rxDoneCb, 0);
    
            /* Wait 300ms for Rx */
            if(Semaphore_pend(rxDoneSem, (300000 / Clock_tickPeriod)) == FALSE)
            {
                /* RX timed out abort */
                if(EasyLink_abort() == EasyLink_Status_Success)
                {
                   /* Wait for the abort */
                   Semaphore_pend(rxDoneSem, BIOS_WAIT_FOREVER);
                }
            }

    此致、
    瑞安

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Ryan、

    感谢您的回复!

    事实上、我的程序通常会在"EasyLink_receiveASYNC_RSSI"停止。

    在哪里、shuld 我对"semaphore_pend"和"Easylnk_abort"进行编程?

    请告诉我。

    达木市

    static void NodeFunction(UArg arg0, UArg arg1)
    {
            /* Start converting. */
            if (!adcBuf){System_abort("adcBuf did not open correctly\n");}
    
            while(i<37){
    
    
                    if(ReceiveAsync==1){
                        i+=1;
                        a+=1;
                        if(i==12)
                            i+=1;
    
                        /* frequency & Clock settings */
                        EasyLink_init(i);
                        ClockTime.EndTime=RF_getCurrentTime()+10*4000;
                    }
    
                    ReceiveAsync=0;
    
                    /*receive CBeacon*/
                    if(EasyLink_receiveAsync_rssi(ADVbit,ClockTime) != EasyLink_Status_Success)
                        {System_abort("EasyLink_receive_CBeacon failed");}
                    else ReceiveAsync=1;
    
                    rssi=ADVbit.rssi;
    
                    if(ReceiveAsync==1){
    
                    usprintf_mng("channel %d(%dMHz) : %d ",a,i*2+2402,rssi);
    
                    if(rssi>-40){
                        usprintf_mng("bad\n");
                        ChM_bitArray[b]|=1<<(7-i);
                    }
                    else {
                        usprintf_mng("good\n");
                        ChM_bitArray[b]|=0<<(7-i);
                    }
    
                    if(i%7==0)
                        b+=1;
    
                    usprintf_mng("\n");
                    }
            }
    

    //rxDoneCallback_rssi
    //*****************************************************************************//
    static void rxDoneCallback_rssi(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
        EasyLink_ADVbit ADVbit;
        EasyLink_Status status = EasyLink_Status_Rx_Error;
    
        rfc_dataEntryGeneral_t *pDataEntry;
        pDataEntry = (rfc_dataEntryGeneral_t*) rxBuffer;
    
        Semaphore_post(busyMutex);
        asyncCmdHndl = EASYLINK_RF_CMD_HANDLE_INVALID;
    
    #if 1
        /*  Wait for 10ms for RX  */
        if(Semaphore_pend(busyMutex,(10000 / Clock_tickPeriod)) == FALSE){
            /*  RX timed out abort  */
            if(EasyLink_abort() == EasyLink_Status_Success){
                /*  wait for the abort  */
                Semaphore_pend(busyMutex,BIOS_WAIT_FOREVER);
            }
        }
    #endif
    
        if (e & RF_EventLastCmdDone)
        {
            if (EasyLink_cmdPropRxAdv.status == PROP_DONE_OK)
            {
                if (pDataEntry->status != DATA_ENTRY_FINISHED)
                {
                    status = EasyLink_Status_Rx_Error;
                    RF_flushCmd(h, RF_CMDHANDLE_FLUSH_ALL, 1);
                    usprintf_mng("E:%d\n",EasyLink_abort());
                }
                else if ( (rxStatistics.nRxOk == 1) ||
                         ((EasyLink_cmdPropRxAdv.pktConf.filterOp == 1) &&
                          (rxStatistics.nRxIgnored == 1)) )
                {
                    ADVbit.length = sizeof(ADVbit.ADV_bitArray);
                    memcpy(ADVbit.ADV_bitArray, (&pDataEntry->data+1), ADVbit.length);
                    ADVbit.rssi=rxStatistics.lastRssi;
                    status = EasyLink_Status_Success;
                }
                else if ( rxStatistics.nRxBufFull == 1)
                {status = EasyLink_Status_Rx_Buffer_Error;}
    
                else if ( rxStatistics.nRxStopped == 1)
                {status = EasyLink_Status_Aborted;}
    
                else
                {status = EasyLink_Status_Rx_Error;
                RF_flushCmd(h, RF_CMDHANDLE_FLUSH_ALL, 1);
                usprintf_mng("E:%d\n",EasyLink_abort());
                }
            }
            else if ( EasyLink_cmdPropRxAdv.status == PROP_DONE_RXTIMEOUT)
            {status = EasyLink_Status_Rx_Timeout;}
    
            else
            {status = EasyLink_Status_Rx_Error;
            RF_flushCmd(h, RF_CMDHANDLE_FLUSH_ALL, 1);
            usprintf_mng("E:%d\n",EasyLink_abort());
            }
    
        }
        else if ( (e == RF_EventCmdAborted) || e == RF_EventCmdStopped )
        {status = EasyLink_Status_Aborted;}
    
        if (ADVbitCb != NULL){ADVbitCb(ADVbit,status);}
        //usprintf_mng("Status:%d \n",status);
    }
    
    //EasyLink_receiveAsync_rssi
    //*****************************************************************************//
    EasyLink_Status EasyLink_receiveAsync_rssi(EasyLink_ADVbit cb,EasyLink_TimeStamp TimeStamp)
    {
    
        EasyLink_Status status = EasyLink_Status_Rx_Error;
        rfc_dataEntryGeneral_t *pDataEntry;
    
        if ( (!configured) || suspended)
        {return EasyLink_Status_Config_Error;}
    
        if (Semaphore_pend(busyMutex, 0) == FALSE)
        {return EasyLink_Status_Busy_Error;}
    
        //ADVbitCb = cb;
    
        pDataEntry = (rfc_dataEntryGeneral_t*) rxBuffer;
    
        pDataEntry->length = 1 + EASYLINK_MAX_ADDR_SIZE + EASYLINK_MAX_DATA_LENGTH;
        pDataEntry->status = 0;
        dataQueue.pCurrEntry = (uint8_t*) pDataEntry;
        dataQueue.pLastEntry = NULL;
        EasyLink_cmdPropRxAdv.pQueue = &dataQueue;               /* Set the Data Entity queue for received data */
        EasyLink_cmdPropRxAdv.pOutput = (uint8_t*)&rxStatistics;
    
        EasyLink_cmdPropRxAdv.startTrigger.triggerType = TRIG_NOW;
        EasyLink_cmdPropRxAdv.startTrigger.pastTrig = 1;
        EasyLink_cmdPropRxAdv.startTime = 0;
    
        EasyLink_cmdPropRxAdv.endTrigger.triggerType = TRIG_ABSTIME;
        EasyLink_cmdPropRxAdv.endTrigger.pastTrig = 1;
        EasyLink_cmdPropRxAdv.endTime = TimeStamp.EndTime;
    
        //Clear the Rx statistics structure
        memset(&rxStatistics, 0, sizeof(rfc_propRxOutput_t));
    
        asyncCmdHndl =RF_postCmd(rfHandle, (RF_Op*)&EasyLink_cmdPropRxAdv,
                RF_PriorityNormal, rxDoneCallback_rssi, EASYLINK_RF_EVENT_MASK_RE);
    
        if (EasyLink_CmdHandle_isValid(asyncCmdHndl))
        {status = EasyLink_Status_Success;}
    
        return status;
    }
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    EasyLink_receiveASYNC_RSSI 不是 TI-RTOS 包提供的函数。  EasyLink_receiveAsync 是在 tirtos_cc13xx_cc26xx_2_21_01_08\packages/examples\rf\EasyLink\EasyLink.c 中定义的:

    EasyLink_Status EasyLink_receiveAsync(EasyLink_ReceiveCb cb, uint32_t absTime)
    {
        EasyLink_Status status = EasyLink_Status_Rx_Error;
        rfc_dataEntryGeneral_t *pDataEntry;
    
        //Check if not configure of already an Async command being performed
        if ( (!configured) || suspended)
        {
            return EasyLink_Status_Config_Error;
        }
        //Check and take the busyMutex
        if ( (Semaphore_pend(busyMutex, 0) == FALSE) || (EasyLink_CmdHandle_isValid(asyncCmdHndl)) )
        {
            return EasyLink_Status_Busy_Error;
        }
    
        rxCb = cb;
    
        pDataEntry = (rfc_dataEntryGeneral_t*) rxBuffer;
        //data entry rx buffer includes hdr (len-1Byte), addr (max 8Bytes) and data
        pDataEntry->length = 1 + EASYLINK_MAX_ADDR_SIZE + EASYLINK_MAX_DATA_LENGTH;
        pDataEntry->status = 0;
        dataQueue.pCurrEntry = (uint8_t*) pDataEntry;
        dataQueue.pLastEntry = NULL;
        EasyLink_cmdPropRxAdv.pQueue = &dataQueue;               /* Set the Data Entity queue for received data */
        EasyLink_cmdPropRxAdv.pOutput = (uint8_t*)&rxStatistics;
    
        if (absTime != 0)
        {
            EasyLink_cmdPropRxAdv.startTrigger.triggerType = TRIG_ABSTIME;
            EasyLink_cmdPropRxAdv.startTrigger.pastTrig = 1;
            EasyLink_cmdPropRxAdv.startTime = absTime;
        }
        else
        {
            EasyLink_cmdPropRxAdv.startTrigger.triggerType = TRIG_NOW;
            EasyLink_cmdPropRxAdv.startTrigger.pastTrig = 1;
            EasyLink_cmdPropRxAdv.startTime = 0;
        }
    
        if (asyncRxTimeOut != 0)
        {
            EasyLink_cmdPropRxAdv.endTrigger.triggerType = TRIG_ABSTIME;
            EasyLink_cmdPropRxAdv.endTime = RF_getCurrentTime() + asyncRxTimeOut;
        }
        else
        {
            EasyLink_cmdPropRxAdv.endTrigger.triggerType = TRIG_NEVER;
            EasyLink_cmdPropRxAdv.endTime = 0;
        }
    
        //Clear the Rx statistics structure
        memset(&rxStatistics, 0, sizeof(rfc_propRxOutput_t));
    
        asyncCmdHndl = RF_postCmd(rfHandle, (RF_Op*)&EasyLink_cmdPropRxAdv,
                RF_PriorityNormal, rxDoneCallback, EASYLINK_RF_EVENT_MASK);
    
        if (EasyLink_CmdHandle_isValid(asyncCmdHndl))
        {
            status = EasyLink_Status_Success;
        }
    
        //busyMutex will be released in callback
    
        return status;
    }

    由于 RF_postCmd 是非阻塞式的、因此该函数应立即返回。  如我之前的代码片段所示、您应该在 RX 命令完成后立即挂起、然后再继续代码。  如果信标挂起超时、您将中止 RX 命令。

    此致、
    瑞安

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Ryan、

    感谢您的回复!

    我想继续读取 RSSI、但如果没有收到任何数据、 我的程序就被 System_abort 停止。

    抱歉、这是错误的。

    Tatsuki.

                    /*receive CBeacon*/
                    if(EasyLink_receiveAsync_rssi(ADVbit,ClockTime) != EasyLink_Status_Success)
                        {System_abort("EasyLink_receive_CBeacon failed");}