Skip to content

Commit e98eca9

Browse files
committed
bluetooth: hogp: Fix bt_hogp_rep_unsubscribe issue
The bt_hogp_rep_unsubscribe did not reset the rep->notify_cb, while bt_hogp_rep_subscribe returned an error if notify_cb was not null. Thus, it would be impossible to subscribe again to the report notification after unsubscribing. This commit fixes this. Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
1 parent a7c1c7c commit e98eca9

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,10 @@ Binary libraries
477477
Bluetooth libraries and services
478478
--------------------------------
479479

480-
|no_changes_yet_note|
480+
* :ref:`hogp_readme` library:
481+
482+
* Fixed an issue where the :c:func:`bt_hogp_rep_unsubscribe` function did not clear the notification callback, which prevented the :c:func:`bt_hogp_rep_subscribe` function from succeeding after unsubscribing.
483+
Also, the notification callback is no longer called with NULL data when the subscription is removed.
481484

482485
Common Application Framework
483486
----------------------------

subsys/bluetooth/services/hogp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,13 +1026,17 @@ static uint8_t rep_notify_process(struct bt_conn *conn,
10261026
LOG_WRN("Data size too big, truncating");
10271027
length = UINT8_MAX;
10281028
}
1029+
10291030
/* Zephyr uses the callback with data set to NULL to inform about the
10301031
* subscription removal. Do not update the report size in that case.
10311032
*/
1032-
if (data != NULL) {
1033-
rep->size = (uint8_t)length;
1033+
if (data == NULL) {
1034+
rep->notify_cb = NULL;
1035+
return BT_GATT_ITER_CONTINUE;
10341036
}
10351037

1038+
rep->size = (uint8_t)length;
1039+
10361040
return rep->notify_cb(rep->hogp, rep, 0, data);
10371041
}
10381042

0 commit comments

Comments
 (0)