Skip to content

Commit e3026d6

Browse files
henrlarugeGerritsen
authored andcommitted
samples: Bluetooth: update scanning_while_connecting sample
Update bluetooth softdevice controller configuration to achieve faster connection establishment. Signed-off-by: Henrik Lander <[email protected]>
1 parent 5e12525 commit e3026d6

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

samples/bluetooth/scanning_while_connecting/README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ The result should look similar to the following output::
182182
I: Connected to FB:92:1D:8E:8C:D8 (random), number of connections 14
183183
I: Connected to D9:E5:51:E0:5E:24 (random), number of connections 15
184184
I: Connected to CF:2F:99:89:A3:4D (random), number of connections 16
185-
I: 12 seconds to create 16 connections
185+
I: 8 seconds to create 16 connections
186186
I: Disconnecting connections...
187187
I: ---------------------------------------------------------------------
188188
I: ---------------------------------------------------------------------
@@ -204,7 +204,7 @@ The result should look similar to the following output::
204204
I: Connected to F4:9C:8C:24:F9:44 (random), number of connections 14
205205
I: Connected to EF:92:DC:88:3B:B3 (random), number of connections 15
206206
I: Connected to C8:BA:1D:6F:95:2B (random), number of connections 16
207-
I: 9 seconds to create 16 connections
207+
I: 7 seconds to create 16 connections
208208
I: Disconnecting connections...
209209
I: ---------------------------------------------------------------------
210210
I: ---------------------------------------------------------------------
@@ -226,7 +226,7 @@ The result should look similar to the following output::
226226
I: Connected to CF:2F:99:89:A3:4D (random), number of connections 14
227227
I: Connected to EF:92:DC:88:3B:B3 (random), number of connections 15
228228
I: Connected to D9:E5:51:E0:5E:24 (random), number of connections 16
229-
I: 4 seconds to create 16 connections
229+
I: 2 seconds to create 16 connections
230230
I: Disconnecting connections...
231231
I: ---------------------------------------------------------------------
232232
I: ---------------------------------------------------------------------

samples/bluetooth/scanning_while_connecting/src/main.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,35 @@ int main(void)
437437

438438
hci_vs_sdc_central_acl_event_spacing_set(&event_spacing_params);
439439

440+
/** Set a small connection event length to leave more time for scanning.
441+
*
442+
* This can also be set at compile time by using the Kconfig option
443+
* CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT in the prj.conf file.
444+
*/
445+
sdc_hci_cmd_vs_event_length_set_t event_length_params = {
446+
.event_length_us = 2000,
447+
};
448+
449+
hci_vs_sdc_event_length_set(&event_length_params);
450+
451+
/** Connection event extension is turned on by default. This is turned on by default
452+
* to achieve higher throughput. As a consequence, the scheduler will schedule
453+
* longer connection events at the cost of scanning events. In this sample application,
454+
* we try to achieve faster connection establishment, so we turn connection
455+
* event extension off. Thus, the controller schedules more time for scanning.
456+
*
457+
* This can also be turned off at compile time by setting the Kconfig option
458+
* BT_CTLR_SDC_CONN_EVENT_EXTEND_DEFAULT=n in the prj.conf file.
459+
*
460+
* See our scheduling documentation under nrfxlib/softdevice_controller for
461+
* more information.
462+
*/
463+
sdc_hci_cmd_vs_conn_event_extend_t conn_event_extend_params = {
464+
.enable = 0,
465+
};
466+
467+
hci_vs_sdc_conn_event_extend(&conn_event_extend_params);
468+
440469
for (uint8_t i = 0; i < ARRAY_SIZE(conn_establishment_modes); i++) {
441470

442471
active_conn_establishment_mode = conn_establishment_modes[i];

0 commit comments

Comments
 (0)