Bluetooth: host: Refactor checks in update_ccc for efficiency
Check peer address only if active. Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
This commit is contained in:
parent
bec05a5d7f
commit
b0207eb778
1 changed files with 10 additions and 9 deletions
|
@ -2009,8 +2009,9 @@ static u8_t update_ccc(const struct bt_gatt_attr *attr, void *user_data)
|
||||||
ccc = attr->user_data;
|
ccc = attr->user_data;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(ccc->cfg); i++) {
|
for (i = 0; i < ARRAY_SIZE(ccc->cfg); i++) {
|
||||||
/* Ignore configuration for different peer */
|
/* Ignore configuration for different peer or not active */
|
||||||
if (bt_conn_addr_le_cmp(conn, &ccc->cfg[i].peer)) {
|
if (!ccc->cfg[i].value ||
|
||||||
|
bt_conn_addr_le_cmp(conn, &ccc->cfg[i].peer)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2040,14 +2041,14 @@ static u8_t update_ccc(const struct bt_gatt_attr *attr, void *user_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ccc->cfg[i].value) {
|
gatt_ccc_changed(attr, ccc);
|
||||||
gatt_ccc_changed(attr, ccc);
|
|
||||||
if (IS_ENABLED(CONFIG_BT_GATT_SERVICE_CHANGED) &&
|
if (IS_ENABLED(CONFIG_BT_GATT_SERVICE_CHANGED) &&
|
||||||
ccc == &sc_ccc) {
|
ccc == &sc_ccc) {
|
||||||
sc_restore(conn);
|
sc_restore(conn);
|
||||||
}
|
|
||||||
return BT_GATT_ITER_CONTINUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return BT_GATT_ITER_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return BT_GATT_ITER_CONTINUE;
|
return BT_GATT_ITER_CONTINUE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue