-
Notifications
You must be signed in to change notification settings - Fork 8.3k
samples: Bluetooth: Broadcast multiple legacy and extended advertising #94304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8031972
96c6734
addc754
612ef6d
9ec0295
1209301
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename this file to cc @nordicjm |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Increased to 4 gives one each of legacy, 2M, 1M and Coded PHY advertising sets | ||
| CONFIG_BT_EXT_ADV_MAX_ADV_SET=4 | ||
|
|
||
| # Use Zephyr Bluetooth Low Energy Controller | ||
| CONFIG_BT_LL_SW_SPLIT=y | ||
|
|
||
| # Enable Coded PHY support in Zephyr Controller, if testing 4 advertising sets | ||
| CONFIG_BT_CTLR_PHY_CODED=y | ||
|
|
||
| # Zephyr Bluetooth LE Controller will need to use chain PDUs when AD data | ||
| # length > 191 bytes | ||
| # - 31 bytes will use 22 bytes for the default name in this sample plus 9 bytes | ||
| # for manufacturer data | ||
| # - 191 bytes will use 22 bytes for the default name in this sample plus 169 | ||
| # bytes for manufacturer data | ||
| # - 277 bytes will use 22 bytes for the default name in this sample plus 255 | ||
| # bytes for manufacturer data | ||
| CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=192 | ||
|
|
||
| # Increase Advertising PDU buffers to number of advertising sets times the | ||
| # number of chain PDUs per advertising set when using Zephyr Bluetooth LE | ||
| # Controller | ||
| CONFIG_BT_CTLR_ADVANCED_FEATURES=y | ||
| CONFIG_BT_CTLR_ADV_RESERVE_MAX=n | ||
| CONFIG_BT_CTLR_ADV_DATA_BUF_MAX=6 | ||
| CONFIG_BT_CTLR_ADV_DATA_CHAIN=y | ||
|
|
||
| # Code size reduction | ||
| CONFIG_ISR_TABLES_LOCAL_DECLARATION=y | ||
| CONFIG_LTO=y |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,23 +1,13 @@ | ||||||
| CONFIG_BT=y | ||||||
| CONFIG_BT_BROADCASTER=y | ||||||
| CONFIG_BT_EXT_ADV=y | ||||||
| CONFIG_BT_EXT_ADV_MAX_ADV_SET=2 | ||||||
| CONFIG_BT_DEVICE_NAME="Broadcaster Multiple" | ||||||
|
|
||||||
| CONFIG_LOG=y | ||||||
|
|
||||||
| # Zephyr Bluetooth LE Controller will need to use chain PDUs when AD data | ||||||
| # length > 191 bytes | ||||||
| # - 31 bytes will use 22 bytes for the default name in this sample plus 9 bytes | ||||||
| # for manufacturer data | ||||||
| # - 191 bytes will use 22 bytes for the default name in this sample plus 169 | ||||||
| # bytes for manufacturer data | ||||||
| # - 277 bytes will use 22 bytes for the default name in this sample plus 255 | ||||||
| # bytes for manufacturer data | ||||||
| # CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=192 | ||||||
| # Require Bluetooth Advertising Extensions Feature | ||||||
| CONFIG_BT_EXT_ADV=y | ||||||
|
|
||||||
| # Increase Advertising PDU buffers to number of advertising sets times the | ||||||
| # number of chain PDUs per advertising set when using Zephyr Bluetooth LE | ||||||
| # Controller | ||||||
| # CONFIG_BT_CTLR_ADVANCED_FEATURES=y | ||||||
| # CONFIG_BT_CTLR_ADV_DATA_BUF_MAX=2 | ||||||
| # Two advertising sets should be supported by most Controller implementations with Advertising | ||||||
| # Extensions support. | ||||||
| # Increasing to 4 should gives one each of legacy, 2M, 1M and Coded PHY advertising sets, when | ||||||
| # supported by Controller implementation. | ||||||
| CONFIG_BT_EXT_ADV_MAX_ADV_SET=2 | ||||||
|
||||||
| CONFIG_BT_EXT_ADV_MAX_ADV_SET=2 | |
| CONFIG_BT_EXT_ADV_MAX_ADV_SET=4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No not all vendors will support 4 as default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue is that the comment states "Increased to 4" but the option assigns 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cvinayak did you forget to push? Comment still says 4 but the value is 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't think the comment makes a lot of sense. Why is the comment even mentioning 4 sets, if we are configuring for 2 sets?
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,24 @@ | ||
| sample: | ||
| name: Bluetooth Multiple Extended Advertising Broadcaster | ||
| common: | ||
| harness: bluetooth | ||
| tags: | ||
| - bluetooth | ||
| tests: | ||
| sample.bluetooth.multiple_broadcast: | ||
| harness: bluetooth | ||
| sample.bluetooth.broadcaster_multiple: | ||
| platform_allow: | ||
| - qemu_cortex_m3 | ||
| - qemu_x86 | ||
| integration_platforms: | ||
| - qemu_cortex_m3 | ||
| sample.bluetooth.broadcaster_multiple.bt_ll_sw_split: | ||
| extra_args: | ||
| - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf | ||
| platform_allow: | ||
| - nrf51dk/nrf51822 | ||
| - nrf52_bsim | ||
| - nrf52dk/nrf52832 | ||
| tags: bluetooth | ||
| - nrf52840dk/nrf52840 | ||
| integration_platforms: | ||
| - qemu_cortex_m3 | ||
| - nrf52dk/nrf52832 | ||
| - nrf52840dk/nrf52840 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -54,44 +54,95 @@ | |||||||||||||||||||
| */ | ||||||||||||||||||||
| static uint8_t mfg_data[BT_MFG_DATA_LEN] = { 0xFF, 0xFF, }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| static const struct bt_data ad[] = { | ||||||||||||||||||||
| static const struct bt_data ad_long[] = { | ||||||||||||||||||||
| BT_DATA(BT_DATA_MANUFACTURER_DATA, mfg_data, sizeof(mfg_data)), | ||||||||||||||||||||
| #if CONFIG_BT_CTLR_ADV_DATA_LEN_MAX > 255 | ||||||||||||||||||||
| BT_DATA(BT_DATA_MANUFACTURER_DATA, mfg_data, sizeof(mfg_data)), | ||||||||||||||||||||
| #endif | ||||||||||||||||||||
| BT_DATA(BT_DATA_NAME_COMPLETE, CONFIG_BT_DEVICE_NAME, sizeof(CONFIG_BT_DEVICE_NAME) - 1), | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| static const struct bt_data ad_short[] = { | ||||||||||||||||||||
| BT_DATA(BT_DATA_NAME_COMPLETE, CONFIG_BT_DEVICE_NAME, sizeof(CONFIG_BT_DEVICE_NAME) - 1), | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| static struct bt_le_ext_adv *adv[CONFIG_BT_EXT_ADV_MAX_ADV_SET]; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| int broadcaster_multiple(void) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| struct bt_le_adv_param adv_param = { | ||||||||||||||||||||
| .id = BT_ID_DEFAULT, | ||||||||||||||||||||
| .sid = 0U, /* Supply unique SID when creating advertising set */ | ||||||||||||||||||||
| .secondary_max_skip = 0U, | ||||||||||||||||||||
| .options = BT_LE_ADV_OPT_EXT_ADV, | ||||||||||||||||||||
| .interval_min = BT_GAP_ADV_FAST_INT_MIN_2, | ||||||||||||||||||||
| .interval_max = BT_GAP_ADV_FAST_INT_MAX_2, | ||||||||||||||||||||
| .peer = NULL, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| int err; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /* Create and start Advertising Sets */ | ||||||||||||||||||||
| for (int index = 0; index < CONFIG_BT_EXT_ADV_MAX_ADV_SET; index++) { | ||||||||||||||||||||
| struct bt_le_adv_param adv_param = { | ||||||||||||||||||||
| .id = BT_ID_DEFAULT, | ||||||||||||||||||||
| .sid = 0U, /* Supply unique SID when creating advertising set */ | ||||||||||||||||||||
| .secondary_max_skip = 0U, | ||||||||||||||||||||
| .options = BT_LE_ADV_OPT_EXT_ADV, | ||||||||||||||||||||
| .interval_min = BT_GAP_ADV_FAST_INT_MIN_2, | ||||||||||||||||||||
| .interval_max = BT_GAP_ADV_FAST_INT_MAX_2, | ||||||||||||||||||||
| .peer = NULL, | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| const struct adv_param_config { | ||||||||||||||||||||
| uint32_t options; | ||||||||||||||||||||
| const struct bt_data *ad; | ||||||||||||||||||||
| size_t ad_size; | ||||||||||||||||||||
| } param_config[] = { | ||||||||||||||||||||
|
Comment on lines
+86
to
+90
|
||||||||||||||||||||
| { /* Use 1M legacy PDU */ | ||||||||||||||||||||
| .options = BT_LE_ADV_OPT_NONE, | ||||||||||||||||||||
| .ad = ad_short, | ||||||||||||||||||||
| .ad_size = ARRAY_SIZE(ad_short), | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| { /* Use 2M auxiliary PDU */ | ||||||||||||||||||||
| .options = BT_LE_ADV_OPT_EXT_ADV, | ||||||||||||||||||||
| .ad = ad_long, | ||||||||||||||||||||
| .ad_size = ARRAY_SIZE(ad_long), | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| { /* Use 1M auxiliary PDU */ | ||||||||||||||||||||
| .options = BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_NO_2M, | ||||||||||||||||||||
| .ad = ad_long, | ||||||||||||||||||||
| .ad_size = ARRAY_SIZE(ad_long), | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| { /* Use Coded PHY */ | ||||||||||||||||||||
| .options = BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CODED, | ||||||||||||||||||||
| .ad = ad_long, | ||||||||||||||||||||
| .ad_size = ARRAY_SIZE(ad_long), | ||||||||||||||||||||
| }}; | ||||||||||||||||||||
| const struct bt_data *ad; | ||||||||||||||||||||
| size_t ad_size; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /* Use advertising set instance index as SID */ | ||||||||||||||||||||
| adv_param.sid = index; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /* Advertising set options, AD and AD array size */ | ||||||||||||||||||||
|
||||||||||||||||||||
| /* Advertising set options, AD and AD array size */ | |
| /* Advertising set options, AD and AD array size */ | |
| /* | |
| * Cycle through param_config using modulo operation. | |
| * If CONFIG_BT_EXT_ADV_MAX_ADV_SET is greater than ARRAY_SIZE(param_config), | |
| * configurations will repeat for additional advertising sets. | |
| * This is intentional; update param_config or CONFIG_BT_EXT_ADV_MAX_ADV_SET | |
| * if a one-to-one mapping is required. | |
| */ |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename this file to cc @nordicjm |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename this file to cc @nordicjm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
overlayfrom name, overlay terminology is for DT (I know there are other files named that way, but it's wrong).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is followed across the net, drivers and bluetooth subsystem... and KConfig settings too refer to
applications can have SoC overlay configuration that is applied to itor phrase likeoverlay configuration fileshere: https://docs.zephyrproject.org/latest/build/kconfig/setting.htmlHence, outside the scope of this PR. You may request a github issue to update rest of the repository and Kconfig settings documentation with a suitable proposal.