Skip to content

Commit 13782e5

Browse files
anhmolteivindj-nordic
authored andcommitted
applications, samples: use conn_handle from sys attr missing event
When responding with sd_ble_gatts_sys_attr_set() to a BLE_GATTS_EVT_SYS_ATTR_MISSING event, use the connection handle from the BLE GATTS event. This is more correct than using some conn_handle stored in some global data. While the conn_handle is stored with the same offset in both the evt.gap_evt and evt.gatts_evt structures, the BLE_GATTS_EVT_SYS_ATTR_MISSING event is a GATTS event and so it is incorrect to read it using evt.gap_evt. Read the conn_handle correctly using the evt.gatts_evt structure. Signed-off-by: Andreas Moltumyr <andreas.moltumyr@nordicsemi.no>
1 parent 63860e4 commit 13782e5

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

  • applications/firmware_loader/ble_mcumgr/src
  • samples

applications/firmware_loader/ble_mcumgr/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static void on_ble_evt(const ble_evt_t *evt, void *ctx)
104104
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
105105
{
106106
/* No system attributes have been stored */
107-
nrf_err = sd_ble_gatts_sys_attr_set(evt->evt.gap_evt.conn_handle, NULL, 0, 0);
107+
nrf_err = sd_ble_gatts_sys_attr_set(evt->evt.gatts_evt.conn_handle, NULL, 0, 0);
108108

109109
if (nrf_err) {
110110
LOG_ERR("Failed to set system attributes, nrf_error %#x", nrf_err);

samples/bluetooth/ble_lbs/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void on_ble_evt(const ble_evt_t *evt, void *ctx)
6565

6666
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
6767
/* No system attributes have been stored */
68-
nrf_err = sd_ble_gatts_sys_attr_set(conn_handle, NULL, 0, 0);
68+
nrf_err = sd_ble_gatts_sys_attr_set(evt->evt.gatts_evt.conn_handle, NULL, 0, 0);
6969
if (nrf_err) {
7070
LOG_ERR("Failed to set system attributes, nrf_error %#x", nrf_err);
7171
}

samples/bluetooth/ble_nus/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static void on_ble_evt(const ble_evt_t *evt, void *ctx)
242242

243243
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
244244
/* No system attributes have been stored */
245-
nrf_err = sd_ble_gatts_sys_attr_set(conn_handle, NULL, 0, 0);
245+
nrf_err = sd_ble_gatts_sys_attr_set(evt->evt.gatts_evt.conn_handle, NULL, 0, 0);
246246
if (nrf_err) {
247247
LOG_ERR("Failed to set system attributes, nrf_error %#x", nrf_err);
248248
}

samples/bluetooth/ble_pwr_profiling/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ static void on_ble_evt(const ble_evt_t *evt, void *ctx)
346346

347347
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
348348
/* No system attributes have been stored */
349-
nrf_err = sd_ble_gatts_sys_attr_set(conn_handle, NULL, 0, 0);
349+
nrf_err = sd_ble_gatts_sys_attr_set(evt->evt.gatts_evt.conn_handle, NULL, 0, 0);
350350
if (nrf_err) {
351351
LOG_ERR("Failed to set system attributes, nrf_error %#x", nrf_err);
352352
}

samples/boot/mcuboot_recovery_entry/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static void on_ble_evt(const ble_evt_t *evt, void *ctx)
9696
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
9797
{
9898
/* No system attributes have been stored */
99-
nrf_err = sd_ble_gatts_sys_attr_set(evt->evt.gap_evt.conn_handle, NULL, 0, 0);
99+
nrf_err = sd_ble_gatts_sys_attr_set(evt->evt.gatts_evt.conn_handle, NULL, 0, 0);
100100

101101
if (nrf_err) {
102102
LOG_ERR("Failed to set system attributes, nrf_error %#x", nrf_err);

0 commit comments

Comments
 (0)