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.

CC2340R5: CC2340 get RSSI of connected device

Part Number: CC2340R5

Hii ,

       I am working with simplelink_lowpower_f3_sdk_7_20_01_10 for CC2340. I want to get RSSI of the connected Central device(Mobile or any other) with  CC2340 working as peripheral. Kindly let me know if anything available for CC2340.

Thank you

Prince Singh

  • Hi Prince Singh,

    Thank you for reaching out. We will look into this and get back to you as soon as possible. In the meantime, could you clarify which project you are using for your CC2340R5? basic_ble, datastream or some other example?

    Best Regards,

    Jan

  • Hii Jan,

                I am using Basic_BLE example

    Thank you

    Prince Singh

  • Prince,

    In order to get get RSSI of the connected Central device with CC2340 working as the peripheral, I would recommend you utilize the "HCI_ReadRssiCmd()" function which you can find more detail on in the HCI Section of the TI BLE5-Stack API Documentation. For a detailed usage section describing how to send these commands and receive events, see the HCI Section of the User's Guide as well.

    Thanks,

    Luke

  • Hii Luke,

                  can you describe how can i use this "HCI_ReadRssiCmd()". for this SDK version.

    Thank you

    Prince

  • Prince, 

    Check out this similar thread on getting the RSSI and other data for the CC2340R5. As mentioned in this thread, I would suggest looking at our SimpleLink Academy training material here on Scanning and Advertising. Make sure to enable the BLEAPPUTIL_ADV_REPORT flag and read the report values at that gap event inside the Central_ScanEventHandler() function. The section about "Scanning Task 2 – Print Scanning Results" provides a good example of how to do this. As you can see in the image below, rssiI is included as part of the information received during a scan.

    You also have the User Guide here to review this as well. Let me know if this is more useful!

    Thanks,

    Luke

  • Hi Luke,

                  I want to read RSSI of the connected central and my device is working as peripheral.

    Thank you

  • Prince, 

    The procedure to read RSSI and process the command complete event is the same on Central and Peripheral. In order to use the HCI_ReadRssiCmd() function, you need to know the Connection handle (which should be known to you) to pass as the argument, as shown in the API guide. After the function is called upon, the hciEvt_CmdComplete_t event will be processed by the Event Handler and will contain the cmdOpcode HCI_READ_RSSI and the pReturnParam pointer to the actual RSSI value.

    I would recommend creating another EventHandler struct as found in the "app_connection.c" file in the basic_ble project and also creating another function to handle connection related events that rise from the GAP and were registered in the BLEAppUtil_registerEventHandler, similar to Connection_ConnEventHandler(). This function can call HCI_ReadRssiCmd() and toggle an LED to help debug as well. 

    Thanks,

    Luke

  • HI Luke,

                   i am using HCI_ReadRssiCmd in SimpleGattProfile_writeAttrCB(). Means whenever central makes any change in characteristics of peripheral this HCI_ReadRssiCmd() will  be called but the controller gets reset whenever this HCI_ReadRssiCmd() function is called.

    as per the description  If the Receiver Modem test is running (HCI_EXT_ModemTestRxCmd ), then the RF RSSI for the last received data will be returned. But i want RSSI in runtime.

    Thanks,

    Princve

  • Prince,

    Thanks for clarifying what you are attempting to do! I'm not sure how I didn't come across this sooner for you, but I was able to find a thread with detailed steps on how to implement a reading of the RSSI value on each connection event in runtime as you requested. Follow through with this thread and you should be able to implement an easier version of attaining the RSSI value as opposed to using the Receiver Modem test function. 

    If you need any additional support following these steps, please let me know!

    Thanks,

    Luke

  •  Hii,

          I have cheked and found that in task.c there is an event case case BLEAPPUTIL_EVT_CONN_EVENT_CB and inside that event BLEAppUtil_processConnEventMsg(pMsgData); function is called in which case GAP_CB_CONN_EVENT_ALL: is used 

    void BLEAppUtil_processConnEventMsg(BLEAppUtil_msgHdr_t *pMsg)
    {
        Gap_ConnEventRpt_t * pMsgData = (Gap_ConnEventRpt_t *)pMsg;
        uint32_t event = 0;
    
        switch(pMsgData->eventType)
        {
            case GAP_CB_EVENT_INVALID:
            {
                event = BLEAPPUTIL_CONN_NOTI_EVENT_INVALID;
                break;
            }
    
            case GAP_CB_CONN_ESTABLISHED:
            {
                event = BLEAPPUTIL_CONN_NOTI_CONN_ESTABLISHED;
                break;
            }
    
            case GAP_CB_PHY_UPDATE:
            {
                event = BLEAPPUTIL_CONN_NOTI_PHY_UPDATE;
                break;
            }
    
            case GAP_CB_CONN_EVENT_ALL:
            {
                event = BLEAPPUTIL_CONN_NOTI_CONN_EVENT_ALL;
                int8_t rssi = pMsgData->lastRssi;
                break;
            }
    
            default:
            {
                break;
            }
        }
    
        // Pass the event and msg to BLEAppUtil_callEventHandler which calls the
        // handler of the application
        BLEAppUtil_callEventHandler(event ,pMsg, BLEAPPUTIL_CONN_NOTI_TYPE);
    }

    i have used the breakpoint at this ca se but in no case compiler hitting the breakpoint i have added   int8_t rssi = pMsgData->lastRssi; . And the events are alredy defined so i did not added any event .

    Thank you

    Prince Singh

  • Prince, 

    I am going to tie in someone on my team who may be able to assist with handling the error you are seeing and the issue with reading the RSSI in runtime a bit better. Just as a heads up, they are based out of Oslo so there may be a slight delay in the next response. Expect to hear back within the next 24-48 hours and let me know if there are any other questions in the meantime!

    Thanks,

    Luke

  • Prince,

    Upon review of your previous message with the included screenshots, it seems you are not properly enabling the connection-event callback. Take a look at the Connection Event Callback section here in the BLE5-Stack User's Guide. It details the correct functions to obtain a detailed report of the entire connection event right after the end of the connection event. One of the listed parameters in this returned report is:

    • lastRssi - The RSSI value measured on the last packet of the most recent connection event.

    To enable the application layer to receive connection report, you can use Gap_RegisterConnEventCb(). The following code is an example of how to register connection event report for all types of event within certain connection.

    // Assuming connHandle was assigned when the connection established.
    uint16_t connHandle;
    
    Gap_RegisterConnEventCb(application_connEvtCB, GAP_CB_REGISTER, GAP_CB_CONN_EVENT_ALL, connHandle);

     You can then utilize the HCI_ReadRssiCmd() function passing in 'connHandle' to have the RSSI of the last connection packet reported specifically. 

    Thanks,

    Luke