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.

CC2640R2L: Read the RSSI for a Tx Tone.

Part Number: CC2640R2L

Hi

I am trying to read the RSSI of a Tx tone on an intended channel. The setup consists of two boards one emits a Tx tone on a intended channel and on the other device Rx Tone Command is set on the same channel and after calling the Rx Tone command I call HCI_ReadRSSI( ), but this api always returns value 0.

Also I receive the RSSI of the scanned beacon under GAP_DEVICE_INFO event, but for finding the RSSI of the Tx tone this event can't be used.

Any suggestions for how to read the RSSI of the Tx tone on any intended channel.

Regards

Sudhanshu 

  • Hi Sudhanshu,

    You may want to review the simple_central example. This example shows how to measure RSSI of incoming packets.

    As you will see, the command HCI_ReadRssiCmd() is first issued. Then, you receive a HCI_GAP_EVENT_EVENT from the stack with the status HCI_COMMAND_COMPLETE_EVENT_CODE an the opCode HCI_READ_RSSI. There you get the value of the RSSI.

    I hope this will help,

    Best regards,

  • Hi Clement

    Will this work with Tx tone on Device 1 and Rx tone on device 2 and then I will call HCI_ReadRssi() ?

    According to me this event only gets raised when a beacon is received. Correct me if I am wrong.

    Regards

    Sudhanshu

  • Hi Sudhanshu,

    Could you specify what you mean by "tone"? Is it a BLE packet exchanged by devices in a connection?

    Regards,

  • Hi Clement

    I use HCI_EXT_ModemTestTxCmd( HCI_EXT_TX_MODULATED_CARRIER, 1 ) api to generate tone on the specific channel. 

    Meanwhile on the same channel I start ModemTestRxCmd on the other device.

    At this point I need to fetch the RSSI.

    Regards

    Sudhanshu

  • Hi,

    I guess you are looking for HCI_EXT_ModemTestRxCmd().

    Best regards,

  • Hi

    I guess you mis understood my scenario.

    On device 1 I initiate  HCI_EXT_ModemTestTxCmd() on a specific channel i.e. channel 1. Meanwhile I call HCI_EXT_ModemTestRxCmd() on device 2 on the same channel i.e. channel 1.

    Now I want to read the RSSI of received signal on device 2. So I call HCI_ReadRSSI(). But it always returns 0.

    Regards

    Sudhanshu

  • Hi Sudhanshu,

    As mentioned in the documentation I linked you to, the function HCI_ReadRssiCmd should be used to read the RSSI. The HCI_GAP_EVENT_EVENT is from the stack with the status HCI_COMMAND_COMPLETE_EVENT_CODE and the opCode HCI_READ_RSSI. There you get the value of the RSSI.

    Regards,

  • Hi

    Under HCI_GAP_EVENT_EVENT  do i need to access the rssis by ( pEvent->deviceInfo.rssi ) ?

    Also how do I use opcode HCI_READ_RSSI to fetch the value?

    case HCI_GAP_EVENT_EVENT:
        {
          switch( pMsg->status )
          {
            case HCI_BLE_HARDWARE_ERROR_EVENT_CODE:
            {
              AssertHandler( HAL_ASSERT_CAUSE_HARDWARE_ERROR,
                             0u );
            }
            break;
          case HCI_COMMAND_COMPLETE_EVENT_CODE:
            /* Fetch the rssi with opcode HCI_READ_RSSI */
            
           // HCI_READ_RSSI;
            
            break;
            default:
            {
              ; /* Do Nothing */
            }
            break;

    Regards 

    Sudhanshu

  • Hi,

    Please review our simple_peripheral example. In out example, the HCI_COMMAND_COMPLETE_EVENT_CODE are handled using the function SimplePeripheral_processCmdCompleteEvt().

        case HCI_GAP_EVENT_EVENT:
        {
          // Process HCI message
          switch(pMsg->status)
          {
            case HCI_COMMAND_COMPLETE_EVENT_CODE:
            // Process HCI Command Complete Events here
            {
              SimplePeripheral_processCmdCompleteEvt((hciEvt_CmdComplete_t *) pMsg);
              break;
            }
    
    
    
    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){
            //...
          } // end of if (status == SUCCESS)
          break;
        }
    
        //...
    
        default:
          break;
      } // end of switch (pMsg->cmdOpcode)
    }

    I hope this will help,

    Regards,

  • Hi

    int8 rssi = (int8)pMsg->pReturnParam[3];

    What does the index 3 signify?

    The above code always returns the value 0, before calling HCI_ReadRssi() I call  HCI_EXT_ModemTestRxCmd() .

    Regards

    Sudhanshu

  • Hi,

    Just to be sure, since the beginning you have been mentioning the function "HCI_ReadRssi()". The proper function to use should rather be "HCI_ReadRssiCmd".

    Regards,

  • Hi

    Apologies for mis typing.

    I am calling HCI_ReadRssiCmd() only and at opcode HCI_READ_RSSI breakpoint is also getting hit . But the value which I am getting is always 0.

    Regards

    Sudhanshu

  • Hi,

    Thank you for the clarification.

    When you hit the breakpoint for the HCI_READ_RSSI, could you verify if other value are inside the buffer pointed by pMsg->pReturnParam. It would also be nice to verify if the status returned is correct (it should be in pMsg->pReturnParam[0]). 

    Regards,

  • Hi

    The returned status that i am getting is 0x02 and the RSSI value is 0.

    02 00 00 00 24 00 00 00 - This is what I am getting in pMsg->pReturnParameters.

    Am I commiting any mistake?

    Regards 

    Sudhanshu

  • Hi,

    It looks like the stack returns an error code corresponding to HCI_ERROR_CODE_UNKNOWN_CONN_ID.

    Could you provide a code snippet showing how you are calling HCI_ReadRssiCmd()? In addition, are there some connections established? Is the device in test mode? Do you grant some time to the stack to "enable"  the HCI_EXT_ModemTestRxCmd() before starting the HCI_ReadRssiCmd() ?

    Regards,

  • Hi

    There are no connection established while reading the RSSI, however my device is in continuous scanning mode. No my device is not in test mode.

    Yes I provide some delay between HCI_EXT_ModemTestRxCmd() and HCI_ReadRssiCmd().

    static eMfgErrType RxToneEnbl( StructData * pMsg )
    {
      eMfgErrType Status = eInvalidCmd;
      hciStatus_t TestStatus = FALSE;
      tUI8 ChnlNo = pMsg->pData[ 3 ];
      if( ChnlNo <= 39u )
      {
        TestStatus = HCI_EXT_ModemTestRxCmd( ChnlNo );/* Channel 0 - to be a part of command */
        if( TestStatus == HCI_SUCCESS )
        {
          memcpy( pMsg->pData, TstPass, cSizeOfRsp );
          pMsg->Len = ( cSizeOfRsp - cDataOffset );
          Status = eSuccess;
        }
        else
        {
          Status = eFailure;
        }
      }
      else
      {
         /* Invalid command */
      }
      return Status; 
    }
    /* ------------------------------------------------------------------------ */
    static eMfgErrType ReadRssi( StructData * pMsg )
    {
      eMfgErrType Status = eInvalidCmd; 
      tUI8 RssiVal = 0;
      HCI_ReadRssiCmd( 0 );
      RssiVal = FetchRSSI_g( );
    
      memcpy( pMsg->pData, &RspnsBuff, cSizeOfRstCntBuff );
      pMsg->Len = cSizeOfRssi + cSizeOfStatus;
      Status = eSuccess;
      return Status;  
    
    }

    PFA code snippet.

    My fetch RSSI function fetches the RSSI value from my SimpleCentral.c.

    Regards

    Sudhanshu 

  • Hi Sudhanshu,

    The HCI_EXT_ModemTestRxCmd() command should only be used while in test mode.

    In addition the parameter passed to the function HCI_ReadRssiCmd() is supposed to be a connection handle. These two elements are probably explaining your issue.

    Maybe we can find together a better way to achieve what you need. Do you want to give us some details on your use case?

    Best regards,

  • Hi Clement

    Can you share some documents regarding test mode i.e. how to use it.

    My use case is as follows

    My device will be working in central mode. So during production manufacturing I need to test my Tx and Rx of my BLE module.

    The method which I planned is My device 1 will start with HCI_EXT_ModemTestTxCmd() on a fixed channel say channel 20.

    Simultaneously my device 2( configured as simple central only ) will call HCI_EXT_ModemTestRxCmd() and after some delay, I'll call HCI_ReadRssiCmd() .

    If the Rssi comes in desired range, I'll pass the test or else the test will get failed.

    The same process will get repeated after interchanging the funtions of device 1 and device 2 . This way I can check my Tx and Rx are working fine or not.

    Since my device can't advertise so I planned this method.

    Can you suggest some other method to test my Tx and Rx of RF during production of my device configured as simple central.

    Regards 

    Sudhanshu

  • Hi Sudhanshu,

    Thank you for the details provided. So I guess you should have a look to our Production Test Mode feature (you can start here). There is also quite a lot of resources on E2E (such as this page).

    I hope this will help,

    Regards,