Skip to content

Commit aeac6be

Browse files
sondrepasilz
andcommitted
bluetooth: services: hrs: Role fix
Only run ble evt when peripheral role is connected. Signed-off-by: Sondre Pettersen <sondre.pettersen@nordicsemi.no> Co-authored-by: Asil Zogby <asil.zogby@nordicsemi.no>
1 parent e4efd35 commit aeac6be

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

doc/nrf-bm/release_notes/release_notes_changelog.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ No changes since the latest nRF Connect SDK Bare Metal release.
7676
Bluetooth LE Services
7777
---------------------
7878

79-
No changes since the latest nRF Connect SDK Bare Metal release.
79+
* :ref:`lib_ble_service_hrs`
80+
81+
* Changed the :c:func:`ble_hrs_on_ble_evt` function to only handle peripheral-role GAP events.
8082

8183
Libraries for NFC
8284
-----------------

subsys/bluetooth/services/ble_hrs/hrs.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,18 @@ void ble_hrs_on_ble_evt(const ble_evt_t *ble_evt, void *hrs_instance)
193193
__ASSERT(ble_evt, "BLE event is NULL");
194194
__ASSERT(hrs_instance, "BLE instance is NULL");
195195

196+
/* Filter:
197+
* Only handle peripheral-role GAP events.
198+
* Central-role events would otherwise overwrite hrs->conn_handle and break notifications
199+
* to the real peer.
200+
*/
201+
if (ble_evt->header.evt_id >= BLE_GAP_EVT_BASE &&
202+
ble_evt->header.evt_id <= BLE_GAP_EVT_LAST &&
203+
ble_evt->evt.gap_evt.params.connected.role != BLE_GAP_ROLE_PERIPH &&
204+
ble_evt->evt.gap_evt.params.connected.role != BLE_GAP_ROLE_INVALID) {
205+
return;
206+
}
207+
196208
switch (ble_evt->header.evt_id) {
197209
case BLE_GAP_EVT_CONNECTED:
198210
on_connect(hrs_instance, &ble_evt->evt.gap_evt);

0 commit comments

Comments
 (0)