Skip to content

Commit fe18625

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Initial Periodic Adv Data fragment op support
Add initial support for Periodic Advertising Data fragment operation support. This commit is limited to detection of partial data if used before Periodic Advertising is enabled, which will lead to HCI error reason of command disallowed. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 8888681 commit fe18625

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

subsys/bluetooth/controller/ll_sw/ull_adv_sync.c

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ uint8_t ll_adv_sync_param_set(uint8_t handle, uint16_t interval, uint16_t flags)
437437

438438
lll_adv_sync_data_enqueue(lll_sync, ter_idx);
439439

440+
sync->is_data_cmplt = 1U;
441+
440442
return 0;
441443
}
442444

@@ -453,13 +455,6 @@ uint8_t ll_adv_sync_ad_data_set(uint8_t handle, uint8_t op, uint8_t len,
453455
uint8_t ter_idx;
454456
uint8_t err;
455457

456-
/* TODO: handle other op values */
457-
if (op != BT_HCI_LE_EXT_ADV_OP_COMPLETE_DATA &&
458-
op != BT_HCI_LE_EXT_ADV_OP_UNCHANGED_DATA) {
459-
/* FIXME: error code */
460-
return BT_HCI_ERR_CMD_DISALLOWED;
461-
}
462-
463458
adv = ull_adv_is_created_get(handle);
464459
if (!adv) {
465460
return BT_HCI_ERR_UNKNOWN_ADV_IDENTIFIER;
@@ -548,16 +543,21 @@ uint8_t ll_adv_sync_ad_data_set(uint8_t handle, uint8_t op, uint8_t len,
548543
*/
549544
adv_sync_pdu_chain_check_and_duplicate(pdu, pdu_prev);
550545

546+
/* Update time reservation if Periodic Advertising events are active */
551547
if (sync->is_started) {
552548
err = ull_adv_sync_time_update(sync, pdu);
553549
if (err) {
554550
return err;
555551
}
556552
}
557553

554+
/* Commit the updated Periodic Advertising Data */
558555
lll_adv_sync_data_enqueue(lll_sync, ter_idx);
559556

560-
return err;
557+
/* Check if Periodic Advertising Data is complete */
558+
sync->is_data_cmplt = (op >= BT_HCI_LE_EXT_ADV_OP_LAST_FRAG);
559+
560+
return 0;
561561
}
562562

563563
uint8_t ll_adv_sync_enable(uint8_t handle, uint8_t enable)
@@ -572,16 +572,19 @@ uint8_t ll_adv_sync_enable(uint8_t handle, uint8_t enable)
572572
uint8_t ter_idx;
573573
uint8_t err;
574574

575+
/* Check for valid advertising set */
575576
adv = ull_adv_is_created_get(handle);
576577
if (!adv) {
577578
return BT_HCI_ERR_UNKNOWN_ADV_IDENTIFIER;
578579
}
579580

581+
/* Check if periodic advertising is associated with advertising set */
580582
lll_sync = adv->lll.sync;
581583
if (!lll_sync) {
582584
return BT_HCI_ERR_CMD_DISALLOWED;
583585
}
584586

587+
/* Check for invalid enable bit fields */
585588
if ((enable > (BT_HCI_LE_SET_PER_ADV_ENABLE_ENABLE |
586589
BT_HCI_LE_SET_PER_ADV_ENABLE_ADI)) ||
587590
(!IS_ENABLED(CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT) &&
@@ -591,6 +594,7 @@ uint8_t ll_adv_sync_enable(uint8_t handle, uint8_t enable)
591594

592595
sync = HDR_LLL2ULL(lll_sync);
593596

597+
/* Handle periodic advertising being disable */
594598
if (!(enable & BT_HCI_LE_SET_PER_ADV_ENABLE_ENABLE)) {
595599
if (!sync->is_enabled) {
596600
return BT_HCI_ERR_CMD_DISALLOWED;
@@ -606,6 +610,7 @@ uint8_t ll_adv_sync_enable(uint8_t handle, uint8_t enable)
606610
return err;
607611
}
608612

613+
/* Check for advertising set type */
609614
if (IS_ENABLED(CONFIG_BT_CTLR_PARAM_CHECK)) {
610615
uint8_t err;
611616

@@ -615,10 +620,14 @@ uint8_t ll_adv_sync_enable(uint8_t handle, uint8_t enable)
615620
}
616621
}
617622

618-
/* TODO: Check for periodic data being complete */
623+
/* Check for periodic data being complete */
624+
if (!sync->is_data_cmplt) {
625+
return BT_HCI_ERR_CMD_DISALLOWED;
626+
}
619627

620628
/* TODO: Check packet too long */
621629

630+
/* Check for already enabled periodic advertising set */
622631
sync_got_enabled = 0U;
623632
if (sync->is_enabled) {
624633
/* TODO: Enabling an already enabled advertising changes its
@@ -671,6 +680,9 @@ uint8_t ll_adv_sync_enable(uint8_t handle, uint8_t enable)
671680
adv_sync_pdu_chain_check_and_duplicate(pdu, pdu_prev);
672681
}
673682

683+
/* Start Periodic Advertising events if Extended Advertising events are
684+
* active.
685+
*/
674686
if (adv->is_enabled && !sync->is_started) {
675687
struct pdu_adv_sync_info *sync_info;
676688
uint8_t value[1 + sizeof(sync_info)];
@@ -759,6 +771,9 @@ uint8_t ll_adv_sync_enable(uint8_t handle, uint8_t enable)
759771
}
760772
}
761773

774+
/* Commit the Periodic Advertising data if ADI supported and has been
775+
* updated.
776+
*/
762777
if (IS_ENABLED(CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT)) {
763778
lll_adv_sync_data_enqueue(lll_sync, ter_idx);
764779
}

subsys/bluetooth/controller/ll_sw/ull_adv_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct ll_adv_sync_set {
8989

9090
uint8_t is_enabled:1;
9191
uint8_t is_started:1;
92+
uint8_t is_data_cmplt:1;
9293
};
9394

9495
struct ll_adv_iso_set {

0 commit comments

Comments
 (0)