Skip to content

Commit

Permalink
Bluetooth: Controller: Fix missing first connection event
Browse files Browse the repository at this point in the history
Fix missing first connection event due to first connection
event ticks_slot of central and peripheral overlapping with
the initiator window ticks_slot and advertising ticks_slot,
respectively.

Use ticker_stop_abs interface so that when the ticker is
stopped the ticks_slot_previous is truncated to the actual
ticks used as requested by the supplied absolute ticks.

Relates to commit 8a294a6 ("Bluetooth: controller:
legacy: Fix missing first conn event").

Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
  • Loading branch information
cvinayak authored and carlescufi committed Nov 2, 2022
1 parent a24ac54 commit fbfa2b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
12 changes: 8 additions & 4 deletions subsys/bluetooth/controller/ll_sw/ull_central.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ void ull_central_setup(struct node_rx_hdr *rx, struct node_rx_ftr *ftr,
struct pdu_adv *pdu_tx;
uint8_t peer_addr_type;
uint32_t ticker_status;
uint32_t ticks_at_stop;
struct node_rx_cc *cc;
struct ll_conn *conn;
memq_link_t *link;
Expand Down Expand Up @@ -988,10 +989,13 @@ void ull_central_setup(struct node_rx_hdr *rx, struct node_rx_ftr *ftr,

/* Stop Scanner */
ticker_id_scan = TICKER_ID_SCAN_BASE + ull_scan_handle_get(scan);
ticker_status = ticker_stop(TICKER_INSTANCE_ID_CTLR,
TICKER_USER_ID_ULL_HIGH,
ticker_id_scan, ticker_op_stop_scan_cb,
scan);
ticks_at_stop = ftr->ticks_anchor +
HAL_TICKER_US_TO_TICKS(conn_offset_us) -
ticks_slot_offset;
ticker_status = ticker_stop_abs(TICKER_INSTANCE_ID_CTLR,
TICKER_USER_ID_ULL_HIGH,
ticker_id_scan, ticks_at_stop,
ticker_op_stop_scan_cb, scan);
LL_ASSERT((ticker_status == TICKER_STATUS_SUCCESS) ||
(ticker_status == TICKER_STATUS_BUSY));

Expand Down
11 changes: 8 additions & 3 deletions subsys/bluetooth/controller/ll_sw/ull_peripheral.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ void ull_periph_setup(struct node_rx_hdr *rx, struct node_rx_ftr *ftr,
struct ll_adv_set *adv;
uint32_t ticker_status;
uint8_t peer_addr_type;
uint32_t ticks_at_stop;
uint16_t win_delay_us;
struct node_rx_cc *cc;
struct ll_conn *conn;
Expand Down Expand Up @@ -439,9 +440,13 @@ void ull_periph_setup(struct node_rx_hdr *rx, struct node_rx_ftr *ftr,

/* Stop Advertiser */
ticker_id_adv = TICKER_ID_ADV_BASE + ull_adv_handle_get(adv);
ticker_status = ticker_stop(TICKER_INSTANCE_ID_CTLR,
TICKER_USER_ID_ULL_HIGH,
ticker_id_adv, ticker_op_stop_adv_cb, adv);
ticks_at_stop = ftr->ticks_anchor +
HAL_TICKER_US_TO_TICKS(conn_offset_us) -
ticks_slot_offset;
ticker_status = ticker_stop_abs(TICKER_INSTANCE_ID_CTLR,
TICKER_USER_ID_ULL_HIGH,
ticker_id_adv, ticks_at_stop,
ticker_op_stop_adv_cb, adv);
ticker_op_stop_adv_cb(ticker_status, adv);

/* Stop Direct Adv Stop */
Expand Down

0 comments on commit fbfa2b4

Please sign in to comment.