Bluetooth: Controller: Add CTE recv and sample in connected mode
In connected mode when Receiving Constant Tone Extensions feature is enabled, controller shall be able to receive CTE in any data channel packet. The commit adds required changes to allow receive of CTE for all data channel packets in peripheral role. Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
This commit is contained in:
parent
bf803514e1
commit
578902960d
35 changed files with 536 additions and 143 deletions
|
@ -2785,9 +2785,7 @@ static void le_df_connectionless_iq_report(struct pdu_data *pdu_rx,
|
|||
struct ll_sync_set *sync;
|
||||
struct lll_sync *lll;
|
||||
uint8_t samples_cnt;
|
||||
int16_t iq_tmp;
|
||||
int16_t rssi;
|
||||
uint8_t idx;
|
||||
|
||||
iq_report = (struct node_rx_iq_report *)node_rx;
|
||||
|
||||
|
@ -2803,7 +2801,7 @@ static void le_df_connectionless_iq_report(struct pdu_data *pdu_rx,
|
|||
* It should be verified here, to avoid reporint IQ samples after
|
||||
* the functionality was disabled.
|
||||
*/
|
||||
if (ull_df_sync_cfg_is_disabled_or_requested_to_disable(&lll->df_cfg)) {
|
||||
if (ull_df_sync_cfg_is_not_enabled(&lll->df_cfg)) {
|
||||
/* Dropp further processing of the event. */
|
||||
return;
|
||||
}
|
||||
|
@ -2846,14 +2844,13 @@ static void le_df_connectionless_iq_report(struct pdu_data *pdu_rx,
|
|||
if (iq_report->packet_status == BT_HCI_LE_CTE_INSUFFICIENT_RESOURCES) {
|
||||
sep->sample[0].i = BT_HCI_LE_CTE_REPORT_NO_VALID_SAMPLE;
|
||||
sep->sample[0].q = BT_HCI_LE_CTE_REPORT_NO_VALID_SAMPLE;
|
||||
sep->sample_count = 0;
|
||||
sep->sample_count = 0U;
|
||||
} else {
|
||||
for (idx = 0; idx < samples_cnt; ++idx) {
|
||||
iq_tmp = IQ_SHIFT_12_TO_8_BIT(iq_report->sample[idx].i);
|
||||
sep->sample[idx].i = (int8_t)iq_tmp;
|
||||
iq_tmp = IQ_SHIFT_12_TO_8_BIT(iq_report->sample[idx].q);
|
||||
sep->sample[idx].q = (int8_t)iq_tmp;
|
||||
for (uint8_t idx = 0U; idx < samples_cnt; ++idx) {
|
||||
sep->sample[idx].i = IQ_SHIFT_12_TO_8_BIT(iq_report->sample[idx].i);
|
||||
sep->sample[idx].q = IQ_SHIFT_12_TO_8_BIT(iq_report->sample[idx].q);
|
||||
}
|
||||
|
||||
sep->sample_count = samples_cnt;
|
||||
}
|
||||
}
|
||||
|
@ -2882,7 +2879,7 @@ static void le_df_set_conn_cte_tx_params(struct net_buf *buf,
|
|||
}
|
||||
#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_TX */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ)
|
||||
#if defined(CONFIG_BT_CTRL_DF_CONN_CTE_RX)
|
||||
static void le_df_set_conn_cte_rx_params(struct net_buf *buf, struct net_buf **evt)
|
||||
{
|
||||
struct bt_hci_cp_le_set_conn_cte_rx_params *cmd = (void *)buf->data;
|
||||
|
@ -2902,6 +2899,81 @@ static void le_df_set_conn_cte_rx_params(struct net_buf *buf, struct net_buf **e
|
|||
rp->handle = handle_le16;
|
||||
}
|
||||
|
||||
static void le_df_connection_iq_report(struct node_rx_pdu *node_rx, struct net_buf *buf)
|
||||
{
|
||||
struct bt_hci_evt_le_connection_iq_report *sep;
|
||||
struct node_rx_iq_report *iq_report;
|
||||
struct lll_conn *lll;
|
||||
uint8_t samples_cnt;
|
||||
uint8_t phy_rx;
|
||||
int16_t rssi;
|
||||
|
||||
iq_report = (struct node_rx_iq_report *)node_rx;
|
||||
|
||||
if (!(event_mask & BT_EVT_MASK_LE_META_EVENT) ||
|
||||
!(le_event_mask & BT_EVT_MASK_LE_CONNECTION_IQ_REPORT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
lll = iq_report->hdr.rx_ftr.param;
|
||||
|
||||
phy_rx = lll->phy_rx;
|
||||
/* Make sure the report is generated for connection on PHY UNCODED */
|
||||
LL_ASSERT(phy_rx != PHY_CODED);
|
||||
|
||||
/* TX LL thread has higher priority than RX thread. It may happen that host succefully
|
||||
* disables CTE sampling in the meantime. It should be verified here, to avoid reporing
|
||||
* IQ samples after the functionality was disabled.
|
||||
*/
|
||||
if (ull_df_conn_cfg_is_not_enabled(&lll->df_rx_cfg)) {
|
||||
/* Dropp further processing of the event. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* If there are no IQ samples due to insufficient resources HCI event should inform about
|
||||
* it by store single octet with special I_sample and Q_sample data.
|
||||
*/
|
||||
samples_cnt = MAX(1, iq_report->sample_count);
|
||||
|
||||
sep = meta_evt(buf, BT_HCI_EVT_LE_CONNECTION_IQ_REPORT,
|
||||
(sizeof(*sep) + (samples_cnt * sizeof(struct bt_hci_le_iq_sample))));
|
||||
|
||||
rssi = RSSI_DBM_TO_DECI_DBM(iq_report->hdr.rx_ftr.rssi);
|
||||
|
||||
sep->conn_handle = sys_cpu_to_le16(iq_report->hdr.handle);
|
||||
sep->rx_phy = phy_rx;
|
||||
sep->rssi = sys_cpu_to_le16(rssi);
|
||||
sep->rssi_ant_id = iq_report->rssi_ant_id;
|
||||
sep->cte_type = iq_report->cte_info.type;
|
||||
|
||||
sep->data_chan_idx = iq_report->chan_idx;
|
||||
sep->conn_evt_counter = sys_cpu_to_le16(lll->event_counter);
|
||||
|
||||
if (sep->cte_type == BT_HCI_LE_AOA_CTE) {
|
||||
sep->slot_durations = iq_report->local_slot_durations;
|
||||
} else if (sep->cte_type == BT_HCI_LE_AOD_CTE_1US) {
|
||||
sep->slot_durations = BT_HCI_LE_ANTENNA_SWITCHING_SLOT_1US;
|
||||
} else {
|
||||
sep->slot_durations = BT_HCI_LE_ANTENNA_SWITCHING_SLOT_2US;
|
||||
}
|
||||
|
||||
sep->packet_status = iq_report->packet_status;
|
||||
|
||||
if (iq_report->packet_status == BT_HCI_LE_CTE_INSUFFICIENT_RESOURCES) {
|
||||
sep->sample[0].i = BT_HCI_LE_CTE_REPORT_NO_VALID_SAMPLE;
|
||||
sep->sample[0].q = BT_HCI_LE_CTE_REPORT_NO_VALID_SAMPLE;
|
||||
sep->sample_count = 0U;
|
||||
} else {
|
||||
for (uint8_t idx = 0U; idx < samples_cnt; ++idx) {
|
||||
sep->sample[idx].i = IQ_SHIFT_12_TO_8_BIT(iq_report->sample[idx].i);
|
||||
sep->sample[idx].q = IQ_SHIFT_12_TO_8_BIT(iq_report->sample[idx].q);
|
||||
}
|
||||
sep->sample_count = samples_cnt;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_CTRL_DF_CONN_CTE_RX */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ)
|
||||
static void le_df_set_conn_cte_req_enable(struct net_buf *buf, struct net_buf **evt)
|
||||
{
|
||||
struct bt_hci_cp_le_conn_cte_req_enable *cmd = (void *)buf->data;
|
||||
|
@ -4260,10 +4332,12 @@ static int controller_cmd_handle(uint16_t ocf, struct net_buf *cmd,
|
|||
le_df_set_conn_cte_tx_params(cmd, evt);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_TX */
|
||||
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ)
|
||||
#if defined(CONFIG_BT_CTRL_DF_CONN_CTE_RX)
|
||||
case BT_OCF(BT_HCI_OP_LE_SET_CONN_CTE_RX_PARAMS):
|
||||
le_df_set_conn_cte_rx_params(cmd, evt);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTRL_DF_CONN_CTE_RX */
|
||||
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ)
|
||||
case BT_OCF(BT_HCI_OP_LE_CONN_CTE_REQ_ENABLE):
|
||||
le_df_set_conn_cte_req_enable(cmd, evt);
|
||||
break;
|
||||
|
@ -6975,7 +7049,7 @@ static void encode_control(struct node_rx_pdu *node_rx,
|
|||
break;
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_DF_SCAN_CTE_RX)
|
||||
case NODE_RX_TYPE_IQ_SAMPLE_REPORT:
|
||||
case NODE_RX_TYPE_SYNC_IQ_SAMPLE_REPORT:
|
||||
le_df_connectionless_iq_report(pdu_data, node_rx, buf);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_DF_SCAN_CTE_RX */
|
||||
|
@ -7072,6 +7146,11 @@ static void encode_control(struct node_rx_pdu *node_rx,
|
|||
return;
|
||||
#endif /* CONFIG_BT_CTLR_CONN_ISO */
|
||||
|
||||
#if defined(CONFIG_BT_CTRL_DF_CONN_CTE_RX)
|
||||
case NODE_RX_TYPE_CONN_IQ_SAMPLE_REPORT:
|
||||
le_df_connection_iq_report(node_rx, buf);
|
||||
return;
|
||||
#endif /* CONFIG_BT_CTRL_DF_CONN_CTE_RX */
|
||||
#endif /* CONFIG_BT_CONN */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_ADV_INDICATION)
|
||||
|
@ -7470,7 +7549,7 @@ uint8_t hci_get_class(struct node_rx_pdu *node_rx)
|
|||
case NODE_RX_TYPE_SYNC_LOST:
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_DF_SCAN_CTE_RX)
|
||||
case NODE_RX_TYPE_IQ_SAMPLE_REPORT:
|
||||
case NODE_RX_TYPE_SYNC_IQ_SAMPLE_REPORT:
|
||||
#endif /* CONFIG_BT_CTLR_DF_SCAN_CTE_RX */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_SYNC_ISO)
|
||||
|
@ -7494,6 +7573,9 @@ uint8_t hci_get_class(struct node_rx_pdu *node_rx)
|
|||
#if defined(CONFIG_BT_CTLR_CONN_ISO)
|
||||
case NODE_RX_TYPE_CIS_ESTABLISHED:
|
||||
#endif /* CONFIG_BT_CTLR_CONN_ISO */
|
||||
#if defined(CONFIG_BT_CTRL_DF_CONN_CTE_RX)
|
||||
case NODE_RX_TYPE_CONN_IQ_SAMPLE_REPORT:
|
||||
#endif /* CONFIG_BT_CTRL_DF_CONN_CTE_RX */
|
||||
return HCI_CLASS_EVT_REQUIRED;
|
||||
|
||||
case NODE_RX_TYPE_TERMINATE:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue