Skip to content

Commit 63860e4

Browse files
anhmolteivindj-nordic
authored andcommitted
applications, samples: do not set sys attrs from connected event
Wait for the SoftDevice to send the BLE_GATTS_EVT_SYS_ATTR_MISSING event before setting the GATTS system attributes with sd_ble_gatts_sys_attr_set(). It is not illegal or wrong to set it on a connection event, but it duplicates some code and it overcomplicates the samples a bit. Signed-off-by: Andreas Moltumyr <andreas.moltumyr@nordicsemi.no>
1 parent 572e80b commit 63860e4

5 files changed

Lines changed: 7 additions & 18 deletions

File tree

applications/firmware_loader/ble_mcumgr/src/main.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ static void on_ble_evt(const ble_evt_t *evt, void *ctx)
6666
{
6767
LOG_INF("Peer connected");
6868
conn_handle = evt->evt.gap_evt.conn_handle;
69-
nrf_err = sd_ble_gatts_sys_attr_set(evt->evt.gap_evt.conn_handle, NULL, 0, 0);
70-
71-
if (nrf_err) {
72-
LOG_ERR("Failed to set system attributes, nrf_error %#x", nrf_err);
73-
}
7469
break;
7570
}
7671

doc/nrf-bm/release_notes/release_notes_changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ Peripheral samples
110110
Bluetooth LE samples
111111
--------------------
112112

113+
* Updated the following samples and applications that do not support pairing to call the :c:func:`sd_ble_gatts_sys_attr_set` function only in response to the :c:macro:`BLE_GATTS_EVT_SYS_ATTR_MISSING` event and not as a response to a :c:macro:`BLE_GAP_EVT_CONNECTED` event:
114+
115+
* :ref:`ug_dfu_firmware_loader` (Bluetooth LE)
116+
* :ref:`ble_lbs_sample`
117+
* :ref:`ble_nus_sample`
118+
* :ref:`ble_mcuboot_recovery_entry_sample`
119+
113120
* :ref:`ble_cgms_sample` sample:
114121

115122
* Removed the call to the :c:func:`sd_ble_gatts_sys_attr_set` function from the main source file.

samples/bluetooth/ble_lbs/src/main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ static void on_ble_evt(const ble_evt_t *evt, void *ctx)
3737
case BLE_GAP_EVT_CONNECTED:
3838
LOG_INF("Peer connected");
3939
conn_handle = evt->evt.gap_evt.conn_handle;
40-
nrf_err = sd_ble_gatts_sys_attr_set(conn_handle, NULL, 0, 0);
41-
if (nrf_err) {
42-
LOG_ERR("Failed to set system attributes, nrf_error %#x", nrf_err);
43-
}
4440
nrf_gpio_pin_write(BOARD_PIN_LED_1, BOARD_LED_ACTIVE_STATE);
4541
break;
4642

samples/bluetooth/ble_nus/src/main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,6 @@ static void on_ble_evt(const ble_evt_t *evt, void *ctx)
201201
LOG_INF("Peer connected");
202202
ble_nus_max_data_len = BLE_NUS_MAX_DATA_LEN_CALC(BLE_GATT_ATT_MTU_DEFAULT);
203203
conn_handle = evt->evt.gap_evt.conn_handle;
204-
nrf_err = sd_ble_gatts_sys_attr_set(conn_handle, NULL, 0, 0);
205-
if (nrf_err) {
206-
LOG_ERR("Failed to set system attributes, nrf_error %#x", nrf_err);
207-
}
208204

209205
nrf_err = ble_qwr_conn_handle_assign(&ble_qwr, conn_handle);
210206
if (nrf_err) {

samples/boot/mcuboot_recovery_entry/src/main.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ static void on_ble_evt(const ble_evt_t *evt, void *ctx)
5858
{
5959
LOG_INF("Peer connected");
6060
conn_handle = evt->evt.gap_evt.conn_handle;
61-
nrf_err = sd_ble_gatts_sys_attr_set(evt->evt.gap_evt.conn_handle, NULL, 0, 0);
62-
63-
if (nrf_err) {
64-
LOG_ERR("Failed to set system attributes, nrf_error %#x", nrf_err);
65-
}
6661
break;
6762
}
6863

0 commit comments

Comments
 (0)