Lines Matching refs:ots
37 struct bt_ots *ots; in oacp_l2cap_closed() local
39 ots = CONTAINER_OF(l2cap_ctx, struct bt_ots, l2cap); in oacp_l2cap_closed()
41 if (!ots->cur_obj) { in oacp_l2cap_closed()
45 ots->cur_obj->state.type = BT_GATT_OTS_OBJECT_IDLE_STATE; in oacp_l2cap_closed()
53 struct bt_ots *ots, in oacp_create_proc_validate() argument
68 if (!BT_OTS_OACP_GET_FEAT_CREATE(ots->features.oacp)) { in oacp_create_proc_validate()
73 err = bt_ots_obj_add_internal(ots, conn, ¶m, &obj); in oacp_create_proc_validate()
81 (void)bt_ots_obj_delete(ots, obj->id); in oacp_create_proc_validate()
88 (void)bt_ots_obj_delete(ots, obj->id); in oacp_create_proc_validate()
95 (void)bt_ots_obj_delete(ots, obj->id); in oacp_create_proc_validate()
100 ots->cur_obj = obj; in oacp_create_proc_validate()
101 ots->cur_obj->state.type = BT_GATT_OTS_OBJECT_IDLE_STATE; in oacp_create_proc_validate()
125 struct bt_ots *ots, in oacp_delete_proc_validate() argument
130 if (!BT_OTS_OACP_GET_FEAT_DELETE(ots->features.oacp)) { in oacp_delete_proc_validate()
135 if (!ots->cur_obj) { in oacp_delete_proc_validate()
140 if (!BT_OTS_OBJ_GET_PROP_DELETE(ots->cur_obj->metadata.props)) { in oacp_delete_proc_validate()
145 err = bt_ots_obj_delete(ots, ots->cur_obj->id); in oacp_delete_proc_validate()
168 struct bt_ots *ots, in oacp_checksum_proc_validate() argument
180 if (!ots->cur_obj) { in oacp_checksum_proc_validate()
184 if (params->offset > ots->cur_obj->metadata.size.cur) { in oacp_checksum_proc_validate()
188 if ((params->offset + (uint64_t) params->len) > ots->cur_obj->metadata.size.alloc) { in oacp_checksum_proc_validate()
192 if (ots->cur_obj->state.type != BT_GATT_OTS_OBJECT_IDLE_STATE) { in oacp_checksum_proc_validate()
196 if (ots->cb->obj_cal_checksum) { in oacp_checksum_proc_validate()
197 err = ots->cb->obj_cal_checksum(ots, conn, ots->cur_obj->id, params->offset, in oacp_checksum_proc_validate()
216 struct bt_ots *ots, in oacp_read_proc_validate() argument
224 if (!ots->cur_obj) { in oacp_read_proc_validate()
228 if (!BT_OTS_OBJ_GET_PROP_READ(ots->cur_obj->metadata.props)) { in oacp_read_proc_validate()
232 if (!bt_gatt_ots_l2cap_is_open(&ots->l2cap, conn)) { in oacp_read_proc_validate()
237 ots->cur_obj->metadata.size.cur) { in oacp_read_proc_validate()
241 if (ots->cur_obj->state.type != BT_GATT_OTS_OBJECT_IDLE_STATE) { in oacp_read_proc_validate()
245 ots->cur_obj->state.type = BT_GATT_OTS_OBJECT_READ_OP_STATE; in oacp_read_proc_validate()
246 ots->cur_obj->state.read_op.sent_len = 0; in oacp_read_proc_validate()
247 memcpy(&ots->cur_obj->state.read_op.oacp_params, &proc->read_params, in oacp_read_proc_validate()
248 sizeof(ots->cur_obj->state.read_op.oacp_params)); in oacp_read_proc_validate()
258 struct bt_ots *ots, in oacp_write_proc_validate() argument
266 if (!ots->cur_obj) { in oacp_write_proc_validate()
270 if (!BT_OTS_OBJ_GET_PROP_WRITE(ots->cur_obj->metadata.props)) { in oacp_write_proc_validate()
275 if (params->offset < ots->cur_obj->metadata.size.cur) { in oacp_write_proc_validate()
276 if (!BT_OTS_OACP_GET_FEAT_PATCH(ots->features.oacp)) { in oacp_write_proc_validate()
279 if (!BT_OTS_OBJ_GET_PROP_PATCH(ots->cur_obj->metadata.props)) { in oacp_write_proc_validate()
289 if (!bt_gatt_ots_l2cap_is_open(&ots->l2cap, conn)) { in oacp_write_proc_validate()
297 if (params->offset > ots->cur_obj->metadata.size.cur) { in oacp_write_proc_validate()
302 if ((params->offset + (uint64_t) params->len) > ots->cur_obj->metadata.size.alloc) { in oacp_write_proc_validate()
306 if (ots->cur_obj->state.type != BT_GATT_OTS_OBJECT_IDLE_STATE) { in oacp_write_proc_validate()
310 ots->l2cap.rx_done = oacp_write_proc_cb; in oacp_write_proc_validate()
311 ots->l2cap.closed = oacp_l2cap_closed; in oacp_write_proc_validate()
312 ots->cur_obj->state.type = BT_GATT_OTS_OBJECT_WRITE_OP_STATE; in oacp_write_proc_validate()
313 ots->cur_obj->state.write_op.recv_len = 0; in oacp_write_proc_validate()
314 memcpy(&ots->cur_obj->state.write_op.oacp_params, params, in oacp_write_proc_validate()
315 sizeof(ots->cur_obj->state.write_op.oacp_params)); in oacp_write_proc_validate()
325 struct bt_ots *ots, in oacp_proc_validate() argument
331 return oacp_read_proc_validate(conn, ots, proc); in oacp_proc_validate()
334 return oacp_write_proc_validate(conn, ots, proc); in oacp_proc_validate()
338 return oacp_create_proc_validate(conn, ots, proc); in oacp_proc_validate()
342 return oacp_delete_proc_validate(conn, ots, proc); in oacp_proc_validate()
346 return oacp_checksum_proc_validate(conn, ots, proc, resp_param); in oacp_proc_validate()
454 struct bt_ots *ots; in oacp_read_proc_cb() local
457 ots = CONTAINER_OF(l2cap_ctx, struct bt_ots, l2cap); in oacp_read_proc_cb()
459 if (ots->cb->obj_read == NULL && in oacp_read_proc_cb()
460 !(IS_ENABLED(CONFIG_BT_OTS_DIR_LIST_OBJ) && ots->cur_obj->id == OTS_OBJ_ID_DIR_LIST)) { in oacp_read_proc_cb()
461 ots->cur_obj->state.type = BT_GATT_OTS_OBJECT_IDLE_STATE; in oacp_read_proc_cb()
467 read_op = &ots->cur_obj->state.read_op; in oacp_read_proc_cb()
477 ots->cur_obj->state.type = BT_GATT_OTS_OBJECT_IDLE_STATE; in oacp_read_proc_cb()
480 ots->cur_obj->id == OTS_OBJ_ID_DIR_LIST) { in oacp_read_proc_cb()
484 ots->cb->obj_read(ots, conn, ots->cur_obj->id, NULL, 0, in oacp_read_proc_cb()
491 ots->cur_obj->id == OTS_OBJ_ID_DIR_LIST) { in oacp_read_proc_cb()
492 len = bt_ots_dir_list_content_get(ots->dir_list, ots->obj_manager, in oacp_read_proc_cb()
495 len = ots->cb->obj_read(ots, conn, ots->cur_obj->id, &obj_chunk, in oacp_read_proc_cb()
502 bt_gatt_ots_l2cap_disconnect(&ots->l2cap); in oacp_read_proc_cb()
503 ots->cur_obj->state.type = BT_GATT_OTS_OBJECT_IDLE_STATE; in oacp_read_proc_cb()
508 ots->l2cap.tx_done = oacp_read_proc_cb; in oacp_read_proc_cb()
509 ots->l2cap.closed = oacp_l2cap_closed; in oacp_read_proc_cb()
510 err = bt_gatt_ots_l2cap_send(&ots->l2cap, obj_chunk, len); in oacp_read_proc_cb()
514 ots->cur_obj->state.type = BT_GATT_OTS_OBJECT_IDLE_STATE; in oacp_read_proc_cb()
520 static void oacp_read_proc_execute(struct bt_ots *ots, in oacp_read_proc_execute() argument
524 &ots->cur_obj->state.read_op.oacp_params; in oacp_read_proc_execute()
526 if (!ots->cur_obj) { in oacp_read_proc_execute()
534 oacp_read_proc_cb(&ots->l2cap, conn); in oacp_read_proc_execute()
542 struct bt_ots *ots; in oacp_write_proc_cb() local
548 ots = CONTAINER_OF(l2cap_ctx, struct bt_ots, l2cap); in oacp_write_proc_cb()
550 if (!ots->cur_obj) { in oacp_write_proc_cb()
555 if (!ots->cb->obj_write) { in oacp_write_proc_cb()
558 ots->cur_obj->state.type = BT_GATT_OTS_OBJECT_IDLE_STATE; in oacp_write_proc_cb()
562 write_op = &ots->cur_obj->state.write_op; in oacp_write_proc_cb()
571 rc = ots->cb->obj_write(ots, conn, ots->cur_obj->id, buf->data, len, in oacp_write_proc_cb()
586 ots->cur_obj->state.type = BT_GATT_OTS_OBJECT_IDLE_STATE; in oacp_write_proc_cb()
598 ots->cur_obj->state.type = BT_GATT_OTS_OBJECT_IDLE_STATE; in oacp_write_proc_cb()
601 if (offset + len > ots->cur_obj->metadata.size.cur) { in oacp_write_proc_cb()
602 ots->cur_obj->metadata.size.cur = offset + len; in oacp_write_proc_cb()
613 struct bt_ots *ots = (struct bt_ots *) params->attr->user_data; in oacp_ind_cb() local
617 if (!ots->cur_obj) { in oacp_ind_cb()
622 switch (ots->cur_obj->state.type) { in oacp_ind_cb()
624 oacp_read_proc_execute(ots, conn); in oacp_ind_cb()
633 LOG_ERR("Unsupported OTS state: %d", ots->cur_obj->state.type); in oacp_ind_cb()
643 struct bt_ots *ots = (struct bt_ots *) oacp_attr->user_data; in oacp_ind_send() local
644 uint8_t *oacp_res = ots->oacp_ind.res; in oacp_ind_send()
658 memset(&ots->oacp_ind.params, 0, sizeof(ots->oacp_ind.params)); in oacp_ind_send()
659 memcpy(&ots->oacp_ind.attr, oacp_attr, sizeof(ots->oacp_ind.attr)); in oacp_ind_send()
660 ots->oacp_ind.params.attr = &ots->oacp_ind.attr; in oacp_ind_send()
661 ots->oacp_ind.params.func = oacp_ind_cb; in oacp_ind_send()
662 ots->oacp_ind.params.data = oacp_res; in oacp_ind_send()
663 ots->oacp_ind.params.len = oacp_res_len; in oacp_ind_send()
668 k_work_submit(&ots->oacp_ind.work); in oacp_ind_send()
679 struct bt_ots *ots = (struct bt_ots *) attr->user_data; in bt_gatt_ots_oacp_write() local
684 if (!ots->oacp_ind.is_enabled) { in bt_gatt_ots_oacp_write()
694 if (k_work_is_pending(&ots->oacp_ind.work)) { in bt_gatt_ots_oacp_write()
702 oacp_status = oacp_proc_validate(conn, ots, &oacp_proc, &resp_param); in bt_gatt_ots_oacp_write()