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.

CC2652R: Build a project with Connection CTE using the RTLS API based on simple_peripheral

Part Number: CC2652R
Other Parts Discussed in Thread: LAUNCHXL-CC26X2R1

Tool/software:

Hi,

I'm building my own project based on the simple_peripheral add  connection-AOA.  At first I used the HCI interface but it didn't work, Now I'm going to use the RTLSSRV api because I've seen someone implement something similar successfully.

such as: 

https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1064708/cc2642r-iq-report-event-stops-after-a-certain-amount-of-packets/3947711?tisearch=e2e-sitesearch&keymatch=RTLSSRV_ERROR_EVT#3947711 

and https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1064166/cc2642r-building-a-custom-rtls-coordinator

Here's my version:

SW: simplelink_cc13xx_cc26xx_sdk_5_40_00_40

HW: LAUNCHXL-CC26X2R1 + BOOSTXL-AOA

Here are my changes:

1. add RTLSSrv initialization function

  
  void RTLSCoordinator_rtlsSrvlMsgCb(rtlsSrv_evt_t *pRtlsSrvEvt)
{
  // Enqueue the message to switch context
    BT_PRINT(("RTLS EVENT TYPE is %02x \r\n" ,pRtlsSrvEvt->evtType));

    BT_DUMP_HEX(pRtlsSrvEvt->evtData,pRtlsSrvEvt->evtSize);

    BT_PRINT(("\r\n"));

}
  
  static void SimplePeripheral_taskFxn(UArg a0, UArg a1)
  {
  ...
  RTLSSrv_init(2);
  RTLSSrv_register(RTLSCoordinator_rtlsSrvlMsgCb);
  ...
  }

2. add BLE AOA config in .syscfg

3. when connect to target, use cmdCTERxCommand and cmdCTEEnabledCommand function.

static cmd_ack_t cmdCTERxCommand(uint8_t *s, uint16_t len, uint16_t id)
{

    BT_PRINT(("cte ENABLE ! \r\n"));

    conn_ctx_t *p_conn_ctx = mible_linkdb_get_info_by_conn_index(0);
        if(p_conn_ctx == NULL)
            return cmd_ack_invalid_param;
    BT_DUMP_HEX(p_conn_ctx->connect.peer_addr,6);
    uint8_t ant_pattern[] = {0,1,2};

#if(USE_RTLS_API)
    uint8_t ret;
    PIN_Handle status;

    status = RTLSSrv_initAntArray(ant_pattern[0]);

    if(status == NULL)
    {
         BT_PRINT(("set ant array error !"));
    }

    ret = RTLSSrv_setConnCteReceiveParams(p_conn_ctx->conn_handle,1,2,sizeof(ant_pattern),ant_pattern);
    if(ret!= 0)
    {
         BT_PRINT(("set cte parms error !"));
    }

    ret = RTLSSrv_setCteSampleAccuracy(p_conn_ctx->conn_handle,1,1,1,1,0x11);

     if(ret!= 0)
     {
          BT_PRINT(("set sample accuracy error !"));
     }
#else
 uint8_t ret = HCI_LE_SetConnectionCteReceiveParamsCmd(p_conn_ctx->conn_handle,1,2,sizeof(ant_pattern),ant_pattern);
    /*Configure AoA receiver parameters */

   if(ret!= 0)
   {
        BT_PRINT(("cte config error !"));
   }
   else
    {
        BT_PRINT(("cte config ok ! \r\n"));
    }
#endif
    BT_PRINT(("end,ok,return !"));
    return cmd_ack_ok;
}

static cmd_ack_t cmdCTEEnabledCommand(uint8_t *s, uint16_t len, uint16_t id)
{
    conn_ctx_t *p_conn_ctx = mible_linkdb_get_info_by_conn_index(0);
    if(p_conn_ctx == NULL)
        return cmd_ack_invalid_param;
    BT_DUMP_HEX(p_conn_ctx->connect.peer_addr,6);

#if(USE_RTLS_API)

    uint8_t ret = RTLSSrv_setConnCteRequestEnableCmd(p_conn_ctx->conn_handle,
                                       1,
                                       2,
                                       10,
                                       0);
    if(ret!= 0)
    {
         BT_PRINT(("set cte enable error !"));
    }
#else
    uint8_t ret = HCI_LE_SetConnectionCteRequestEnableCmd(p_conn_ctx->conn_handle,1,2,10,0);

   if(ret!= 0)
   {
        BT_PRINT(("cte request error !"));
   }
   else
   {
        BT_PRINT(("cte request enabled !"));
   }

#endif
    return cmd_ack_ok;
}

Here are some logs when it works:

[13:41:58.029]发→◇AT+CTE_RX
□
[13:41:58.032]收←◆cte ENABLE ! 
EB F2 E3 92 C6 84 end,ok,return !
OK
 MSG Event type is 91 !!!!  
 hci message is FF

[13:42:02.980]发→◇AT+CTE_ENABLE
□
[13:42:02.983]收←◆EB F2 E3 92 C6 84 RTLS EVENT TYPE is 04 
00 00 56 20 1A 00 

OK

when cmdCTEEnabledCommand  works, RTLSCoordinator_rtlsSrvlMsgCb will throws an  

