Skip to content

Commit

Permalink
samples: Bluetooth: update scanning_while_connecting sample
Browse files Browse the repository at this point in the history
Update bluetooth softdevice controller configuration
to achieve faster connection establishment.

Signed-off-by: Henrik Lander <[email protected]>
  • Loading branch information
henrla committed Jan 17, 2025
1 parent 8fde9ff commit 4783bfb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
6 changes: 3 additions & 3 deletions samples/bluetooth/scanning_while_connecting/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ The result should look similar to the following output::
I: Connected to FB:92:1D:8E:8C:D8 (random), number of connections 14
I: Connected to D9:E5:51:E0:5E:24 (random), number of connections 15
I: Connected to CF:2F:99:89:A3:4D (random), number of connections 16
I: 12 seconds to create 16 connections
I: 8 seconds to create 16 connections
I: Disconnecting connections...
I: ---------------------------------------------------------------------
I: ---------------------------------------------------------------------
Expand All @@ -204,7 +204,7 @@ The result should look similar to the following output::
I: Connected to F4:9C:8C:24:F9:44 (random), number of connections 14
I: Connected to EF:92:DC:88:3B:B3 (random), number of connections 15
I: Connected to C8:BA:1D:6F:95:2B (random), number of connections 16
I: 9 seconds to create 16 connections
I: 7 seconds to create 16 connections
I: Disconnecting connections...
I: ---------------------------------------------------------------------
I: ---------------------------------------------------------------------
Expand All @@ -226,7 +226,7 @@ The result should look similar to the following output::
I: Connected to CF:2F:99:89:A3:4D (random), number of connections 14
I: Connected to EF:92:DC:88:3B:B3 (random), number of connections 15
I: Connected to D9:E5:51:E0:5E:24 (random), number of connections 16
I: 4 seconds to create 16 connections
I: 2 seconds to create 16 connections
I: Disconnecting connections...
I: ---------------------------------------------------------------------
I: ---------------------------------------------------------------------
28 changes: 28 additions & 0 deletions samples/bluetooth/scanning_while_connecting/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,34 @@ int main(void)

hci_vs_sdc_central_acl_event_spacing_set(&event_spacing_params);

/** Set a small connection event length to leave more time for scanning.
*
* This can also be set at compile time by using the Kconfig option
* CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT in the prj.conf file.
*/
sdc_hci_cmd_vs_event_length_set_t event_length_params = {
.event_length_us = 2000,
};

sdc_hci_cmd_vs_event_length_set(&event_length_params);

/** Connection event extension is turned on by default. This is turned on by default
* to achieve higher throughput. As a consequence, the scheduler will schedule
* longer connection events at the cost of scanning events. In this sample application,
* we try to achieve faster connection establishment, so we turn connection
* event extension off. Thus, the controller shedules more time for scanning.
*
* This can also be turned off on compile time by setting the Kconfig option
* BT_CTLR_SDC_CONN_EVENT_EXTEND_DEFAULT=n in the prj.conf file.
*
* See our scheduling documentation under nrfxlib/softdevice_controller for more info.
*/
sdc_hci_cmd_vs_conn_event_extend_t conn_event_extend_params = {
.enable = 0,
};

hci_vs_sdc_conn_event_extend(&conn_event_extend_params);

for (uint8_t i = 0; i < ARRAY_SIZE(conn_establishment_modes); i++) {

active_conn_establishment_mode = conn_establishment_modes[i];
Expand Down

0 comments on commit 4783bfb

Please sign in to comment.