Skip to content
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

Concurrent scan init sample #19177

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

henrla
Copy link
Contributor

@henrla henrla commented Dec 2, 2024

No description provided.

@henrla henrla requested review from a team as code owners December 2, 2024 08:21
@github-actions github-actions bot added doc-required PR must not be merged without tech writer approval. changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. labels Dec 2, 2024
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Dec 2, 2024

CI Information

To view the history of this post, clich the 'edited' button above
Build number: 16

Inputs:

Sources:

sdk-nrf: PR head: 121c77c1909fc10b3e76940a4c36d46bee6a0111

more details

sdk-nrf:

PR head: 121c77c1909fc10b3e76940a4c36d46bee6a0111
merge base: e2cfdfd0f4c8b30e89463b7f421b4e27f2f1f35e
target head (main): e2cfdfd0f4c8b30e89463b7f421b4e27f2f1f35e
Diff

Github labels

Enabled Name Description
ci-disabled Disable the ci execution
ci-all-test Run all of ci, no test spec filtering will be done
ci-force-downstream Force execution of downstream even if twister fails
ci-run-twister Force run twister
ci-run-zephyr-twister Force run zephyr twister
List of changed files detected by CI (9)
CODEOWNERS
doc
│  ├── nrf
│  │  ├── releases_and_maturity
│  │  │  ├── releases
│  │  │  │  │ release-notes-changelog.rst
samples
│  ├── bluetooth
│  │  ├── scanning_while_connecting
│  │  │  ├── CMakeLists.txt
│  │  │  ├── Kconfig.sysbuild
│  │  │  ├── README.rst
│  │  │  ├── prj.conf
│  │  │  ├── sample.yaml
│  │  │  ├── src
│  │  │  │  │ main.c
│  │  │  ├── sysbuild
│  │  │  │  ├── ipc_radio
│  │  │  │  │  │ prj.conf

Outputs:

Toolchain

Version: b77d8c1312
Build docker image: docker-dtr.nordicsemi.no/sw-production/ncs-build:b77d8c1312_912848a074

Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped; ⚠️ Quarantine

  • ◻️ Toolchain - Skipped: existing toolchain is used
  • ✅ Build twister
    • sdk-nrf test count: 478
  • ✅ Integration tests
    • ✅ test-fw-nrfconnect-ble_samples
Disabled integration tests
    • desktop52_verification
    • doc-internal
    • test_ble_nrf_config
    • test-fw-nrfconnect-apps
    • test-fw-nrfconnect-ble_mesh
    • test-fw-nrfconnect-boot
    • test-fw-nrfconnect-chip
    • test-fw-nrfconnect-fem
    • test-fw-nrfconnect-nfc
    • test-fw-nrfconnect-nrf-iot_libmodem-nrf
    • test-fw-nrfconnect-nrf-iot_lwm2m
    • test-fw-nrfconnect-nrf-iot_mosh
    • test-fw-nrfconnect-nrf-iot_nrf_provisioning
    • test-fw-nrfconnect-nrf-iot_positioning
    • test-fw-nrfconnect-nrf-iot_samples
    • test-fw-nrfconnect-nrf-iot_serial_lte_modem
    • test-fw-nrfconnect-nrf-iot_thingy91
    • test-fw-nrfconnect-nrf-iot_zephyr_lwm2m
    • test-fw-nrfconnect-nrf_crypto
    • test-fw-nrfconnect-ps
    • test-fw-nrfconnect-rpc
    • test-fw-nrfconnect-rs
    • test-fw-nrfconnect-tfm
    • test-fw-nrfconnect-thread
    • test-fw-nrfconnect-zigbee
    • test-low-level
    • test-sdk-audio
    • test-sdk-dfu
    • test-sdk-find-my
    • test-sdk-mcuboot
    • test-sdk-pmic-samples
    • test-sdk-sidewalk
    • test-sdk-wifi
    • test-secdom-samples-public

Note: This message is automatically posted and updated by the CI


|config|

Configuration options
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this section unless you have some sample-specific new Kconfig options that are not available in the Kconfig reference. The one here is already available.

@@ -0,0 +1,238 @@
.. _bt_scanning_while_connecting:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably buried too deep in the structure. Suggesting to leave out the central folder.

Copy link
Contributor Author

