Lines Matching refs:bt_dev
134 if (bt_addr_eq(addr, &bt_dev.random_addr.a)) { in set_random_address()
159 bt_addr_copy(&bt_dev.random_addr.a, addr); in set_random_address()
160 bt_dev.random_addr.type = BT_ADDR_LE_RANDOM; in set_random_address()
176 BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features))) { in bt_id_set_adv_random_addr()
230 if (adv->id >= bt_dev.id_count) { in adv_rpa_expired()
259 if (adv->id >= bt_dev.id_count) { in adv_rpa_clear_data()
266 bt_addr_copy(&bt_dev.rpa[adv->id], BT_ADDR_NONE); in adv_rpa_clear_data()
277 atomic_test_bit(bt_dev.flags, BT_DEV_SCAN_LIMITED))) { in le_rpa_invalidate()
278 atomic_clear_bit(bt_dev.flags, BT_DEV_RPA_VALID); in le_rpa_invalidate()
283 if (bt_dev.id_count == 0) { in le_rpa_invalidate()
286 bool rpa_expired_data[bt_dev.id_count]; in le_rpa_invalidate()
303 if (atomic_test_and_clear_bit(bt_dev.flags, BT_DEV_RPA_TIMEOUT_CHANGED)) { in le_rpa_timeout_update()
316 cp->rpa_timeout = sys_cpu_to_le16(bt_dev.rpa_timeout); in le_rpa_timeout_update()
326 atomic_set_bit(bt_dev.flags, BT_DEV_RPA_TIMEOUT_CHANGED); in le_rpa_timeout_update()
337 (void)k_work_schedule(&bt_dev.rpa_update, K_SECONDS(bt_dev.rpa_timeout)); in le_rpa_timeout_submit()
351 if (atomic_test_bit(bt_dev.flags, BT_DEV_RPA_VALID)) { in bt_id_set_private_addr()
355 err = bt_rpa_create(bt_dev.irk[id], &rpa); in bt_id_set_private_addr()
359 atomic_set_bit(bt_dev.flags, BT_DEV_RPA_VALID); in bt_id_set_private_addr()
381 if (bt_addr_eq(&bt_dev.rpa[adv->id], BT_ADDR_NONE)) { in adv_rpa_get()
382 err = bt_rpa_create(bt_dev.irk[adv->id], &bt_dev.rpa[adv->id]); in adv_rpa_get()
388 bt_addr_copy(rpa, &bt_dev.rpa[adv->id]); in adv_rpa_get()
397 err = bt_rpa_create(bt_dev.irk[adv->id], rpa); in adv_rpa_get()
426 BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features))) { in bt_id_set_adv_private_addr()
451 err = bt_id_set_adv_random_addr(adv, &bt_dev.random_addr.a); in bt_id_set_adv_private_addr()
565 BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features)) { in le_adv_rpa_timeout()
604 if (atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING) && in le_update_private_addr()
606 atomic_test_bit(bt_dev.flags, BT_DEV_SCAN_LIMITED))) { in le_update_private_addr()
612 atomic_test_bit(bt_dev.flags, BT_DEV_INITIATING)) { in le_update_private_addr()
621 BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features))) { in le_update_private_addr()
645 BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features)) { in le_update_private_addr()
666 k_work_cancel_delayable_sync(&bt_dev.rpa_update, &sync); in le_force_rpa_timeout()
696 if (!(adv_enabled || atomic_test_bit(bt_dev.flags, BT_DEV_INITIATING) || in rpa_timeout()
712 BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features))) { in bt_id_scan_random_addr_check()
739 bt_dev.id_addr[adv->id].type == BT_ADDR_LE_RANDOM) || in bt_id_scan_random_addr_check()
761 BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features))) { in bt_id_adv_random_addr_check()
769 if (!(atomic_test_bit(bt_dev.flags, BT_DEV_INITIATING) || in bt_id_adv_random_addr_check()
770 atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING))) { in bt_id_adv_random_addr_check()
784 bt_dev.id_addr[param->id].type == BT_ADDR_LE_RANDOM) || in bt_id_adv_random_addr_check()
789 atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING) && in bt_id_adv_random_addr_check()
790 bt_dev.id_addr[BT_ID_DEFAULT].type == BT_ADDR_LE_RANDOM) { in bt_id_adv_random_addr_check()
802 } else if (bt_dev.id_addr[param->id].type == in bt_id_adv_random_addr_check()
833 if (!BT_CMD_TEST(bt_dev.supported_commands, 39, 2)) { in le_set_privacy_mode()
896 (void)memcpy(cp->local_irk, &bt_dev.irk[id], 16); in hci_id_add()
921 atomic_set_bit(bt_dev.flags, BT_DEV_ID_PENDING); in bt_id_pending_keys_update_set()
927 if (atomic_test_and_clear_bit(bt_dev.flags, BT_DEV_ID_PENDING)) { in bt_id_pending_keys_update()
1011 if (!bt_dev.le.rl_size || bt_dev.le.rl_entries > bt_dev.le.rl_size) { in bt_id_add()
1012 bt_dev.le.rl_entries++; in bt_id_add()
1037 bool scan_enabled = atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING); in bt_id_add()
1040 atomic_test_bit(bt_dev.flags, BT_DEV_SCAN_LIMITED)) { in bt_id_add()
1056 if (bt_dev.le.rl_entries) { in bt_id_add()
1064 if (bt_dev.le.rl_entries == bt_dev.le.rl_size) { in bt_id_add()
1073 bt_dev.le.rl_entries++; in bt_id_add()
1085 bt_dev.le.rl_entries++; in bt_id_add()
1156 if (!bt_dev.le.rl_size || in bt_id_del()
1157 bt_dev.le.rl_entries > bt_dev.le.rl_size + 1) { in bt_id_del()
1158 __ASSERT_NO_MSG(bt_dev.le.rl_entries > 0); in bt_id_del()
1159 if (bt_dev.le.rl_entries > 0) { in bt_id_del()
1160 bt_dev.le.rl_entries--; in bt_id_del()
1185 bool scan_enabled = atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING); in bt_id_del()
1188 atomic_test_bit(bt_dev.flags, BT_DEV_SCAN_LIMITED)) { in bt_id_del()
1210 if (bt_dev.le.rl_entries > bt_dev.le.rl_size) { in bt_id_del()
1211 bt_dev.le.rl_entries--; in bt_id_del()
1228 bt_dev.le.rl_entries--; in bt_id_del()
1233 if (bt_dev.le.rl_entries) { in bt_id_del()
1252 size_t to_copy = MIN(*count, bt_dev.id_count); in bt_id_get()
1254 memcpy(addrs, bt_dev.id_addr, to_copy * sizeof(bt_addr_le_t)); in bt_id_get()
1257 *count = bt_dev.id_count; in bt_id_get()
1265 for (id = 0U; id < bt_dev.id_count; id++) { in id_find()
1266 if (bt_addr_le_eq(addr, &bt_dev.id_addr[id])) { in id_find()
1277 bt_addr_le_copy(&bt_dev.id_addr[id], addr); in id_create()
1291 bt_addr_le_copy(&bt_dev.id_addr[id], &new_addr); in id_create()
1294 bt_addr_le_copy(addr, &bt_dev.id_addr[id]); in id_create()
1303 memcpy(&bt_dev.irk[id], irk, 16); in id_create()
1307 err = bt_rand(&bt_dev.irk[id], 16); in id_create()
1313 memcpy(irk, &bt_dev.irk[id], 16); in id_create()
1318 bt_addr_copy(&bt_dev.rpa[id], BT_ADDR_NONE); in id_create()
1327 atomic_test_bit(bt_dev.flags, BT_DEV_READY)) { in id_create()
1350 if (bt_dev.id_count != 0) { in bt_id_create()
1353 bt_addr_le_copy(&bt_dev.id_addr[BT_ID_DEFAULT], addr); in bt_id_create()
1354 bt_dev.id_count++; in bt_id_create()
1362 if (bt_dev.id_count == ARRAY_SIZE(bt_dev.id_addr)) { in bt_id_create()
1367 if (!atomic_test_bit(bt_dev.flags, BT_DEV_ENABLE)) { in bt_id_create()
1380 new_id = bt_dev.id_count++; in bt_id_create()
1383 bt_dev.id_count--; in bt_id_create()
1410 if (id == BT_ID_DEFAULT || id >= bt_dev.id_count) { in bt_id_reset()
1427 !bt_addr_le_eq(&bt_dev.id_addr[id], BT_ADDR_LE_ANY)) { in bt_id_reset()
1444 if (id == BT_ID_DEFAULT || id >= bt_dev.id_count) { in bt_id_delete()
1448 if (bt_addr_le_eq(&bt_dev.id_addr[id], BT_ADDR_LE_ANY)) { in bt_id_delete()
1474 (void)memset(bt_dev.irk[id], 0, 16); in bt_id_delete()
1476 bt_addr_le_copy(&bt_dev.id_addr[id], BT_ADDR_LE_ANY); in bt_id_delete()
1478 if (id == bt_dev.id_count - 1) { in bt_id_delete()
1479 bt_dev.id_count--; in bt_id_delete()
1483 atomic_test_bit(bt_dev.flags, BT_DEV_READY)) { in bt_id_delete()
1502 if (!BT_VS_CMD_READ_KEY_ROOTS(bt_dev.vs_commands)) { in bt_read_identity_root()
1567 bt_dev.id_count = bt_id_read_public_addr(&addr); in bt_setup_public_id_addr()
1569 if (!bt_dev.id_count) { in bt_setup_public_id_addr()
1592 atomic_set_bit(bt_dev.flags, BT_DEV_STORE_ID); in bt_setup_public_id_addr()
1607 if (!BT_VS_CMD_READ_STATIC_ADDRS(bt_dev.vs_commands)) { in vs_read_static_addr()
1657 if (IS_ENABLED(CONFIG_BT_HCI_VS) && !bt_dev.id_count) { in bt_setup_random_id_addr()
1660 bt_dev.id_count = vs_read_static_addr(addrs, CONFIG_BT_ID_MAX); in bt_setup_random_id_addr()
1662 for (uint8_t i = 0; i < bt_dev.id_count; i++) { in bt_setup_random_id_addr()
1682 atomic_set_bit(bt_dev.flags, BT_DEV_STORE_ID); in bt_setup_random_id_addr()
1695 if (bt_dev.id_count > 0) { in bt_setup_random_id_addr()
1701 atomic_set_bit(bt_dev.flags, BT_DEV_STORE_ID); in bt_setup_random_id_addr()
1712 k_work_delayable_remaining_get(&bt_dev.rpa_update)); in rpa_timeout_valid_check()
1714 return remaining_ms > (10 * bt_dev.create_param.timeout); in rpa_timeout_valid_check()
1741 if (BT_FEAT_LE_PRIVACY(bt_dev.le.features)) { in bt_id_set_create_conn_own_addr()
1747 const bt_addr_le_t *addr = &bt_dev.id_addr[BT_ID_DEFAULT]; in bt_id_set_create_conn_own_addr()
1779 BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features))) { in is_adv_using_rand_addr()
1802 if (BT_FEAT_LE_PRIVACY(bt_dev.le.features)) { in bt_id_set_scan_own_addr()
1809 if (err == -EACCES && (atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING) || in bt_id_set_scan_own_addr()
1810 atomic_test_bit(bt_dev.flags, BT_DEV_INITIATING))) { in bt_id_set_scan_own_addr()
1836 if (bt_dev.id_addr[BT_ID_DEFAULT].type == BT_ADDR_LE_RANDOM) { in bt_id_set_scan_own_addr()
1842 err = set_random_address(&bt_dev.id_addr[BT_ID_DEFAULT].a); in bt_id_set_scan_own_addr()
1848 } else if (bt_dev.id_addr[BT_ID_DEFAULT].type == BT_ADDR_LE_PUBLIC) { in bt_id_set_scan_own_addr()
1869 id_addr = &bt_dev.id_addr[adv->id]; in bt_id_set_adv_own_addr()
1890 !BT_FEAT_LE_PRIVACY(bt_dev.le.features)) { in bt_id_set_adv_own_addr()
1945 BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features))) { in bt_id_set_adv_own_addr()
1956 atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING)) { in bt_id_set_adv_own_addr()
1989 bt_addr_copy(&oob->addr, &bt_dev.id_addr[0].a); in bt_br_oob_get_local()
2004 if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) { in bt_le_oob_get_local()
2020 bt_dev.id_addr[id].type == BT_ADDR_LE_RANDOM)) { in bt_le_oob_get_local()
2022 atomic_test_bit(bt_dev.flags, BT_DEV_INITIATING)) { in bt_le_oob_get_local()
2039 (bt_dev.id_addr[id].type == BT_ADDR_LE_RANDOM)) { in bt_le_oob_get_local()
2050 (atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING) || in bt_le_oob_get_local()
2051 atomic_test_bit(bt_dev.flags, BT_DEV_INITIATING))) { in bt_le_oob_get_local()
2058 bt_addr_le_copy(&oob->addr, &bt_dev.random_addr); in bt_le_oob_get_local()
2060 bt_addr_le_copy(&oob->addr, &bt_dev.id_addr[id]); in bt_le_oob_get_local()
2083 if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) { in bt_le_ext_adv_oob_get_local()
2097 atomic_test_bit(bt_dev.flags, BT_DEV_INITIATING)) { in bt_le_ext_adv_oob_get_local()
2118 bt_addr_le_copy(&oob->addr, &bt_dev.id_addr[adv->id]); in bt_le_ext_adv_oob_get_local()
2153 if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) { in bt_le_oob_set_sc_data()
2168 if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) { in bt_le_oob_get_sc_data()
2182 k_work_init_delayable(&bt_dev.rpa_update, rpa_timeout); in bt_id_init()
2184 for (uint8_t id = 0U; id < ARRAY_SIZE(bt_dev.rpa); id++) { in bt_id_init()
2185 bt_addr_copy(&bt_dev.rpa[id], BT_ADDR_NONE); in bt_id_init()
2190 if (!IS_ENABLED(CONFIG_BT_SETTINGS) && !bt_dev.id_count) { in bt_id_init()
2200 if (!IS_ENABLED(CONFIG_BT_SETTINGS) && !bt_dev.id_count) { in bt_id_init()
2214 err = set_random_address(&bt_dev.id_addr[0].a); in bt_id_init()