Lines Matching full:ccc
54 /* Persistent storage format for GATT CCC */
1101 * random addresses in the ccc attribute's cfg array with the device's id address after
1112 struct _bt_gatt_ccc *ccc; in convert_to_id_on_match() local
1119 ccc = attr->user_data; in convert_to_id_on_match()
1124 for (size_t i = 0; i < ARRAY_SIZE(ccc->cfg); i++) { in convert_to_id_on_match()
1125 if (bt_addr_le_eq(&ccc->cfg[i].peer, match->private_addr)) { in convert_to_id_on_match()
1126 bt_addr_le_copy(&ccc->cfg[i].peer, match->id_addr); in convert_to_id_on_match()
1136 /* Update the ccc cfg addresses */ in bt_gatt_identity_resolved()
1145 /* Store the ccc */ in bt_gatt_identity_resolved()
1164 /* Store the ccc and cf data */ in bt_gatt_pairing_complete()
1447 __ASSERT(el != NULL, "Can't save CF / CCC to flash"); in gatt_delayed_store_enqueue()
1547 * be notified when pairing has completed. This is used to enable CCC in bt_gatt_init()
1556 /* Also update the address of CCC or CF writes that happened before the in bt_gatt_init()
1638 static void gatt_unregister_ccc(struct _bt_gatt_ccc *ccc) in gatt_unregister_ccc() argument
1640 ccc->value = 0; in gatt_unregister_ccc()
1642 for (size_t i = 0; i < ARRAY_SIZE(ccc->cfg); i++) { in gatt_unregister_ccc()
1643 struct bt_gatt_ccc_cfg *cfg = &ccc->cfg[i]; in gatt_unregister_ccc()
2121 struct _bt_gatt_ccc *ccc) in find_ccc_cfg() argument
2123 for (size_t i = 0; i < ARRAY_SIZE(ccc->cfg); i++) { in find_ccc_cfg()
2124 struct bt_gatt_ccc_cfg *cfg = &ccc->cfg[i]; in find_ccc_cfg()
2143 struct _bt_gatt_ccc *ccc = attr->user_data; in bt_gatt_attr_read_ccc() local
2147 cfg = find_ccc_cfg(conn, ccc); in bt_gatt_attr_read_ccc()
2160 struct _bt_gatt_ccc *ccc) in gatt_ccc_changed() argument
2165 for (i = 0; i < ARRAY_SIZE(ccc->cfg); i++) { in gatt_ccc_changed()
2166 /* `ccc->value` shall be a summary of connected peers' CCC values, but in gatt_ccc_changed()
2167 * `ccc->cfg` can contain entries for bonded but not connected peers. in gatt_ccc_changed()
2169 struct bt_conn *conn = bt_conn_lookup_addr_le(ccc->cfg[i].id, &ccc->cfg[i].peer); in gatt_ccc_changed()
2172 if (ccc->cfg[i].value > value) { in gatt_ccc_changed()
2173 value = ccc->cfg[i].value; in gatt_ccc_changed()
2180 LOG_DBG("ccc %p value 0x%04x", ccc, value); in gatt_ccc_changed()
2182 if (value != ccc->value) { in gatt_ccc_changed()
2183 ccc->value = value; in gatt_ccc_changed()
2184 if (ccc->cfg_changed) { in gatt_ccc_changed()
2185 ccc->cfg_changed(attr, value); in gatt_ccc_changed()
2194 struct _bt_gatt_ccc *ccc = attr->user_data; in bt_gatt_attr_write_ccc() local
2213 cfg = find_ccc_cfg(conn, ccc); in bt_gatt_attr_write_ccc()
2216 * we don't need to do anything, since a disabled CCC is in bt_gatt_attr_write_ccc()
2217 * behaviorally the same as no written CCC. in bt_gatt_attr_write_ccc()
2223 cfg = find_ccc_cfg(NULL, ccc); in bt_gatt_attr_write_ccc()
2225 LOG_WRN("No space to store CCC cfg"); in bt_gatt_attr_write_ccc()
2234 if (ccc->cfg_write) { in bt_gatt_attr_write_ccc()
2235 ssize_t write = ccc->cfg_write(conn, attr, value); in bt_gatt_attr_write_ccc()
2253 if (cfg->value != ccc->value) { in bt_gatt_attr_write_ccc()
2254 gatt_ccc_changed(attr, ccc); in bt_gatt_attr_write_ccc()
2259 /* Enqueue CCC store if value has changed for the connection */ in bt_gatt_attr_write_ccc()
2264 /* Disabled CCC is the same as no configured CCC, so clear the entry */ in bt_gatt_attr_write_ccc()
2726 struct _bt_gatt_ccc *ccc; in notify_cb() local
2733 ccc = attr->user_data; in notify_cb()
2736 if (IS_ENABLED(CONFIG_BT_GATT_SERVICE_CHANGED) && ccc == &sc_ccc) { in notify_cb()
2762 for (i = 0; i < ARRAY_SIZE(ccc->cfg); i++) { in notify_cb()
2763 struct bt_gatt_ccc_cfg *cfg = &ccc->cfg[i]; in notify_cb()
2785 if (ccc->cfg_match && !ccc->cfg_match(conn, attr)) { in notify_cb()
3307 struct _bt_gatt_ccc *ccc; in update_ccc() local
3315 ccc = attr->user_data; in update_ccc()
3317 for (i = 0; i < ARRAY_SIZE(ccc->cfg); i++) { in update_ccc()
3318 struct bt_gatt_ccc_cfg *cfg = &ccc->cfg[i]; in update_ccc()
3332 LOG_WRN("CCC %p not writable", attr); in update_ccc()
3352 gatt_ccc_changed(attr, ccc); in update_ccc()
3355 ccc == &sc_ccc) { in update_ccc()
3369 struct _bt_gatt_ccc *ccc; in disconnected_cb() local
3377 ccc = attr->user_data; in disconnected_cb()
3380 if (!ccc->value) { in disconnected_cb()
3387 for (i = 0; i < ARRAY_SIZE(ccc->cfg); i++) { in disconnected_cb()
3388 struct bt_gatt_ccc_cfg *cfg = &ccc->cfg[i]; in disconnected_cb()
3410 if (ccc == &sc_ccc) { in disconnected_cb()
3424 ccc->value = 0U; in disconnected_cb()
3425 if (ccc->cfg_changed) { in disconnected_cb()
3426 ccc->cfg_changed(attr, ccc->value); in disconnected_cb()
3429 LOG_DBG("ccc %p reset", ccc); in disconnected_cb()
3482 /* Find the CCC Descriptor */ in bt_gatt_is_subscribed()
3514 /* Check if the CCC bits match the subscription type */ in bt_gatt_is_subscribed()
4220 struct bt_gatt_ccc ccc; in parse_read_std_char_desc() member
4252 LOG_WRN("Parse err ccc"); in parse_read_std_char_desc()
4256 value.ccc.flags = sys_get_le16(data->value); in parse_read_std_char_desc()
5313 /* if write to CCC failed we remove subscription and notify app */ in gatt_write_ccc_rsp()
5368 * repeat CCC writes when the AUTO_RESUBSCRIBE quirk is enabled. in gatt_write_ccc()
5428 LOG_DBG("CCC Discovery failed (err %d)", err); in gatt_ccc_discover()
5503 * reported to send notification before reply to CCC write. in bt_gatt_subscribe()
5632 * disconnection during the CCC value ATT Write, there is no in gatt_resub_ccc_rsp()
5669 /* Force write to CCC to workaround devices that don't in add_subscriptions()
5703 static struct bt_gatt_ccc_cfg *ccc_find_cfg(struct _bt_gatt_ccc *ccc, in ccc_find_cfg() argument
5707 for (size_t i = 0; i < ARRAY_SIZE(ccc->cfg); i++) { in ccc_find_cfg()
5708 if (id == ccc->cfg[i].id && in ccc_find_cfg()
5709 bt_addr_le_eq(&ccc->cfg[i].peer, addr)) { in ccc_find_cfg()
5710 return &ccc->cfg[i]; in ccc_find_cfg()
5728 static void ccc_clear(struct _bt_gatt_ccc *ccc, in ccc_clear() argument
5734 cfg = ccc_find_cfg(ccc, addr, id); in ccc_clear()
5736 LOG_DBG("Unable to clear CCC: cfg not found"); in ccc_clear()
5747 struct _bt_gatt_ccc *ccc; in ccc_load() local
5754 ccc = attr->user_data; in ccc_load()
5758 ccc_clear(ccc, load->addr_with_id.addr, load->addr_with_id.id); in ccc_load()
5771 LOG_DBG("Unable to restore CCC: handle 0x%04x cannot be" in ccc_load()
5778 LOG_DBG("Restoring CCC: handle 0x%04x value 0x%04x", load->entry->handle, in ccc_load()
5781 cfg = ccc_find_cfg(ccc, load->addr_with_id.addr, load->addr_with_id.id); in ccc_load()
5783 cfg = ccc_find_cfg(ccc, BT_ADDR_LE_ANY, 0); in ccc_load()
5785 LOG_DBG("Unable to restore CCC: no cfg left"); in ccc_load()
5850 LOG_DBG("Read CCC: handle 0x%04x value 0x%04x", ccc_store[i].handle, in ccc_set()
5860 LOG_DBG("Restored CCC for id:%" PRIu8 " addr:%s", load.addr_with_id.id, in ccc_set()
5878 BT_SETTINGS_DEFINE(ccc, "ccc", ccc_set_cb, NULL);
5888 /* Only "bt/ccc" settings should ever come here */ in ccc_set_direct()
5889 if (!settings_name_steq((const char *)param, "bt/ccc", &name)) { in ccc_set_direct()
5908 /* Load CCC settings from backend if bonded */ in bt_gatt_connected()
5917 bt_settings_encode_key(key, sizeof(key), "ccc", in bt_gatt_connected()
5920 bt_settings_encode_key(key, sizeof(key), "ccc", in bt_gatt_connected()
6084 struct _bt_gatt_ccc *ccc; in ccc_save() local
6091 ccc = attr->user_data; in ccc_save()
6094 cfg = ccc_find_cfg(ccc, save->addr_with_id.addr, save->addr_with_id.id); in ccc_save()
6145 LOG_DBG(" CCC: handle 0x%04x value 0x%04x", save.store[i].handle, in bt_gatt_store_ccc()
6149 LOG_DBG(" CCC: NULL"); in bt_gatt_store_ccc()
6367 struct _bt_gatt_ccc *ccc; in remove_peer_from_attr() local
6374 ccc = attr->user_data; in remove_peer_from_attr()
6377 cfg = ccc_find_cfg(ccc, addr_with_id->addr, addr_with_id->id); in remove_peer_from_attr()
6496 /* Make sure to clear the CCC entry when using lazy loading */ in bt_gatt_disconnected()