Skip to content

Commit d7c9a28

Browse files
committed
samples: bluetooth: HID SCI support in central_hids
This commit adds usage of the HID SCI feature in the central_hids sample. Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
1 parent 0bad07f commit d7c9a28

7 files changed

Lines changed: 474 additions & 20 deletions

File tree

samples/bluetooth/central_hids/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ config SAMPLE_BT_CENTRAL_HIDS_CONTINUOUS_REPORT_RX_STATS_RATE
3434
instead of logging every payload.
3535

3636
source "Kconfig.zephyr"
37+
38+
if BT_HOGP_SCI
39+
40+
rsource "Kconfig.sci"
41+
42+
endif # BT_HOGP_SCI
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#
2+
# Copyright (c) 2026 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
menu "Central HIDS SCI default connection rate parameters"
8+
9+
# Do not confuse the central default connection rate parameters
10+
# with the HIDS SCI default mode parameters.
11+
# Central default rate parameters (bt_conn_le_conn_rate_set_defaults) apply to future
12+
# connections as the host's default window
13+
# HID SCI default (and other) mode link parameters are chosen in procedures
14+
# with the peripheral and typically differ from these local defaults.
15+
16+
config CENTRAL_HIDS_SCI_INTERVAL_MIN_125US
17+
int "Minimum connection interval (125 microsecond units)"
18+
default 7
19+
range 3 32000
20+
help
21+
Minimum connection interval in 125 microsecond units (LE connection interval
22+
quantum), matching struct bt_conn_le_conn_rate_param.interval_min_125us.
23+
24+
config CENTRAL_HIDS_SCI_INTERVAL_MAX_125US
25+
int "Maximum connection interval (125 microsecond units)"
26+
default 120
27+
range CENTRAL_HIDS_SCI_INTERVAL_MIN_125US 32000
28+
help
29+
Maximum connection interval in 125 microsecond units (LE connection interval
30+
quantum), matching struct bt_conn_le_conn_rate_param.interval_max_125us.
31+
32+
config CENTRAL_HIDS_SCI_SUBRATE_MIN
33+
int "Subrate factor minimum"
34+
default 1
35+
range 1 500
36+
help
37+
Minimum subrate factor, matching struct bt_conn_le_conn_rate_param.subrate_min.
38+
39+
config CENTRAL_HIDS_SCI_SUBRATE_MAX
40+
int "Subrate factor maximum"
41+
default 4
42+
range CENTRAL_HIDS_SCI_SUBRATE_MIN 500
43+
help
44+
Maximum subrate factor, matching struct bt_conn_le_conn_rate_param.subrate_max.
45+
46+
config CENTRAL_HIDS_SCI_MAX_LATENCY
47+
int "Maximum peripheral latency"
48+
default 100
49+
range 0 499
50+
help
51+
Maximum peripheral latency, matching struct bt_conn_le_conn_rate_param.max_latency.
52+
53+
config CENTRAL_HIDS_SCI_CONTINUATION_NUM
54+
int "Continuation number"
55+
default 0
56+
range 0 499
57+
help
58+
Continuation number, matching struct bt_conn_le_conn_rate_param.continuation_number.
59+
60+
config CENTRAL_HIDS_SCI_SUPERVISION_TIMEOUT_10MS
61+
int "Supervision timeout (units of 10 ms)"
62+
default 3200
63+
range 10 3200
64+
help
65+
Link supervision timeout, matching struct bt_conn_le_conn_rate_param.supervision_timeout_10ms.
66+
67+
endmenu

samples/bluetooth/central_hids/README.rst

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ User interface
9292
In this mode, the buttons have different functionalities than in the normal mode.
9393
The available functionalities depend on the sample configuration and are printed in the terminal window after button press.
9494

95+
Currently the following functionalities are available:
96+
97+
* Button 2: Request the next HID SCI mode. Only available if :kconfig:option:`CONFIG_BT_HOGP_SCI` is enabled.
98+
* Button 4: Exit the "Alternative button functions" mode.
99+
95100
.. group-tab:: nRF54 DKs
96101

97102
Button 0:
@@ -116,6 +121,12 @@ User interface
116121
In this mode, the buttons have different functionalities than in the normal mode.
117122
The available functionalities depend on the sample configuration and are printed in the terminal window after button press.
118123

124+
Currently the following functionalities are available:
125+
126+
* Button 1: Request the next HID SCI mode. Only available if :kconfig:option:`CONFIG_BT_HOGP_SCI` is enabled.
127+
* Button 3: Exit the "Alternative button functions" mode.
128+
129+
119130
Configuration
120131
*************
121132

