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.

CC2564C: error and help needed on RSSI API

Part Number: CC2564C

HI everybody , 

I m trying to use  Stack API   HCI_Read_RSSI  to get  RSSI  in a BLE conncetion 

 

L’API  is like that   :    

BTPSAPI_DECLARATION int BTPSAPI HCI_Read_RSSI(unsigned int BluetoothStackID, Word_t Connection_Handle, Byte_t *StatusResult, Word_t *Connection_HandleResult, SByte_t *RSSIResult);

it needs a connection Handle  , and I m using Connecion ID got during connection  with the event    etGATT_Connection_Device_Connection

 now  we get all the times   a constant value  = 81    no matter  distance , between devices  etc  

please am I wrong ?  wat is the proper command to get  the RSSI ?

I cannot find any example on web or e2e 

thank you 

BR
Carlo

  • Hi Carlo,

    Are you saying the return value of this function is 81? This function is likely returning an error. See the declaration below:

     /*! @brief The following function issues the HCI_Read_RSSI Command to the
        * Bluetooth Device that is associated with the Bluetooth Protocol
        * Stack specified by the BluetoothStackID parameter.
        * @param BluetoothStackID Unique identifier assigned to this Bluetooth
        * Protocol Stack via a call to BSC_Initialize
        * @param Connection_Handle Unique identifier for the connection returned
        * in the Connection Complete event associated with the HCI_Create_Connection command.
        * @param StatusResult Returned HCI status code.
        * @param Connection_HandleResult Unique identifier for the connection
        * handle for which the operation was done.
        * @param RSSIResult Difference between the measured RSSI and the limits
        * of the Golden Receive Power Range.  This value may range from
        * -28 to +27 dB.
        * @return This function returns zero if successful, or a non-zero value if there was an
        * error.  If this function returns zero (success) then the
        * StatusResult variable will contain the Status Result returned from
        * the Bluetooth Device AND the Connection_HandleResult variable will
        * contain the Connection Handle Result returned from the Bluetooth
        * Device AND the RSSIResult variable will contain the RSSI Result
        * returned from the Bluetooth Device.
        * \note This function blocks until either a result is returned
        *          from the Bluetooth Device OR the function Times Out
        *          Waiting for a response from the Bluetooth Device.
        */
    BTPSAPI_DECLARATION int BTPSAPI HCI_Read_RSSI(unsigned int BluetoothStackID, Word_t Connection_Handle, Byte_t *StatusResult, Word_t *Connection_HandleResult, SByte_t *RSSIResult);

    Can you clarify if this 81 you see is the RSSIResult or the return value from HCI_Read_RSSI?

    Thanks,
    Jacob

  • Also, I think the Connection Handle is supposed to use data from this event:

       /*! The following structure represents the Data that is associated
        * with the HCI Connection Complete Event.
        */
    typedef struct _tagHCI_Connection_Complete_Event_Data_t
    {
       Byte_t    Status;
       Word_t    Connection_Handle;
       BD_ADDR_t BD_ADDR;
       Byte_t    Link_Type;
       Byte_t    Encryption_Mode;
    } HCI_Connection_Complete_Event_Data_t;

    Best regards,

    Jacob

  • Hi Jacob , 

    more details coudl you kindly help ?

    I read from  HCI_Read_RSSI  always  81   as RSSI NOT as error ....81 is RSSI  alwasy fixed 

    As connection handel  we used the one from the strcut

    typedef struct _tagHCI_Connection_Complete_Event_Data_t

    {

       Byte_t    Status;

       Word_t    Connection_Handle;

       BD_ADDR_t BD_ADDR;

       Byte_t    Link_Type;

       Byte_t    Encryption_Mode;

    } HCI_Connection_Complete_Event_Data_t;

     

    Now  trying to get it in the event   etConnection_Complete_Event, -> but this never happens  when you start a connection  

    It starts only  when you have a BT audio not on BLE connection

    Now  since no  able to get a connection handle  we used GAP_Query_Connection_Handle()    to see  active connection   but here always same error  BTPS_ERROR_DEVICE_NOT_CONNECTED  (-98)

     

    what can we do ?  thank you 

    BR

    Carlo

  • Hi Carlo,

    So you are using the Connection_Handle from _tagHCI_Connection_Complete_Event_Data_tWhy are you trying to use the etConnection_Complete_Event

    If you received an 81 from HCI_Read_RSSI, that is an error. That error in BTErrors.h refers to:

    ```#define BTPS_ERROR_RFCOMM_COMMAND_NOT_ALLOWED                   (-81)```
      

    The RSSIResult variable will contain the actual RSSI value from the Bluetooth device.

    Can you confirm with me that you are using Connection_Handle from _tagHCI_Connection_Complete_Event_Data_t?

    Thanks,
    Jacob

  • Hi Jacob,

    there is a misunderstanding, i'll try to clarify.

    1) we use:

    retval = HCI_Read_RSSI(BluetoothStackID, Connection_Handle, StatusResult, Connection_HandleResult, RSSIResult);

    retval is OK

    RSSIResult = -81 (fixed at every call)

    2) the _tagHCI_Connection_Complete_Event_Data_t is reported by the event etConnection_Complete_Event right ?

    Inside the event etConnection_Complete_Event, we catch the Connection_Handle, to be used with  HCI_Read_RSSI.

    the problem is that when the BLE device is connecting we never reveice the event tConnection_Complete_Event.

    We receive the event tConnection_Complete_Event only when we connect a BT EDR device.

    Is now more clear the situation ? so the problem could be why we are not receiveing the event tConnection_Complete_Event ?

  • Hi Paolo,

    Thanks for the clarification. I'll double check these points and follow up with you by Friday.

    Thanks,

    Jacob

  • Hi Paolo,

    A few things:

    1. Make sure the support LE is enabled in your project:

    You should add this in your predefined symbols in CCS compiler build settings.

    2. Ensure that you are able to connect to a BLE device. You should be getting a GAP_LE_Event_Callback with an event "etLE_Connection_ Complete."

    3. Are you calling HCI_Read_RSSI only after you connect to the device?

    Thanks,

    Jacob

  • Hi Jacob,

    1) Yes, __SUPPORT_LOW_ENERGY__ is enabled because we use to connect to BLE devices

    2) Yes, we are able to connect to devices and we receive the evt etLE_Connection_ Complete inside GAP_LE_Event_Callback

    3) We ask HCI_Read_RSSI only when connection is established, the problem is which Handle to use for calling HCI_Read_RSSI. As said before the problem is that when the BLE device is connecting we never reveice the event tConnection_Complete_Event, we receive this evet only if we connect to a BT EDR device, do you know the reason ?

    thanks,

    Paolo

  • Hey Paolo,

    I think we will need to take BT FW logs at this point. Can you take logs following this document?

    Thank you,
    Jacob

  • Hi Jacob,

    thanks, at the moment we are in holidays, we will do as soon we will be back to the office.

    regards,

    Paolo

  • Hi Jacob,

    we are back from holidays, and we were able to do test you asked, taking the BT log.

    When we connect to our BLE device we still do not receive the evt -> etConnection_Complete_Event
    So we are using the API -> GAP_Query_Connection_Handle() obtaining the error: BTPS_ERROR_DEVICE_NOT_CONNECTED

    We did the test twice, one time without swapping the MAC address of the BLE device before calling the GAP_Query_Connection_Handle, and a second time swapping it, having always the same error.

    How i can share with you the log files and the configuration used? It seems i'm not able to upload here the file collected.

    Thank you

    Best regards,

    Paolo

  • Hi Paolo 

    please share with me  offline 

    thanks 

    Carlo

  • Hi Paolo,

    I received your files and will take a look at them and reply to you tomorrow.

    Best regards,

    Jacob

  • Hi Paolo,

    I've looked at your logs and I do not immediately see any errors. I'll investigate further next week and get back to you on Monday.

    Thanks,
    Jacob

  • Hi Paolo,

    For successful BLE connection, you should be seeing the etLE_Connection_Complete and etGATT_Connection_Device_Connection events (please disregard the red circles).

    I'm not seeing these in your logs. You said earlier that you are able to see the etLE_Connection_Complete event from the GAP_LE_Event_Callback, is this still the case? I think your device is not actually establishing a connection. 

    Thanks,

    Jacob

  • Hi Jacob,

    as already described the device is able to establish a connection, and you should be able to see inside your log that the device is communication over LE with the peripheral connected (even if you do not see the connection and i do not understand why)

    I can confirm that we receive the evt etLE_Connection_Complete and also the evt etGATT_Connection_Device_Connection.

    I repeat that when we connect to our BLE device we still do not receive the evt -> etConnection_Complete_Event -> and we receive this event only when a BT EDR connection is established.
    So we are using the API -> GAP_Query_Connection_Handle() to obtain the right handle to use for the RSSI API but we obtain the error: BTPS_ERROR_DEVICE_NOT_CONNECTED

    Can you provide some information on GAP_Query_Connection_Handle() ?

    Please can you tell us if some specifics settings has to be set into the BT logger in order to permit to you to see the events received and/or about the execution of GAP_Query_Connection_Handle() ?

    thanks,

    best regards,

    Paolo

  • Hi Paolo,

    I need to reach out to another expert on the team for this one. Please give me another day to get back to you.

    Thanks,
    Jacob

  • HI Paolo,

    The HCI_Read_RSSI should be able to process a BLE connection handle you provide. The next step is for me to test this on my end. We have a holiday here in the US (9/6). After the holiday, I will return to work on this issue and will provide you a response next Thursday.

    Thanks,
    Jacob

  • Hi Paolo,

    I was able to reproduce your issue and am still trying to resolve it. The GAP_Query_Connection_Handle() should be the correct function to use to retrieve a connection handle for HCI_Read_RSSI. 

    I know you are able to connect your device with a BLE connection, but are you also able to pair it? 

    Thanks,
    Jacob

  • Hi Jacob,

    The fact you are able to reproduce it is a good news.

    Yes, we are able to connect and communicate with our BLE devices, but we do not use pairing or security mode at this stage.

    Thanks,

    Paolo

  • Hi Paolo,

    I tested the HCI_Read_RSSI API by providing the connection handle from GAP_Query_Connection_Handle. I receive an error when I have a BLE connection, but not when I have a BT connection. 

    I think the HCI_Read_RSSI API may only work for BT connections. Can you use BLE scanning to retrieve RSSI instead?

    Thanks,
    Jacob

  • Hi Jacob,

    that was also our suspect, i think that is good that also on your side yuo are seeing the same problems, and it means that we are doing the right operations and configuration.

    At the moment we are already collecting the RSSI of the BLE device before the connection establishment when the BLE device is in advertising phase, but unfortunately our customer need to collect the RSSI also during the connection life.

    Can you verifty if it is possible or not ?

    Thanks,

    Paolo

  • Hi Paolo,

    I do not have the hardware setup in front of me now, but I can check this for you tomorrow. 

    I'll follow up with you here shortly.

    Best regards,
    Jacob

  • Hi Paolo,

    Good news! After digging through the stack some more, I found the API you need:

    GAP_LE_Query_Connection_Handle(unsigned int BluetoothStackID, BD_ADDR_t BD_ADDR, Word_t *Connection_Handle);
    This API can be found in GAPAPI.h and gives a BLE connection handle to provide to HCI_Read_RSSI. I verified this works for me. Very sorry this took me so long to find!
    Thanks,
    Jacob
  • Hi Jacob,

    I can confirm that this API solve, and now we are able to obtain the RSSI also during the BLE connection with ours devices.

    Very good! Thank you very much for the support provided.

    Paolo