Lines Matching +full:periodic +full:- +full:trigger

2  * Copyright (c) 2016-2021 Nordic Semiconductor ASA
5 * SPDX-License-Identifier: Apache-2.0
139 adv->hci_handle = 0; in ll_adv_cmds_set()
141 adv->is_created = 1; in ll_adv_cmds_set()
146 return -EINVAL; in ll_adv_cmds_set()
167 if (adv->is_created && (adv->hci_handle == hci_handle)) { in ll_adv_set_by_hci_handle_get()
185 if (adv->is_created) { in ll_adv_set_by_hci_handle_get_or_new()
186 if (adv->hci_handle == hci_handle) { in ll_adv_set_by_hci_handle_get_or_new()
196 adv_empty->hci_handle = hci_handle; in ll_adv_set_by_hci_handle_get_or_new()
209 LL_ASSERT(adv && adv->is_created); in ll_adv_set_hci_handle_get()
211 return adv->hci_handle; in ll_adv_set_hci_handle_get()
269 * periodic advertising enabled.
271 if (adv->lll.sync) {
274 sync = HDR_LLL2ULL(adv->lll.sync);
275 if (sync->is_enabled) {
283 adv->lll.phy_p = PHY_1M;
285 /* - Connectable and scannable not allowed;
286 * - High duty cycle directed connectable not allowed
297 if (adv->lll.sync &&
303 sync = HDR_LLL2ULL(adv->lll.sync);
304 if (sync->is_enabled) {
332 adv->lll.phy_p = phy_p;
333 adv->lll.phy_flags = PHY_FLAGS_S8;
336 adv->lll.phy_p = PHY_1M;
339 is_new_set = !adv->is_created;
340 adv->is_created = 1;
341 adv->is_ad_data_cmplt = 1U;
342 adv->max_skip = skip;
351 adv->interval = interval;
353 adv->interval = 0;
355 adv->lll.chan_map = chan_map;
356 adv->lll.filter_policy = filter_policy;
359 adv->lll.scan_req_notify = sreq;
363 pdu = lll_adv_data_peek(&adv->lll);
364 pdu_type_prev = pdu->type;
369 pdu->type = pdu_adv_type[adv_type];
370 if (pdu->type != PDU_ADV_TYPE_EXT_IND) {
371 pdu->len = 0U;
374 } else if (pdu->type != pdu_adv_type[adv_type]) {
378 * auxiliary and periodic advertising sets.
380 if (pdu->type == PDU_ADV_TYPE_EXT_IND) {
381 struct lll_adv_aux *lll_aux = adv->lll.aux;
389 pdu->len = 0;
392 if (adv->lll.sync) {
395 sync = HDR_LLL2ULL(adv->lll.sync);
396 adv->lll.sync = NULL;
404 adv->lll.aux = NULL;
411 pdu->len = 0;
415 pdu->type = pdu_adv_type[adv_type];
419 pdu->type = pdu_adv_type[adv_type];
422 pdu->rfu = 0;
425 ((pdu->type == PDU_ADV_TYPE_ADV_IND) ||
426 (pdu->type == PDU_ADV_TYPE_DIRECT_IND))) {
427 pdu->chan_sel = 1;
429 pdu->chan_sel = 0;
436 if (((pdu->type == PDU_ADV_TYPE_DIRECT_IND) ||
438 (pdu->type == PDU_ADV_TYPE_EXT_IND))) &&
442 if (pdu->len == 0U) {
443 adv->ad_data_backup.len = 0U;
445 LL_ASSERT(pdu->len >=
448 adv->ad_data_backup.len = pdu->len -
450 memcpy(adv->ad_data_backup.data, pdu->adv_ind.data,
451 adv->ad_data_backup.len);
457 adv->own_addr_type = own_addr_type;
458 if (adv->own_addr_type == BT_HCI_OWN_ADDR_RPA_OR_PUBLIC ||
459 adv->own_addr_type == BT_HCI_OWN_ADDR_RPA_OR_RANDOM) {
460 adv->peer_addr_type = direct_addr_type;
461 memcpy(&adv->peer_addr, direct_addr, BDADDR_SIZE);
465 if (pdu->type == PDU_ADV_TYPE_DIRECT_IND) {
466 pdu->tx_addr = own_addr_type & 0x1;
467 pdu->rx_addr = direct_addr_type;
468 memcpy(&pdu->direct_ind.tgt_addr[0], direct_addr, BDADDR_SIZE);
469 pdu->len = sizeof(struct pdu_adv_direct_ind);
472 } else if (pdu->type == PDU_ADV_TYPE_EXT_IND) {
478 pri_com_hdr = (void *)&pdu->adv_ext_ind;
479 pri_hdr = (void *)pri_com_hdr->ext_hdr_adv_data;
480 pri_dptr = pri_hdr->data;
484 pri_com_hdr->adv_mode = evt_prop & 0x03;
486 /* Zero-init header flags */
498 if (!pri_com_hdr->adv_mode &&
502 pri_hdr->adv_addr = 1;
505 pdu->tx_addr = own_addr_type & 0x1;
508 pdu->tx_addr = 0;
517 pri_hdr->tgt_addr = 1;
518 pdu->rx_addr = direct_addr_type;
521 pdu->rx_addr = 0;
530 pri_hdr->adi = 1;
543 pri_hdr->aux_ptr = 1;
559 pri_hdr->tx_pwr = 1;
568 pdu->len = len;
578 pri_dptr_prev -= sizeof(uint8_t);
580 if (pri_hdr->tx_pwr) {
592 pri_dptr -= sizeof(uint8_t);
610 adv->lll.phy_s = phy_s;
614 pri_dptr_prev -= sizeof(struct pdu_adv_aux_ptr);
616 if (pri_hdr->aux_ptr) {
617 pri_dptr -= sizeof(struct pdu_adv_aux_ptr);
619 adv->lll.phy_s);
625 pri_dptr_prev -= sizeof(struct pdu_adv_adi);
627 if (pri_hdr->adi) {
630 pri_dptr -= sizeof(struct pdu_adv_adi);
639 adv->sid = sid;
645 pri_dptr_prev -= BDADDR_SIZE;
647 if (pri_hdr->tgt_addr) {
648 pri_dptr -= BDADDR_SIZE;
657 if (pri_hdr->aux_ptr) {
670 lll_adv_aux_data_enqueue(adv->lll.aux, sec_idx);
671 lll_adv_data_enqueue(&adv->lll, pri_idx);
677 } else if (pdu->len == 0) {
678 pdu->tx_addr = own_addr_type & 0x1;
679 pdu->rx_addr = 0;
680 pdu->len = BDADDR_SIZE;
687 (pdu->type != PDU_ADV_TYPE_DIRECT_IND) &&
689 (pdu->type != PDU_ADV_TYPE_EXT_IND))) {
691 memcpy(pdu->adv_ind.data, adv->ad_data_backup.data,
692 adv->ad_data_backup.len);
693 pdu->len = offsetof(struct pdu_adv_adv_ind, data) +
694 adv->ad_data_backup.len;
698 pdu->tx_addr = own_addr_type & 0x1;
699 pdu->rx_addr = 0;
705 lll_hdr_init(&adv->lll, adv);
709 } else if (pdu->type == PDU_ADV_TYPE_EXT_IND) {
717 (void)lll_adv_data_release(&adv->lll.scan_rsp);
718 lll_adv_data_reset(&adv->lll.scan_rsp);
719 err = lll_adv_aux_data_init(&adv->lll.scan_rsp);
724 pdu = lll_adv_scan_rsp_peek(&adv->lll);
725 pdu->type = PDU_ADV_TYPE_AUX_SCAN_RSP;
726 pdu->len = 0;
730 pdu = lll_adv_scan_rsp_peek(&adv->lll);
737 (void)lll_adv_data_release(&adv->lll.scan_rsp);
738 lll_adv_data_reset(&adv->lll.scan_rsp);
739 err = lll_adv_data_init(&adv->lll.scan_rsp);
744 pdu = lll_adv_scan_rsp_peek(&adv->lll);
751 pdu->type = PDU_ADV_TYPE_SCAN_RSP;
752 pdu->rfu = 0;
753 pdu->chan_sel = 0;
754 pdu->tx_addr = own_addr_type & 0x1;
755 pdu->rx_addr = 0;
756 if (pdu->len == 0) {
757 pdu->len = BDADDR_SIZE;
872 lll = &adv->lll;
882 if (!adv->lll.node_rx_adv_term) {
884 * adv->is_enabled would be 0 if
892 type = &adv->lll.node_rx_adv_term->hdr.type;
922 lll = &adv->lll;
925 lll->rl_idx = FILTER_IDX_NONE;
928 ull_filter_adv_update(lll->filter_policy);
930 if (adv->own_addr_type == BT_HCI_OWN_ADDR_RPA_OR_PUBLIC ||
931 adv->own_addr_type == BT_HCI_OWN_ADDR_RPA_OR_RANDOM) {
933 lll->rl_idx = ull_filter_rl_find(adv->peer_addr_type,
934 adv->peer_addr, NULL);
936 if (lll->rl_idx != FILTER_IDX_NONE) {
950 if (pdu_adv->type == PDU_ADV_TYPE_EXT_IND) {
955 err = lll_adv_data_init(&adv->lll.scan_rsp);
979 lll->is_mesh = 1;
985 if ((pdu_adv->type == PDU_ADV_TYPE_ADV_IND) ||
986 (pdu_adv->type == PDU_ADV_TYPE_DIRECT_IND) ||
988 ((pdu_adv->type == PDU_ADV_TYPE_EXT_IND) &&
989 (pdu_adv->adv_ext_ind.adv_mode & BT_HCI_LE_ADV_PROP_CONN))
1000 if (lll->conn) {
1024 conn_lll = &conn->lll;
1025 conn_lll->handle = 0xFFFF;
1027 if (!conn_lll->link_tx_free) {
1028 conn_lll->link_tx_free = &conn_lll->link_tx;
1031 memq_init(conn_lll->link_tx_free, &conn_lll->memq_tx.head,
1032 &conn_lll->memq_tx.tail);
1033 conn_lll->link_tx_free = NULL;
1035 conn_lll->packet_tx_head_len = 0;
1036 conn_lll->packet_tx_head_offset = 0;
1038 conn_lll->sn = 0;
1039 conn_lll->nesn = 0;
1040 conn_lll->empty = 0;
1045 } else if (pdu_adv->type == PDU_ADV_TYPE_EXT_IND) {
1046 conn_lll->phy_tx = lll->phy_s;
1047 conn_lll->phy_tx_time = lll->phy_s;
1048 conn_lll->phy_flags = lll->phy_flags;
1049 conn_lll->phy_rx = lll->phy_s;
1052 conn_lll->phy_tx = PHY_1M;
1053 conn_lll->phy_tx_time = PHY_1M;
1054 conn_lll->phy_flags = PHY_FLAGS_S8;
1055 conn_lll->phy_rx = PHY_1M;
1060 conn_lll->rssi_latest = BT_HCI_LE_RSSI_NOT_AVAILABLE;
1062 conn_lll->rssi_reported = BT_HCI_LE_RSSI_NOT_AVAILABLE;
1063 conn_lll->rssi_sample_count = 0;
1068 conn_lll->tx_pwr_lvl = RADIO_TXP_DEFAULT;
1072 conn_lll->role = 1;
1073 conn_lll->periph.initiated = 0;
1074 conn_lll->periph.cancelled = 0;
1075 conn_lll->periph.forced = 0;
1076 conn_lll->data_chan_sel = 0;
1077 conn_lll->data_chan_use = 0;
1078 conn_lll->event_counter = 0;
1080 conn_lll->latency_prepare = 0;
1081 conn_lll->latency_event = 0;
1082 conn_lll->periph.latency_enabled = 0;
1083 conn_lll->periph.window_widening_prepare_us = 0;
1084 conn_lll->periph.window_widening_event_us = 0;
1085 conn_lll->periph.window_size_prepare_us = 0;
1088 memset(&conn_lll->conn_meta, 0, sizeof(conn_lll->conn_meta));
1091 conn_lll->df_rx_cfg.is_initialized = 0U;
1092 conn_lll->df_rx_cfg.hdr.elem_size = sizeof(struct lll_df_conn_rx_params);
1095 conn_lll->df_tx_cfg.is_initialized = 0U;
1096 conn_lll->df_tx_cfg.cte_rsp_en = 0U;
1098 conn->connect_expire = 6;
1099 conn->supervision_expire = 0;
1102 conn->apto_expire = 0U;
1103 conn->appto_expire = 0U;
1107 conn->own_id_addr_type = BT_ADDR_LE_NONE->type;
1108 (void)memcpy(conn->own_id_addr, BT_ADDR_LE_NONE->a.val,
1109 sizeof(conn->own_id_addr));
1110 conn->peer_id_addr_type = BT_ADDR_LE_NONE->type;
1111 (void)memcpy(conn->peer_id_addr, BT_ADDR_LE_NONE->a.val,
1112 sizeof(conn->peer_id_addr));
1115 /* Re-initialize the control procedure data structures */
1118 conn->llcp_terminate.reason_final = 0;
1122 conn->llcp_terminate.node_rx.rx.hdr.link = link;
1125 conn->phy_pref_tx = ull_conn_default_phy_tx_get();
1126 conn->phy_pref_rx = ull_conn_default_phy_rx_get();
1130 conn->pause_rx_data = 0U;
1138 if (pdu_adv->type == PDU_ADV_TYPE_EXT_IND) {
1139 phy_in_use = lll->phy_s;
1146 /* Re-initialize the Tx Q */
1147 ull_tx_q_init(&conn->tx_q);
1150 adv->link_cc_free = link;
1151 adv->node_rx_cc_free = node_rx;
1152 lll->conn = conn_lll;
1154 ull_hdr_init(&conn->ull);
1155 lll_hdr_init(&conn->lll, conn);
1176 if (adv->lll.conn) {
1188 if (adv->lll.conn) {
1199 node_rx_adv_term->hdr.type = NODE_RX_TYPE_NONE;
1201 node_rx_adv_term->hdr.link = (void *)link_adv_term;
1202 adv->lll.node_rx_adv_term = (void *)node_rx_adv_term;
1206 } else if (lll->is_hdcd) {
1214 adv->lll.node_rx_adv_term = NULL;
1218 const uint8_t phy = lll->phy_p;
1219 const uint8_t phy_flags = lll->phy_flags;
1221 adv->event_counter = 0U;
1229 uint8_t ch_map = lll->chan_map;
1241 uint16_t interval = adv->interval;
1243 if (lll->is_mesh) {
1276 ull_hdr_init(&adv->ull);
1279 adv->ull.ticks_active_to_start = 0;
1280 adv->ull.ticks_prepare_to_start =
1282 adv->ull.ticks_preempt_to_start =
1284 adv->ull.ticks_slot = HAL_TICKER_US_TO_TICKS_CEIL(time_us);
1286 ticks_slot_offset = MAX(adv->ull.ticks_active_to_start,
1287 adv->ull.ticks_prepare_to_start);
1307 lll->is_hdcd = !interval && (pdu_adv->type == PDU_ADV_TYPE_DIRECT_IND);
1308 if (lll->is_hdcd) {
1329 (adv->ull.ticks_slot + ticks_slot_overhead),
1331 (adv->ull.ticks_slot + ticks_slot_overhead),
1357 const uint32_t ticks_slot = adv->ull.ticks_slot +
1364 if (lll->sync) {
1365 sync = HDR_LLL2ULL(lll->sync);
1366 if (sync->is_enabled && !sync->is_started) {
1378 /* First byte in the length-value encoded
1386 /* Do not start periodic advertising */
1392 if (lll->aux) {
1393 struct lll_adv_aux *lll_aux = lll->aux;
1406 * the +/- 1 tick ticker scheduling jitter due
1414 EVENT_OVERHEAD_START_US) -
1422 /* Start periodic advertising if enabled and not already
1439 ticks_slot_aux = aux->ull.ticks_slot +
1445 /* Schedule periodic advertising PDU after
1451 * the +/- 1 tick ticker scheduling jitter due
1459 EVENT_OVERHEAD_START_US) -
1480 lll_adv_aux_data_enqueue(adv->lll.aux, sec_idx);
1484 * active Periodic Advertising events, so
1486 * that auxiliary sets and Periodic
1487 * Advertising sets are non-overlapping
1495 * Use periodic interval units to represent the
1496 * periodic behavior of scheduling of AUX_ADV_IND PDUs
1498 * used for ACL Connections, Periodic Advertising and
1501 interval_us = (uint64_t)adv->interval * ADV_INT_UNIT_US;
1503 if (adv->max_skip == 0U) {
1509 aux->interval = DIV_ROUND_UP(interval_us +
1513 aux->interval = (interval_us * (adv->max_skip + 1))
1536 if (lll->aux) {
1583 aux->is_started = aux_is_started;
1587 sync->is_started = sync_is_started;
1593 adv->is_enabled = 1;
1619 /* TODO: Stop periodic advertising and release resources */
1625 if (adv->lll.conn) {
1721 struct lll_adv *lll = &adv->lll;
1724 adv->is_created = 0;
1725 lll->aux = NULL;
1727 lll->sync = NULL;
1730 lll_adv_data_reset(&lll->adv_data);
1731 lll_adv_data_reset(&lll->scan_rsp);
1753 return ((uint8_t *)adv - (uint8_t *)ll_adv) / sizeof(*adv);
1766 if (!adv || !adv->is_enabled) {
1791 return adv->lll.filter_policy;
1800 if (!adv || !adv->is_created) {
1810 if (adv->lll.aux && adv->is_enabled) {
1811 uint8_t aux_handle = ull_adv_aux_handle_get(HDR_LLL2ULL(adv->lll.aux));
1835 prev = lll_adv_data_peek(&adv->lll);
1838 if ((prev->type == PDU_ADV_TYPE_DIRECT_IND) ||
1840 (prev->type == PDU_ADV_TYPE_EXT_IND))) {
1843 adv->ad_data_backup.len = len;
1844 memcpy(adv->ad_data_backup.data, data, adv->ad_data_backup.len);
1853 pdu = lll_adv_data_alloc(&adv->lll, &idx);
1859 lll_adv_data_alloc(&adv->lll, &idx_test);
1863 pdu->type = prev->type;
1864 pdu->rfu = 0U;
1867 pdu->chan_sel = prev->chan_sel;
1869 pdu->chan_sel = 0U;
1872 pdu->tx_addr = prev->tx_addr;
1873 pdu->rx_addr = prev->rx_addr;
1874 memmove(&pdu->adv_ind.addr[0], &prev->adv_ind.addr[0], BDADDR_SIZE);
1875 memcpy(&pdu->adv_ind.data[0], data, len);
1876 pdu->len = BDADDR_SIZE + len;
1879 if (adv->is_enabled) {
1884 lll = &adv->lll;
1893 lll_adv_data_enqueue(&adv->lll, idx);
1910 prev = lll_adv_scan_rsp_peek(&adv->lll);
1914 err = lll_adv_data_init(&adv->lll.scan_rsp);
1919 prev = lll_adv_scan_rsp_peek(&adv->lll);
1923 pdu = lll_adv_scan_rsp_alloc(&adv->lll, &idx);
1924 pdu->type = PDU_ADV_TYPE_SCAN_RSP;
1925 pdu->rfu = 0;
1926 pdu->chan_sel = 0;
1927 pdu->tx_addr = prev->tx_addr;
1928 pdu->rx_addr = 0;
1929 pdu->len = BDADDR_SIZE + len;
1930 memmove(&pdu->scan_rsp.addr[0], &prev->scan_rsp.addr[0], BDADDR_SIZE);
1931 memcpy(&pdu->scan_rsp.data[0], data, len);
1934 if (adv->is_enabled) {
1939 lll = &adv->lll;
1942 if ((pdu_adv_scan->type == PDU_ADV_TYPE_ADV_IND) ||
1943 (pdu_adv_scan->type == PDU_ADV_TYPE_SCAN_IND)) {
1951 lll_adv_scan_rsp_enqueue(&adv->lll, idx);
1964 /* Get pseudo-random number in the range [0..ticks_delay_window].
2000 adv = CONTAINER_OF(done->param, struct ll_adv_set, ull);
2001 lll = &adv->lll;
2004 if (done->extra.type == EVENT_DONE_EXTRA_TYPE_ADV && done->extra.result != DONE_COMPLETED) {
2005 /* Event aborted or too late - try to re-schedule */
2012 const uint32_t ticks_adv_airtime = adv->ticks_at_expire +
2018 if ((int32_t)(ticks_now - ticks_adv_airtime) > 0) {
2019 ticks_elapsed = ticks_now - ticks_adv_airtime;
2022 if (adv->delay_at_expire + ticks_elapsed <= ULL_ADV_RANDOM_DELAY) {
2024 delay_remain = ULL_ADV_RANDOM_DELAY - (adv->delay_at_expire +
2030 /* Check if we have enough time to re-schedule */
2032 uint32_t interval_us = adv->interval * ADV_INT_UNIT_US;
2041 ticks_adjust_minus = HAL_TICKER_US_TO_TICKS(interval_us) + adv->delay;
2044 if (adv->remain_duration_us > interval_us) {
2046 * to correct for the re-scheduling
2048 adv->remain_duration_us += interval_us +
2050 adv->delay_at_expire);
2059 random_delay = ticker_update_rand(adv, delay_remain - prepare_overhead,
2064 adv->delay = random_delay;
2065 adv->delay += adv->delay_at_expire;
2070 adv->lll.hdr.score -= 1;
2074 if (done->extra.type == EVENT_DONE_EXTRA_TYPE_ADV && adv->lll.aux) {
2075 /* Primary event of extended advertising done - wait for aux done */
2082 if (adv->max_events && (adv->event_counter >= adv->max_events)) {
2083 adv->max_events = 0U;
2085 rx = (void *)lll->node_rx_adv_term;
2086 rx->rx_ftr.param_adv_term.status = BT_HCI_ERR_LIMIT_REACHED;
2087 } else if (adv->remain_duration_us &&
2088 (adv->remain_duration_us <=
2089 ((uint64_t)adv->interval * ADV_INT_UNIT_US))) {
2090 adv->remain_duration_us = 0U;
2092 rx = (void *)lll->node_rx_adv_term;
2093 rx->rx_ftr.param_adv_term.status = BT_HCI_ERR_ADV_TIMEOUT;
2101 rx->hdr.type = NODE_RX_TYPE_EXT_ADV_TERMINATE;
2102 rx->hdr.handle = handle;
2103 rx->rx_ftr.param_adv_term.conn_handle = 0xffff;
2104 rx->rx_ftr.param_adv_term.num_events = adv->event_counter;
2106 lll_aux = lll->aux;
2136 struct pdu_adv_com_ext_adv *com_hdr = (void *)&pdu->adv_ext_ind;
2137 struct pdu_adv_ext_hdr *hdr = (void *)com_hdr->ext_hdr_adv_data;
2140 if (com_hdr->ext_hdr_len) {
2153 if ((pdu->type == PDU_ADV_TYPE_DIRECT_IND) ||
2155 ((pdu->type == PDU_ADV_TYPE_EXT_IND) && hdr_flags.tgt_addr) ||
2175 lll = &adv->lll;
2178 phy = lll->phy_p;
2179 phy_flags = lll->phy_flags;
2185 chan_map = lll->chan_map;
2196 if (adv->ull.ticks_slot > time_ticks) {
2197 ticks_minus = adv->ull.ticks_slot - time_ticks;
2199 } else if (adv->ull.ticks_slot < time_ticks) {
2201 ticks_plus = time_ticks - adv->ull.ticks_slot;
2219 adv->ull.ticks_slot = time_ticks;
2267 if (!adv || adv->is_enabled) {
2280 /* NOTE: 16-bit value is sufficient to calculate the maximum radio
2287 if (pdu->type == PDU_ADV_TYPE_EXT_IND) {
2288 time_us += PDU_AC_US(pdu->len, phy, phy_flags) * adv_chn_cnt +
2289 EVENT_RX_TX_TURNAROUND(phy) * (adv_chn_cnt - 1);
2303 ADVA_SIZE + pdu_scan->len), PHY_1M);
2307 if (pdu->type == PDU_ADV_TYPE_NONCONN_IND) {
2308 adv_size += pdu->len;
2310 rxtx_turn_us * (adv_chn_cnt - 1);
2312 if (pdu->type == PDU_ADV_TYPE_DIRECT_IND) {
2315 } else if (pdu->type == PDU_ADV_TYPE_ADV_IND) {
2316 adv_size += pdu->len;
2319 } else if (pdu->type == PDU_ADV_TYPE_SCAN_IND) {
2320 adv_size += pdu->len;
2327 rxtx_turn_us) * (adv_chn_cnt - 1) +
2344 struct ll_adv_set *adv = context->context;
2355 lll = &adv->lll;
2358 if (lll->aux) {
2366 if ((adv->max_events && adv->event_counter >= adv->max_events) ||
2367 (adv->remain_duration_us &&
2368 adv->remain_duration_us <= (uint64_t)adv->interval * ADV_INT_UNIT_US)) {
2377 ref = ull_ref_inc(&adv->ull);
2382 if (adv->lll.aux) {
2386 LL_ASSERT(context->other_expire_info);
2389 ticks_to_expire = context->other_expire_info->ticks_to_expire;
2390 other_remainder = context->other_expire_info->remainder;
2394 adv->lll.aux->ticks_pri_pdu_offset = ticks_to_expire;
2395 adv->lll.aux->us_pri_pdu_offset = other_remainder;
2422 adv->ticks_at_expire = ticks_at_expire;
2425 adv->delay_at_expire = adv->delay;
2435 if (adv->lll.aux) {
2445 if (!lll->is_hdcd)
2457 adv->delay = random_delay;
2473 if (adv->remain_duration_us && adv->event_counter > 0U) {
2476 ticks_drift = adv->delay_at_expire;
2478 uint32_t interval_us = (uint64_t)adv->interval * ADV_INT_UNIT_US;
2483 if (adv->remain_duration_us > elapsed_us + interval_us +
2485 adv->remain_duration_us -= elapsed_us;
2487 adv->remain_duration_us = interval_us;
2491 adv->event_counter += event_counter_inc;
2505 struct pdu_adv *pdu = lll_adv_data_peek(&adv->lll);
2506 bool connectable = (pdu->type == PDU_ADV_TYPE_ADV_IND) ||
2507 (pdu->type == PDU_ADV_TYPE_DIRECT_IND) ||
2509 ((pdu->type == PDU_ADV_TYPE_EXT_IND) &&
2510 (pdu->adv_ext_ind.adv_mode & BT_HCI_LE_ADV_PROP_CONN)) ||
2518 /* if using connectable adv and lll.conn is 0 -> a connection is underway */
2519 (connectable && !adv->lll.conn) ||
2577 hdr = &adv->ull;
2583 mfy.param = &adv->lll;
2588 LL_ASSERT(!hdr->disabled_cb);
2589 hdr->disabled_param = mfy.param;
2590 hdr->disabled_cb = disabled_cb;
2592 /* Trigger LLL disable */
2598 disabled_cb(&adv->lll);
2609 adv = ((struct lll_hdr *)param)->parent;
2611 LL_ASSERT(adv->link_cc_free);
2612 link = adv->link_cc_free;
2613 adv->link_cc_free = NULL;
2615 LL_ASSERT(adv->node_rx_cc_free);
2616 rx = adv->node_rx_cc_free;
2617 adv->node_rx_cc_free = NULL;
2619 rx->hdr.type = NODE_RX_TYPE_CONNECTION;
2620 rx->hdr.handle = 0xffff;
2622 cc = (void *)rx->pdu;
2624 cc->status = BT_HCI_ERR_ADV_TIMEOUT;
2626 rx->rx_ftr.param = param;
2629 if (adv->lll.node_rx_adv_term) {
2637 rx = (void *)adv->lll.node_rx_adv_term;
2638 rx->hdr.type = NODE_RX_TYPE_EXT_ADV_TERMINATE;
2639 rx->hdr.handle = handle;
2640 rx->rx_ftr.param_adv_term.status = BT_HCI_ERR_ADV_TIMEOUT;
2641 rx->rx_ftr.param_adv_term.conn_handle = 0xffff;
2642 rx->rx_ftr.param_adv_term.num_events = adv->event_counter;
2644 link = rx->hdr.link;
2653 struct lll_conn *lll = adv->lll.conn;
2656 LL_ASSERT(!lll->link_tx_free);
2657 link = memq_deinit(&lll->memq_tx.head, &lll->memq_tx.tail);
2659 lll->link_tx_free = link;
2661 ll_conn_release(lll->hdr.parent);
2662 adv->lll.conn = NULL;
2664 ll_rx_release(adv->node_rx_cc_free);
2665 adv->node_rx_cc_free = NULL;
2666 ll_rx_link_release(adv->link_cc_free);
2667 adv->link_cc_free = NULL;
2698 adv->event_counter = 0;
2699 adv->max_events = max_ext_adv_evts;
2700 adv->remain_duration_us = (uint32_t)duration * 10U * USEC_PER_MSEC;
2726 lll_aux = adv->lll.aux;
2728 hdr = &aux->ull;
2730 LL_ASSERT(!hdr->disabled_cb);
2731 hdr->disabled_param = adv;
2732 hdr->disabled_cb = aux_disabled_cb;
2779 hdr = &adv->ull;
2785 mfy.param = &adv->lll;
2790 LL_ASSERT(!hdr->disabled_cb);
2791 hdr->disabled_param = mfy.param;
2792 hdr->disabled_cb = ext_disabled_cb;
2794 /* Trigger LLL disable */
2800 ext_disabled_cb(&adv->lll);
2807 struct node_rx_pdu *rx = lll->node_rx_adv_term;
2818 ll_rx_put_sched(rx->hdr.link, rx);
2844 if (adv->lll.conn) {
2846 adv->lll.conn->periph.cancelled = 1U;
2852 if (unlikely(adv->lll.conn->periph.initiated)) {
2862 if (adv->lll.is_hdcd) {
2889 err = ull_disable(&adv->lll);
2890 LL_ASSERT(!err || (err == -EALREADY));
2896 struct lll_adv_aux *lll_aux = adv->lll.aux;
2904 if (err && (err != -EALREADY)) {
2911 if (adv->lll.conn) {
2917 struct lll_adv *lll = &adv->lll;
2919 if (lll->node_rx_adv_term) {
2921 (void *)lll->node_rx_adv_term;
2923 lll->node_rx_adv_term = NULL;
2925 ll_rx_link_release(node_rx_adv_term->hdr.link);
2930 adv->is_enabled = 0U;
2949 lll = &adv->lll;
2953 } else if (pdu->type == PDU_ADV_TYPE_EXT_IND) {
2958 pri_com_hdr = (void *)&pdu->adv_ext_ind;
2959 pri_hdr = (void *)pri_com_hdr->ext_hdr_adv_data;
2960 if (pri_com_hdr->ext_hdr_len) {
2966 if (pri_com_hdr->adv_mode & BT_HCI_LE_ADV_PROP_SCAN) {
2969 if (!sr->len) {
2984 sec_pdu = lll_adv_aux_data_peek(lll->aux);
2986 sec_com_hdr = (void *)&sec_pdu->adv_ext_ind;
2987 sec_hdr = (void *)sec_com_hdr->ext_hdr_adv_data;
2988 if (sec_com_hdr->ext_hdr_len) {
3013 if (pdu_adv_to_update->tx_addr &&
3019 /* Do not update scan response for extended non-scannable since
3022 if ((pdu->type != PDU_ADV_TYPE_EXT_IND) ||
3023 (pdu->adv_ext_ind.adv_mode & BT_HCI_LE_ADV_PROP_SCAN)) {
3038 struct pdu_adv_com_ext_adv *com_hdr = (void *)&pdu->adv_ext_ind;
3039 struct pdu_adv_ext_hdr *hdr = (void *)com_hdr->ext_hdr_adv_data;
3042 if (com_hdr->ext_hdr_len) {
3049 if (pdu->type == PDU_ADV_TYPE_EXT_IND) {
3052 return &com_hdr->ext_hdr_adv_data[1];
3057 return pdu->adv_ind.addr;
3063 const uint8_t *rpa = ull_filter_adva_get(adv->lll.rl_idx);
3074 } else if (ll_adv_cmds_is_ext() && pdu->tx_addr) {
3075 own_id_addr = adv->rnd_addr;
3078 own_id_addr = ll_addr_get(pdu->tx_addr);
3083 (void)memcpy(adv->own_id_addr, own_id_addr, BDADDR_SIZE);
3087 pdu->tx_addr = 1;
3105 rx_addr = ull_filter_tgta_get(adv->lll.rl_idx);
3107 pdu->rx_addr = 1;
3123 pdu->type = pdu_type;
3124 pdu->rfu = 0;
3125 pdu->chan_sel = 0;
3126 pdu->tx_addr = 0;
3127 pdu->rx_addr = 0;
3128 pdu->len = BDADDR_SIZE;
3133 adv->interval = BT_LE_ADV_INTERVAL_DEFAULT;
3135 adv->own_addr_type = BT_HCI_OWN_ADDR_RPA_OR_PUBLIC;
3137 adv->lll.chan_map = BT_LE_ADV_CHAN_MAP_ALL;
3138 adv->lll.filter_policy = BT_LE_ADV_FP_NO_FILTER;
3140 adv->delay = 0U;