Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,10 @@ Bluetooth libraries and services

* Fixed missing ATT write length validation in the GATT write handler for the Fast Pair Additional Data characteristic, used by the experimental Personalized Name extension (:kconfig:option:`CONFIG_BT_FAST_PAIR_PN`).

* :ref:`hogp_readme` library:

* 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.

Common Application Framework
----------------------------

Expand Down
8 changes: 7 additions & 1 deletion include/bluetooth/services/hogp.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ struct bt_hogp_rep_info;
* @param hogp HOGP object.
* @param rep Report object.
* @param err ATT error code.
* @param data Pointer to the received data.
* @param data Pointer to the received data or NULL to indicate
* that the subscription has been cleared.
*
* @retval BT_GATT_ITER_STOP Stop notification.
* @retval BT_GATT_ITER_CONTINUE Continue notification.
Expand Down Expand Up @@ -407,6 +408,11 @@ int bt_hogp_rep_subscribe(struct bt_hogp *hogp,
/**
* @brief Remove the subscription for a selected report.
*
* When the subscription has been cleared the callback function
* will be called with data set to NULL.
* This will happen both on successful unsubscription as well as
* on CCC write error.
*
* @param hogp HOGP object.
* @param rep Report object.
*
Expand Down
15 changes: 14 additions & 1 deletion subsys/bluetooth/services/hogp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,7 @@ static uint8_t rep_notify_process(struct bt_conn *conn,
const void *data, uint16_t length)
{
struct bt_hogp_rep_info *rep;
uint8_t err = 0;

rep = CONTAINER_OF(params,
struct bt_hogp_rep_info,
Expand All @@ -1026,14 +1027,26 @@ static uint8_t rep_notify_process(struct bt_conn *conn,
LOG_WRN("Data size too big, truncating");
length = UINT8_MAX;
}

/* Zephyr uses the callback with data set to NULL to inform about the
* subscription removal. Do not update the report size in that case.
*/
if (data != NULL) {
rep->size = (uint8_t)length;
}

return rep->notify_cb(rep->hogp, rep, 0, data);

err = rep->notify_cb(rep->hogp, rep, 0, data);

if (data == NULL) {
Comment thread
MarekPieta marked this conversation as resolved.
/* Zephyr uses the callback with data set to NULL to inform about the
* subscription removal.
* The notification callback can be safely cleared.
*/
rep->notify_cb = NULL;
Comment thread
MarekPieta marked this conversation as resolved.
}

return err;
}

int bt_hogp_rep_subscribe(struct bt_hogp *hogp,
Expand Down
Loading