Lines Matching refs:per_adv_sync
949 static void per_adv_sync_delete(struct bt_le_per_adv_sync *per_adv_sync) in per_adv_sync_delete() argument
951 atomic_clear(per_adv_sync->flags); in per_adv_sync_delete()
956 struct bt_le_per_adv_sync *per_adv_sync = NULL; in per_adv_sync_new() local
961 per_adv_sync = &per_adv_sync_pool[i]; in per_adv_sync_new()
966 if (!per_adv_sync) { in per_adv_sync_new()
970 (void)memset(per_adv_sync, 0, sizeof(*per_adv_sync)); in per_adv_sync_new()
971 atomic_set_bit(per_adv_sync->flags, BT_PER_ADV_SYNC_CREATED); in per_adv_sync_new()
974 net_buf_simple_init_with_data(&per_adv_sync->reassembly, in per_adv_sync_new()
975 per_adv_sync->reassembly_data, in per_adv_sync_new()
977 net_buf_simple_reset(&per_adv_sync->reassembly); in per_adv_sync_new()
980 return per_adv_sync; in per_adv_sync_new()
1015 void bt_hci_le_per_adv_report_recv(struct bt_le_per_adv_sync *per_adv_sync, in bt_hci_le_per_adv_report_recv() argument
1025 listener->recv(per_adv_sync, info, buf); in bt_hci_le_per_adv_report_recv()
1032 static void bt_hci_le_per_adv_report_recv_failure(struct bt_le_per_adv_sync *per_adv_sync, in bt_hci_le_per_adv_report_recv_failure() argument
1039 listener->recv(per_adv_sync, info, NULL); in bt_hci_le_per_adv_report_recv_failure()
1053 struct bt_le_per_adv_sync *per_adv_sync; in bt_hci_le_per_adv_report_common() local
1063 per_adv_sync = bt_hci_per_adv_sync_lookup_handle(sys_le16_to_cpu(evt->handle)); in bt_hci_le_per_adv_report_common()
1065 if (!per_adv_sync) { in bt_hci_le_per_adv_report_common()
1071 if (atomic_test_bit(per_adv_sync->flags, in bt_hci_le_per_adv_report_common()
1080 info.addr = &per_adv_sync->addr; in bt_hci_le_per_adv_report_common()
1081 info.sid = per_adv_sync->sid; in bt_hci_le_per_adv_report_common()
1088 if (!per_adv_sync->report_truncated) { in bt_hci_le_per_adv_report_common()
1090 if (net_buf_simple_tailroom(&per_adv_sync->reassembly) < evt->length) { in bt_hci_le_per_adv_report_common()
1096 per_adv_sync->report_truncated = true; in bt_hci_le_per_adv_report_common()
1097 net_buf_simple_reset(&per_adv_sync->reassembly); in bt_hci_le_per_adv_report_common()
1102 if (per_adv_sync->reassembly.len == 0) { in bt_hci_le_per_adv_report_common()
1106 bt_hci_le_per_adv_report_recv(per_adv_sync, &buf->b, &info); in bt_hci_le_per_adv_report_common()
1108 net_buf_simple_add_mem(&per_adv_sync->reassembly, in bt_hci_le_per_adv_report_common()
1110 bt_hci_le_per_adv_report_recv(per_adv_sync, in bt_hci_le_per_adv_report_common()
1111 &per_adv_sync->reassembly, &info); in bt_hci_le_per_adv_report_common()
1112 net_buf_simple_reset(&per_adv_sync->reassembly); in bt_hci_le_per_adv_report_common()
1118 net_buf_simple_reset(&per_adv_sync->reassembly); in bt_hci_le_per_adv_report_common()
1121 net_buf_simple_add_mem(&per_adv_sync->reassembly, buf->data, evt->length); in bt_hci_le_per_adv_report_common()
1124 per_adv_sync->num_subevents) { in bt_hci_le_per_adv_report_common()
1125 bt_hci_le_per_adv_report_recv_failure(per_adv_sync, &info); in bt_hci_le_per_adv_report_common()
1132 bt_hci_le_per_adv_report_recv(per_adv_sync, &buf->b, &info); in bt_hci_le_per_adv_report_common()
1134 per_adv_sync->report_truncated = true; in bt_hci_le_per_adv_report_common()
1138 per_adv_sync->report_truncated = false; in bt_hci_le_per_adv_report_common()
1173 static void per_adv_sync_terminated(struct bt_le_per_adv_sync *per_adv_sync, in per_adv_sync_terminated() argument
1178 .addr = &per_adv_sync->addr, in per_adv_sync_terminated()
1179 .sid = per_adv_sync->sid, in per_adv_sync_terminated()
1187 per_adv_sync_delete(per_adv_sync); in per_adv_sync_terminated()
1191 listener->term(per_adv_sync, &term_info); in per_adv_sync_terminated()
1341 int bt_le_per_adv_sync_subevent(struct bt_le_per_adv_sync *per_adv_sync, in bt_le_per_adv_sync_subevent() argument
1360 cp->sync_handle = sys_cpu_to_le16(per_adv_sync->handle); in bt_le_per_adv_sync_subevent()
1368 int bt_le_per_adv_set_response_data(struct bt_le_per_adv_sync *per_adv_sync, in bt_le_per_adv_set_response_data() argument
1375 if (per_adv_sync->num_subevents == 0) { in bt_le_per_adv_set_response_data()
1379 if (param->request_subevent >= per_adv_sync->num_subevents) { in bt_le_per_adv_set_response_data()
1383 if (param->response_subevent >= per_adv_sync->num_subevents) { in bt_le_per_adv_set_response_data()
1400 cp->sync_handle = sys_cpu_to_le16(per_adv_sync->handle); in bt_le_per_adv_set_response_data()
1417 struct bt_le_per_adv_sync *per_adv_sync; in bt_hci_le_per_adv_sync_lost() local
1419 per_adv_sync = bt_hci_per_adv_sync_lookup_handle(sys_le16_to_cpu(evt->handle)); in bt_hci_le_per_adv_sync_lost()
1421 if (!per_adv_sync) { in bt_hci_le_per_adv_sync_lost()
1428 per_adv_sync_terminated(per_adv_sync, BT_HCI_ERR_UNSPECIFIED); in bt_hci_le_per_adv_sync_lost()
1459 struct bt_le_per_adv_sync *per_adv_sync; in bt_hci_le_past_received_common() local
1479 per_adv_sync = per_adv_sync_new(); in bt_hci_le_past_received_common()
1480 if (!per_adv_sync) { in bt_hci_le_past_received_common()
1487 atomic_set_bit(per_adv_sync->flags, BT_PER_ADV_SYNC_SYNCED); in bt_hci_le_past_received_common()
1496 per_adv_sync->handle = sys_le16_to_cpu(evt->sync_handle); in bt_hci_le_past_received_common()
1497 per_adv_sync->interval = sys_le16_to_cpu(evt->interval); in bt_hci_le_past_received_common()
1498 per_adv_sync->clock_accuracy = sys_le16_to_cpu(evt->clock_accuracy); in bt_hci_le_past_received_common()
1499 per_adv_sync->phy = bt_get_phy(evt->phy); in bt_hci_le_past_received_common()
1500 bt_addr_le_copy(&per_adv_sync->addr, &id_addr); in bt_hci_le_past_received_common()
1501 per_adv_sync->sid = evt->adv_sid; in bt_hci_le_past_received_common()
1504 per_adv_sync->num_subevents = evt->num_subevents; in bt_hci_le_past_received_common()
1505 per_adv_sync->subevent_interval = evt->subevent_interval; in bt_hci_le_past_received_common()
1506 per_adv_sync->response_slot_delay = evt->response_slot_delay; in bt_hci_le_past_received_common()
1507 per_adv_sync->response_slot_spacing = evt->response_slot_spacing; in bt_hci_le_past_received_common()
1510 sync_info.interval = per_adv_sync->interval; in bt_hci_le_past_received_common()
1511 sync_info.phy = per_adv_sync->phy; in bt_hci_le_past_received_common()
1512 sync_info.addr = &per_adv_sync->addr; in bt_hci_le_past_received_common()
1513 sync_info.sid = per_adv_sync->sid; in bt_hci_le_past_received_common()
1529 sync_info.num_subevents = per_adv_sync->num_subevents; in bt_hci_le_past_received_common()
1530 sync_info.subevent_interval = per_adv_sync->subevent_interval; in bt_hci_le_past_received_common()
1531 sync_info.response_slot_delay = per_adv_sync->response_slot_delay; in bt_hci_le_past_received_common()
1532 sync_info.response_slot_spacing = per_adv_sync->response_slot_spacing; in bt_hci_le_past_received_common()
1537 listener->synced(per_adv_sync, &sync_info); in bt_hci_le_past_received_common()
1579 struct bt_le_per_adv_sync *per_adv_sync; in bt_hci_le_biginfo_adv_report() local
1585 per_adv_sync = bt_hci_per_adv_sync_lookup_handle(sys_le16_to_cpu(evt->sync_handle)); in bt_hci_le_biginfo_adv_report()
1587 if (!per_adv_sync) { in bt_hci_le_biginfo_adv_report()
1593 biginfo.addr = &per_adv_sync->addr; in bt_hci_le_biginfo_adv_report()
1594 biginfo.sid = per_adv_sync->sid; in bt_hci_le_biginfo_adv_report()
1610 listener->biginfo(per_adv_sync, &biginfo); in bt_hci_le_biginfo_adv_report()
1621 struct bt_le_per_adv_sync *per_adv_sync; in bt_hci_le_df_connectionless_iq_report_common() local
1625 err = hci_df_prepare_connectionless_iq_report(buf, &cte_report, &per_adv_sync); in bt_hci_le_df_connectionless_iq_report_common()
1632 err = hci_df_vs_prepare_connectionless_iq_report(buf, &cte_report, &per_adv_sync); in bt_hci_le_df_connectionless_iq_report_common()
1644 listener->cte_report_cb(per_adv_sync, &cte_report); in bt_hci_le_df_connectionless_iq_report_common()
1839 uint8_t bt_le_per_adv_sync_get_index(struct bt_le_per_adv_sync *per_adv_sync) in bt_le_per_adv_sync_get_index() argument
1841 ptrdiff_t index = per_adv_sync - per_adv_sync_pool; in bt_le_per_adv_sync_get_index()
1857 int bt_le_per_adv_sync_get_info(struct bt_le_per_adv_sync *per_adv_sync, in bt_le_per_adv_sync_get_info() argument
1860 CHECKIF(per_adv_sync == NULL || info == NULL) { in bt_le_per_adv_sync_get_info()
1864 bt_addr_le_copy(&info->addr, &per_adv_sync->addr); in bt_le_per_adv_sync_get_info()
1865 info->sid = per_adv_sync->sid; in bt_le_per_adv_sync_get_info()
1866 info->phy = per_adv_sync->phy; in bt_le_per_adv_sync_get_info()
1867 info->interval = per_adv_sync->interval; in bt_le_per_adv_sync_get_info()
1896 struct bt_le_per_adv_sync *per_adv_sync; in bt_le_per_adv_sync_create() local
1914 per_adv_sync = per_adv_sync_new(); in bt_le_per_adv_sync_create()
1915 if (!per_adv_sync) { in bt_le_per_adv_sync_create()
1921 per_adv_sync_delete(per_adv_sync); in bt_le_per_adv_sync_create()
1929 atomic_set_bit(per_adv_sync->flags, in bt_le_per_adv_sync_create()
1948 atomic_set_bit(per_adv_sync->flags, in bt_le_per_adv_sync_create()
1980 per_adv_sync_delete(per_adv_sync); in bt_le_per_adv_sync_create()
1984 atomic_set_bit(per_adv_sync->flags, BT_PER_ADV_SYNC_SYNCING); in bt_le_per_adv_sync_create()
1999 bt_le_per_adv_sync_delete(per_adv_sync); in bt_le_per_adv_sync_create()
2003 *out_sync = per_adv_sync; in bt_le_per_adv_sync_create()
2004 bt_addr_le_copy(&per_adv_sync->addr, ¶m->addr); in bt_le_per_adv_sync_create()
2005 per_adv_sync->sid = param->sid; in bt_le_per_adv_sync_create()
2011 struct bt_le_per_adv_sync *per_adv_sync) in bt_le_per_adv_sync_create_cancel() argument
2016 if (get_pending_per_adv_sync() != per_adv_sync) { in bt_le_per_adv_sync_create_cancel()
2040 static int bt_le_per_adv_sync_terminate(struct bt_le_per_adv_sync *per_adv_sync) in bt_le_per_adv_sync_terminate() argument
2044 if (!atomic_test_bit(per_adv_sync->flags, BT_PER_ADV_SYNC_SYNCED)) { in bt_le_per_adv_sync_terminate()
2048 err = per_adv_sync_terminate(per_adv_sync->handle); in bt_le_per_adv_sync_terminate()
2057 int bt_le_per_adv_sync_delete(struct bt_le_per_adv_sync *per_adv_sync) in bt_le_per_adv_sync_delete() argument
2065 if (atomic_test_bit(per_adv_sync->flags, BT_PER_ADV_SYNC_SYNCED)) { in bt_le_per_adv_sync_delete()
2066 err = bt_le_per_adv_sync_terminate(per_adv_sync); in bt_le_per_adv_sync_delete()
2069 per_adv_sync_terminated(per_adv_sync, in bt_le_per_adv_sync_delete()
2072 } else if (get_pending_per_adv_sync() == per_adv_sync) { in bt_le_per_adv_sync_delete()
2073 err = bt_le_per_adv_sync_create_cancel(per_adv_sync); in bt_le_per_adv_sync_delete()
2094 struct bt_le_per_adv_sync *per_adv_sync, bool enable) in bt_le_set_per_adv_recv_enable() argument
2111 if (!atomic_test_bit(per_adv_sync->flags, BT_PER_ADV_SYNC_SYNCED)) { in bt_le_set_per_adv_recv_enable()
2115 if ((enable && !atomic_test_bit(per_adv_sync->flags, in bt_le_set_per_adv_recv_enable()
2117 (!enable && atomic_test_bit(per_adv_sync->flags, in bt_le_set_per_adv_recv_enable()
2131 cp->handle = sys_cpu_to_le16(per_adv_sync->handle); in bt_le_set_per_adv_recv_enable()
2134 bt_hci_cmd_state_set_init(buf, &state, per_adv_sync->flags, in bt_le_set_per_adv_recv_enable()
2144 info.recv_enabled = !atomic_test_bit(per_adv_sync->flags, in bt_le_set_per_adv_recv_enable()
2149 listener->state_changed(per_adv_sync, &info); in bt_le_set_per_adv_recv_enable()
2156 int bt_le_per_adv_sync_recv_enable(struct bt_le_per_adv_sync *per_adv_sync) in bt_le_per_adv_sync_recv_enable() argument
2158 return bt_le_set_per_adv_recv_enable(per_adv_sync, true); in bt_le_per_adv_sync_recv_enable()
2161 int bt_le_per_adv_sync_recv_disable(struct bt_le_per_adv_sync *per_adv_sync) in bt_le_per_adv_sync_recv_disable() argument
2163 return bt_le_set_per_adv_recv_enable(per_adv_sync, false); in bt_le_per_adv_sync_recv_disable()
2167 int bt_le_per_adv_sync_transfer(const struct bt_le_per_adv_sync *per_adv_sync, in bt_le_per_adv_sync_transfer() argument
2191 cp->sync_handle = sys_cpu_to_le16(per_adv_sync->handle); in bt_le_per_adv_sync_transfer()