Lines Matching +full:rx +full:- +full:sync +full:- +full:mode
2 * Copyright (c) 2020-2021 Nordic Semiconductor ASA
4 * SPDX-License-Identifier: Apache-2.0
58 prepare_cl_cte_rx_enable_cmd_params(struct net_buf **buf, struct bt_le_per_adv_sync *sync,
61 static int hci_df_set_cl_cte_rx_enable(struct bt_le_per_adv_sync *sync, bool enable,
97 if (params->cte_type == BT_DF_CTE_TYPE_AOD_1US || in hci_df_set_cl_cte_tx_params()
98 params->cte_type == BT_DF_CTE_TYPE_AOD_2US) { in hci_df_set_cl_cte_tx_params()
100 return -EINVAL; in hci_df_set_cl_cte_tx_params()
103 if (params->cte_type == BT_DF_CTE_TYPE_AOD_1US && in hci_df_set_cl_cte_tx_params()
105 return -EINVAL; in hci_df_set_cl_cte_tx_params()
108 if (params->num_ant_ids < BT_HCI_LE_SWITCH_PATTERN_LEN_MIN || in hci_df_set_cl_cte_tx_params()
109 params->num_ant_ids > BT_HCI_LE_SWITCH_PATTERN_LEN_MAX || in hci_df_set_cl_cte_tx_params()
110 !params->ant_ids) { in hci_df_set_cl_cte_tx_params()
111 return -EINVAL; in hci_df_set_cl_cte_tx_params()
113 } else if (params->cte_type != BT_DF_CTE_TYPE_AOA) { in hci_df_set_cl_cte_tx_params()
114 return -EINVAL; in hci_df_set_cl_cte_tx_params()
117 if (params->cte_len < BT_HCI_LE_CTE_LEN_MIN || in hci_df_set_cl_cte_tx_params()
118 params->cte_len > BT_HCI_LE_CTE_LEN_MAX) { in hci_df_set_cl_cte_tx_params()
119 return -EINVAL; in hci_df_set_cl_cte_tx_params()
122 if (params->cte_count < BT_HCI_LE_CTE_COUNT_MIN || in hci_df_set_cl_cte_tx_params()
123 params->cte_count > BT_HCI_LE_CTE_COUNT_MAX) { in hci_df_set_cl_cte_tx_params()
124 return -EINVAL; in hci_df_set_cl_cte_tx_params()
128 sizeof(*cp) + params->num_ant_ids); in hci_df_set_cl_cte_tx_params()
130 return -ENOBUFS; in hci_df_set_cl_cte_tx_params()
134 cp->handle = adv->handle; in hci_df_set_cl_cte_tx_params()
135 cp->cte_len = params->cte_len; in hci_df_set_cl_cte_tx_params()
136 cp->cte_type = get_hci_cte_type(params->cte_type); in hci_df_set_cl_cte_tx_params()
137 cp->cte_count = params->cte_count; in hci_df_set_cl_cte_tx_params()
139 if (params->num_ant_ids) { in hci_df_set_cl_cte_tx_params()
140 uint8_t *dest_ant_ids = net_buf_add(buf, params->num_ant_ids); in hci_df_set_cl_cte_tx_params()
142 memcpy(dest_ant_ids, params->ant_ids, params->num_ant_ids); in hci_df_set_cl_cte_tx_params()
143 cp->switch_pattern_len = params->num_ant_ids; in hci_df_set_cl_cte_tx_params()
145 cp->switch_pattern_len = 0; in hci_df_set_cl_cte_tx_params()
183 rp = (void *)rsp->data; in hci_df_read_ant_info()
186 "max CTE len %d", rp->switch_sample_rates, rp->num_ant, in hci_df_read_ant_info()
187 rp->max_switch_pattern_len, rp->max_cte_len); in hci_df_read_ant_info()
189 *switch_sample_rates = rp->switch_sample_rates; in hci_df_read_ant_info()
190 *num_ant = rp->num_ant; in hci_df_read_ant_info()
191 *max_switch_pattern_len = rp->max_switch_pattern_len; in hci_df_read_ant_info()
192 *max_cte_len = rp->max_cte_len; in hci_df_read_ant_info()
216 return -ENOBUFS; in hci_df_set_adv_cte_tx_enable()
222 cp->handle = adv->handle; in hci_df_set_adv_cte_tx_enable()
223 cp->cte_enable = enable ? 1 : 0; in hci_df_set_adv_cte_tx_enable()
225 bt_hci_cmd_state_set_init(buf, &state, adv->flags, BT_PER_ADV_CTE_ENABLED, in hci_df_set_adv_cte_tx_enable()
265 if (params->max_cte_count > BT_HCI_LE_SAMPLE_CTE_COUNT_MAX) { in valid_cl_cte_rx_params()
269 if (params->cte_types & BT_DF_CTE_TYPE_AOA) { in valid_cl_cte_rx_params()
270 return valid_cte_rx_common_params(params->cte_types, params->slot_durations, in valid_cl_cte_rx_params()
271 params->num_ant_ids, params->ant_ids); in valid_cl_cte_rx_params()
278 prepare_cl_cte_rx_enable_cmd_params(struct net_buf **buf, struct bt_le_per_adv_sync *sync, in prepare_cl_cte_rx_enable_cmd_params() argument
285 if (params->cte_types & BT_DF_CTE_TYPE_AOA) { in prepare_cl_cte_rx_enable_cmd_params()
286 switch_pattern_len = params->num_ant_ids; in prepare_cl_cte_rx_enable_cmd_params()
291 /* If CTE Rx is enabled, command parameters total length must include in prepare_cl_cte_rx_enable_cmd_params()
298 return -ENOBUFS; in prepare_cl_cte_rx_enable_cmd_params()
304 cp->sync_handle = sys_cpu_to_le16(sync->handle); in prepare_cl_cte_rx_enable_cmd_params()
305 cp->sampling_enable = enable ? 1 : 0; in prepare_cl_cte_rx_enable_cmd_params()
311 cp->max_sampled_cte = params->max_cte_count; in prepare_cl_cte_rx_enable_cmd_params()
313 if (params->cte_types & BT_DF_CTE_TYPE_AOA) { in prepare_cl_cte_rx_enable_cmd_params()
314 cp->slot_durations = params->slot_durations; in prepare_cl_cte_rx_enable_cmd_params()
315 ant_ids = params->ant_ids; in prepare_cl_cte_rx_enable_cmd_params()
320 * receive for AoD mode (e.g. device equipped with single antenna). in prepare_cl_cte_rx_enable_cmd_params()
322 cp->slot_durations = BT_HCI_LE_ANTENNA_SWITCHING_SLOT_2US; in prepare_cl_cte_rx_enable_cmd_params()
326 cp->switch_pattern_len = switch_pattern_len; in prepare_cl_cte_rx_enable_cmd_params()
327 dest_ant_ids = net_buf_add(*buf, cp->switch_pattern_len); in prepare_cl_cte_rx_enable_cmd_params()
328 memcpy(dest_ant_ids, ant_ids, cp->switch_pattern_len); in prepare_cl_cte_rx_enable_cmd_params()
334 static int hci_df_set_cl_cte_rx_enable(struct bt_le_per_adv_sync *sync, bool enable, in hci_df_set_cl_cte_rx_enable() argument
344 return -EINVAL; in hci_df_set_cl_cte_rx_enable()
348 err = prepare_cl_cte_rx_enable_cmd_params(&buf, sync, params, enable); in hci_df_set_cl_cte_rx_enable()
353 bt_hci_cmd_state_set_init(buf, &state, sync->flags, BT_PER_ADV_SYNC_CTE_ENABLED, enable); in hci_df_set_cl_cte_rx_enable()
360 rp = (void *)rsp->data; in hci_df_set_cl_cte_rx_enable()
361 if (sync->handle != sys_le16_to_cpu(rp->sync_handle)) { in hci_df_set_cl_cte_rx_enable()
362 err = -EIO; in hci_df_set_cl_cte_rx_enable()
364 sync->cte_types = (enable ? params->cte_types : 0); in hci_df_set_cl_cte_rx_enable()
379 if (buf->len < sizeof(*evt)) { in hci_df_prepare_connectionless_iq_report()
381 return -EINVAL; in hci_df_prepare_connectionless_iq_report()
386 per_adv_sync = bt_hci_per_adv_sync_lookup_handle(sys_le16_to_cpu(evt->sync_handle)); in hci_df_prepare_connectionless_iq_report()
390 sys_le16_to_cpu(evt->sync_handle)); in hci_df_prepare_connectionless_iq_report()
391 return -EINVAL; in hci_df_prepare_connectionless_iq_report()
394 if (!atomic_test_bit(per_adv_sync->flags, BT_PER_ADV_SYNC_CTE_ENABLED)) { in hci_df_prepare_connectionless_iq_report()
396 return -EINVAL; in hci_df_prepare_connectionless_iq_report()
399 if (!(per_adv_sync->cte_types & BIT(evt->cte_type))) { in hci_df_prepare_connectionless_iq_report()
400 LOG_DBG("CTE filtered out by cte_type: %u", evt->cte_type); in hci_df_prepare_connectionless_iq_report()
401 return -EINVAL; in hci_df_prepare_connectionless_iq_report()
404 report->chan_idx = evt->chan_idx; in hci_df_prepare_connectionless_iq_report()
405 report->rssi = sys_le16_to_cpu(evt->rssi); in hci_df_prepare_connectionless_iq_report()
406 report->rssi_ant_id = evt->rssi_ant_id; in hci_df_prepare_connectionless_iq_report()
407 report->cte_type = BIT(evt->cte_type); in hci_df_prepare_connectionless_iq_report()
408 report->packet_status = evt->packet_status; in hci_df_prepare_connectionless_iq_report()
409 report->slot_durations = evt->slot_durations; in hci_df_prepare_connectionless_iq_report()
410 report->per_evt_counter = sys_le16_to_cpu(evt->per_evt_counter); in hci_df_prepare_connectionless_iq_report()
411 report->sample_type = BT_DF_IQ_SAMPLE_8_BITS_INT; in hci_df_prepare_connectionless_iq_report()
412 report->sample_count = evt->sample_count; in hci_df_prepare_connectionless_iq_report()
413 report->sample = &evt->sample[0]; in hci_df_prepare_connectionless_iq_report()
427 if (buf->len < sizeof(*evt)) { in hci_df_vs_prepare_connectionless_iq_report()
429 return -EINVAL; in hci_df_vs_prepare_connectionless_iq_report()
434 per_adv_sync = bt_hci_per_adv_sync_lookup_handle(sys_le16_to_cpu(evt->sync_handle)); in hci_df_vs_prepare_connectionless_iq_report()
438 sys_le16_to_cpu(evt->sync_handle)); in hci_df_vs_prepare_connectionless_iq_report()
439 return -EINVAL; in hci_df_vs_prepare_connectionless_iq_report()
442 if (!atomic_test_bit(per_adv_sync->flags, BT_PER_ADV_SYNC_CTE_ENABLED)) { in hci_df_vs_prepare_connectionless_iq_report()
444 return -EINVAL; in hci_df_vs_prepare_connectionless_iq_report()
447 if (!(per_adv_sync->cte_types & BIT(evt->cte_type))) { in hci_df_vs_prepare_connectionless_iq_report()
448 LOG_DBG("CTE filtered out by cte_type: %u", evt->cte_type); in hci_df_vs_prepare_connectionless_iq_report()
449 return -EINVAL; in hci_df_vs_prepare_connectionless_iq_report()
452 report->chan_idx = evt->chan_idx; in hci_df_vs_prepare_connectionless_iq_report()
453 report->rssi = sys_le16_to_cpu(evt->rssi); in hci_df_vs_prepare_connectionless_iq_report()
454 report->rssi_ant_id = evt->rssi_ant_id; in hci_df_vs_prepare_connectionless_iq_report()
455 report->cte_type = BIT(evt->cte_type); in hci_df_vs_prepare_connectionless_iq_report()
456 report->packet_status = evt->packet_status; in hci_df_vs_prepare_connectionless_iq_report()
457 report->slot_durations = evt->slot_durations; in hci_df_vs_prepare_connectionless_iq_report()
458 report->per_evt_counter = sys_le16_to_cpu(evt->per_evt_counter); in hci_df_vs_prepare_connectionless_iq_report()
459 report->sample_count = evt->sample_count; in hci_df_vs_prepare_connectionless_iq_report()
460 report->sample_type = BT_DF_IQ_SAMPLE_16_BITS_INT; in hci_df_vs_prepare_connectionless_iq_report()
461 report->sample16 = &evt->sample[0]; in hci_df_vs_prepare_connectionless_iq_report()
472 if (!(params->cte_types & BT_DF_CTE_TYPE_ALL)) { in valid_conn_cte_tx_params()
479 if ((params->cte_types & BT_DF_CTE_TYPE_AOD_1US || in valid_conn_cte_tx_params()
480 params->cte_types & BT_DF_CTE_TYPE_AOD_1US) && in valid_conn_cte_tx_params()
481 (params->num_ant_ids < BT_HCI_LE_SWITCH_PATTERN_LEN_MIN || in valid_conn_cte_tx_params()
482 params->num_ant_ids > BT_HCI_LE_SWITCH_PATTERN_LEN_MAX || !params->ant_ids || in valid_conn_cte_tx_params()
499 cp->handle = sys_cpu_to_le16(conn->handle); in prepare_conn_cte_tx_params_cmd()
500 cp->cte_types = params->cte_types; in prepare_conn_cte_tx_params_cmd()
502 if (params->cte_types & (BT_DF_CTE_TYPE_AOD_1US | BT_DF_CTE_TYPE_AOD_2US)) { in prepare_conn_cte_tx_params_cmd()
503 cp->switch_pattern_len = params->num_ant_ids; in prepare_conn_cte_tx_params_cmd()
505 ant_ids = net_buf_add(buf, cp->switch_pattern_len); in prepare_conn_cte_tx_params_cmd()
506 (void)memcpy(ant_ids, params->ant_ids, cp->switch_pattern_len); in prepare_conn_cte_tx_params_cmd()
508 cp->switch_pattern_len = 0U; in prepare_conn_cte_tx_params_cmd()
533 return -EINVAL; in hci_df_set_conn_cte_tx_param()
536 num_ant_ids = ((params->cte_types & (BT_DF_CTE_TYPE_AOD_1US | BT_DF_CTE_TYPE_AOD_2US)) ? in hci_df_set_conn_cte_tx_param()
537 params->num_ant_ids : 0); in hci_df_set_conn_cte_tx_param()
542 return -ENOBUFS; in hci_df_set_conn_cte_tx_param()
550 bt_hci_cmd_state_set_init(buf, &state, conn->flags, BT_CONN_CTE_TX_PARAMS_SET, true); in hci_df_set_conn_cte_tx_param()
557 rp = (void *)rsp->data; in hci_df_set_conn_cte_tx_param()
558 if (conn->handle != sys_le16_to_cpu(rp->handle)) { in hci_df_set_conn_cte_tx_param()
559 err = -EIO; in hci_df_set_conn_cte_tx_param()
576 if (params->cte_types & BT_DF_CTE_TYPE_AOA) { in prepare_conn_cte_rx_enable_cmd_params()
577 switch_pattern_len = params->num_ant_ids; in prepare_conn_cte_rx_enable_cmd_params()
582 /* If CTE Rx is enabled, command parameters total length must include in prepare_conn_cte_rx_enable_cmd_params()
589 return -ENOBUFS; in prepare_conn_cte_rx_enable_cmd_params()
595 cp->handle = sys_cpu_to_le16(conn->handle); in prepare_conn_cte_rx_enable_cmd_params()
596 cp->sampling_enable = enable ? 1 : 0; in prepare_conn_cte_rx_enable_cmd_params()
602 if (params->cte_types & BT_DF_CTE_TYPE_AOA) { in prepare_conn_cte_rx_enable_cmd_params()
603 cp->slot_durations = params->slot_durations; in prepare_conn_cte_rx_enable_cmd_params()
604 ant_ids = params->ant_ids; in prepare_conn_cte_rx_enable_cmd_params()
609 * receive for AoD mode (e.g. device equipped with single antenna). in prepare_conn_cte_rx_enable_cmd_params()
613 cp->slot_durations = BT_HCI_LE_ANTENNA_SWITCHING_SLOT_2US; in prepare_conn_cte_rx_enable_cmd_params()
617 cp->switch_pattern_len = switch_pattern_len; in prepare_conn_cte_rx_enable_cmd_params()
618 dest_ant_ids = net_buf_add(*buf, cp->switch_pattern_len); in prepare_conn_cte_rx_enable_cmd_params()
619 (void)memcpy(dest_ant_ids, ant_ids, cp->switch_pattern_len); in prepare_conn_cte_rx_enable_cmd_params()
634 if (!valid_cte_rx_common_params(params->cte_types, params->slot_durations, in hci_df_set_conn_cte_rx_enable()
635 params->num_ant_ids, params->ant_ids)) { in hci_df_set_conn_cte_rx_enable()
636 return -EINVAL; in hci_df_set_conn_cte_rx_enable()
645 bt_hci_cmd_state_set_init(buf, &state, conn->flags, BT_CONN_CTE_RX_ENABLED, enable); in hci_df_set_conn_cte_rx_enable()
652 rp = (void *)rsp->data; in hci_df_set_conn_cte_rx_enable()
653 if (conn->handle != sys_le16_to_cpu(rp->handle)) { in hci_df_set_conn_cte_rx_enable()
654 err = -EIO; in hci_df_set_conn_cte_rx_enable()
656 conn->cte_types = (enable ? params->cte_types : 0); in hci_df_set_conn_cte_rx_enable()
657 /* This flag is set once for connection object. It is never cleared because CTE RX in hci_df_set_conn_cte_rx_enable()
661 atomic_set_bit(conn->flags, BT_CONN_CTE_RX_PARAMS_SET); in hci_df_set_conn_cte_rx_enable()
676 if (buf->len < sizeof(*evt)) { in hci_df_prepare_connection_iq_report()
678 return -EINVAL; in hci_df_prepare_connection_iq_report()
683 conn = bt_conn_lookup_handle(sys_le16_to_cpu(evt->conn_handle), BT_CONN_TYPE_LE); in hci_df_prepare_connection_iq_report()
686 sys_le16_to_cpu(evt->conn_handle)); in hci_df_prepare_connection_iq_report()
687 return -EINVAL; in hci_df_prepare_connection_iq_report()
690 if (!atomic_test_bit(conn->flags, BT_CONN_CTE_RX_ENABLED)) { in hci_df_prepare_connection_iq_report()
693 return -EINVAL; in hci_df_prepare_connection_iq_report()
696 if (!(conn->cte_types & BIT(evt->cte_type))) { in hci_df_prepare_connection_iq_report()
697 LOG_DBG("CTE filtered out by cte_type: %u", evt->cte_type); in hci_df_prepare_connection_iq_report()
699 return -EINVAL; in hci_df_prepare_connection_iq_report()
702 report->err = BT_DF_IQ_REPORT_ERR_SUCCESS; in hci_df_prepare_connection_iq_report()
703 report->chan_idx = evt->data_chan_idx; in hci_df_prepare_connection_iq_report()
704 report->rx_phy = evt->rx_phy; in hci_df_prepare_connection_iq_report()
705 report->chan_idx = evt->data_chan_idx; in hci_df_prepare_connection_iq_report()
706 report->rssi = evt->rssi; in hci_df_prepare_connection_iq_report()
707 report->rssi_ant_id = evt->rssi_ant_id; in hci_df_prepare_connection_iq_report()
708 report->cte_type = BIT(evt->cte_type); in hci_df_prepare_connection_iq_report()
709 report->packet_status = evt->packet_status; in hci_df_prepare_connection_iq_report()
710 report->slot_durations = evt->slot_durations; in hci_df_prepare_connection_iq_report()
711 report->conn_evt_counter = sys_le16_to_cpu(evt->conn_evt_counter); in hci_df_prepare_connection_iq_report()
712 report->sample_type = BT_DF_IQ_SAMPLE_8_BITS_INT; in hci_df_prepare_connection_iq_report()
713 report->sample_count = evt->sample_count; in hci_df_prepare_connection_iq_report()
714 report->sample = evt->sample; in hci_df_prepare_connection_iq_report()
728 if (buf->len < sizeof(*evt)) { in hci_df_vs_prepare_connection_iq_report()
730 return -EINVAL; in hci_df_vs_prepare_connection_iq_report()
735 conn = bt_conn_lookup_handle(sys_le16_to_cpu(evt->conn_handle), BT_CONN_TYPE_LE); in hci_df_vs_prepare_connection_iq_report()
738 sys_le16_to_cpu(evt->conn_handle)); in hci_df_vs_prepare_connection_iq_report()
739 return -EINVAL; in hci_df_vs_prepare_connection_iq_report()
742 if (!atomic_test_bit(conn->flags, BT_CONN_CTE_RX_ENABLED)) { in hci_df_vs_prepare_connection_iq_report()
745 return -EINVAL; in hci_df_vs_prepare_connection_iq_report()
748 if (!(conn->cte_types & BIT(evt->cte_type))) { in hci_df_vs_prepare_connection_iq_report()
749 LOG_DBG("CTE filtered out by cte_type: %u", evt->cte_type); in hci_df_vs_prepare_connection_iq_report()
751 return -EINVAL; in hci_df_vs_prepare_connection_iq_report()
754 report->err = BT_DF_IQ_REPORT_ERR_SUCCESS; in hci_df_vs_prepare_connection_iq_report()
755 report->chan_idx = evt->data_chan_idx; in hci_df_vs_prepare_connection_iq_report()
756 report->rx_phy = evt->rx_phy; in hci_df_vs_prepare_connection_iq_report()
757 report->chan_idx = evt->data_chan_idx; in hci_df_vs_prepare_connection_iq_report()
758 report->rssi = evt->rssi; in hci_df_vs_prepare_connection_iq_report()
759 report->rssi_ant_id = evt->rssi_ant_id; in hci_df_vs_prepare_connection_iq_report()
760 report->cte_type = BIT(evt->cte_type); in hci_df_vs_prepare_connection_iq_report()
761 report->packet_status = evt->packet_status; in hci_df_vs_prepare_connection_iq_report()
762 report->slot_durations = evt->slot_durations; in hci_df_vs_prepare_connection_iq_report()
763 report->conn_evt_counter = sys_le16_to_cpu(evt->conn_evt_counter); in hci_df_vs_prepare_connection_iq_report()
764 report->sample_type = BT_DF_IQ_SAMPLE_16_BITS_INT; in hci_df_vs_prepare_connection_iq_report()
765 report->sample_count = evt->sample_count; in hci_df_vs_prepare_connection_iq_report()
766 report->sample16 = evt->sample; in hci_df_vs_prepare_connection_iq_report()
779 if (!(conn->cte_types & cte_type)) { in valid_cte_req_params()
799 cp->handle = sys_cpu_to_le16(conn->handle); in prepare_conn_cte_req_enable_cmd_params()
800 cp->enable = enable ? 1 : 0; in prepare_conn_cte_req_enable_cmd_params()
803 cp->cte_request_interval = params->interval; in prepare_conn_cte_req_enable_cmd_params()
804 cp->requested_cte_length = sys_cpu_to_le16(params->cte_length); in prepare_conn_cte_req_enable_cmd_params()
805 cp->requested_cte_type = get_hci_cte_type(params->cte_type); in prepare_conn_cte_req_enable_cmd_params()
817 if (enable && !valid_cte_req_params(conn, params->cte_type, params->cte_length)) { in hci_df_set_conn_cte_req_enable()
818 return -EINVAL; in hci_df_set_conn_cte_req_enable()
824 return -ENOBUFS; in hci_df_set_conn_cte_req_enable()
829 bt_hci_cmd_state_set_init(buf, &state, conn->flags, BT_CONN_CTE_REQ_ENABLED, enable); in hci_df_set_conn_cte_req_enable()
836 rp = (void *)rsp->data; in hci_df_set_conn_cte_req_enable()
837 if (conn->handle != sys_le16_to_cpu(rp->handle)) { in hci_df_set_conn_cte_req_enable()
838 err = -EIO; in hci_df_set_conn_cte_req_enable()
853 if (buf->len < sizeof(*evt)) { in hci_df_prepare_conn_cte_req_failed()
855 return -EINVAL; in hci_df_prepare_conn_cte_req_failed()
860 conn = bt_conn_lookup_handle(sys_le16_to_cpu(evt->conn_handle), BT_CONN_TYPE_LE); in hci_df_prepare_conn_cte_req_failed()
863 sys_le16_to_cpu(evt->conn_handle)); in hci_df_prepare_conn_cte_req_failed()
864 return -EINVAL; in hci_df_prepare_conn_cte_req_failed()
867 if (!atomic_test_bit(conn->flags, BT_CONN_CTE_REQ_ENABLED)) { in hci_df_prepare_conn_cte_req_failed()
870 return -EINVAL; in hci_df_prepare_conn_cte_req_failed()
875 if (evt->status == BT_HCI_CTE_REQ_STATUS_RSP_WITHOUT_CTE) { in hci_df_prepare_conn_cte_req_failed()
876 report->err = BT_DF_IQ_REPORT_ERR_NO_CTE; in hci_df_prepare_conn_cte_req_failed()
878 report->err = BT_DF_IQ_REPORT_ERR_PEER_REJECTED; in hci_df_prepare_conn_cte_req_failed()
896 cp->handle = sys_cpu_to_le16(conn->handle); in prepare_conn_cte_rsp_enable_cmd_params()
897 cp->enable = enable ? 1U : 0U; in prepare_conn_cte_rsp_enable_cmd_params()
910 return -ENOBUFS; in hci_df_set_conn_cte_rsp_enable()
915 bt_hci_cmd_state_set_init(buf, &state, conn->flags, BT_CONN_CTE_RSP_ENABLED, enable); in hci_df_set_conn_cte_rsp_enable()
922 rp = (void *)rsp->data; in hci_df_set_conn_cte_rsp_enable()
923 if (conn->handle != sys_le16_to_cpu(rp->handle)) { in hci_df_set_conn_cte_rsp_enable()
924 err = -EIO; in hci_df_set_conn_cte_rsp_enable()
969 return -ENOTSUP; in bt_df_set_adv_cte_tx_param()
975 if (!atomic_test_bit(adv->flags, BT_ADV_PARAMS_SET)) { in bt_df_set_adv_cte_tx_param()
976 return -EINVAL; in bt_df_set_adv_cte_tx_param()
979 if (atomic_test_bit(adv->flags, BT_PER_ADV_CTE_ENABLED)) { in bt_df_set_adv_cte_tx_param()
980 return -EINVAL; in bt_df_set_adv_cte_tx_param()
988 atomic_set_bit(adv->flags, BT_PER_ADV_CTE_PARAMS_SET); in bt_df_set_adv_cte_tx_param()
995 if (!atomic_test_bit(adv->flags, BT_PER_ADV_PARAMS_SET)) { in bt_df_set_adv_cte_tx_enabled()
996 return -EINVAL; in bt_df_set_adv_cte_tx_enabled()
999 if (!atomic_test_bit(adv->flags, BT_PER_ADV_CTE_PARAMS_SET)) { in bt_df_set_adv_cte_tx_enabled()
1000 return -EINVAL; in bt_df_set_adv_cte_tx_enabled()
1003 if (enable == atomic_test_bit(adv->flags, BT_PER_ADV_CTE_ENABLED)) { in bt_df_set_adv_cte_tx_enabled()
1004 return -EALREADY; in bt_df_set_adv_cte_tx_enabled()
1024 bt_df_set_per_adv_sync_cte_rx_enable(struct bt_le_per_adv_sync *sync, bool enable, in bt_df_set_per_adv_sync_cte_rx_enable() argument
1028 return -ENOTSUP; in bt_df_set_per_adv_sync_cte_rx_enable()
1031 if (!atomic_test_bit(sync->flags, BT_PER_ADV_SYNC_SYNCED)) { in bt_df_set_per_adv_sync_cte_rx_enable()
1032 return -EINVAL; in bt_df_set_per_adv_sync_cte_rx_enable()
1036 !atomic_test_bit(sync->flags, BT_PER_ADV_SYNC_CTE_ENABLED)) { in bt_df_set_per_adv_sync_cte_rx_enable()
1037 return -EALREADY; in bt_df_set_per_adv_sync_cte_rx_enable()
1040 return hci_df_set_cl_cte_rx_enable(sync, enable, params); in bt_df_set_per_adv_sync_cte_rx_enable()
1043 int bt_df_per_adv_sync_cte_rx_enable(struct bt_le_per_adv_sync *sync, in bt_df_per_adv_sync_cte_rx_enable() argument
1046 CHECKIF(!sync) { in bt_df_per_adv_sync_cte_rx_enable()
1047 return -EINVAL; in bt_df_per_adv_sync_cte_rx_enable()
1050 return -EINVAL; in bt_df_per_adv_sync_cte_rx_enable()
1053 return bt_df_set_per_adv_sync_cte_rx_enable(sync, true, params); in bt_df_per_adv_sync_cte_rx_enable()
1056 int bt_df_per_adv_sync_cte_rx_disable(struct bt_le_per_adv_sync *sync) in bt_df_per_adv_sync_cte_rx_disable() argument
1058 CHECKIF(!sync) { in bt_df_per_adv_sync_cte_rx_disable()
1059 return -EINVAL; in bt_df_per_adv_sync_cte_rx_disable()
1062 return bt_df_set_per_adv_sync_cte_rx_enable(sync, false, NULL); in bt_df_per_adv_sync_cte_rx_disable()
1072 return -ENOTSUP; in bt_df_set_conn_cte_rx_enable()
1075 if (conn->state != BT_CONN_CONNECTED) { in bt_df_set_conn_cte_rx_enable()
1077 return -ENOTCONN; in bt_df_set_conn_cte_rx_enable()
1086 return -EINVAL; in bt_df_conn_cte_rx_enable()
1090 return -EINVAL; in bt_df_conn_cte_rx_enable()
1099 return -EINVAL; in bt_df_conn_cte_rx_disable()
1110 return -EINVAL; in bt_df_set_conn_cte_tx_param()
1114 return -EINVAL; in bt_df_set_conn_cte_tx_param()
1117 if (conn->state != BT_CONN_CONNECTED) { in bt_df_set_conn_cte_tx_param()
1119 return -ENOTCONN; in bt_df_set_conn_cte_tx_param()
1122 if (atomic_test_bit(conn->flags, BT_CONN_CTE_RSP_ENABLED)) { in bt_df_set_conn_cte_tx_param()
1124 return -EINVAL; in bt_df_set_conn_cte_tx_param()
1138 return -ENOTSUP; in bt_df_set_conn_cte_req_enable()
1141 if (conn->state != BT_CONN_CONNECTED) { in bt_df_set_conn_cte_req_enable()
1143 return -ENOTCONN; in bt_df_set_conn_cte_req_enable()
1146 if (!atomic_test_bit(conn->flags, BT_CONN_CTE_RX_PARAMS_SET)) { in bt_df_set_conn_cte_req_enable()
1147 LOG_ERR("Can't start CTE request procedure before CTE RX params setup"); in bt_df_set_conn_cte_req_enable()
1148 return -EINVAL; in bt_df_set_conn_cte_req_enable()
1157 return -EINVAL; in bt_df_conn_cte_req_enable()
1161 return -EINVAL; in bt_df_conn_cte_req_enable()
1170 return -EINVAL; in bt_df_conn_cte_req_disable()
1181 return -EINVAL; in bt_df_set_conn_cte_rsp_enable()
1186 return -ENOTSUP; in bt_df_set_conn_cte_rsp_enable()
1189 if (conn->state != BT_CONN_CONNECTED) { in bt_df_set_conn_cte_rsp_enable()
1191 return -ENOTCONN; in bt_df_set_conn_cte_rsp_enable()
1194 if (!atomic_test_bit(conn->flags, BT_CONN_CTE_TX_PARAMS_SET)) { in bt_df_set_conn_cte_rsp_enable()
1196 return -EINVAL; in bt_df_set_conn_cte_rsp_enable()