Bluetooth: GATT: Force write to CCC when reconnecting
Some devices may actually lose track of CCC setting so this is required to work around the problem, in case the device does work track CCC properly the extra write shall not cause anything more than one extra round trip thus it is probably work doing it anyway. Change-Id: I9e5ed3fa459e4617c6fae094d0ce0f80cb2682e4 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
0d446131d2
commit
7b4ddaf73d
1 changed files with 28 additions and 6 deletions
|
@ -609,12 +609,6 @@ static uint8_t connected_cb(const struct bt_gatt_attr *attr, void *user_data)
|
|||
return BT_GATT_ITER_CONTINUE;
|
||||
}
|
||||
|
||||
void bt_gatt_connected(struct bt_conn *conn)
|
||||
{
|
||||
BT_DBG("conn %p", conn);
|
||||
bt_gatt_foreach_attr(0x0001, 0xffff, connected_cb, conn);
|
||||
}
|
||||
|
||||
static uint8_t disconnected_cb(const struct bt_gatt_attr *attr, void *user_data)
|
||||
{
|
||||
struct bt_conn *conn = user_data;
|
||||
|
@ -1688,8 +1682,36 @@ void bt_gatt_cancel(struct bt_conn *conn)
|
|||
bt_att_cancel(conn);
|
||||
}
|
||||
|
||||
static void add_subscriptions(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_gatt_subscribe_params *params, *prev;
|
||||
|
||||
/* Lookup existing subscriptions */
|
||||
for (params = subscriptions, prev = NULL; params;
|
||||
prev = params, params = params->_next) {
|
||||
if (bt_addr_le_cmp(¶ms->_peer, &conn->le.dst)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Force write to CCC to workaround devices that don't track
|
||||
* it properly.
|
||||
*/
|
||||
gatt_write_ccc(conn, params->ccc_handle, params->value,
|
||||
NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */
|
||||
|
||||
void bt_gatt_connected(struct bt_conn *conn)
|
||||
{
|
||||
BT_DBG("conn %p", conn);
|
||||
bt_gatt_foreach_attr(0x0001, 0xffff, connected_cb, conn);
|
||||
#if defined(CONFIG_BLUETOOTH_GATT_CLIENT)
|
||||
add_subscriptions(conn);
|
||||
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */
|
||||
}
|
||||
|
||||
void bt_gatt_disconnected(struct bt_conn *conn)
|
||||
{
|
||||
BT_DBG("conn %p", conn);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue