Skip to content

Commit eeb550c

Browse files
committed
Implement bt_gatt_cb_unregister method for sys_slist_find_and_remove.
Signed-off-by: Zhijie Zhong <zhongzhijie1@xiaomi.com>
1 parent a0096b7 commit eeb550c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/zephyr/bluetooth/gatt.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,15 @@ static inline const char *bt_gatt_err_to_str(int gatt_err)
622622
*/
623623
void bt_gatt_cb_register(struct bt_gatt_cb *cb);
624624

625+
/** @brief Unregister GATT callbacks.
626+
*
627+
* Unregister callbacks for monitoring the state of GATT. The callback
628+
* struct should be one that was previously registered.
629+
*
630+
* @param cb Callback struct.
631+
*/
632+
void bt_gatt_cb_unregister(struct bt_gatt_cb *cb);
633+
625634
/** @brief Register GATT authorization callbacks.
626635
*
627636
* Register callbacks to perform application-specific authorization of GATT

subsys/bluetooth/host/gatt.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,11 @@ void bt_gatt_cb_register(struct bt_gatt_cb *cb)
16281628
sys_slist_append(&callback_list, &cb->node);
16291629
}
16301630

1631+
void bt_gatt_cb_unregister(struct bt_gatt_cb *cb)
1632+
{
1633+
sys_slist_find_and_remove(&callback_list, &cb->node);
1634+
}
1635+
16311636
#if defined(CONFIG_BT_GATT_DYNAMIC_DB)
16321637
static void db_changed(void)
16331638
{

0 commit comments

Comments
 (0)