@henrla henrla Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your feedback @peknis. The doc build fails because there are references to another sample which is also still in review (#19133). Apart from that, I think you can look at the documentation again.

Comment on lines 30 to 31
To illustrate how connection establishment speed can be improved, it measures the time needed to connect to 16 devices with three different modes: sequential scanning and connection establishment, concurrent scanning while connecting, and concurrent scanning while connecting with the filter accept list.
It will connect to any device that matches the device name set with :kconfig:option:`CONFIG_BT_DEVICE_NAME`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To illustrate how connection establishment speed can be improved, it measures the time needed to connect to 16 devices with three different modes: sequential scanning and connection establishment, concurrent scanning while connecting, and concurrent scanning while connecting with the filter accept list.
It will connect to any device that matches the device name set with :kconfig:option:`CONFIG_BT_DEVICE_NAME`.
To illustrate how connection establishment speed can be improved, it measures the time needed to connect to 16 devices with three different modes:
* Sequential scanning and connection establishment
* Concurrent scanning while connecting
* Concurrent scanning while connecting with the filter accept list
It will connect to any device that matches the device name set with the :kconfig:option:`CONFIG_BT_DEVICE_NAME` Kconfig option.

It (ín two places) referring here to the sample?

.. table-from-sample-yaml::

The sample also requires at least one other development kit running a sample advertising with the name set with :kconfig:option:`CONFIG_BT_DEVICE_NAME`.
It is recommended to use the sample :ref:`peripheral_uart`, because this sample acts as multiple peripheral devices.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It is recommended to use the sample :ref:`peripheral_uart`, because this sample acts as multiple peripheral devices.
It is recommended to use the :ref:`peripheral_uart` sample, because this sample acts as multiple peripheral devices.

================================================

This is the slowest and simplest approach.
Sequential scanning and connection establishment is therefore recommended when the application only needs to connect a handful of devices.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Sequential scanning and connection establishment is therefore recommended when the application only needs to connect a handful of devices.
Sequential scanning and connection establishment is recommended when the application only needs to connect a handful of devices.

Concurrent scanning while connecting
====================================

This mode requires the application to enable :kconfig:option:`CONFIG_BT_SCAN_AND_INITIATE_IN_PARALLEL`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This mode requires the application to enable :kconfig:option:`CONFIG_BT_SCAN_AND_INITIATE_IN_PARALLEL`.
This mode requires the application to enable the :kconfig:option:`CONFIG_BT_SCAN_AND_INITIATE_IN_PARALLEL` Kconfig option.

====================================

This mode requires the application to enable :kconfig:option:`CONFIG_BT_SCAN_AND_INITIATE_IN_PARALLEL`.
In this mode the scanner is not stopped when the application creates connections.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In this mode the scanner is not stopped when the application creates connections.
In this mode, the scanner is not stopped when the application creates connections.

Concurrent scanning while connecting with the filter accept list
================================================================

This mode requires the application to enable :kconfig:option:`CONFIG_BT_FILTER_ACCEPT_LIST` in addition to :kconfig:option:`CONFIG_BT_SCAN_AND_INITIATE_IN_PARALLEL`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This mode requires the application to enable :kconfig:option:`CONFIG_BT_FILTER_ACCEPT_LIST` in addition to :kconfig:option:`CONFIG_BT_SCAN_AND_INITIATE_IN_PARALLEL`.
This mode requires the application to enable the :kconfig:option:`CONFIG_BT_FILTER_ACCEPT_LIST` Kconfig option in addition to :kconfig:option:`CONFIG_BT_SCAN_AND_INITIATE_IN_PARALLEL`.


.. note::
This sample application assumes it will never have to cache more devices than the maximum number of addresses that can be stored in the filter accept list.
For applications that cannot adhere to this simplification, the function :cfunc:`cache_peer_address` can be changed to not store more than :kconfig:option:`CONFIG_BT_CTLR_FAL_SIZE`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For applications that cannot adhere to this simplification, the function :cfunc:`cache_peer_address` can be changed to not store more than :kconfig:option:`CONFIG_BT_CTLR_FAL_SIZE`.
For applications that cannot adhere to this simplification, the function :cfunc:`cache_peer_address` can be changed to not store more than defined by the :kconfig:option:`CONFIG_BT_CTLR_FAL_SIZE` Kconfig option.

@henrla henrla added this to the 2.9.0 milestone Dec 2, 2024
@henrla henrla force-pushed the concurrent_scan_init_sample branch from ef7b520 to d38bea7 Compare December 2, 2024 12:07
@rugeGerritsen rugeGerritsen self-requested a review December 2, 2024 12:12
@henrla henrla force-pushed the concurrent_scan_init_sample branch from d38bea7 to e4e3a24 Compare December 2, 2024 12:16
Copy link
Contributor

@rugeGerritsen rugeGerritsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor comments. Otherwise the sample is ready

integration_platforms:
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
- nrf54l15dk/nrf54l15/cpuapp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add nrf54l15dk/nrf54l10/cpuapp and nrf54l15dk/nrf54l05/cpuapp as well?

LOG_ERR("Failed to stop scanning (err %d)", err);
}
LOG_DBG("Stopped scanning");
LOG_INF("Stopped scanning");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be removed

