Skip to content

Commit 8cac1f5

Browse files
jakkrafabiobaltieri
authored andcommitted
Bluetooth: Host: Add function to retreive per_adv_sync obj from index.
Gives the application a two way mapping between array index and a per_adv_sync object instead of current only per_adv_sync obj -> index using bt_le_per_adv_sync_get_index. Signed-off-by: Jakob Krantz <[email protected]>
1 parent 9018338 commit 8cac1f5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

include/zephyr/bluetooth/bluetooth.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,20 @@ struct bt_le_per_adv_sync_param {
14171417
*/
14181418
uint8_t bt_le_per_adv_sync_get_index(struct bt_le_per_adv_sync *per_adv_sync);
14191419

1420+
/**
1421+
* @brief Get a periodic advertising sync object from the array index.
1422+
*
1423+
* This function is to get the periodic advertising sync object from
1424+
* the array index.
1425+
* The array has CONFIG_BT_PER_ADV_SYNC_MAX elements.
1426+
*
1427+
* @param index The index of the periodic advertising sync object.
1428+
* The range of the index value is 0..CONFIG_BT_PER_ADV_SYNC_MAX-1
1429+
*
1430+
* @return The periodic advertising sync object of the array index or NULL if invalid index.
1431+
*/
1432+
struct bt_le_per_adv_sync *bt_le_per_adv_sync_lookup_index(uint8_t index);
1433+
14201434
/** @brief Advertising set info structure. */
14211435
struct bt_le_per_adv_sync_info {
14221436
/** Periodic Advertiser Address */

subsys/bluetooth/host/scan.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,15 @@ uint8_t bt_le_per_adv_sync_get_index(struct bt_le_per_adv_sync *per_adv_sync)
13451345
return (uint8_t)index;
13461346
}
13471347

1348+
struct bt_le_per_adv_sync *bt_le_per_adv_sync_lookup_index(uint8_t index)
1349+
{
1350+
if (index >= ARRAY_SIZE(per_adv_sync_pool)) {
1351+
return NULL;
1352+
}
1353+
1354+
return &per_adv_sync_pool[index];
1355+
}
1356+
13481357
int bt_le_per_adv_sync_get_info(struct bt_le_per_adv_sync *per_adv_sync,
13491358
struct bt_le_per_adv_sync_info *info)
13501359
{

0 commit comments

Comments
 (0)