@@ -135,6 +146,8 @@ Building and Running
135146

136147
.. include:: /includes/build_and_run_ns.txt
137148

149+
To build the sample with HID SCI support, build with ``-DFILE_SUFFIX=hid_sci``
150+
138151
Testing
139152
=======
140153

@@ -151,6 +164,7 @@ Testing with another development kit
151164
1. |connect_terminal_specific|
152165
#. Reset the kit.
153166
#. Program the other kit with the :ref:`peripheral_hids_keyboard` sample and reset it.
167+
#. If you see "NFC configuration done" on the peripheral kit, press **Button 4** on the peripheral kit in order for it to start advertising.
154168
#. When connected, press **Button 1** on both devices to confirm the passkey value used for bonding, or press **Button 2** to reject it.
155169
#. Wait until the HIDS keyboard is detected by the central.
156170
All detected descriptors are listed.
@@ -194,6 +208,7 @@ Testing with another development kit
194208
1. |connect_terminal_specific|
195209
#. Reset the kit.
196210
#. Program the other kit with the :ref:`peripheral_hids_keyboard` sample and reset it.
211+
#. If you see "NFC configuration done" on the peripheral kit, press **Button 3** on the peripheral kit in order for it to start advertising.
197212
#. When connected, press **Button 0** on both devices to confirm the passkey value used for bonding, or press **Button 1** to reject it.
198213
#. Wait until the HIDS keyboard is detected by the central.
199214
All detected descriptors are listed.
@@ -332,6 +347,57 @@ Testing with Bluetooth Low Energy app
332347
#. Press **Button 1** on the kit and observe that the **Protocol Mode** value changes from ``01`` to ``00``.
333348
#. Press **Button 0** and **Button 2** one after another and observe that the **Boot Keyboard Output Report** value toggles between ``00`` and ``02``.
334349

350+
Testing with HID SCI support
351+
----------------------------
352+
353+
To test the sample with HID SCI support, both the central and the peripheral must be built with ``-DFILE_SUFFIX=hid_sci``.
354+
355+
.. tabs::
356+
357+
.. group-tab:: nRF52 and nRF53 DKs
358+
359+
1. |connect_terminal_specific|
360+
#. Reset the kit.
361+
#. Program the other kit with the :ref:`peripheral_hids_keyboard` sample and reset it.
362+
#. If you see "NFC configuration done" on the peripheral kit, press **Button 4** on the peripheral kit in order for it to start advertising.
363+
#. When connected, press **Button 1** on both devices to confirm the passkey value used for bonding, or press **Button 2** to reject it.
364+
#. Wait until the HIDS keyboard is detected by the central.
365+
Check for information similar to the following::
366+
367+
HIDS is ready to work
368+
Subscribe in report id: 1
369+
Subscribe in boot keyboard report
370+
#. Press **Button 4** on the central kit to enter the "Alternative button functions" mode.
371+
#. Press **Button 2** on the central kit and wait for the SCI mode to change to DEFAULT.
372+
#. Cycle through the HID SCI modes by pressing **Button 2** on the central kit.
373+
The HID SCI mode will change to FAST, LOW POWER, FULL RANGE, and DEFAULT again.
374+
You might need to wait a few seconds for the mode to change each time.
375+
You will see a message similar to the following::
376+
377+
SCI mode changed notification received, new mode: <mode_name>
378+
379+
.. group-tab:: nRF54 DKs
380+
381+
1. |connect_terminal_specific|
382+
#. Reset the kit.
383+
#. Program the other kit with the :ref:`peripheral_hids_keyboard` sample and reset it.
384+
#. If you see "NFC configuration done" on the peripheral kit, press **Button 3** on the peripheral kit in order for it to start advertising.
385+
#. When connected, press **Button 0** on both devices to confirm the passkey value used for bonding, or press **Button 1** to reject it.
386+
#. Wait until the HIDS keyboard is detected by the central.
387+
Check for information similar to the following::
388+
389+
HIDS is ready to work
390+
Subscribe in report id: 1
391+
Subscribe in boot keyboard report
392+
#. Press **Button 3** on the central kit to enter the "Alternative button functions" mode.
393+
#. Press **Button 1** on the central kit and wait for the SCI mode to change to DEFAULT.
394+
#. Cycle through the HID SCI modes by pressing **Button 1** on the central kit.
395+
The HID SCI mode will change to FAST, LOW POWER, FULL RANGE, and DEFAULT again.
396+
You might need to wait a few seconds for the mode to change each time.
397+
You will see a message similar to the following::
398+
399+
SCI mode changed notification received, new mode: <mode_name>
400+
335401
Dependencies
336402
*************
337403

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#
2+
# Copyright (c) 2026 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
CONFIG_NCS_SAMPLES_DEFAULTS=y
7+
8+
CONFIG_BT=y
9+
CONFIG_BT_CENTRAL=y
10+
CONFIG_BT_SMP=y
11+
CONFIG_BT_ATT_TX_COUNT=5
12+
CONFIG_BT_GATT_CLIENT=y
13+
CONFIG_BT_GATT_DM=y
14+
CONFIG_HEAP_MEM_POOL_SIZE=2048
15+
CONFIG_BT_HOGP=y
16+
17+
CONFIG_BT_SCAN=y
18+
CONFIG_BT_SCAN_FILTER_ENABLE=y
19+
CONFIG_BT_SCAN_UUID_CNT=1
20+
CONFIG_BT_PRIVACY=y
21+
22+
# Increase BT TX processor thread stack size to prevent stack overflow when receiving directed
23+
# advertising right after boot. On nRF54L15 the maximum measured stack usage is 936 bytes.
24+
CONFIG_BT_TX_PROCESSOR_STACK_SIZE=1024
25+
26+
CONFIG_MAIN_STACK_SIZE=2048
27+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
28+
29+
CONFIG_BT_SETTINGS=y
30+
CONFIG_FLASH=y
31+
CONFIG_FLASH_PAGE_LAYOUT=y
32+
CONFIG_FLASH_MAP=y
33+
34+
CONFIG_DK_LIBRARY=y
35+
36+
CONFIG_LOG_MODE_DEFERRED=y
37+
CONFIG_LOG_PROCESS_THREAD_SLEEP_MS=100
38+
39+
CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=n
40+
41+
# HOGP SCI configuration
42+
CONFIG_BT_SUBRATING=y
43+
CONFIG_BT_LE_EXTENDED_FEAT_SET=y
44+
CONFIG_BT_SHORTER_CONNECTION_INTERVALS=y
45+
46+
CONFIG_BT_HOGP_SCI=y

