Lines Matching full:inst

53 	struct bt_vocs_server *inst = BT_AUDIO_CHRC_USER_DATA(attr);  in read_offset_state()  local
55 LOG_DBG("offset %d, counter %u", inst->state.offset, inst->state.change_counter); in read_offset_state()
56 return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->state, in read_offset_state()
57 sizeof(inst->state)); in read_offset_state()
79 static void notify_work_reschedule(struct bt_vocs_server *inst, enum bt_vocs_notify notify, in notify_work_reschedule() argument
84 atomic_set_bit(inst->notify, notify); in notify_work_reschedule()
86 err = k_work_reschedule(&inst->notify_work, K_NO_WAIT); in notify_work_reschedule()
93 static void notify(struct bt_vocs_server *inst, enum bt_vocs_notify notify, in notify() argument
98 err = bt_gatt_notify_uuid(NULL, uuid, inst->service_p->attrs, data, len); in notify()
100 notify_work_reschedule(inst, notify, K_USEC(BT_AUDIO_NOTIFY_RETRY_DELAY_US)); in notify()
109 struct bt_vocs_server *inst = CONTAINER_OF(d_work, struct bt_vocs_server, notify_work); in notify_work_handler() local
111 if (atomic_test_and_clear_bit(inst->notify, NOTIFY_STATE)) { in notify_work_handler()
112 notify(inst, NOTIFY_STATE, BT_UUID_VOCS_STATE, &inst->state, sizeof(inst->state)); in notify_work_handler()
115 if (atomic_test_and_clear_bit(inst->notify, NOTIFY_LOCATION)) { in notify_work_handler()
116 notify(inst, NOTIFY_LOCATION, BT_UUID_VOCS_LOCATION, &inst->location, in notify_work_handler()
117 sizeof(inst->location)); in notify_work_handler()
120 if (atomic_test_and_clear_bit(inst->notify, NOTIFY_OUTPUT_DESC)) { in notify_work_handler()
121 notify(inst, NOTIFY_OUTPUT_DESC, BT_UUID_VOCS_DESCRIPTION, &inst->output_desc, in notify_work_handler()
122 strlen(inst->output_desc)); in notify_work_handler()
126 static void value_changed(struct bt_vocs_server *inst, enum bt_vocs_notify notify) in value_changed() argument
128 notify_work_reschedule(inst, notify, K_NO_WAIT); in value_changed()
137 struct bt_vocs_server *inst = BT_AUDIO_CHRC_USER_DATA(attr); in write_location() local
144 if (len != sizeof(inst->location)) { in write_location()
155 if (new_location != inst->location) { in write_location()
156 inst->location = new_location; in write_location()
158 value_changed(inst, NOTIFY_LOCATION); in write_location()
160 if (inst->cb && inst->cb->location) { in write_location()
161 inst->cb->location(&inst->vocs, 0, inst->location); in write_location()
172 struct bt_vocs_server *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_location() local
174 LOG_DBG("0x%08x", inst->location); in read_location()
175 return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->location, in read_location()
176 sizeof(inst->location)); in read_location()
183 struct bt_vocs_server *inst = BT_AUDIO_CHRC_USER_DATA(attr); in write_vocs_control() local
208 if (cp->counter != inst->state.change_counter) { in write_vocs_control()
219 if (inst->state.offset != sys_le16_to_cpu(cp->offset)) { in write_vocs_control()
220 inst->state.offset = sys_le16_to_cpu(cp->offset); in write_vocs_control()
229 inst->state.change_counter++; in write_vocs_control()
230 LOG_DBG("New state: offset %d, counter %u", inst->state.offset, in write_vocs_control()
231 inst->state.change_counter); in write_vocs_control()
233 value_changed(inst, NOTIFY_STATE); in write_vocs_control()
235 if (inst->cb && inst->cb->state) { in write_vocs_control()
236 inst->cb->state(&inst->vocs, 0, inst->state.offset); in write_vocs_control()
254 struct bt_vocs_server *inst = BT_AUDIO_CHRC_USER_DATA(attr); in write_output_desc() local
260 if (len >= sizeof(inst->output_desc)) { in write_output_desc()
262 sizeof(inst->output_desc) - 1); in write_output_desc()
264 len = (uint16_t)sizeof(inst->output_desc) - 1; in write_output_desc()
267 if (len != strlen(inst->output_desc) || memcmp(buf, inst->output_desc, len)) { in write_output_desc()
268 memcpy(inst->output_desc, buf, len); in write_output_desc()
269 inst->output_desc[len] = '\0'; in write_output_desc()
271 value_changed(inst, NOTIFY_OUTPUT_DESC); in write_output_desc()
273 if (inst->cb && inst->cb->description) { in write_output_desc()
274 inst->cb->description(&inst->vocs, 0, inst->output_desc); in write_output_desc()
278 LOG_DBG("%s", inst->output_desc); in write_output_desc()
283 static int vocs_write(struct bt_vocs_server *inst, in vocs_write() argument
291 .user_data = inst, in vocs_write()
310 struct bt_vocs_server *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_output_desc() local
312 LOG_DBG("%s", inst->output_desc); in read_output_desc()
313 return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->output_desc, in read_output_desc()
314 strlen(inst->output_desc)); in read_output_desc()
357 struct bt_vocs_server *inst; in bt_vocs_svc_decl_get() local
369 inst = CONTAINER_OF(vocs, struct bt_vocs_server, vocs); in bt_vocs_svc_decl_get()
371 return inst->service_p->attrs; in bt_vocs_svc_decl_get()
384 struct bt_vocs_server *inst; in bt_vocs_register() local
400 inst = CONTAINER_OF(vocs, struct bt_vocs_server, vocs); in bt_vocs_register()
412 CHECKIF(inst->initialized) { in bt_vocs_register()
422 inst->location = param->location; in bt_vocs_register()
423 inst->state.offset = param->offset; in bt_vocs_register()
424 inst->cb = param->cb; in bt_vocs_register()
427 (void)utf8_lcpy(inst->output_desc, param->output_desc, in bt_vocs_register()
428 sizeof(inst->output_desc)); in bt_vocs_register()
430 strcmp(inst->output_desc, param->output_desc)) { in bt_vocs_register()
431 LOG_DBG("Output desc clipped to %s", inst->output_desc); in bt_vocs_register()
441 for (int i = 1; i < inst->service_p->attr_count; i++) { in bt_vocs_register()
442 attr = &inst->service_p->attrs[i]; in bt_vocs_register()
446 chrc = inst->service_p->attrs[i - 1].user_data; in bt_vocs_register()
452 chrc = inst->service_p->attrs[i - 1].user_data; in bt_vocs_register()
458 err = bt_gatt_service_register(inst->service_p); in bt_vocs_register()
464 atomic_clear(inst->notify); in bt_vocs_register()
465 k_work_init_delayable(&inst->notify_work, notify_work_handler); in bt_vocs_register()
467 inst->initialized = true; in bt_vocs_register()
472 int bt_vocs_state_get(struct bt_vocs *inst) in bt_vocs_state_get() argument
474 CHECKIF(!inst) { in bt_vocs_state_get()
479 if (IS_ENABLED(CONFIG_BT_VOCS_CLIENT) && inst->client_instance) { in bt_vocs_state_get()
480 struct bt_vocs_client *cli = CONTAINER_OF(inst, struct bt_vocs_client, vocs); in bt_vocs_state_get()
483 } else if (IS_ENABLED(CONFIG_BT_VOCS) && !inst->client_instance) { in bt_vocs_state_get()
484 struct bt_vocs_server *srv = CONTAINER_OF(inst, struct bt_vocs_server, vocs); in bt_vocs_state_get()
487 srv->cb->state(inst, 0, srv->state.offset); in bt_vocs_state_get()
495 int bt_vocs_location_get(struct bt_vocs *inst) in bt_vocs_location_get() argument
497 CHECKIF(!inst) { in bt_vocs_location_get()
502 if (IS_ENABLED(CONFIG_BT_VOCS_CLIENT) && inst->client_instance) { in bt_vocs_location_get()
503 struct bt_vocs_client *cli = CONTAINER_OF(inst, struct bt_vocs_client, vocs); in bt_vocs_location_get()
506 } else if (IS_ENABLED(CONFIG_BT_VOCS) && !inst->client_instance) { in bt_vocs_location_get()
507 struct bt_vocs_server *srv = CONTAINER_OF(inst, struct bt_vocs_server, vocs); in bt_vocs_location_get()
510 srv->cb->location(inst, 0, srv->location); in bt_vocs_location_get()
518 int bt_vocs_location_set(struct bt_vocs *inst, uint32_t location) in bt_vocs_location_set() argument
520 CHECKIF(!inst) { in bt_vocs_location_set()
525 if (IS_ENABLED(CONFIG_BT_VOCS_CLIENT) && inst->client_instance) { in bt_vocs_location_set()
526 struct bt_vocs_client *cli = CONTAINER_OF(inst, struct bt_vocs_client, vocs); in bt_vocs_location_set()
529 } else if (IS_ENABLED(CONFIG_BT_VOCS) && !inst->client_instance) { in bt_vocs_location_set()
530 struct bt_vocs_server *srv = CONTAINER_OF(inst, struct bt_vocs_server, vocs); in bt_vocs_location_set()
538 int bt_vocs_state_set(struct bt_vocs *inst, int16_t offset) in bt_vocs_state_set() argument
540 CHECKIF(!inst) { in bt_vocs_state_set()
545 if (IS_ENABLED(CONFIG_BT_VOCS_CLIENT) && inst->client_instance) { in bt_vocs_state_set()
546 struct bt_vocs_client *cli = CONTAINER_OF(inst, struct bt_vocs_client, vocs); in bt_vocs_state_set()
549 } else if (IS_ENABLED(CONFIG_BT_VOCS) && !inst->client_instance) { in bt_vocs_state_set()
550 struct bt_vocs_server *srv = CONTAINER_OF(inst, struct bt_vocs_server, vocs); in bt_vocs_state_set()
563 int bt_vocs_description_get(struct bt_vocs *inst) in bt_vocs_description_get() argument
565 CHECKIF(!inst) { in bt_vocs_description_get()
570 if (IS_ENABLED(CONFIG_BT_VOCS_CLIENT) && inst->client_instance) { in bt_vocs_description_get()
571 struct bt_vocs_client *cli = CONTAINER_OF(inst, struct bt_vocs_client, vocs); in bt_vocs_description_get()
574 } else if (IS_ENABLED(CONFIG_BT_VOCS) && !inst->client_instance) { in bt_vocs_description_get()
575 struct bt_vocs_server *srv = CONTAINER_OF(inst, struct bt_vocs_server, vocs); in bt_vocs_description_get()
578 srv->cb->description(inst, 0, srv->output_desc); in bt_vocs_description_get()
586 int bt_vocs_description_set(struct bt_vocs *inst, const char *description) in bt_vocs_description_set() argument
588 CHECKIF(!inst) { in bt_vocs_description_set()
598 if (IS_ENABLED(CONFIG_BT_VOCS_CLIENT) && inst->client_instance) { in bt_vocs_description_set()
599 struct bt_vocs_client *cli = CONTAINER_OF(inst, struct bt_vocs_client, vocs); in bt_vocs_description_set()
602 } else if (IS_ENABLED(CONFIG_BT_VOCS) && !inst->client_instance) { in bt_vocs_description_set()
603 struct bt_vocs_server *srv = CONTAINER_OF(inst, struct bt_vocs_server, vocs); in bt_vocs_description_set()