Suggested change
LOG_INF("Stopped scanning");

return 0;
}

sdc_hci_cmd_vs_central_acl_event_spacing_set_t event_spacing_params = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sdc_hci_cmd_vs_central_acl_event_spacing_set_t event_spacing_params = {
/* Set a small spacing between central links to leave more time for scanning. */
sdc_hci_cmd_vs_central_acl_event_spacing_set_t event_spacing_params = {


cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(connection_establishment_benchmark)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename this?

Suggested change
project(connection_establishment_benchmark)
project(scanning_while_connecting)

@henrla henrla force-pushed the concurrent_scan_init_sample branch from e4e3a24 to 941381f Compare December 2, 2024 12:24
@henrla henrla force-pushed the concurrent_scan_init_sample branch from 941381f to ce79f80 Compare December 2, 2024 12:42
@github-actions github-actions bot removed the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Dec 2, 2024
@henrla henrla force-pushed the concurrent_scan_init_sample branch 2 times, most recently from 355ade8 to 01cf1b8 Compare December 2, 2024 13:25
Copy link
Contributor

@peknis peknis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember the changelog entry!


.. note::
This sample application assumes it will never have to cache more devices than the maximum number of addresses that can be stored in the filter accept list.
For applications that cannot adhere to this simplification, the function :cfunc:`cache_peer_address` can be changed to not store more than defined by the :kconfig:option:`CONFIG_BT_CTLR_FAL_SIZE` Kconfig option.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For applications that cannot adhere to this simplification, the function :cfunc:`cache_peer_address` can be changed to not store more than defined by the :kconfig:option:`CONFIG_BT_CTLR_FAL_SIZE` Kconfig option.
For applications that cannot adhere to this simplification, the function :c:func:`cache_peer_address` can be changed to not store more than defined by the :kconfig:option:`CONFIG_BT_CTLR_FAL_SIZE` Kconfig option.

the missing colon also gave a warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let me know if something in the changelog entry I added should be changed.

@henrla henrla force-pushed the concurrent_scan_init_sample branch from 01cf1b8 to e2b60e9 Compare December 2, 2024 15:11
@henrla henrla requested a review from a team as a code owner December 2, 2024 15:11
@henrla henrla force-pushed the concurrent_scan_init_sample branch 2 times, most recently from a09ec01 to 235061e Compare December 3, 2024 07:37
@henrla henrla force-pushed the concurrent_scan_init_sample branch 4 times, most recently from c0e38cd to 1cfafcb Compare December 3, 2024 15:50
@NordicBuilder
Copy link
Contributor

You can find the documentation preview for this PR at this link. It will be updated about 10 minutes after the documentation build succeeds.

Note: This comment is automatically posted by the Documentation Publish GitHub Action.

@henrla henrla force-pushed the concurrent_scan_init_sample branch from 1cfafcb to 1144d8c Compare December 4, 2024 07:37
Add sample application that demonstrates faster connection
establishment using CONFIG_BT_SCAN_AND_INITIATE_IN_PARALLEL.

Signed-off-by: Henrik Lander <[email protected]>
@henrla henrla force-pushed the concurrent_scan_init_sample branch from 1144d8c to 121c77c Compare December 4, 2024 08:03
@henrla
Copy link
Contributor Author

henrla commented Dec 4, 2024

@nrfconnect/ncs-co-build-system @nrfconnect/ncs-dragoon-doc @nrfconnect/ncs-code-owners can you have a look at this PR?

@jukkar jukkar merged commit 651daf0 into nrfconnect:main Dec 4, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-required PR must not be merged without tech writer approval.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants