Lines Matching +full:scan +full:- +full:limit

2  * Copyright (c) 2017-2021 Nordic Semiconductor ASA
3 * Copyright (c) 2015-2016 Intel Corporation
5 * SPDX-License-Identifier: Apache-2.0
38 return -ENOBUFS; in reject_conn()
42 bt_addr_copy(&cp->bdaddr, bdaddr); in reject_conn()
43 cp->reason = reason; in reject_conn()
61 return -ENOBUFS; in accept_sco_conn()
65 bt_addr_copy(&cp->bdaddr, bdaddr); in accept_sco_conn()
66 cp->pkt_type = sco_conn->sco.pkt_type; in accept_sco_conn()
67 cp->tx_bandwidth = 0x00001f40; in accept_sco_conn()
68 cp->rx_bandwidth = 0x00001f40; in accept_sco_conn()
69 cp->max_latency = 0x0007; in accept_sco_conn()
70 cp->retrans_effort = 0x01; in accept_sco_conn()
71 cp->content_format = BT_VOICE_CVSD_16BIT; in accept_sco_conn()
89 return -ENOBUFS; in accept_conn()
93 bt_addr_copy(&cp->bdaddr, bdaddr); in accept_conn()
94 cp->role = BT_HCI_ROLE_PERIPHERAL; in accept_conn()
108 sco_conn = bt_conn_add_sco(&evt->bdaddr, evt->link_type); in bt_esco_conn_req()
110 reject_conn(&evt->bdaddr, BT_HCI_ERR_INSUFFICIENT_RESOURCES); in bt_esco_conn_req()
114 if (accept_sco_conn(&evt->bdaddr, sco_conn)) { in bt_esco_conn_req()
115 LOG_ERR("Error accepting connection from %s", bt_addr_str(&evt->bdaddr)); in bt_esco_conn_req()
116 reject_conn(&evt->bdaddr, BT_HCI_ERR_UNSPECIFIED); in bt_esco_conn_req()
121 sco_conn->role = BT_HCI_ROLE_PERIPHERAL; in bt_esco_conn_req()
128 struct bt_hci_evt_conn_request *evt = (void *)buf->data; in bt_hci_conn_req()
131 LOG_DBG("conn req from %s, type 0x%02x", bt_addr_str(&evt->bdaddr), evt->link_type); in bt_hci_conn_req()
133 if (evt->link_type != BT_HCI_ACL) { in bt_hci_conn_req()
138 conn = bt_conn_add_br(&evt->bdaddr); in bt_hci_conn_req()
140 reject_conn(&evt->bdaddr, BT_HCI_ERR_INSUFFICIENT_RESOURCES); in bt_hci_conn_req()
144 accept_conn(&evt->bdaddr); in bt_hci_conn_req()
145 conn->role = BT_HCI_ROLE_PERIPHERAL; in bt_hci_conn_req()
166 cp->handle = sys_cpu_to_le16(conn->handle); in br_sufficient_key_size()
175 if (rsp->len < sizeof(*rp)) { in br_sufficient_key_size()
181 rp = (void *)rsp->data; in br_sufficient_key_size()
182 key_size = rp->key_size; in br_sufficient_key_size()
187 if (conn->sec_level == BT_SECURITY_L4) { in br_sufficient_key_size()
196 if (!conn->encrypt) { in bt_br_update_sec_level()
197 conn->sec_level = BT_SECURITY_L1; in bt_br_update_sec_level()
201 if (conn->br.link_key) { in bt_br_update_sec_level()
202 if (conn->br.link_key->flags & BT_LINK_KEY_AUTHENTICATED) { in bt_br_update_sec_level()
203 if (conn->encrypt == 0x02) { in bt_br_update_sec_level()
204 conn->sec_level = BT_SECURITY_L4; in bt_br_update_sec_level()
206 conn->sec_level = BT_SECURITY_L3; in bt_br_update_sec_level()
209 conn->sec_level = BT_SECURITY_L2; in bt_br_update_sec_level()
213 conn->sec_level = BT_SECURITY_L2; in bt_br_update_sec_level()
222 if (conn->required_sec_level > conn->sec_level) { in bt_br_update_sec_level()
233 struct bt_hci_evt_sync_conn_complete *evt = (void *)buf->data; in bt_hci_synchronous_conn_complete()
235 uint16_t handle = sys_le16_to_cpu(evt->handle); in bt_hci_synchronous_conn_complete()
237 LOG_DBG("status 0x%02x, handle %u, type 0x%02x", evt->status, handle, evt->link_type); in bt_hci_synchronous_conn_complete()
239 sco_conn = bt_conn_lookup_addr_sco(&evt->bdaddr); in bt_hci_synchronous_conn_complete()
241 LOG_ERR("Unable to find conn for %s", bt_addr_str(&evt->bdaddr)); in bt_hci_synchronous_conn_complete()
245 if (evt->status) { in bt_hci_synchronous_conn_complete()
246 sco_conn->err = evt->status; in bt_hci_synchronous_conn_complete()
252 sco_conn->handle = handle; in bt_hci_synchronous_conn_complete()
259 struct bt_hci_evt_conn_complete *evt = (void *)buf->data; in bt_hci_conn_complete()
262 uint16_t handle = sys_le16_to_cpu(evt->handle); in bt_hci_conn_complete()
264 LOG_DBG("status 0x%02x, handle %u, type 0x%02x", evt->status, handle, evt->link_type); in bt_hci_conn_complete()
266 conn = bt_conn_lookup_addr_br(&evt->bdaddr); in bt_hci_conn_complete()
268 LOG_ERR("Unable to find conn for %s", bt_addr_str(&evt->bdaddr)); in bt_hci_conn_complete()
272 if (evt->status) { in bt_hci_conn_complete()
273 conn->err = evt->status; in bt_hci_conn_complete()
279 conn->handle = handle; in bt_hci_conn_complete()
280 conn->err = 0U; in bt_hci_conn_complete()
281 conn->encrypt = evt->encr_enabled; in bt_hci_conn_complete()
297 cp->handle = evt->handle; in bt_hci_conn_complete()
315 return -ENOBUFS; in request_name()
320 bt_addr_copy(&cp->bdaddr, addr); in request_name()
321 cp->pscan_rep_mode = pscan; in request_name()
322 cp->reserved = 0x00; /* reserved, should be set to 0x00 */ in request_name()
323 cp->clock_offset = offset; in request_name()
346 if (eir[0] > len - 1) { in eir_has_name()
362 len -= eir[0] + 1; in eir_has_name()
392 priv->pscan_rep_mode, priv->clock_offset)) { in report_discovery_results()
396 priv->resolving = 1U; in report_discovery_results()
414 struct bt_hci_evt_inquiry_complete *evt = (void *)buf->data; in bt_hci_inquiry_complete()
416 if (evt->status) { in bt_hci_inquiry_complete()
457 if (!result || result->rssi > discovery_results[i].rssi) { in get_result_slot()
463 LOG_DBG("Reusing slot (old %s rssi %d dBm)", bt_addr_str(&result->addr), in get_result_slot()
464 result->rssi); in get_result_slot()
466 bt_addr_copy(&result->addr, addr); in get_result_slot()
482 while (num_reports--) { in bt_hci_inquiry_result_with_rssi()
487 if (buf->len < sizeof(*evt)) { in bt_hci_inquiry_result_with_rssi()
493 LOG_DBG("%s rssi %d dBm", bt_addr_str(&evt->addr), evt->rssi); in bt_hci_inquiry_result_with_rssi()
495 result = get_result_slot(&evt->addr, evt->rssi); in bt_hci_inquiry_result_with_rssi()
500 priv = (struct discovery_priv *)&result->_priv; in bt_hci_inquiry_result_with_rssi()
501 priv->pscan_rep_mode = evt->pscan_rep_mode; in bt_hci_inquiry_result_with_rssi()
502 priv->clock_offset = evt->clock_offset; in bt_hci_inquiry_result_with_rssi()
504 memcpy(result->cod, evt->cod, 3); in bt_hci_inquiry_result_with_rssi()
505 result->rssi = evt->rssi; in bt_hci_inquiry_result_with_rssi()
508 (void)memset(result->eir, 0, sizeof(result->eir)); in bt_hci_inquiry_result_with_rssi()
514 struct bt_hci_evt_extended_inquiry_result *evt = (void *)buf->data; in bt_hci_extended_inquiry_result()
522 LOG_DBG("%s rssi %d dBm", bt_addr_str(&evt->addr), evt->rssi); in bt_hci_extended_inquiry_result()
524 result = get_result_slot(&evt->addr, evt->rssi); in bt_hci_extended_inquiry_result()
529 priv = (struct discovery_priv *)&result->_priv; in bt_hci_extended_inquiry_result()
530 priv->pscan_rep_mode = evt->pscan_rep_mode; in bt_hci_extended_inquiry_result()
531 priv->clock_offset = evt->clock_offset; in bt_hci_extended_inquiry_result()
533 result->rssi = evt->rssi; in bt_hci_extended_inquiry_result()
534 memcpy(result->cod, evt->cod, 3); in bt_hci_extended_inquiry_result()
535 memcpy(result->eir, evt->eir, sizeof(result->eir)); in bt_hci_extended_inquiry_result()
540 struct bt_hci_evt_remote_name_req_complete *evt = (void *)buf->data; in bt_hci_remote_name_request_complete()
547 result = get_result_slot(&evt->bdaddr, 0xff); in bt_hci_remote_name_request_complete()
552 priv = (struct discovery_priv *)&result->_priv; in bt_hci_remote_name_request_complete()
553 priv->resolving = 0U; in bt_hci_remote_name_request_complete()
555 if (evt->status) { in bt_hci_remote_name_request_complete()
559 eir = result->eir; in bt_hci_remote_name_request_complete()
570 eir_len -= 2; in bt_hci_remote_name_request_complete()
573 name_len = strlen((const char *)evt->name); in bt_hci_remote_name_request_complete()
583 memcpy(&eir[2], evt->name, eir[0] - 1); in bt_hci_remote_name_request_complete()
589 if (eir[0] > eir_len - 1) { in bt_hci_remote_name_request_complete()
594 eir_len -= eir[0] + 1; in bt_hci_remote_name_request_complete()
605 if (dpriv->resolving) { in bt_hci_remote_name_request_complete()
621 struct bt_hci_evt_remote_features *evt = (void *)buf->data; in bt_hci_read_remote_features_complete()
622 uint16_t handle = sys_le16_to_cpu(evt->handle); in bt_hci_read_remote_features_complete()
626 LOG_DBG("status 0x%02x handle %u", evt->status, handle); in bt_hci_read_remote_features_complete()
634 if (evt->status) { in bt_hci_read_remote_features_complete()
638 memcpy(conn->br.features[0], evt->features, sizeof(evt->features)); in bt_hci_read_remote_features_complete()
640 if (!BT_FEAT_EXT_FEATURES(conn->br.features)) { in bt_hci_read_remote_features_complete()
652 cp->handle = evt->handle; in bt_hci_read_remote_features_complete()
653 cp->page = 0x01; in bt_hci_read_remote_features_complete()
663 struct bt_hci_evt_remote_ext_features *evt = (void *)buf->data; in bt_hci_read_remote_ext_features_complete()
664 uint16_t handle = sys_le16_to_cpu(evt->handle); in bt_hci_read_remote_ext_features_complete()
667 LOG_DBG("status 0x%02x handle %u", evt->status, handle); in bt_hci_read_remote_ext_features_complete()
675 if (!evt->status && evt->page == 0x01) { in bt_hci_read_remote_ext_features_complete()
676 memcpy(conn->br.features[1], evt->features, in bt_hci_read_remote_ext_features_complete()
677 sizeof(conn->br.features[1])); in bt_hci_read_remote_ext_features_complete()
685 struct bt_hci_evt_role_change *evt = (void *)buf->data; in bt_hci_role_change()
688 LOG_DBG("status 0x%02x role %u addr %s", evt->status, evt->role, bt_addr_str(&evt->bdaddr)); in bt_hci_role_change()
690 if (evt->status) { in bt_hci_role_change()
694 conn = bt_conn_lookup_addr_br(&evt->bdaddr); in bt_hci_role_change()
696 LOG_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr)); in bt_hci_role_change()
700 if (evt->role) { in bt_hci_role_change()
701 conn->role = BT_CONN_ROLE_PERIPHERAL; in bt_hci_role_change()
703 conn->role = BT_CONN_ROLE_CENTRAL; in bt_hci_role_change()
723 return -ENOBUFS; in read_ext_features()
727 cp->page = i; in read_ext_features()
735 rp = (void *)rsp->data; in read_ext_features()
737 memcpy(&bt_dev.features[i], rp->ext_features, in read_ext_features()
740 if (rp->max_page <= i) { in read_ext_features()
790 struct bt_hci_rp_read_buffer_size *rp = (void *)buf->data; in read_buffer_size_complete()
793 LOG_DBG("status 0x%02x", rp->status); in read_buffer_size_complete()
795 bt_dev.br.mtu = sys_le16_to_cpu(rp->acl_max_len); in read_buffer_size_complete()
796 pkts = sys_le16_to_cpu(rp->acl_max_num); in read_buffer_size_complete()
834 return -ENOBUFS; in bt_br_init()
838 ssp_cp->mode = 0x01; in bt_br_init()
847 return -ENOBUFS; in bt_br_init()
851 inq_cp->mode = 0x02; in bt_br_init()
860 return -ENOBUFS; in bt_br_init()
864 strncpy((char *)name_cp->local_name, CONFIG_BT_DEVICE_NAME, in bt_br_init()
865 sizeof(name_cp->local_name)); in bt_br_init()
875 return -ENOBUFS; in bt_br_init()
892 return -ENOBUFS; in bt_br_init()
896 sc_cp->sc_support = 0x01; in bt_br_init()
916 return -ENOBUFS; in br_start_inquiry()
921 cp->length = param->length; in br_start_inquiry()
922 cp->num_rsp = 0xff; /* we limit discovery only by time */ in br_start_inquiry()
924 memcpy(cp->lap, iac, 3); in br_start_inquiry()
925 if (param->limited) { in br_start_inquiry()
926 cp->lap[0] = 0x00; in br_start_inquiry()
939 if (!param->length || param->length > 0x30) { in valid_br_discov_param()
955 return -EINVAL; in bt_br_discovery_start()
959 return -EALREADY; in bt_br_discovery_start()
987 return -EALREADY; in bt_br_discovery_stop()
1002 if (!priv->resolving) { in bt_br_discovery_stop()
1013 bt_addr_copy(&cp->bdaddr, &discovery_results[i].addr); in bt_br_discovery_stop()
1028 static int write_scan_enable(uint8_t scan) in write_scan_enable() argument
1033 LOG_DBG("type %u", scan); in write_scan_enable()
1037 return -ENOBUFS; in write_scan_enable()
1040 net_buf_add_u8(buf, scan); in write_scan_enable()
1047 (scan & BT_BREDR_SCAN_INQUIRY)); in write_scan_enable()
1049 (scan & BT_BREDR_SCAN_PAGE)); in write_scan_enable()
1058 return -EALREADY; in bt_br_set_connectable()
1064 return -EALREADY; in bt_br_set_connectable()
1075 return -EALREADY; in bt_br_set_discoverable()
1079 return -EPERM; in bt_br_set_discoverable()
1086 return -EALREADY; in bt_br_set_discoverable()