Skip to content

Commit

Permalink
Bluetooth: host: Improve error reporting on gatt subscribe
Browse files Browse the repository at this point in the history
* Return EALREADY when the subscription already exists but
it is a different entry. This indicates to the application to not
wait on subscribe callback. This is needed because the callback
is called from the ccc_write which does not happen when another
subscription exists

Signed-off-by: Yago Fontoura do Rosario <[email protected]>
  • Loading branch information
Yago Fontoura do Rosario committed Nov 27, 2024
1 parent d4b7bf9 commit a6476e7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion subsys/bluetooth/host/gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -5523,7 +5523,11 @@ int bt_gatt_subscribe(struct bt_conn *conn,
*/
sys_slist_prepend(&sub->list, &params->node);

return 0;
/*
* Report already if subscription exist so that application does not wait
* for the subscribe callback
*/
return has_subscription ? -EALREADY : 0;
}

int bt_gatt_resubscribe(uint8_t id, const bt_addr_le_t *peer,
Expand Down

0 comments on commit a6476e7

Please sign in to comment.