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:
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