Lines Matching full:inst

88 static bool inst_is_registered(const struct tbs_inst *inst)  in inst_is_registered()  argument
90 return inst->attrs != NULL; in inst_is_registered()
93 static bool inst_is_gtbs(const struct tbs_inst *inst) in inst_is_gtbs() argument
96 return inst == &gtbs_inst; in inst_is_gtbs()
102 static uint8_t inst_index(const struct tbs_inst *inst) in inst_index() argument
106 __ASSERT_NO_MSG(inst); in inst_index()
108 if (inst_is_gtbs(inst)) { in inst_index()
112 index = inst - svc_insts; in inst_index()
120 struct tbs_inst *inst = NULL; in inst_lookup_index() local
123 inst = &gtbs_inst; in inst_lookup_index()
125 inst = &svc_insts[index]; in inst_lookup_index()
128 if (inst == NULL || !inst_is_registered(inst)) { in inst_lookup_index()
132 return inst; in inst_lookup_index()
135 static struct bt_tbs_call *lookup_call_in_inst(struct tbs_inst *inst, uint8_t call_index) in lookup_call_in_inst() argument
142 if (inst->calls[i].index == call_index) { in lookup_call_in_inst()
143 return &inst->calls[i]; in lookup_call_in_inst()
179 static bool inst_check_attr(struct tbs_inst *inst, const struct bt_gatt_attr *attr) in inst_check_attr() argument
181 for (size_t j = 0; j < inst->attr_count; j++) { in inst_check_attr()
182 if (&inst->attrs[j] == attr) { in inst_check_attr()
228 static bool is_authorized(const struct tbs_inst *inst, struct bt_conn *conn) in is_authorized() argument
230 if (inst->authorization_required) { in is_authorized()
306 static void tbs_set_terminate_reason(struct tbs_inst *inst, uint8_t call_index, uint8_t reason) in tbs_set_terminate_reason() argument
308 inst->terminate_reason.call_index = call_index; in tbs_set_terminate_reason()
309 inst->terminate_reason.reason = reason; in tbs_set_terminate_reason()
310 LOG_DBG("Index %u: call index 0x%02x, reason %s", inst_index(inst), call_index, in tbs_set_terminate_reason()
313 bt_gatt_notify_uuid(NULL, BT_UUID_TBS_TERMINATE_REASON, inst->attrs, in tbs_set_terminate_reason()
314 (void *)&inst->terminate_reason, sizeof(inst->terminate_reason)); in tbs_set_terminate_reason()
353 static struct bt_tbs_call *call_alloc(struct tbs_inst *inst, uint8_t state, const uint8_t *uri, in call_alloc() argument
358 for (size_t i = 0; i < ARRAY_SIZE(inst->calls); i++) { in call_alloc()
359 if (inst->calls[i].index == BT_TBS_FREE_CALL_INDEX) { in call_alloc()
360 free_call = &inst->calls[i]; in call_alloc()
389 static void net_buf_put_call_states_by_inst(const struct tbs_inst *inst, struct net_buf_simple *buf) in net_buf_put_call_states_by_inst() argument
395 calls = inst->calls; in net_buf_put_call_states_by_inst()
396 call_count = ARRAY_SIZE(inst->calls); in net_buf_put_call_states_by_inst()
415 static void net_buf_put_call_states(const struct tbs_inst *inst, struct net_buf_simple *buf) in net_buf_put_call_states() argument
419 net_buf_put_call_states_by_inst(inst, buf); in net_buf_put_call_states()
424 if (inst_is_gtbs(inst)) { in net_buf_put_call_states()
431 static void net_buf_put_current_calls_by_inst(const struct tbs_inst *inst, in net_buf_put_current_calls_by_inst() argument
440 calls = inst->calls; in net_buf_put_current_calls_by_inst()
441 call_count = ARRAY_SIZE(inst->calls); in net_buf_put_current_calls_by_inst()
468 static void net_buf_put_current_calls(const struct tbs_inst *inst, struct net_buf_simple *buf) in net_buf_put_current_calls() argument
472 net_buf_put_current_calls_by_inst(inst, buf); in net_buf_put_current_calls()
477 if (inst_is_gtbs(inst)) { in net_buf_put_current_calls()
484 static int inst_notify_calls(const struct tbs_inst *inst) in inst_notify_calls() argument
488 if (inst->notify_call_states) { in inst_notify_calls()
489 net_buf_put_call_states(inst, &read_buf); in inst_notify_calls()
491 err = bt_gatt_notify_uuid(NULL, BT_UUID_TBS_CALL_STATE, inst->attrs, read_buf.data, in inst_notify_calls()
498 if (inst->notify_current_calls) { in inst_notify_calls()
499 net_buf_put_current_calls(inst, &read_buf); in inst_notify_calls()
501 err = bt_gatt_notify_uuid(NULL, BT_UUID_TBS_LIST_CURRENT_CALLS, inst->attrs, in inst_notify_calls()
511 static int notify_calls(const struct tbs_inst *inst) in notify_calls() argument
515 if (inst == NULL) { in notify_calls()
520 err = inst_notify_calls(inst); in notify_calls()
525 if (!inst_is_gtbs(inst)) { in notify_calls()
539 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_provider_name() local
541 LOG_DBG("Index %u, Provider name %s", inst_index(inst), inst->provider_name); in read_provider_name()
543 return bt_gatt_attr_read(conn, attr, buf, len, offset, inst->provider_name, in read_provider_name()
544 strlen(inst->provider_name)); in read_provider_name()
549 const struct tbs_inst *inst = lookup_inst_by_attr(attr); in provider_name_cfg_changed() local
551 if (inst != NULL) { in provider_name_cfg_changed()
552 LOG_DBG("Index %u: value 0x%04x", inst_index(inst), value); in provider_name_cfg_changed()
559 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_uci() local
561 LOG_DBG("Index %u: UCI %s", inst_index(inst), inst->uci); in read_uci()
563 return bt_gatt_attr_read(conn, attr, buf, len, offset, inst->uci, strlen(inst->uci)); in read_uci()
569 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_technology() local
571 LOG_DBG("Index %u: Technology 0x%02x", inst_index(inst), inst->technology); in read_technology()
573 return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->technology, in read_technology()
574 sizeof(inst->technology)); in read_technology()
579 const struct tbs_inst *inst = lookup_inst_by_attr(attr); in technology_cfg_changed() local
581 if (inst != NULL) { in technology_cfg_changed()
582 LOG_DBG("Index %u: value 0x%04x", inst_index(inst), value); in technology_cfg_changed()
589 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_uri_scheme_list() local
593 net_buf_simple_add_mem(&read_buf, inst->uri_scheme_list, strlen(inst->uri_scheme_list)); in read_uri_scheme_list()
595 if (inst_is_gtbs(inst)) { in read_uri_scheme_list()
611 LOG_DBG("Index %u: URI scheme %.*s", inst_index(inst), read_buf.len, read_buf.data); in read_uri_scheme_list()
619 const struct tbs_inst *inst = lookup_inst_by_attr(attr); in uri_scheme_list_cfg_changed() local
621 if (inst != NULL) { in uri_scheme_list_cfg_changed()
622 LOG_DBG("Index %u: value 0x%04x", inst_index(inst), value); in uri_scheme_list_cfg_changed()
629 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_signal_strength() local
631 LOG_DBG("Index %u: Signal strength 0x%02x", inst_index(inst), inst->signal_strength); in read_signal_strength()
633 return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->signal_strength, in read_signal_strength()
634 sizeof(inst->signal_strength)); in read_signal_strength()
639 const struct tbs_inst *inst = lookup_inst_by_attr(attr); in signal_strength_cfg_changed() local
641 if (inst != NULL) { in signal_strength_cfg_changed()
642 LOG_DBG("Index %u: value 0x%04x", inst_index(inst), value); in signal_strength_cfg_changed()
649 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_signal_strength_interval() local
652 inst_index(inst), inst->signal_strength_interval); in read_signal_strength_interval()
654 return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->signal_strength_interval, in read_signal_strength_interval()
655 sizeof(inst->signal_strength_interval)); in read_signal_strength_interval()
662 struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in write_signal_strength_interval() local
666 if (!is_authorized(inst, conn)) { in write_signal_strength_interval()
681 inst->signal_strength_interval = signal_strength_interval; in write_signal_strength_interval()
682 LOG_DBG("Index %u: 0x%02x", inst_index(inst), signal_strength_interval); in write_signal_strength_interval()
689 struct tbs_inst *inst = lookup_inst_by_attr(attr); in current_calls_cfg_changed() local
691 if (inst != NULL) { in current_calls_cfg_changed()
692 LOG_DBG("Index %u: value 0x%04x", inst_index(inst), value); in current_calls_cfg_changed()
693 inst->notify_current_calls = (value == BT_GATT_CCC_NOTIFY); in current_calls_cfg_changed()
700 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_current_calls() local
702 LOG_DBG("Index %u", inst_index(inst)); in read_current_calls()
704 net_buf_put_current_calls(inst, &read_buf); in read_current_calls()
716 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_ccid() local
718 LOG_DBG("Index %u: CCID 0x%02x", inst_index(inst), inst->ccid); in read_ccid()
720 return bt_gatt_attr_read(conn, attr, buf, len, offset, &inst->ccid, sizeof(inst->ccid)); in read_ccid()
726 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_status_flags() local
727 const uint16_t status_flags_le = sys_cpu_to_le16(inst->optional_opcodes); in read_status_flags()
729 LOG_DBG("Index %u: status_flags 0x%04x", inst_index(inst), inst->status_flags); in read_status_flags()
737 const struct tbs_inst *inst = lookup_inst_by_attr(attr); in status_flags_cfg_changed() local
739 if (inst != NULL) { in status_flags_cfg_changed()
740 LOG_DBG("Index %u: value 0x%04x", inst_index(inst), value); in status_flags_cfg_changed()
747 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_incoming_uri() local
751 inc_call_target = &inst->incoming_uri; in read_incoming_uri()
753 LOG_DBG("Index %u: call index 0x%02x, URI %s", inst_index(inst), in read_incoming_uri()
769 const struct tbs_inst *inst = lookup_inst_by_attr(attr); in incoming_uri_cfg_changed() local
771 if (inst != NULL) { in incoming_uri_cfg_changed()
772 LOG_DBG("Index %u: value 0x%04x", inst_index(inst), value); in incoming_uri_cfg_changed()
779 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_call_state() local
781 LOG_DBG("Index %u", inst_index(inst)); in read_call_state()
783 net_buf_put_call_states(inst, &read_buf); in read_call_state()
794 struct tbs_inst *inst = lookup_inst_by_attr(attr); in call_state_cfg_changed() local
796 if (inst != NULL) { in call_state_cfg_changed()
797 LOG_DBG("Index %u: value 0x%04x", inst_index(inst), value); in call_state_cfg_changed()
798 inst->notify_call_states = (value == BT_GATT_CCC_NOTIFY); in call_state_cfg_changed()
814 static void hold_other_calls(struct tbs_inst *inst, uint8_t call_index_cnt, in hold_other_calls() argument
819 for (int i = 0; i < ARRAY_SIZE(inst->calls); i++) { in hold_other_calls()
824 if (inst->calls[i].index == call_indexes[j]) { in hold_other_calls()
834 call_state = inst->calls[i].state; in hold_other_calls()
836 inst->calls[i].state = BT_TBS_CALL_STATE_LOCALLY_HELD; in hold_other_calls()
837 held_calls[held_calls_cnt++] = &inst->calls[i]; in hold_other_calls()
839 inst->calls[i].state = BT_TBS_CALL_STATE_LOCALLY_AND_REMOTELY_HELD; in hold_other_calls()
840 held_calls[held_calls_cnt++] = &inst->calls[i]; in hold_other_calls()
845 static uint8_t accept_call(struct tbs_inst *inst, const struct bt_tbs_call_cp_acc *ccp) in accept_call() argument
847 struct bt_tbs_call *call = lookup_call_in_inst(inst, ccp->call_index); in accept_call()
856 hold_other_calls(inst, 1, &ccp->call_index); in accept_call()
864 static uint8_t terminate_call(struct tbs_inst *inst, const struct bt_tbs_call_cp_term *ccp, in terminate_call() argument
867 struct bt_tbs_call *call = lookup_call_in_inst(inst, ccp->call_index); in terminate_call()
874 tbs_set_terminate_reason(inst, ccp->call_index, reason); in terminate_call()
876 if (!inst_is_gtbs(inst)) { in terminate_call()
886 static uint8_t tbs_hold_call(struct tbs_inst *inst, const struct bt_tbs_call_cp_hold *ccp) in tbs_hold_call() argument
888 struct bt_tbs_call *call = lookup_call_in_inst(inst, ccp->call_index); in tbs_hold_call()
890 if ((inst->optional_opcodes & BT_TBS_FEATURE_HOLD) == 0) { in tbs_hold_call()
911 static uint8_t retrieve_call(struct tbs_inst *inst, const struct bt_tbs_call_cp_retrieve *ccp) in retrieve_call() argument
913 struct bt_tbs_call *call = lookup_call_in_inst(inst, ccp->call_index); in retrieve_call()
915 if ((inst->optional_opcodes & BT_TBS_FEATURE_HOLD) == 0) { in retrieve_call()
931 hold_other_calls(inst, 1, &ccp->call_index); in retrieve_call()
936 static int originate_call(struct tbs_inst *inst, const struct bt_tbs_call_cp_originate *ccp, in originate_call() argument
943 if (inst->calls[i].state == BT_TBS_CALL_STATE_ALERTING) { in originate_call()
952 call = call_alloc(inst, BT_TBS_CALL_STATE_DIALING, ccp->uri, uri_len); in originate_call()
959 hold_other_calls(inst, 1, &call->index); in originate_call()
961 notify_calls(inst); in originate_call()
963 notify_calls(inst); in originate_call()
971 static uint8_t join_calls(struct tbs_inst *inst, const struct bt_tbs_call_cp_join *ccp, in join_calls() argument
977 if ((inst->optional_opcodes & BT_TBS_FEATURE_JOIN) == 0) { in join_calls()
997 joined_calls[i] = lookup_call_in_inst(inst, ccp->call_indexes[i]); in join_calls()
1029 hold_other_calls(inst, call_index_cnt, ccp->call_indexes); in join_calls()
1034 static void notify_app(struct bt_conn *conn, struct tbs_inst *inst, uint16_t len, in notify_app() argument
1049 tbs_cbs->terminate_call(conn, call_index, inst->terminate_reason.reason); in notify_app()
1068 call = lookup_call_in_inst(inst, call_index); in notify_app()
1088 terminate_call(inst, &term, BT_TBS_REASON_CALL_FAILED); in notify_app()
1091 notify_calls(inst); in notify_app()
1119 struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in write_call_cp() local
1124 const bool is_gtbs = inst_is_gtbs(inst); in write_call_cp()
1126 if (!is_authorized(inst, conn)) { in write_call_cp()
1138 LOG_DBG("Index %u: Processing the %s opcode", inst_index(inst), in write_call_cp()
1156 tbs = inst; in write_call_cp()
1175 tbs = inst; in write_call_cp()
1194 tbs = inst; in write_call_cp()
1213 tbs = inst; in write_call_cp()
1232 tbs = inst; in write_call_cp()
1254 tbs = inst; in write_call_cp()
1268 inst_index(inst), bt_tbs_opcode_str(ccp->opcode), bt_tbs_status_str(status), in write_call_cp()
1301 const struct tbs_inst *inst = lookup_inst_by_attr(attr); in call_cp_cfg_changed() local
1303 if (inst != NULL) { in call_cp_cfg_changed()
1304 LOG_DBG("Index %u: value 0x%04x", inst_index(inst), value); in call_cp_cfg_changed()
1311 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_optional_opcodes() local
1312 const uint16_t optional_opcodes_le = sys_cpu_to_le16(inst->optional_opcodes); in read_optional_opcodes()
1314 LOG_DBG("Index %u: Supported opcodes 0x%02x", inst_index(inst), inst->optional_opcodes); in read_optional_opcodes()
1322 const struct tbs_inst *inst = lookup_inst_by_attr(attr); in terminate_reason_cfg_changed() local
1324 if (inst != NULL) { in terminate_reason_cfg_changed()
1325 LOG_DBG("Index %u: value 0x%04x", inst_index(inst), value); in terminate_reason_cfg_changed()
1332 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_friendly_name() local
1333 const struct bt_tbs_in_uri *friendly_name = &inst->friendly_name; in read_friendly_name()
1336 LOG_DBG("Index: 0x%02x call index 0x%02x, URI %s", inst_index(inst), in read_friendly_name()
1351 const struct tbs_inst *inst = lookup_inst_by_attr(attr); in friendly_name_cfg_changed() local
1353 if (inst != NULL) { in friendly_name_cfg_changed()
1354 LOG_DBG("Index %u: value 0x%04x", inst_index(inst), value); in friendly_name_cfg_changed()
1361 const struct tbs_inst *inst = BT_AUDIO_CHRC_USER_DATA(attr); in read_incoming_call() local
1362 const struct bt_tbs_in_uri *remote_uri = &inst->in_call; in read_incoming_call()
1365 LOG_DBG("Index: 0x%02x call index 0x%02x, URI %s", inst_index(inst), remote_uri->call_index, in read_incoming_call()
1381 const struct tbs_inst *inst = lookup_inst_by_attr(attr); in in_call_cfg_changed() local
1383 if (inst != NULL) { in in_call_cfg_changed()
1384 LOG_DBG("Index %u: value 0x%04x", inst_index(inst), value); in in_call_cfg_changed()
1388 #define BT_TBS_CHR_PROVIDER_NAME(inst) \ argument
1390 BT_GATT_PERM_READ_ENCRYPT, read_provider_name, NULL, inst), \
1393 #define BT_TBS_CHR_UCI(inst) \ argument
1395 NULL, inst)
1397 #define BT_TBS_CHR_TECHNOLOGY(inst) \ argument
1399 BT_GATT_PERM_READ_ENCRYPT, read_technology, NULL, inst), \
1402 #define BT_TBS_CHR_URI_LIST(inst) \ argument
1404 BT_GATT_PERM_READ_ENCRYPT, read_uri_scheme_list, NULL, inst), \
1407 #define BT_TBS_CHR_SIGNAL_STRENGTH(inst) \ argument
1410 read_signal_strength, NULL, inst), \
1413 #define BT_TBS_CHR_SIGNAL_INTERVAL(inst) \ argument
1417 read_signal_strength_interval, write_signal_strength_interval, inst)
1419 #define BT_TBS_CHR_CURRENT_CALLS(inst) \ argument
1421 BT_GATT_PERM_READ_ENCRYPT, read_current_calls, NULL, inst), \
1424 #define BT_TBS_CHR_CCID(inst) \ argument
1426 inst)
1428 #define BT_TBS_CHR_STATUS_FLAGS(inst) \ argument
1430 BT_GATT_PERM_READ_ENCRYPT, read_status_flags, NULL, inst), \
1433 #define BT_TBS_CHR_INCOMING_URI(inst) \ argument
1436 read_incoming_uri, NULL, inst), \
1439 #define BT_TBS_CHR_CALL_STATE(inst) \ argument
1441 BT_GATT_PERM_READ_ENCRYPT, read_call_state, NULL, inst), \
1444 #define BT_TBS_CHR_CONTROL_POINT(inst) \ argument
1447 BT_GATT_PERM_WRITE_ENCRYPT, NULL, write_call_cp, inst), \
1450 #define BT_TBS_CHR_OPTIONAL_OPCODES(inst) \ argument
1452 read_optional_opcodes, NULL, inst)
1454 #define BT_TBS_CHR_TERMINATE_REASON(inst) \ argument
1456 BT_GATT_PERM_READ_ENCRYPT, NULL, NULL, inst), \
1459 #define BT_TBS_CHR_INCOMING_CALL(inst) \ argument
1461 BT_GATT_PERM_READ_ENCRYPT, read_incoming_call, NULL, inst), \
1464 #define BT_TBS_CHR_FRIENDLY_NAME(inst) \ argument
1467 read_friendly_name, NULL, inst), \
1494 struct tbs_inst *inst = CONTAINER_OF(dwork, struct tbs_inst, reporting_interval_work); in signal_interval_timeout() local
1496 if (!inst->pending_signal_strength_notification) { in signal_interval_timeout()
1500 bt_gatt_notify_uuid(NULL, BT_UUID_TBS_SIGNAL_STRENGTH, inst->attrs, &inst->signal_strength, in signal_interval_timeout()
1501 sizeof(inst->signal_strength)); in signal_interval_timeout()
1503 if (inst->signal_strength_interval) { in signal_interval_timeout()
1504 k_work_reschedule(&inst->reporting_interval_work, in signal_interval_timeout()
1505 K_SECONDS(inst->signal_strength_interval)); in signal_interval_timeout()
1508 inst->pending_signal_strength_notification = false; in signal_interval_timeout()
1511 static int tbs_inst_init_and_register(struct tbs_inst *inst, struct bt_gatt_service *svc, in tbs_inst_init_and_register() argument
1516 LOG_DBG("inst %p index 0x%02x", inst, inst_index(inst)); in tbs_inst_init_and_register()
1524 inst->ccid = (uint8_t)ret; in tbs_inst_init_and_register()
1525 (void)utf8_lcpy(inst->provider_name, param->provider_name, sizeof(inst->provider_name)); in tbs_inst_init_and_register()
1526 (void)utf8_lcpy(inst->uci, param->uci, sizeof(inst->uci)); in tbs_inst_init_and_register()
1527 (void)utf8_lcpy(inst->uri_scheme_list, param->uri_schemes_supported, in tbs_inst_init_and_register()
1528 sizeof(inst->uri_scheme_list)); in tbs_inst_init_and_register()
1529 inst->optional_opcodes = param->supported_features; in tbs_inst_init_and_register()
1530 inst->technology = param->technology; in tbs_inst_init_and_register()
1531 inst->attrs = svc->attrs; in tbs_inst_init_and_register()
1532 inst->attr_count = svc->attr_count; in tbs_inst_init_and_register()
1533 inst->authorization_required = param->authorization_required; in tbs_inst_init_and_register()
1535 k_work_init_delayable(&inst->reporting_interval_work, signal_interval_timeout); in tbs_inst_init_and_register()
1540 memset(inst, 0, sizeof(*inst)); in tbs_inst_init_and_register()
1545 return inst_index(inst); in tbs_inst_init_and_register()
1556 struct tbs_inst *inst = &svc_insts[i]; in tbs_service_inst_register() local
1558 if (!(inst_is_registered(inst))) { in tbs_service_inst_register()
1559 return tbs_inst_init_and_register(inst, &tbs_service_list[i], param); in tbs_service_inst_register()
1672 struct tbs_inst *inst = inst_lookup_index(bearer_index); in bt_tbs_unregister_bearer() local
1678 if (inst == NULL) { in bt_tbs_unregister_bearer()
1679 LOG_DBG("Could not find inst by index %u", bearer_index); in bt_tbs_unregister_bearer()
1684 if (!inst_is_registered(inst)) { in bt_tbs_unregister_bearer()
1690 if (inst_is_gtbs(inst)) { in bt_tbs_unregister_bearer()
1706 k_work_cancel_delayable_sync(&inst->reporting_interval_work, &sync); in bt_tbs_unregister_bearer()
1712 if (restart_reporting_interval && inst->signal_strength_interval != 0U) { in bt_tbs_unregister_bearer()
1719 k_work_schedule(&inst->reporting_interval_work, in bt_tbs_unregister_bearer()
1720 K_SECONDS(inst->signal_strength_interval)); in bt_tbs_unregister_bearer()
1726 memset(inst, 0, sizeof(*inst)); in bt_tbs_unregister_bearer()
1733 struct tbs_inst *inst = lookup_inst_by_call_index(call_index); in bt_tbs_accept() local
1738 if (inst != NULL) { in bt_tbs_accept()
1739 status = accept_call(inst, &ccp); in bt_tbs_accept()
1743 notify_calls(inst); in bt_tbs_accept()
1751 struct tbs_inst *inst = lookup_inst_by_call_index(call_index); in bt_tbs_hold() local
1756 if (inst != NULL) { in bt_tbs_hold()
1757 status = tbs_hold_call(inst, &ccp); in bt_tbs_hold()
1760 notify_calls(inst); in bt_tbs_hold()
1767 struct tbs_inst *inst = lookup_inst_by_call_index(call_index); in bt_tbs_retrieve() local
1772 if (inst != NULL) { in bt_tbs_retrieve()
1773 status = retrieve_call(inst, &ccp); in bt_tbs_retrieve()
1776 notify_calls(inst); in bt_tbs_retrieve()
1783 struct tbs_inst *inst = lookup_inst_by_call_index(call_index); in bt_tbs_terminate() local
1788 if (inst != NULL) { in bt_tbs_terminate()
1789 status = terminate_call(inst, &ccp, BT_TBS_REASON_SERVER_ENDED_CALL); in bt_tbs_terminate()
1792 notify_calls(inst); in bt_tbs_terminate()
1822 struct tbs_inst *inst; in bt_tbs_join() local
1828 inst = lookup_inst_by_call_index(call_indexes[0]); in bt_tbs_join()
1833 if (inst != NULL) { in bt_tbs_join()
1838 status = join_calls(inst, ccp, call_index_cnt); in bt_tbs_join()
1846 struct tbs_inst *inst = lookup_inst_by_call_index(call_index); in bt_tbs_remote_answer() local
1849 if (inst == NULL) { in bt_tbs_remote_answer()
1853 call = lookup_call_in_inst(inst, call_index); in bt_tbs_remote_answer()
1861 notify_calls(inst); in bt_tbs_remote_answer()
1870 struct tbs_inst *inst = lookup_inst_by_call_index(call_index); in bt_tbs_remote_hold() local
1874 if (inst == NULL) { in bt_tbs_remote_hold()
1878 call = lookup_call_in_inst(inst, call_index); in bt_tbs_remote_hold()
1895 notify_calls(inst); in bt_tbs_remote_hold()
1903 struct tbs_inst *inst = lookup_inst_by_call_index(call_index); in bt_tbs_remote_retrieve() local
1907 if (inst == NULL) { in bt_tbs_remote_retrieve()
1911 call = lookup_call_in_inst(inst, call_index); in bt_tbs_remote_retrieve()
1928 notify_calls(inst); in bt_tbs_remote_retrieve()
1936 struct tbs_inst *inst = lookup_inst_by_call_index(call_index); in bt_tbs_remote_terminate() local
1941 if (inst != NULL) { in bt_tbs_remote_terminate()
1942 status = terminate_call(inst, &ccp, BT_TBS_REASON_REMOTE_ENDED_CALL); in bt_tbs_remote_terminate()
1945 notify_calls(inst); in bt_tbs_remote_terminate()
1950 static void tbs_inst_remote_incoming(struct tbs_inst *inst, const char *to, const char *from, in tbs_inst_remote_incoming() argument
1963 inst->in_call.call_index = call->index; in tbs_inst_remote_incoming()
1964 (void)utf8_lcpy(inst->in_call.uri, from, sizeof(inst->in_call.uri)); in tbs_inst_remote_incoming()
1966 inst->incoming_uri.call_index = call->index; in tbs_inst_remote_incoming()
1967 (void)utf8_lcpy(inst->incoming_uri.uri, to, sizeof(inst->incoming_uri.uri)); in tbs_inst_remote_incoming()
1969 bt_gatt_notify_uuid(NULL, BT_UUID_TBS_INCOMING_URI, inst->attrs, &inst->incoming_uri, in tbs_inst_remote_incoming()
1972 bt_gatt_notify_uuid(NULL, BT_UUID_TBS_INCOMING_CALL, inst->attrs, &inst->in_call, in tbs_inst_remote_incoming()
1976 inst->friendly_name.call_index = call->index; in tbs_inst_remote_incoming()
1977 utf8_lcpy(inst->friendly_name.uri, friendly_name, sizeof(inst->friendly_name.uri)); in tbs_inst_remote_incoming()
1980 bt_gatt_notify_uuid(NULL, BT_UUID_TBS_FRIENDLY_NAME, inst->attrs, in tbs_inst_remote_incoming()
1981 &inst->friendly_name, friend_name_ind_len); in tbs_inst_remote_incoming()
1983 inst->friendly_name.call_index = BT_TBS_FREE_CALL_INDEX; in tbs_inst_remote_incoming()
1984 bt_gatt_notify_uuid(NULL, BT_UUID_TBS_FRIENDLY_NAME, inst->attrs, NULL, 0); in tbs_inst_remote_incoming()
1991 struct tbs_inst *inst = inst_lookup_index(bearer_index); in bt_tbs_remote_incoming() local
1994 if (inst == NULL) { in bt_tbs_remote_incoming()
2005 call = call_alloc(inst, BT_TBS_CALL_STATE_INCOMING, (uint8_t *)from, strlen(from)); in bt_tbs_remote_incoming()
2013 tbs_inst_remote_incoming(inst, to, from, friendly_name, call); in bt_tbs_remote_incoming()
2015 if (!inst_is_gtbs(inst)) { in bt_tbs_remote_incoming()
2022 notify_calls(inst); in bt_tbs_remote_incoming()
2031 struct tbs_inst *inst = inst_lookup_index(bearer_index); in bt_tbs_set_bearer_provider_name() local
2036 } else if (inst == NULL) { in bt_tbs_set_bearer_provider_name()
2040 if (strcmp(inst->provider_name, name) == 0) { in bt_tbs_set_bearer_provider_name()
2044 (void)utf8_lcpy(inst->provider_name, name, sizeof(inst->provider_name)); in bt_tbs_set_bearer_provider_name()
2046 bt_gatt_notify_uuid(NULL, BT_UUID_TBS_PROVIDER_NAME, inst->attrs, inst->provider_name, in bt_tbs_set_bearer_provider_name()
2047 strlen(inst->provider_name)); in bt_tbs_set_bearer_provider_name()
2053 struct tbs_inst *inst = inst_lookup_index(bearer_index); in bt_tbs_set_bearer_technology() local
2057 } else if (inst == NULL) { in bt_tbs_set_bearer_technology()
2061 if (inst->technology == new_technology) { in bt_tbs_set_bearer_technology()
2065 inst->technology = new_technology; in bt_tbs_set_bearer_technology()
2067 bt_gatt_notify_uuid(NULL, BT_UUID_TBS_TECHNOLOGY, inst->attrs, &inst->technology, in bt_tbs_set_bearer_technology()
2068 sizeof(inst->technology)); in bt_tbs_set_bearer_technology()
2075 struct tbs_inst *inst = inst_lookup_index(bearer_index); in bt_tbs_set_signal_strength() local
2081 } else if (inst == NULL) { in bt_tbs_set_signal_strength()
2085 if (inst->signal_strength == new_signal_strength) { in bt_tbs_set_signal_strength()
2089 inst->signal_strength = new_signal_strength; in bt_tbs_set_signal_strength()
2090 inst->pending_signal_strength_notification = true; in bt_tbs_set_signal_strength()
2092 timer_status = k_work_delayable_remaining_get(&inst->reporting_interval_work); in bt_tbs_set_signal_strength()
2094 k_work_reschedule(&inst->reporting_interval_work, K_NO_WAIT); in bt_tbs_set_signal_strength()
2104 struct tbs_inst *inst = inst_lookup_index(bearer_index); in bt_tbs_set_status_flags() local
2108 } else if (inst == NULL) { in bt_tbs_set_status_flags()
2112 if (inst->status_flags == status_flags) { in bt_tbs_set_status_flags()
2116 inst->status_flags = status_flags; in bt_tbs_set_status_flags()
2118 bt_gatt_notify_uuid(NULL, BT_UUID_TBS_STATUS_FLAGS, inst->attrs, &status_flags, in bt_tbs_set_status_flags()
2127 struct tbs_inst *inst; in bt_tbs_set_uri_scheme_list() local
2135 inst = &svc_insts[bearer_index]; in bt_tbs_set_uri_scheme_list()
2157 if (strcmp(inst->uri_scheme_list, uri_scheme_list) == 0) { in bt_tbs_set_uri_scheme_list()
2163 (void)utf8_lcpy(inst->uri_scheme_list, uri_scheme_list, sizeof(inst->uri_scheme_list)); in bt_tbs_set_uri_scheme_list()
2165 LOG_DBG("TBS instance %u uri prefix list is now %s", bearer_index, inst->uri_scheme_list); in bt_tbs_set_uri_scheme_list()
2167 bt_gatt_notify_uuid(NULL, BT_UUID_TBS_URI_LIST, inst->attrs, &inst->uri_scheme_list, in bt_tbs_set_uri_scheme_list()
2168 strlen(inst->uri_scheme_list)); in bt_tbs_set_uri_scheme_list()
2170 if (!inst_is_gtbs(inst)) { in bt_tbs_set_uri_scheme_list()