RTLSSRV_ERROR_EVT(0x04) event, error reason is RTLSSRV_REMOTE_FEATURE_NOT_SUPPORTED (0x1A),I do not know the specific reason for this error and how to solve it.
  • Hi,

    Thank you for reaching out.

    Several issues have been fixed since the release of the SDK you are using. Please consider migrating to the newest SDK available - 7.41.00.17 as of today. 

    Best regards,

  • Hi,

    Do you mean the problem caused by the old SDK version?

  • Hi,

    Do you mean the problem caused by the old SDK version?

    I am saying this should not be excluded, and should be checked for sanity.

    Best regards,

  • Hi,

    Did you find anything unusual about the use of all the RTLSSrv functions above? If it is good, I will try to update to the new SDK and try again

  • Hi,

    Your code looks ok at first sight.

    You may be missing a way to ensure the remote device supports AoA Tx - which could explain the error raised.

    Regards,

  • Hi, 

    I use two remote devices. One of them was Ti's device and downloaded the rtls_responder firmware, Download the rtls_coordinator firmware and use the rtls_connected script to work well. another is Nordic's device and downloaded the direction_finding_peripheral firmware, Works well with the direction finding central device

  • Hi,

    Just so you are aware, I am not sure on SDK 5.40 the rtls_coordinator can act as a CTE-transmitter - It is now possible in SDK 7.40.

    Regards,

  • Hi,

    I have changed the SDK to 7.4.0. Based on simple_central demo, the specified peripheral can be connected after modification, and CTE can be enabled.event 01 was generated from the RTLSCoordinator_rtlsSrvlMsgCb. That seems to have worked.But when I looked at the data content, it didn't seem to match rtlsSrv_connectionIQReport_t.I don't know what went wrong

    here is my RTLSCoordinator_rtlsSrvlMsgCb and log:

    void RTLSCoordinator_rtlsSrvlMsgCb(rtlsSrv_evt_t *pRtlsSrvEvt)
    {
    // Enqueue the message to switch context
        static bool flag = true;
    
        if(flag)
        {
            flag = false;
    
      Display_printf(dispHandle, 1, 0, "RTLS EVENT TYPE is %02x, size is %d" ,pRtlsSrvEvt->evtType,pRtlsSrvEvt->evtSize);
    
      for(int i=0;i<pRtlsSrvEvt->evtSize;i++)
      {
          Display_printf(dispHandle, i+2, 0, "row_data[%d] is %02x " ,i,pRtlsSrvEvt->evtData[i]);
      }
    }
    
    }

    *Simple Central
    RTLS EVENT TYPE is 01, size is 24
    row_data[0] is 00
    row_data[1] is 00
    row_data[2] is 01
    row_data[3] is 1b
    row_data[4] is cc
    row_data[5] is ff
    row_data[6] is 00
    row_data[7] is 00
    row_data[8] is 01
    row_data[9] is 00
    row_data[10] is 3b
    row_data[11] is 00
    row_data[12] is 70
    row_data[13] is 02
    row_data[14] is 04
    row_data[15] is 02
    row_data[16] is 01
    row_data[17] is 04
    row_data[18] is b0
    row_data[19] is b3
    row_data[20] is 38
    row_data[23] is 20
    

  • To correct the previous statement, the data conforms to the rtlsSrv_connectionIQReport_t structure, but some of the parameters are not as expected.like 

    RTLSSrv_setCteSampleAccuracy(p_conn_ctx->conn_handle,1,1,1,1,0x11);

    I've set sampleSize and sampleRate to 1, which means 1M and 8bit. But actually from pRtlsSrvEvt->evtData I read sampleRate:4,sampleSize: 2

  • Hi Ethan,

    Looks like you have made quite some progress. Well done.

    To ease the debugging, I would then recommend to cast the data into a rtlsSrv_connectionIQReport_t structure and ensure the display is done outside of the callback (otherwise it may lead to some side effects on timing).

    Best regards,

  • Hi , 

    I've already referred to the rtls_coordinator routine to put data in XX_processAppMsg and convert it to rtlsSrv_connectionIQReport_t for parsing.After many tests and adjustments, the problem of abnormal parameter configuration has been solved.The workaround is to adjust sampleCtrl to use Default filtering mode.It would be better if you had more explanation or found the problem with the configuration of this parameter earlier,because these questions can be time-consuming for unfamiliar Ti developers

  • Hi Ethan,

    Good catch. Thank you for sharing your solution.

    Regards,

  • Hi Clément,

    When I was testing Connection-CTE, RTLSCoordinator_rtlsSrvlMsgCb will stop or cause my device to restart after reporting about 430 RTLSSRV_CONNECTION_CTE_IQ_REPORT_EVT events. Do you know why?

  • Hi Ethan,

    This kind of issue where the SW crashes after a fixed number of event makes me think about a memory leak issue. You can use the Runtime Object Viewer (ROV) - see debuginng guide https://dev.ti.com/tirex/explore/content/simplelink_cc13xx_cc26xx_sdk_7_40_00_77/docs/ble5stack/ble_user_guide/html/ble-stack-5.x-guide/debugging-index.html#ti-rtos-object-viewer - to look at the heap usage.

    Here, my intuition is that the buffer of data passed within the rtlsSrv_connectionIQReport_t structure is not properly freed-up leading to this memory leak. As done in the rlts_coordinator example, ensure the payload is properly freed-up.

    static void RTLSCoordinator_processRtlsSrvMsg(rtlsSrv_evt_t *pEvt)
    {
    
      //...
      
      switch (pEvt->evtType)
      {
        //...
    
        case RTLSSRV_CONNECTION_CTE_IQ_REPORT_EVT:
    
        //...
    
      }
    
      // Free the payload
      if (pEvt->evtData)
      {
        ICall_free(pEvt->evtData);
      }
    }

    I hope this will help,

    Best regards,

  • Hi Clément

    I have solved the problem. You're right. This is a memory leak. But not only at the end of RTLSCoordinator_processRtlsSrvMsg, but also in RTLSSRV_CONNECTION_CTE_IQ_REPORT_EVT release pReport->iqSamples. Similar to this topic:e2e.ti.com/.../3947711

  • Well done, thank you for telling us!