samples/bluetooth/central_hids/sample.yaml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
sample:
22
description: Bluetooth Low Energy central Human Interface Device sample
33
name: Bluetooth LE Central HIDS
4+
common:
5+
sysbuild: true
6+
harness: console
7+
harness_config:
8+
type: multi_line
9+
ordered: true
10+
regex:
11+
- "Starting Bluetooth Central HIDS sample"
12+
- "Bluetooth initialized"
13+
- "Scanning successfully started"
14+
timeout: 15
15+
tags:
16+
- bluetooth
17+
- ci_build
18+
- sysbuild
19+
- ci_samples_bluetooth
420
tests:
521
sample.bluetooth.central_hids:
622
sysbuild: true
@@ -25,17 +41,16 @@ tests:
2541
- nrf54lv10dk/nrf54lv10a/cpuapp
2642
- nrf54lv10dk/nrf54lv10a/cpuapp/ns
2743
- nrf54h20dk/nrf54h20/cpuapp
28-
tags:
29-
- bluetooth
30-
- ci_build
31-
- sysbuild
32-
- ci_samples_bluetooth
33-
harness: console
34-
harness_config:
35-
type: multi_line
36-
ordered: true
37-
regex:
38-
- "Starting Bluetooth Central HIDS sample"
39-
- "Bluetooth initialized"
40-
- "Scanning successfully started"
41-
timeout: 15
44+
sample.bluetooth.central_hids.hid_sci:
45+
sysbuild: true
46+
integration_platforms:
47+
- nrf54l15dk/nrf54l05/cpuapp
48+
- nrf54lm20dk/nrf54lm20a/cpuapp
49+
- nrf54lm20dk/nrf54lm20b/cpuapp
50+
- nrf54lv10dk/nrf54lv10a/cpuapp
51+
platform_allow:
52+
- nrf54l15dk/nrf54l05/cpuapp
53+
- nrf54lm20dk/nrf54lm20a/cpuapp
54+
- nrf54lm20dk/nrf54lm20b/cpuapp
55+
- nrf54lv10dk/nrf54lv10a/cpuapp
56+
extra_args: FILE_SUFFIX=hid_sci

0 commit comments

Comments
 (0)