Skip to content

Commit 7cedaa4

Browse files
PizzaAllTheWayeivindj-nordic
authored andcommitted
bluetooth: subsys: samples: clarify BMS auth code Kconfig scope
The BMS authorization code configuration has been aligned with its actual usage by making it sample‑specific. CONFIG_BLE_BMS_AUTHORIZATION_CODE (and BLE_BMS_AUTHORIZATION_CODE) was previously defined at the BMS library level even though it is only used by the BLE BMS sample. This change clarifies the configuration scope and avoids confusion for users by ensuring the authorization code setting is defined and documented where it is actually applied. Signed-off-by: Martynas Smilingis <martynas.smilingis@nordicsemi.no>
1 parent 0498758 commit 7cedaa4

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed

doc/nrf-bm/release_notes/release_notes_changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Bluetooth LE Services
104104

105105
* Renamed the ``ble_hrs_central`` service to the :ref:`lib_ble_service_hrs_client` sample.
106106
* Updated all services to return errors from the SoftDevice directly.
107+
* Removed the BMS authorization code Kconfig options (:kconfig:option:`CONFIG_BLE_BMS_AUTHORIZATION_CODE` and :kconfig:option:`CONFIG_BLE_BMS_USE_AUTHORIZATION_CODE`) from the service library, as they are only used by the BMS sample.
107108

108109
Libraries for NFC
109110
-----------------
@@ -137,6 +138,10 @@ Samples
137138
Bluetooth LE samples
138139
--------------------
139140

141+
* :ref:`ble_bms_sample`:
142+
143+
* Added sample-specific Kconfig options for the BMS authorization code by moving them from the service library scope and renaming them from :kconfig:option:`CONFIG_BLE_BMS_AUTHORIZATION_CODE` and :kconfig:option:`CONFIG_BLE_BMS_USE_AUTHORIZATION_CODE` to :kconfig:option:`CONFIG_APP_BLE_BMS_AUTHORIZATION_CODE` and :kconfig:option:`CONFIG_APP_BLE_BMS_USE_AUTHORIZATION_CODE`.
144+
140145
* :ref:`ble_hids_keyboard_sample`:
141146

142147
* Added support for boot mode.

samples/bluetooth/ble_bms/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ config SAMPLE_BLE_BMS_PEERS_TO_DELETE_ON_DISCONNECT_MAX
1414
int "Maximum number of peers to delete upon a peer disconnect"
1515
default 10
1616

17+
config SAMPLE_BLE_BMS_USE_AUTHORIZATION_CODE
18+
bool "Use authorization code"
19+
default y
20+
21+
config SAMPLE_BLE_BMS_AUTHORIZATION_CODE
22+
string "Authorization code"
23+
default "ABCD"
24+
1725
module=SAMPLE_BLE_BMS
1826
module-str=BLE Bond Management Service Sample
1927
source "$(ZEPHYR_BASE)/subsys/logging/Kconfig.template.log_config"

samples/bluetooth/ble_bms/README.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,17 @@ Testing
109109
#. Reconnect the devices and verify that the connection security is not updated.
110110
#. Bond both devices again.
111111
#. Write ``06 41 42 43 44`` to the Bond Management Service Control Point Characteristic.
112-
``06`` is the command to delete all bonds on the server, followed by the authorization code ``ABCD``.
112+
``06`` is the command to delete all bonds on the server, followed by the authorization code ``ABCD`` (ASCII ``0x41 0x42 0x43 0x44``).
113113
#. Disconnect the device to trigger the bond deletion procedures.
114114
#. Delete the bond information of the central device again.
115115
#. Reconnect the devices again and verify that the connection security is not updated.
116+
117+
.. note::
118+
The default authorization code ``ABCD`` (ASCII ``0x41 0x42 0x43 0x44``) is configurable through the :kconfig:option:`CONFIG_SAMPLE_BLE_BMS_AUTHORIZATION_CODE` Kconfig option.
119+
The maximum allowed length is :c:macro:`BLE_BMS_AUTH_CODE_MAX_LEN` (127 bytes), which comes from the BMS control point definition.
120+
121+
Authorization codes up to **127 bytes** are supported.
122+
You may configure the code to any value within this limit as needed.
123+
124+
If this security feature is not required, it can be enabled or disabled using the :kconfig:option:`CONFIG_SAMPLE_BLE_BMS_USE_AUTHORIZATION_CODE` Kconfig option.
125+
After changing the configuration, rebuild the sample and test how bond deletion behaves with or without an authorization code.

samples/bluetooth/ble_bms/src/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,10 @@ void bms_evt_handler(struct ble_bms *bms, struct ble_bms_evt *evt)
414414
break;
415415
case BLE_BMS_EVT_AUTH:
416416
LOG_DBG("Authorization request.");
417-
#if defined(CONFIG_BLE_BMS_USE_AUTHORIZATION_CODE)
418-
if ((evt->auth.auth_code.len != strlen(CONFIG_BLE_BMS_AUTHORIZATION_CODE)) ||
419-
(memcmp(CONFIG_BLE_BMS_AUTHORIZATION_CODE, evt->auth.auth_code.code,
420-
strlen(CONFIG_BLE_BMS_AUTHORIZATION_CODE)) != 0)) {
417+
#if defined(CONFIG_SAMPLE_BLE_BMS_USE_AUTHORIZATION_CODE)
418+
if ((evt->auth.auth_code.len != strlen(CONFIG_SAMPLE_BLE_BMS_AUTHORIZATION_CODE)) ||
419+
(memcmp(CONFIG_SAMPLE_BLE_BMS_AUTHORIZATION_CODE, evt->auth.auth_code.code,
420+
strlen(CONFIG_SAMPLE_BLE_BMS_AUTHORIZATION_CODE)) != 0)) {
421421
is_authorized = false;
422422
}
423423
#endif
@@ -575,7 +575,7 @@ int main(void)
575575

576576
struct ble_bms_config bms_cfg = {
577577
.evt_handler = bms_evt_handler,
578-
#if defined(CONFIG_BLE_BMS_USE_AUTHORIZATION_CODE)
578+
#if defined(CONFIG_SAMPLE_BLE_BMS_USE_AUTHORIZATION_CODE)
579579
/* Do not require auth to delete requesting. */
580580
.feature.delete_requesting = true,
581581
.feature.delete_all_auth = true,

subsys/bluetooth/services/ble_bms/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ menuconfig BLE_BMS
1212

1313
if BLE_BMS
1414

15-
config BLE_BMS_USE_AUTHORIZATION_CODE
16-
bool "Use authorization code"
17-
default y
18-
19-
config BLE_BMS_AUTHORIZATION_CODE
20-
string "Authorization code"
21-
default "ABCD"
22-
2315
module=BLE_BMS
2416
module-str=BLE_BMS
2517
source "$(ZEPHYR_BASE)/subsys/logging/Kconfig.template.log_config"

0 commit comments

Comments
 (0)