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
14 changes: 14 additions & 0 deletions include/bluetooth/gatt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,20 @@ enum {
*/
BT_GATT_SUBSCRIBE_FLAG_VOLATILE,

/** No resubscribe flag
*
* By default when BT_GATT_SUBSCRIBE_FLAG_VOLATILE is unset, the
* subscription will be automatically renewed when the client
* reconnects, as a workaround for GATT servers that do not persist
* subscriptions.
*
* This flag will disable the automatic resubscription. It is useful
* if the application layer knows that the GATT server remembers
* subscriptions from previous connections and wants to avoid renewing
* the subscriptions.
*/
BT_GATT_SUBSCRIBE_FLAG_NO_RESUB,

/** Write pending flag
*
* If set, indicates write operation is pending waiting remote end to
Expand Down
14 changes: 9 additions & 5 deletions subsys/bluetooth/host/gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3579,11 +3579,15 @@ static void add_subscriptions(struct bt_conn *conn)
continue;
}

/* Force write to CCC to workaround devices that don't track
* it properly.
*/
gatt_write_ccc(conn, params->ccc_handle, params->value,
gatt_write_ccc_rsp, params);
if (bt_addr_le_is_bonded(conn->id, &conn->le.dst) &&
!atomic_test_bit(params->flags,
BT_GATT_SUBSCRIBE_FLAG_NO_RESUB)) {
/* Force write to CCC to workaround devices that don't
* track it properly.
*/
gatt_write_ccc(conn, params->ccc_handle, params->value,
gatt_write_ccc_rsp, params);
}
}
}

Expand Down