Skip to content

Commit 4cc5c56

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Fix setting fragment when Periodic Adv is active
Fix implementation to reject setting fragment when periodic advertising is enabled. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent fe18625 commit 4cc5c56

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

subsys/bluetooth/controller/ll_sw/ull_adv_sync.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,13 @@ uint8_t ll_adv_sync_ad_data_set(uint8_t handle, uint8_t op, uint8_t len,
455455
uint8_t ter_idx;
456456
uint8_t err;
457457

458+
/* Check for valid advertising set */
458459
adv = ull_adv_is_created_get(handle);
459460
if (!adv) {
460461
return BT_HCI_ERR_UNKNOWN_ADV_IDENTIFIER;
461462
}
462463

464+
/* Check for advertising set type */
463465
if (IS_ENABLED(CONFIG_BT_CTLR_PARAM_CHECK)) {
464466
uint8_t err;
465467

@@ -469,11 +471,19 @@ uint8_t ll_adv_sync_ad_data_set(uint8_t handle, uint8_t op, uint8_t len,
469471
}
470472
}
471473

474+
/* Check if periodic advertising is associated with advertising set */
472475
lll_sync = adv->lll.sync;
473476
if (!lll_sync) {
474477
return BT_HCI_ERR_UNKNOWN_ADV_IDENTIFIER;
475478
}
476479

480+
sync = HDR_LLL2ULL(lll_sync);
481+
482+
/* Reject setting fragment when periodic advertising is enabled */
483+
if (sync->is_enabled && (op <= BT_HCI_LE_EXT_ADV_OP_LAST_FRAG)) {
484+
return BT_HCI_ERR_CMD_DISALLOWED;
485+
}
486+
477487
err = ull_adv_sync_pdu_alloc(adv, ULL_ADV_PDU_EXTRA_DATA_ALLOC_IF_EXIST,
478488
&pdu_prev, &pdu, &extra_data_prev,
479489
&extra_data, &ter_idx);
@@ -511,12 +521,10 @@ uint8_t ll_adv_sync_ad_data_set(uint8_t handle, uint8_t op, uint8_t len,
511521
return err;
512522
}
513523

514-
sync = HDR_LLL2ULL(lll_sync);
515-
516524
/* Parameter validation, if operation is 0x04 (unchanged data)
517525
* - periodic advertising is disabled, or
518526
* - periodic advertising contains no data, or
519-
* - Advertising Data Length is zero
527+
* - Advertising Data Length is not zero
520528
*/
521529
if (IS_ENABLED(CONFIG_BT_CTLR_PARAM_CHECK) &&
522530
(op == BT_HCI_LE_EXT_ADV_OP_UNCHANGED_DATA) &&

0 commit comments

Comments
 (0)