Lines Matching refs:params
301 struct bt_gatt_indicate_params params; member
1296 struct bt_gatt_indicate_params *params, uint8_t err) in sc_indicate_rsp() argument
1347 sc->params.attr = &_1_gatt_svc.attrs[2]; in sc_process()
1348 sc->params.func = sc_indicate_rsp; in sc_process()
1349 sc->params.data = &sc_range[0]; in sc_process()
1350 sc->params.len = sizeof(sc_range); in sc_process()
1352 sc->params.chan_opt = BT_ATT_CHAN_OPT_NONE; in sc_process()
1355 if (bt_gatt_indicate(NULL, &sc->params)) { in sc_process()
2423 struct bt_gatt_notify_params *params) in gatt_add_nfy_to_buf() argument
2427 nfy = net_buf_add(buf, sizeof(*nfy) + params->len); in gatt_add_nfy_to_buf()
2429 nfy->len = sys_cpu_to_le16(params->len); in gatt_add_nfy_to_buf()
2430 (void)memcpy(nfy->value, params->data, params->len); in gatt_add_nfy_to_buf()
2435 struct bt_gatt_notify_params *params) in gatt_notify_mult() argument
2442 if (*buf && ((net_buf_tailroom(*buf) < sizeof(struct bt_att_notify_mult) + params->len) || in gatt_notify_mult()
2443 !bt_att_tx_meta_data_match(*buf, params->func, params->user_data, in gatt_notify_mult()
2444 BT_ATT_CHAN_OPT(params)))) { in gatt_notify_mult()
2456 sizeof(struct bt_att_notify_mult) + params->len); in gatt_notify_mult()
2461 bt_att_set_tx_meta_data(*buf, params->func, params->user_data, in gatt_notify_mult()
2462 BT_ATT_CHAN_OPT(params)); in gatt_notify_mult()
2470 LOG_DBG("handle 0x%04x len %u", handle, params->len); in gatt_notify_mult()
2471 gatt_add_nfy_to_buf(*buf, handle, params); in gatt_notify_mult()
2485 struct bt_gatt_notify_params *params) in gatt_notify() argument
2504 if (bt_gatt_check_perm(conn, params->attr, BT_GATT_PERM_READ_ENCRYPT_MASK)) { in gatt_notify()
2514 if (!bt_gatt_is_subscribed(conn, params->attr, BT_GATT_CCC_NOTIFY)) { in gatt_notify()
2521 !bt_att_chan_opt_valid(conn, BT_ATT_CHAN_OPT(params))) { in gatt_notify()
2527 return gatt_notify_mult(conn, handle, params); in gatt_notify()
2532 sizeof(*nfy) + params->len); in gatt_notify()
2540 nfy = net_buf_add(buf, sizeof(*nfy) + params->len); in gatt_notify()
2542 memcpy(nfy->value, params->data, params->len); in gatt_notify()
2544 bt_att_set_tx_meta_data(buf, params->func, params->user_data, BT_ATT_CHAN_OPT(params)); in gatt_notify()
2564 struct bt_gatt_indicate_params *params = user_data; in gatt_indicate_rsp() local
2566 if (params->func) { in gatt_indicate_rsp()
2567 params->func(conn, params, att_err_from_int(err)); in gatt_indicate_rsp()
2570 params->_ref--; in gatt_indicate_rsp()
2571 if (params->destroy && (params->_ref == 0)) { in gatt_indicate_rsp()
2572 params->destroy(params); in gatt_indicate_rsp()
2576 static struct bt_att_req *gatt_req_alloc(bt_att_func_t func, void *params, in gatt_req_alloc() argument
2595 req->user_data = params; in gatt_req_alloc()
2601 static int gatt_req_send(struct bt_conn *conn, bt_att_func_t func, void *params, in gatt_req_send() argument
2615 req = gatt_req_alloc(func, params, encode, op, len); in gatt_req_send()
2630 err = encode(buf, len, params); in gatt_req_send()
2646 struct bt_gatt_indicate_params *params) in gatt_indicate() argument
2660 if (!(params->func && (params->func == sc_indicate_rsp || in gatt_indicate()
2661 params->func == sc_restore_rsp)) && in gatt_indicate()
2668 if (bt_gatt_check_perm(conn, params->attr, BT_GATT_PERM_READ_ENCRYPT_MASK)) { in gatt_indicate()
2678 if (!bt_gatt_is_subscribed(conn, params->attr, BT_GATT_CCC_INDICATE)) { in gatt_indicate()
2685 !bt_att_chan_opt_valid(conn, BT_ATT_CHAN_OPT(params))) { in gatt_indicate()
2689 len = sizeof(*ind) + params->len; in gatt_indicate()
2691 req = gatt_req_alloc(gatt_indicate_rsp, params, NULL, in gatt_indicate()
2704 bt_att_set_tx_meta_data(buf, NULL, NULL, BT_ATT_CHAN_OPT(params)); in gatt_indicate()
2706 ind = net_buf_add(buf, sizeof(*ind) + params->len); in gatt_indicate()
2708 memcpy(ind->value, params->data, params->len); in gatt_indicate()
2866 struct bt_gatt_notify_params *params) in bt_gatt_notify_cb() argument
2870 __ASSERT(params, "invalid parameters\n"); in bt_gatt_notify_cb()
2871 __ASSERT(params->attr || params->uuid, "invalid parameters\n"); in bt_gatt_notify_cb()
2881 data.attr = params->attr; in bt_gatt_notify_cb()
2885 if (params->uuid) { in bt_gatt_notify_cb()
2886 if (!gatt_find_by_uuid(&data, params->uuid)) { in bt_gatt_notify_cb()
2890 params->attr = data.attr; in bt_gatt_notify_cb()
2909 return gatt_notify(conn, data.handle, params); in bt_gatt_notify_cb()
2914 data.nfy_params = params; in bt_gatt_notify_cb()
2924 struct bt_gatt_notify_params params[], in gatt_notify_multiple_verify_args() argument
2927 __ASSERT(params, "invalid parameters\n"); in gatt_notify_multiple_verify_args()
2928 __ASSERT(params->attr, "invalid parameters\n"); in gatt_notify_multiple_verify_args()
2974 struct bt_gatt_notify_params params[], in gatt_notify_multiple_verify_params() argument
2979 *total_len += params[i].len; in gatt_notify_multiple_verify_params()
2982 if (bt_gatt_check_perm(conn, params[i].attr, in gatt_notify_multiple_verify_params()
2992 if ((params[0].func != params[i].func) || in gatt_notify_multiple_verify_params()
2993 (params[0].user_data != params[i].user_data)) { in gatt_notify_multiple_verify_params()
2998 if (params[i].uuid) { in gatt_notify_multiple_verify_params()
3003 if (!bt_gatt_attr_get_handle(params[i].attr)) { in gatt_notify_multiple_verify_params()
3009 !bt_gatt_is_subscribed(conn, params[i].attr, in gatt_notify_multiple_verify_params()
3032 struct bt_gatt_notify_params params[]) in bt_gatt_notify_multiple() argument
3039 err = gatt_notify_multiple_verify_args(conn, params, num_params); in bt_gatt_notify_multiple()
3047 err = gatt_notify_multiple_verify_params(conn, params, num_params, &total_len); in bt_gatt_notify_multiple()
3065 bt_att_set_tx_meta_data(buf, params->func, params->user_data, BT_ATT_CHAN_OPT(params)); in bt_gatt_notify_multiple()
3071 data.attr = params[i].attr; in bt_gatt_notify_multiple()
3082 gatt_add_nfy_to_buf(buf, data.handle, ¶ms[i]); in bt_gatt_notify_multiple()
3091 struct bt_gatt_indicate_params *params) in bt_gatt_indicate() argument
3095 __ASSERT(params, "invalid parameters\n"); in bt_gatt_indicate()
3096 __ASSERT(params->attr || params->uuid, "invalid parameters\n"); in bt_gatt_indicate()
3106 data.attr = params->attr; in bt_gatt_indicate()
3110 if (params->uuid) { in bt_gatt_indicate()
3111 if (!gatt_find_by_uuid(&data, params->uuid)) { in bt_gatt_indicate()
3115 params->attr = data.attr; in bt_gatt_indicate()
3134 params->_ref = 1; in bt_gatt_indicate()
3135 return gatt_indicate(conn, data.handle, params); in bt_gatt_indicate()
3140 data.ind_params = params; in bt_gatt_indicate()
3142 params->_ref = 0; in bt_gatt_indicate()
3227 struct bt_gatt_indicate_params *params, uint8_t err) in sc_restore_rsp() argument
3537 struct bt_gatt_subscribe_params *params) in gatt_sub_remove() argument
3539 if (params) { in gatt_sub_remove()
3541 sys_slist_remove(&sub->list, prev, ¶ms->node); in gatt_sub_remove()
3543 params->notify(conn, params, NULL, 0); in gatt_sub_remove()
3617 const struct bt_gatt_subscribe_params *params) in check_subscribe_security_level() argument
3620 return conn->sec_level >= params->min_security; in check_subscribe_security_level()
3628 struct bt_gatt_subscribe_params *params, *tmp; in call_notify_cb_and_maybe_unsubscribe() local
3631 SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&sub->list, params, tmp, node) { in call_notify_cb_and_maybe_unsubscribe()
3632 if (handle != params->value_handle) { in call_notify_cb_and_maybe_unsubscribe()
3636 if (check_subscribe_security_level(conn, params)) { in call_notify_cb_and_maybe_unsubscribe()
3637 if (params->notify(conn, params, data, length) == BT_GATT_ITER_STOP) { in call_notify_cb_and_maybe_unsubscribe()
3638 err = bt_gatt_unsubscribe(conn, params); in call_notify_cb_and_maybe_unsubscribe()
3713 struct bt_gatt_subscribe_params *params, *tmp; in remove_subscriptions() local
3722 SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&sub->list, params, tmp, node) { in remove_subscriptions()
3723 atomic_clear_bit(params->flags, BT_GATT_SUBSCRIBE_FLAG_SENT); in remove_subscriptions()
3726 (atomic_test_bit(params->flags, in remove_subscriptions()
3729 params->value = 0U; in remove_subscriptions()
3730 gatt_sub_remove(conn, sub, prev, params); in remove_subscriptions()
3733 prev = ¶ms->node; in remove_subscriptions()
3741 struct bt_gatt_exchange_params *params = user_data; in gatt_mtu_rsp() local
3743 params->func(conn, att_err_from_int(err), params); in gatt_mtu_rsp()
3763 struct bt_gatt_exchange_params *params) in bt_gatt_exchange_mtu() argument
3768 __ASSERT(params && params->func, "invalid parameters\n"); in bt_gatt_exchange_mtu()
3779 err = gatt_req_send(conn, gatt_mtu_rsp, params, in bt_gatt_exchange_mtu()
3791 struct bt_gatt_discover_params *params) in gatt_discover_next() argument
3799 params->start_handle = last_handle; in gatt_discover_next()
3800 if (params->start_handle < UINT16_MAX) { in gatt_discover_next()
3801 params->start_handle++; in gatt_discover_next()
3807 if (params->start_handle > params->end_handle) { in gatt_discover_next()
3813 if (!bt_gatt_discover(conn, params)) { in gatt_discover_next()
3818 params->func(conn, NULL, params); in gatt_discover_next()
3826 struct bt_gatt_discover_params *params = user_data; in gatt_find_type_rsp() local
3850 if (params->type == BT_GATT_DISCOVER_PRIMARY) { in gatt_find_type_rsp()
3857 value.uuid = params->uuid; in gatt_find_type_rsp()
3865 if (params->func(conn, &attr, params) == BT_GATT_ITER_STOP) { in gatt_find_type_rsp()
3870 gatt_discover_next(conn, end_handle, params); in gatt_find_type_rsp()
3874 params->func(conn, NULL, params); in gatt_find_type_rsp()
3880 struct bt_gatt_discover_params *params = user_data; in gatt_find_type_encode() local
3885 req->start_handle = sys_cpu_to_le16(params->start_handle); in gatt_find_type_encode()
3886 req->end_handle = sys_cpu_to_le16(params->end_handle); in gatt_find_type_encode()
3888 if (params->type == BT_GATT_DISCOVER_PRIMARY) { in gatt_find_type_encode()
3896 LOG_DBG("uuid %s start_handle 0x%04x end_handle 0x%04x", bt_uuid_str(params->uuid), in gatt_find_type_encode()
3897 params->start_handle, params->end_handle); in gatt_find_type_encode()
3899 switch (params->uuid->type) { in gatt_find_type_encode()
3901 net_buf_add_le16(buf, BT_UUID_16(params->uuid)->val); in gatt_find_type_encode()
3904 net_buf_add_mem(buf, BT_UUID_128(params->uuid)->val, 16); in gatt_find_type_encode()
3912 struct bt_gatt_discover_params *params) in gatt_find_type() argument
3918 switch (params->uuid->type) { in gatt_find_type()
3926 LOG_ERR("Unknown UUID type %u", params->uuid->type); in gatt_find_type()
3930 return gatt_req_send(conn, gatt_find_type_rsp, params, in gatt_find_type()
3932 len, BT_ATT_CHAN_OPT(params)); in gatt_find_type()
3939 struct bt_gatt_discover_params *params = user_data; in read_included_uuid_cb() local
3950 params->func(conn, NULL, params); in read_included_uuid_cb()
3954 handle = params->_included.attr_handle; in read_included_uuid_cb()
3955 value.start_handle = params->_included.start_handle; in read_included_uuid_cb()
3956 value.end_handle = params->_included.end_handle; in read_included_uuid_cb()
3962 "end_handle 0x%04x\n", params->_included.attr_handle, in read_included_uuid_cb()
3966 if (params->uuid && bt_uuid_cmp(&u.uuid, params->uuid)) { in read_included_uuid_cb()
3976 if (params->func(conn, &attr, params) == BT_GATT_ITER_STOP) { in read_included_uuid_cb()
3980 gatt_discover_next(conn, params->start_handle, params); in read_included_uuid_cb()
3988 struct bt_gatt_discover_params *params = user_data; in read_included_uuid_encode() local
3992 req->handle = sys_cpu_to_le16(params->_included.start_handle); in read_included_uuid_encode()
3998 struct bt_gatt_discover_params *params) in read_included_uuid() argument
4000 LOG_DBG("handle 0x%04x", params->_included.start_handle); in read_included_uuid()
4002 return gatt_req_send(conn, read_included_uuid_cb, params, in read_included_uuid()
4004 sizeof(struct bt_att_read_req), BT_ATT_CHAN_OPT(params)); in read_included_uuid()
4008 struct bt_gatt_discover_params *params, in parse_include() argument
4070 params->_included.attr_handle = handle; in parse_include()
4071 params->_included.start_handle = value.start_handle; in parse_include()
4072 params->_included.end_handle = value.end_handle; in parse_include()
4074 return read_included_uuid(conn, params); in parse_include()
4082 if (params->uuid && bt_uuid_cmp(&u.uuid, params->uuid)) { in parse_include()
4092 if (params->func(conn, &attr, params) == BT_GATT_ITER_STOP) { in parse_include()
4103 params->func(conn, NULL, params); in parse_include()
4108 struct bt_gatt_discover_params *params, in parse_characteristic() argument
4166 if (params->uuid && bt_uuid_cmp(&u.uuid, params->uuid)) { in parse_characteristic()
4180 if (params->func(conn, &attr, params) == BT_GATT_ITER_STOP) { in parse_characteristic()
4191 params->func(conn, NULL, params); in parse_characteristic()
4196 struct bt_gatt_discover_params *params, in parse_read_std_char_desc() argument
4203 if (params->uuid->type != BT_UUID_TYPE_16) { in parse_read_std_char_desc()
4207 uuid_val = BT_UUID_16(params->uuid)->val; in parse_read_std_char_desc()
4289 .uuid = params->uuid, in parse_read_std_char_desc()
4294 if (params->func(conn, &attr, params) == BT_GATT_ITER_STOP) { in parse_read_std_char_desc()
4305 params->func(conn, NULL, params); in parse_read_std_char_desc()
4313 struct bt_gatt_discover_params *params = user_data; in gatt_read_type_rsp() local
4319 params->func(conn, NULL, params); in gatt_read_type_rsp()
4323 if (params->type == BT_GATT_DISCOVER_INCLUDE) { in gatt_read_type_rsp()
4324 handle = parse_include(conn, pdu, params, length); in gatt_read_type_rsp()
4325 } else if (params->type == BT_GATT_DISCOVER_CHARACTERISTIC) { in gatt_read_type_rsp()
4326 handle = parse_characteristic(conn, pdu, params, length); in gatt_read_type_rsp()
4328 handle = parse_read_std_char_desc(conn, pdu, params, length); in gatt_read_type_rsp()
4335 gatt_discover_next(conn, handle, params); in gatt_read_type_rsp()
4341 struct bt_gatt_discover_params *params = user_data; in gatt_read_type_encode() local
4345 req->start_handle = sys_cpu_to_le16(params->start_handle); in gatt_read_type_encode()
4346 req->end_handle = sys_cpu_to_le16(params->end_handle); in gatt_read_type_encode()
4348 switch (params->type) { in gatt_read_type_encode()
4357 net_buf_add_le16(buf, BT_UUID_16(params->uuid)->val); in gatt_read_type_encode()
4365 struct bt_gatt_discover_params *params) in gatt_read_type() argument
4367 LOG_DBG("start_handle 0x%04x end_handle 0x%04x", params->start_handle, params->end_handle); in gatt_read_type()
4369 return gatt_req_send(conn, gatt_read_type_rsp, params, in gatt_read_type()
4371 sizeof(struct bt_att_read_type_req), BT_ATT_CHAN_OPT(params)); in gatt_read_type()
4375 struct bt_gatt_discover_params *params, in parse_service() argument
4438 if (params->type == BT_GATT_DISCOVER_PRIMARY) { in parse_service()
4451 if (params->func(conn, &attr, params) == BT_GATT_ITER_STOP) { in parse_service()
4462 params->func(conn, NULL, params); in parse_service()
4470 struct bt_gatt_discover_params *params = user_data; in gatt_read_group_rsp() local
4476 params->func(conn, NULL, params); in gatt_read_group_rsp()
4480 handle = parse_service(conn, pdu, params, length); in gatt_read_group_rsp()
4485 gatt_discover_next(conn, handle, params); in gatt_read_group_rsp()
4491 struct bt_gatt_discover_params *params = user_data; in gatt_read_group_encode() local
4495 req->start_handle = sys_cpu_to_le16(params->start_handle); in gatt_read_group_encode()
4496 req->end_handle = sys_cpu_to_le16(params->end_handle); in gatt_read_group_encode()
4498 if (params->type == BT_GATT_DISCOVER_PRIMARY) { in gatt_read_group_encode()
4508 struct bt_gatt_discover_params *params) in gatt_read_group() argument
4510 LOG_DBG("start_handle 0x%04x end_handle 0x%04x", params->start_handle, params->end_handle); in gatt_read_group()
4512 return gatt_req_send(conn, gatt_read_group_rsp, params, in gatt_read_group()
4516 BT_ATT_CHAN_OPT(params)); in gatt_read_group()
4524 struct bt_gatt_discover_params *params = user_data; in gatt_find_info_rsp() local
4599 if (params->uuid && bt_uuid_cmp(&u.uuid, params->uuid)) { in gatt_find_info_rsp()
4603 if (params->type == BT_GATT_DISCOVER_DESCRIPTOR) { in gatt_find_info_rsp()
4628 if (params->func(conn, &attr, params) == BT_GATT_ITER_STOP) { in gatt_find_info_rsp()
4633 gatt_discover_next(conn, handle, params); in gatt_find_info_rsp()
4638 params->func(conn, NULL, params); in gatt_find_info_rsp()
4644 struct bt_gatt_discover_params *params = user_data; in gatt_find_info_encode() local
4648 req->start_handle = sys_cpu_to_le16(params->start_handle); in gatt_find_info_encode()
4649 req->end_handle = sys_cpu_to_le16(params->end_handle); in gatt_find_info_encode()
4655 struct bt_gatt_discover_params *params) in gatt_find_info() argument
4657 LOG_DBG("start_handle 0x%04x end_handle 0x%04x", params->start_handle, params->end_handle); in gatt_find_info()
4659 return gatt_req_send(conn, gatt_find_info_rsp, params, in gatt_find_info()
4662 BT_ATT_CHAN_OPT(params)); in gatt_find_info()
4666 struct bt_gatt_discover_params *params) in bt_gatt_discover() argument
4669 __ASSERT(params && params->func, "invalid parameters\n"); in bt_gatt_discover()
4670 __ASSERT((params->start_handle && params->end_handle), in bt_gatt_discover()
4672 __ASSERT((params->start_handle <= params->end_handle), in bt_gatt_discover()
4679 switch (params->type) { in bt_gatt_discover()
4682 if (params->uuid) { in bt_gatt_discover()
4683 return gatt_find_type(conn, params); in bt_gatt_discover()
4685 return gatt_read_group(conn, params); in bt_gatt_discover()
4688 if (!(params->uuid && params->uuid->type == BT_UUID_TYPE_16 && in bt_gatt_discover()
4689 (!bt_uuid_cmp(params->uuid, BT_UUID_GATT_CEP) || in bt_gatt_discover()
4690 !bt_uuid_cmp(params->uuid, BT_UUID_GATT_CCC) || in bt_gatt_discover()
4691 !bt_uuid_cmp(params->uuid, BT_UUID_GATT_SCC) || in bt_gatt_discover()
4692 !bt_uuid_cmp(params->uuid, BT_UUID_GATT_CPF)))) { in bt_gatt_discover()
4698 return gatt_read_type(conn, params); in bt_gatt_discover()
4701 if (params->uuid && in bt_gatt_discover()
4702 (!bt_uuid_cmp(params->uuid, BT_UUID_GATT_PRIMARY) || in bt_gatt_discover()
4703 !bt_uuid_cmp(params->uuid, BT_UUID_GATT_SECONDARY) || in bt_gatt_discover()
4704 !bt_uuid_cmp(params->uuid, BT_UUID_GATT_INCLUDE) || in bt_gatt_discover()
4705 !bt_uuid_cmp(params->uuid, BT_UUID_GATT_CHRC))) { in bt_gatt_discover()
4710 return gatt_find_info(conn, params); in bt_gatt_discover()
4712 LOG_ERR("Invalid discovery type: %u", params->type); in bt_gatt_discover()
4719 struct bt_gatt_read_params *params, in parse_read_by_uuid() argument
4724 const uint16_t req_start_handle = params->by_uuid.start_handle; in parse_read_by_uuid()
4725 const uint16_t req_end_handle = params->by_uuid.end_handle; in parse_read_by_uuid()
4751 params->func(conn, BT_ATT_ERR_UNLIKELY, params, NULL, 0); in parse_read_by_uuid()
4756 params->by_uuid.start_handle = handle; in parse_read_by_uuid()
4758 if (params->func(conn, 0, params, data->value, len) == in parse_read_by_uuid()
4769 if (params->by_uuid.start_handle == params->by_uuid.end_handle) { in parse_read_by_uuid()
4770 params->func(conn, 0, params, NULL, 0); in parse_read_by_uuid()
4774 params->by_uuid.start_handle++; in parse_read_by_uuid()
4778 if (bt_gatt_read(conn, params) < 0) { in parse_read_by_uuid()
4779 params->func(conn, BT_ATT_ERR_UNLIKELY, params, NULL, 0); in parse_read_by_uuid()
4786 struct bt_gatt_read_params *params = user_data; in gatt_read_rsp() local
4791 params->func(conn, att_err_from_int(err), params, NULL, 0); in gatt_read_rsp()
4795 if (!params->handle_count) { in gatt_read_rsp()
4796 parse_read_by_uuid(conn, params, pdu, length); in gatt_read_rsp()
4800 if (params->func(conn, 0, params, pdu, length) == BT_GATT_ITER_STOP) { in gatt_read_rsp()
4813 if (length < (params->_att_mtu - 1)) { in gatt_read_rsp()
4814 params->func(conn, 0, params, NULL, 0); in gatt_read_rsp()
4818 params->single.offset += length; in gatt_read_rsp()
4821 if (bt_gatt_read(conn, params) < 0) { in gatt_read_rsp()
4822 params->func(conn, BT_ATT_ERR_UNLIKELY, params, NULL, 0); in gatt_read_rsp()
4829 struct bt_gatt_read_params *params = user_data; in gatt_read_blob_encode() local
4833 req->handle = sys_cpu_to_le16(params->single.handle); in gatt_read_blob_encode()
4834 req->offset = sys_cpu_to_le16(params->single.offset); in gatt_read_blob_encode()
4840 struct bt_gatt_read_params *params) in gatt_read_blob() argument
4842 LOG_DBG("handle 0x%04x offset 0x%04x", params->single.handle, params->single.offset); in gatt_read_blob()
4844 return gatt_req_send(conn, gatt_read_rsp, params, in gatt_read_blob()
4847 BT_ATT_CHAN_OPT(params)); in gatt_read_blob()
4853 struct bt_gatt_read_params *params = user_data; in gatt_read_uuid_encode() local
4857 req->start_handle = sys_cpu_to_le16(params->by_uuid.start_handle); in gatt_read_uuid_encode()
4858 req->end_handle = sys_cpu_to_le16(params->by_uuid.end_handle); in gatt_read_uuid_encode()
4860 if (params->by_uuid.uuid->type == BT_UUID_TYPE_16) { in gatt_read_uuid_encode()
4861 net_buf_add_le16(buf, BT_UUID_16(params->by_uuid.uuid)->val); in gatt_read_uuid_encode()
4863 net_buf_add_mem(buf, BT_UUID_128(params->by_uuid.uuid)->val, 16); in gatt_read_uuid_encode()
4870 struct bt_gatt_read_params *params) in gatt_read_uuid() argument
4872 LOG_DBG("start_handle 0x%04x end_handle 0x%04x uuid %s", params->by_uuid.start_handle, in gatt_read_uuid()
4873 params->by_uuid.end_handle, bt_uuid_str(params->by_uuid.uuid)); in gatt_read_uuid()
4875 return gatt_req_send(conn, gatt_read_rsp, params, in gatt_read_uuid()
4878 BT_ATT_CHAN_OPT(params)); in gatt_read_uuid()
4885 struct bt_gatt_read_params *params = user_data; in gatt_read_mult_rsp() local
4890 params->func(conn, att_err_from_int(err), params, NULL, 0); in gatt_read_mult_rsp()
4894 params->func(conn, 0, params, pdu, length); in gatt_read_mult_rsp()
4897 params->func(conn, 0, params, NULL, 0); in gatt_read_mult_rsp()
4903 struct bt_gatt_read_params *params = user_data; in gatt_read_mult_encode() local
4906 for (i = 0U; i < params->handle_count; i++) { in gatt_read_mult_encode()
4907 net_buf_add_le16(buf, params->multiple.handles[i]); in gatt_read_mult_encode()
4914 struct bt_gatt_read_params *params) in gatt_read_mult() argument
4916 LOG_DBG("handle_count %zu", params->handle_count); in gatt_read_mult()
4918 return gatt_req_send(conn, gatt_read_mult_rsp, params, in gatt_read_mult()
4920 params->handle_count * sizeof(uint16_t), in gatt_read_mult()
4921 BT_ATT_CHAN_OPT(params)); in gatt_read_mult()
4926 struct bt_gatt_read_params *params) in gatt_read_mult() argument
4937 struct bt_gatt_read_params *params = user_data; in gatt_read_mult_vl_rsp() local
4944 params->func(conn, att_err_from_int(err), params, NULL, 0); in gatt_read_mult_vl_rsp()
4964 params->func(conn, 0, params, rsp->value, len); in gatt_read_mult_vl_rsp()
4970 params->func(conn, 0, params, NULL, 0); in gatt_read_mult_vl_rsp()
4976 struct bt_gatt_read_params *params = user_data; in gatt_read_mult_vl_encode() local
4979 for (i = 0U; i < params->handle_count; i++) { in gatt_read_mult_vl_encode()
4980 net_buf_add_le16(buf, params->multiple.handles[i]); in gatt_read_mult_vl_encode()
4987 struct bt_gatt_read_params *params) in gatt_read_mult_vl() argument
4989 LOG_DBG("handle_count %zu", params->handle_count); in gatt_read_mult_vl()
4991 return gatt_req_send(conn, gatt_read_mult_vl_rsp, params, in gatt_read_mult_vl()
4994 params->handle_count * sizeof(uint16_t), in gatt_read_mult_vl()
4995 BT_ATT_CHAN_OPT(params)); in gatt_read_mult_vl()
5000 struct bt_gatt_read_params *params) in gatt_read_mult_vl() argument
5008 struct bt_gatt_read_params *params = user_data; in gatt_read_encode() local
5012 req->handle = sys_cpu_to_le16(params->single.handle); in gatt_read_encode()
5017 int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params) in bt_gatt_read() argument
5020 __ASSERT(params && params->func, "invalid parameters\n"); in bt_gatt_read()
5026 if (params->handle_count == 0) { in bt_gatt_read()
5027 return gatt_read_uuid(conn, params); in bt_gatt_read()
5030 if (params->handle_count > 1) { in bt_gatt_read()
5031 if (params->multiple.variable) { in bt_gatt_read()
5032 return gatt_read_mult_vl(conn, params); in bt_gatt_read()
5034 return gatt_read_mult(conn, params); in bt_gatt_read()
5038 if (params->single.offset) { in bt_gatt_read()
5039 return gatt_read_blob(conn, params); in bt_gatt_read()
5042 LOG_DBG("handle 0x%04x", params->single.handle); in bt_gatt_read()
5044 return gatt_req_send(conn, gatt_read_rsp, params, gatt_read_encode, in bt_gatt_read()
5046 BT_ATT_CHAN_OPT(params)); in bt_gatt_read()
5052 struct bt_gatt_write_params *params = user_data; in gatt_write_rsp() local
5056 params->func(conn, att_err_from_int(err), params); in gatt_write_rsp()
5121 struct bt_gatt_write_params *params) in gatt_exec_write() argument
5125 return gatt_req_send(conn, gatt_write_rsp, params, gatt_exec_encode, in gatt_exec_write()
5128 BT_ATT_CHAN_OPT(params)); in gatt_exec_write()
5142 struct bt_gatt_write_params *params) in gatt_cancel_all_writes() argument
5146 return gatt_req_send(conn, gatt_write_rsp, params, gatt_cancel_encode, in gatt_cancel_all_writes()
5149 BT_ATT_CHAN_OPT(params)); in gatt_cancel_all_writes()
5156 struct bt_gatt_write_params *params = user_data; in gatt_prepare_write_rsp() local
5165 params->func(conn, att_err_from_int(err), params); in gatt_prepare_write_rsp()
5177 if (len > params->length) { in gatt_prepare_write_rsp()
5179 if (gatt_cancel_all_writes(conn, params)) { in gatt_prepare_write_rsp()
5186 data_valid = memcmp(params->data, rsp->value, len) == 0; in gatt_prepare_write_rsp()
5187 if (params->offset != rsp->offset || !data_valid) { in gatt_prepare_write_rsp()
5189 if (gatt_cancel_all_writes(conn, params)) { in gatt_prepare_write_rsp()
5197 params->offset += len; in gatt_prepare_write_rsp()
5198 params->data = (const uint8_t *)params->data + len; in gatt_prepare_write_rsp()
5199 params->length -= len; in gatt_prepare_write_rsp()
5202 if (!params->length) { in gatt_prepare_write_rsp()
5203 if (gatt_exec_write(conn, params)) { in gatt_prepare_write_rsp()
5211 if (!bt_gatt_write(conn, params)) { in gatt_prepare_write_rsp()
5218 params->func(conn, BT_ATT_ERR_UNLIKELY, params); in gatt_prepare_write_rsp()
5224 struct bt_gatt_write_params *params = user_data; in gatt_prepare_write_encode() local
5229 req->handle = sys_cpu_to_le16(params->handle); in gatt_prepare_write_encode()
5230 req->offset = sys_cpu_to_le16(params->offset); in gatt_prepare_write_encode()
5233 (uint8_t *)params->data, K_NO_WAIT, NULL, in gatt_prepare_write_encode()
5243 struct bt_gatt_write_params *params) in gatt_prepare_write() argument
5250 len = MIN(params->length, len); in gatt_prepare_write()
5253 return gatt_req_send(conn, gatt_prepare_write_rsp, params, in gatt_prepare_write()
5256 BT_ATT_CHAN_OPT(params)); in gatt_prepare_write()
5261 struct bt_gatt_write_params *params = user_data; in gatt_write_encode() local
5266 req->handle = sys_cpu_to_le16(params->handle); in gatt_write_encode()
5268 write = net_buf_append_bytes(buf, params->length, params->data, in gatt_write_encode()
5270 if (write != params->length) { in gatt_write_encode()
5277 int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params) in bt_gatt_write() argument
5282 __ASSERT(params && params->func, "invalid parameters\n"); in bt_gatt_write()
5283 __ASSERT(params->handle, "invalid parameters\n"); in bt_gatt_write()
5289 len = sizeof(struct bt_att_write_req) + params->length; in bt_gatt_write()
5292 if (params->offset || len > (bt_att_get_mtu(conn) - 1)) { in bt_gatt_write()
5293 return gatt_prepare_write(conn, params); in bt_gatt_write()
5296 LOG_DBG("handle 0x%04x length %u", params->handle, params->length); in bt_gatt_write()
5298 return gatt_req_send(conn, gatt_write_rsp, params, gatt_write_encode, in bt_gatt_write()
5299 BT_ATT_OP_WRITE_REQ, len, BT_ATT_CHAN_OPT(params)); in bt_gatt_write()
5306 struct bt_gatt_subscribe_params *params = user_data; in gatt_write_ccc_rsp() local
5311 atomic_clear_bit(params->flags, BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING); in gatt_write_ccc_rsp()
5326 if (node == ¶ms->node) { in gatt_write_ccc_rsp()
5327 gatt_sub_remove(conn, sub, prev, params); in gatt_write_ccc_rsp()
5332 } else if (!params->value) { in gatt_write_ccc_rsp()
5334 params->notify(conn, params, NULL, 0); in gatt_write_ccc_rsp()
5339 if (params->subscribe) { in gatt_write_ccc_rsp()
5340 params->subscribe(conn, att_err, params); in gatt_write_ccc_rsp()
5347 struct bt_gatt_subscribe_params *params = user_data; in gatt_write_ccc_buf() local
5351 write_req->handle = sys_cpu_to_le16(params->ccc_handle); in gatt_write_ccc_buf()
5352 net_buf_add_le16(buf, params->value); in gatt_write_ccc_buf()
5354 atomic_set_bit(params->flags, BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING); in gatt_write_ccc_buf()
5360 struct bt_gatt_subscribe_params *params, in gatt_write_ccc() argument
5365 LOG_DBG("handle 0x%04x value 0x%04x", params->ccc_handle, params->value); in gatt_write_ccc()
5370 atomic_set_bit(params->flags, BT_GATT_SUBSCRIBE_FLAG_SENT); in gatt_write_ccc()
5372 return gatt_req_send(conn, rsp, params, in gatt_write_ccc()
5374 BT_ATT_CHAN_OPT(params)); in gatt_write_ccc()
5380 struct bt_gatt_discover_params *params) in gatt_ccc_discover_cb() argument
5382 struct bt_gatt_subscribe_params *sub_params = params->sub_params; in gatt_ccc_discover_cb()
5385 memset(params, 0, sizeof(*params)); in gatt_ccc_discover_cb()
5390 if (params->type == BT_GATT_DISCOVER_DESCRIPTOR) { in gatt_ccc_discover_cb()
5391 memset(params, 0, sizeof(*params)); in gatt_ccc_discover_cb()
5408 struct bt_gatt_subscribe_params *params) in gatt_ccc_discover() argument
5414 memset(params->disc_params, 0, sizeof(*params->disc_params)); in gatt_ccc_discover()
5416 params->disc_params->sub_params = params; in gatt_ccc_discover()
5417 params->disc_params->uuid = &ccc_uuid.uuid; in gatt_ccc_discover()
5418 params->disc_params->type = BT_GATT_DISCOVER_DESCRIPTOR; in gatt_ccc_discover()
5419 params->disc_params->start_handle = params->value_handle; in gatt_ccc_discover()
5420 params->disc_params->end_handle = params->end_handle; in gatt_ccc_discover()
5421 params->disc_params->func = gatt_ccc_discover_cb; in gatt_ccc_discover()
5423 params->disc_params->chan_opt = params->chan_opt; in gatt_ccc_discover()
5426 err = bt_gatt_discover(conn, params->disc_params); in gatt_ccc_discover()
5437 struct bt_gatt_subscribe_params *params) in bt_gatt_subscribe() argument
5444 __ASSERT(params && params->notify, "invalid parameters\n"); in bt_gatt_subscribe()
5445 __ASSERT(params->value, "invalid parameters\n"); in bt_gatt_subscribe()
5447 __ASSERT(params->ccc_handle || in bt_gatt_subscribe()
5448 (params->end_handle && params->disc_params), in bt_gatt_subscribe()
5451 __ASSERT(params->ccc_handle, "invalid parameters\n"); in bt_gatt_subscribe()
5464 if (params->disc_params != NULL && params->disc_params->func == gatt_ccc_discover_cb) { in bt_gatt_subscribe()
5473 if (tmp == params) { in bt_gatt_subscribe()
5479 if (tmp->value_handle == params->value_handle && in bt_gatt_subscribe()
5480 tmp->value >= params->value) { in bt_gatt_subscribe()
5490 if (params->ccc_handle == BT_GATT_AUTO_DISCOVER_CCC_HANDLE) { in bt_gatt_subscribe()
5491 return gatt_ccc_discover(conn, params); in bt_gatt_subscribe()
5494 err = gatt_write_ccc(conn, params, gatt_write_ccc_rsp); in bt_gatt_subscribe()
5505 sys_slist_prepend(&sub->list, ¶ms->node); in bt_gatt_subscribe()
5511 struct bt_gatt_subscribe_params *params) in bt_gatt_resubscribe() argument
5516 __ASSERT(params && params->notify, "invalid parameters\n"); in bt_gatt_resubscribe()
5517 __ASSERT(params->value, "invalid parameters\n"); in bt_gatt_resubscribe()
5518 __ASSERT(params->ccc_handle, "invalid parameters\n"); in bt_gatt_resubscribe()
5528 if (tmp == params) { in bt_gatt_resubscribe()
5534 sys_slist_prepend(&sub->list, ¶ms->node); in bt_gatt_resubscribe()
5539 struct bt_gatt_subscribe_params *params) in bt_gatt_unsubscribe() argument
5546 __ASSERT(params, "invalid parameters\n"); in bt_gatt_unsubscribe()
5559 if (params == tmp) { in bt_gatt_unsubscribe()
5565 if (tmp->value_handle == params->value_handle) { in bt_gatt_unsubscribe()
5575 if (atomic_test_bit(params->flags, BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING)) { in bt_gatt_unsubscribe()
5576 bt_gatt_cancel(conn, params); in bt_gatt_unsubscribe()
5582 params->value = 0x0000; in bt_gatt_unsubscribe()
5583 err = gatt_write_ccc(conn, params, gatt_write_ccc_rsp); in bt_gatt_unsubscribe()
5589 sys_slist_find_and_remove(&sub->list, ¶ms->node); in bt_gatt_unsubscribe()
5597 params->notify(conn, params, NULL, 0); in bt_gatt_unsubscribe()
5603 void bt_gatt_cancel(struct bt_conn *conn, void *params) in bt_gatt_cancel() argument
5610 req = bt_att_find_req_by_user_data(conn, params); in bt_gatt_cancel()
5619 func(conn, BT_ATT_ERR_UNLIKELY, NULL, 0, params); in bt_gatt_cancel()
5642 struct bt_gatt_subscribe_params *params) in gatt_resub_ccc() argument
5644 return gatt_write_ccc(conn, params, gatt_resub_ccc_rsp); in gatt_resub_ccc()
5650 struct bt_gatt_subscribe_params *params; in add_subscriptions() local
5662 SYS_SLIST_FOR_EACH_CONTAINER(&sub->list, params, node) { in add_subscriptions()
5663 if (!atomic_test_bit(params->flags, in add_subscriptions()
5665 !atomic_test_bit(params->flags, in add_subscriptions()
5672 err = gatt_resub_ccc(conn, params); in add_subscriptions()
5675 (void *)conn, params, err); in add_subscriptions()
5684 struct bt_gatt_exchange_params *params) in gatt_exchange_mtu_func() argument
6437 struct bt_gatt_subscribe_params *params, *tmp; in bt_gatt_clear_subscriptions() local
6445 SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&sub->list, params, tmp, in bt_gatt_clear_subscriptions()
6447 params->value = 0U; in bt_gatt_clear_subscriptions()
6448 gatt_sub_remove(NULL, sub, prev, params); in bt_gatt_clear_subscriptions()
6521 struct bt_gatt_read_params *params = req->user_data; in bt_gatt_req_set_mtu()
6523 __ASSERT_NO_MSG(params); in bt_gatt_req_set_mtu()
6524 params->_att_mtu = mtu; in bt_gatt_req_set_mtu()