Skip to content

Commit

Permalink
Bluetooth: Host: Fix not sending Service Changed indication
Browse files Browse the repository at this point in the history
gatt_unregister() clears handles if those were auto-assigned by host.
This resulted in Service Changed indication not beding sent since
call to sc_indicate() pass already cleared handles.

This was affecting GATT/SR/GAS/BV-01-C and GATT/SR/GAS/BV-07-C test
cases.

Signed-off-by: Szymon Janc <[email protected]>
  • Loading branch information
sjanc committed Dec 19, 2024
1 parent 4986126 commit 626bdd5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions subsys/bluetooth/host/gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1743,10 +1743,18 @@ int bt_gatt_service_register(struct bt_gatt_service *svc)

int bt_gatt_service_unregister(struct bt_gatt_service *svc)
{
uint16_t sc_start_handle;
uint16_t sc_end_handle;
int err;

__ASSERT(svc, "invalid parameters\n");

/* gatt_unregister() clears handles when those were auto-assigned
* by host
*/
sc_start_handle = svc->attrs[0].handle;
sc_end_handle = svc->attrs[svc->attr_count - 1].handle;

k_sched_lock();

err = gatt_unregister(svc);
Expand All @@ -1761,8 +1769,7 @@ int bt_gatt_service_unregister(struct bt_gatt_service *svc)
return 0;
}

sc_indicate(svc->attrs[0].handle,
svc->attrs[svc->attr_count - 1].handle);
sc_indicate(sc_start_handle, sc_end_handle);

db_changed();

Expand Down

0 comments on commit 626bdd5

Please sign in to comment.