Lines Matching refs:client
113 struct bt_csip_set_coordinator_inst *client = in active_members_reset() local
116 atomic_clear_bit(client->flags, SET_COORDINATOR_FLAG_BUSY); in active_members_reset()
126 struct bt_csip_set_coordinator_inst *client; in lookup_instance_by_handle() local
132 client = &client_insts[conn_index]; in lookup_instance_by_handle()
134 for (int i = 0; i < ARRAY_SIZE(client->svc_insts); i++) { in lookup_instance_by_handle()
135 if (client->svc_insts[i].start_handle <= handle && in lookup_instance_by_handle()
136 client->svc_insts[i].end_handle >= handle) { in lookup_instance_by_handle()
137 return &client->svc_insts[i]; in lookup_instance_by_handle()
148 struct bt_csip_set_coordinator_inst *client; in bt_csip_set_coordinator_lookup_instance_by_index() local
156 client = &client_insts[conn_index]; in bt_csip_set_coordinator_lookup_instance_by_index()
157 return &client->svc_insts[idx]; in bt_csip_set_coordinator_lookup_instance_by_index()
362 static void discover_complete(struct bt_csip_set_coordinator_inst *client, in discover_complete() argument
367 client->cur_inst = NULL; in discover_complete()
368 atomic_clear_bit(client->flags, SET_COORDINATOR_FLAG_BUSY); in discover_complete()
373 listener->discover(client->conn, in discover_complete()
374 &client->set_member, in discover_complete()
375 err, client->inst_count); in discover_complete()
377 listener->discover(client->conn, NULL, err, 0U); in discover_complete()
407 struct bt_csip_set_coordinator_inst *client; in sirk_notify_func() local
411 client = &client_insts[bt_conn_index(conn)]; in sirk_notify_func()
412 inst = &client->set_member.insts[svc_inst->idx]; in sirk_notify_func()
476 struct bt_csip_set_coordinator_inst *client; in size_notify_func() local
479 client = &client_insts[bt_conn_index(conn)]; in size_notify_func()
480 set_info = &client->set_member.insts[svc_inst->idx].info; in size_notify_func()
522 struct bt_csip_set_coordinator_inst *client; in lock_notify_func() local
539 client = &client_insts[bt_conn_index(conn)]; in lock_notify_func()
540 inst = &client->set_member.insts[svc_inst->idx]; in lock_notify_func()
558 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(inst->conn)]; in csip_set_coordinator_write_set_lock() local
562 client->cur_inst = NULL; in csip_set_coordinator_write_set_lock()
567 client->gatt_write_buf[0] = lock ? BT_CSIP_LOCK_VALUE : BT_CSIP_RELEASE_VALUE; in csip_set_coordinator_write_set_lock()
568 client->write_params.data = client->gatt_write_buf; in csip_set_coordinator_write_set_lock()
569 client->write_params.length = sizeof(lock); in csip_set_coordinator_write_set_lock()
570 client->write_params.func = cb; in csip_set_coordinator_write_set_lock()
571 client->write_params.handle = inst->set_lock_handle; in csip_set_coordinator_write_set_lock()
573 return bt_gatt_write(inst->conn, &client->write_params); in csip_set_coordinator_write_set_lock()
578 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(svc_inst->conn)]; in read_sirk() local
580 if (client->cur_inst != NULL) { in read_sirk()
581 if (client->cur_inst != svc_inst) { in read_sirk()
585 client->cur_inst = svc_inst; in read_sirk()
593 client->read_params.func = csip_set_coordinator_discover_insts_read_sirk_cb; in read_sirk()
594 client->read_params.handle_count = 1; in read_sirk()
595 client->read_params.single.handle = svc_inst->sirk_handle; in read_sirk()
596 client->read_params.single.offset = 0U; in read_sirk()
598 return bt_gatt_read(svc_inst->conn, &client->read_params); in read_sirk()
605 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(conn)]; in csip_set_coordinator_read_set_size() local
609 } else if (client->cur_inst != NULL) { in csip_set_coordinator_read_set_size()
610 if (client->cur_inst != in csip_set_coordinator_read_set_size()
615 client->cur_inst = bt_csip_set_coordinator_lookup_instance_by_index(conn, inst_idx); in csip_set_coordinator_read_set_size()
616 if (client->cur_inst == NULL) { in csip_set_coordinator_read_set_size()
622 if (client->cur_inst->set_size_handle == 0) { in csip_set_coordinator_read_set_size()
624 client->cur_inst = NULL; in csip_set_coordinator_read_set_size()
628 client->read_params.func = cb; in csip_set_coordinator_read_set_size()
629 client->read_params.handle_count = 1; in csip_set_coordinator_read_set_size()
630 client->read_params.single.handle = client->cur_inst->set_size_handle; in csip_set_coordinator_read_set_size()
631 client->read_params.single.offset = 0U; in csip_set_coordinator_read_set_size()
633 return bt_gatt_read(conn, &client->read_params); in csip_set_coordinator_read_set_size()
640 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(conn)]; in csip_set_coordinator_read_rank() local
644 } else if (client->cur_inst != NULL) { in csip_set_coordinator_read_rank()
645 if (client->cur_inst != in csip_set_coordinator_read_rank()
650 client->cur_inst = bt_csip_set_coordinator_lookup_instance_by_index(conn, inst_idx); in csip_set_coordinator_read_rank()
651 if (client->cur_inst == NULL) { in csip_set_coordinator_read_rank()
657 if (client->cur_inst->rank_handle == 0) { in csip_set_coordinator_read_rank()
659 client->cur_inst = NULL; in csip_set_coordinator_read_rank()
663 client->read_params.func = cb; in csip_set_coordinator_read_rank()
664 client->read_params.handle_count = 1; in csip_set_coordinator_read_rank()
665 client->read_params.single.handle = client->cur_inst->rank_handle; in csip_set_coordinator_read_rank()
666 client->read_params.single.offset = 0U; in csip_set_coordinator_read_rank()
668 return bt_gatt_read(conn, &client->read_params); in csip_set_coordinator_read_rank()
671 static int csip_set_coordinator_discover_sets(struct bt_csip_set_coordinator_inst *client) in csip_set_coordinator_discover_sets() argument
673 struct bt_csip_set_coordinator_set_member *member = &client->set_member; in csip_set_coordinator_discover_sets()
684 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(conn)]; in discover_func() local
689 LOG_DBG("Setup complete for %u / %u", client->cur_inst->idx + 1, in discover_func()
690 client->inst_count); in discover_func()
694 (client->cur_inst->idx + 1) < client->inst_count) { in discover_func()
697 client->cur_inst = &client->svc_insts[client->cur_inst->idx + 1]; in discover_func()
698 client->discover_params.uuid = NULL; in discover_func()
699 client->discover_params.start_handle = client->cur_inst->start_handle; in discover_func()
700 client->discover_params.end_handle = client->cur_inst->end_handle; in discover_func()
701 client->discover_params.type = BT_GATT_DISCOVER_CHARACTERISTIC; in discover_func()
702 client->discover_params.func = discover_func; in discover_func()
704 err = bt_gatt_discover(conn, &client->discover_params); in discover_func()
707 discover_complete(client, err); in discover_func()
713 client->cur_inst = NULL; in discover_func()
714 err = csip_set_coordinator_discover_sets(client); in discover_func()
717 discover_complete(client, err); in discover_func()
726 client->inst_count != 0) { in discover_func()
730 client->cur_inst->sirk_handle = chrc->value_handle; in discover_func()
731 sub_params = &client->cur_inst->sirk_sub_params; in discover_func()
732 sub_params->disc_params = &client->cur_inst->sirk_sub_disc_params; in discover_func()
736 client->cur_inst->set_size_handle = chrc->value_handle; in discover_func()
737 sub_params = &client->cur_inst->size_sub_params; in discover_func()
738 sub_params->disc_params = &client->cur_inst->size_sub_disc_params; in discover_func()
744 client->cur_inst->set_lock_handle = chrc->value_handle; in discover_func()
745 sub_params = &client->cur_inst->lock_sub_params; in discover_func()
746 sub_params->disc_params = &client->cur_inst->lock_sub_disc_params; in discover_func()
749 set_info = &client->set_member.insts[client->cur_inst->idx].info; in discover_func()
753 client->cur_inst->rank_handle = chrc->value_handle; in discover_func()
768 sub_params->end_handle = client->cur_inst->end_handle; in discover_func()
776 discover_complete(client, err); in discover_func()
792 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(conn)]; in primary_discover_func() local
795 client->inst_count == CONFIG_BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES) { in primary_discover_func()
796 LOG_DBG("Discover complete, found %u instances", client->inst_count); in primary_discover_func()
799 if (client->inst_count != 0) { in primary_discover_func()
802 client->cur_inst = &client->svc_insts[0]; in primary_discover_func()
803 client->discover_params.uuid = NULL; in primary_discover_func()
804 client->discover_params.start_handle = client->cur_inst->start_handle; in primary_discover_func()
805 client->discover_params.end_handle = client->cur_inst->end_handle; in primary_discover_func()
806 client->discover_params.type = BT_GATT_DISCOVER_CHARACTERISTIC; in primary_discover_func()
807 client->discover_params.func = discover_func; in primary_discover_func()
809 err = bt_gatt_discover(conn, &client->discover_params); in primary_discover_func()
812 discover_complete(client, err); in primary_discover_func()
815 discover_complete(client, 0); in primary_discover_func()
825 client->discover_params.start_handle = attr->handle + 1; in primary_discover_func()
827 client->cur_inst = &client->svc_insts[client->inst_count]; in primary_discover_func()
828 client->cur_inst->idx = client->inst_count; in primary_discover_func()
829 client->cur_inst->start_handle = attr->handle; in primary_discover_func()
830 client->cur_inst->end_handle = prim_service->end_handle; in primary_discover_func()
831 client->cur_inst->conn = bt_conn_ref(conn); in primary_discover_func()
832 client->cur_inst->set_info = &client->set_member.insts[client->cur_inst->idx].info; in primary_discover_func()
833 client->inst_count++; in primary_discover_func()
874 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(conn)]; in csip_set_coordinator_discover_insts_read_rank_cb() local
876 __ASSERT(client->cur_inst != NULL, "client->cur_inst must not be NULL"); in csip_set_coordinator_discover_insts_read_rank_cb()
881 discover_complete(client, err); in csip_set_coordinator_discover_insts_read_rank_cb()
887 set_info = &client->set_member.insts[client->cur_inst->idx].info; in csip_set_coordinator_discover_insts_read_rank_cb()
906 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(conn)]; in csip_set_coordinator_discover_insts_read_set_size_cb() local
908 __ASSERT(client->cur_inst != NULL, "client->cur_inst must not be NULL"); in csip_set_coordinator_discover_insts_read_set_size_cb()
913 discover_complete(client, err); in csip_set_coordinator_discover_insts_read_set_size_cb()
919 set_info = &client->set_member.insts[client->cur_inst->idx].info; in csip_set_coordinator_discover_insts_read_set_size_cb()
928 discover_insts_resume(conn, 0, 0, client->cur_inst->rank_handle); in csip_set_coordinator_discover_insts_read_set_size_cb()
934 static int parse_sirk(struct bt_csip_set_coordinator_inst *client, in parse_sirk() argument
939 sirk = client->set_member.insts[client->cur_inst->idx].info.sirk; in parse_sirk()
953 err = sirk_decrypt(client->conn, recvd_sirk->value, sirk); in parse_sirk()
984 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(conn)]; in csip_set_coordinator_discover_insts_read_sirk_cb() local
986 __ASSERT(client->cur_inst != NULL, "client->cur_inst must not be NULL"); in csip_set_coordinator_discover_insts_read_sirk_cb()
991 discover_complete(client, err); in csip_set_coordinator_discover_insts_read_sirk_cb()
995 cb_err = parse_sirk(client, data, length); in csip_set_coordinator_discover_insts_read_sirk_cb()
1000 discover_insts_resume(conn, 0, client->cur_inst->set_size_handle, in csip_set_coordinator_discover_insts_read_sirk_cb()
1001 client->cur_inst->rank_handle); in csip_set_coordinator_discover_insts_read_sirk_cb()
1022 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(conn)]; in discover_insts_resume() local
1026 conn, client->cur_inst->idx, in discover_insts_resume()
1033 conn, client->cur_inst->idx, in discover_insts_resume()
1039 uint8_t next_idx = client->cur_inst->idx + 1; in discover_insts_resume()
1041 client->cur_inst = NULL; in discover_insts_resume()
1042 if (next_idx < client->inst_count) { in discover_insts_resume()
1043 client->cur_inst = in discover_insts_resume()
1047 cb_err = read_sirk(client->cur_inst); in discover_insts_resume()
1049 discover_complete(client, 0); in discover_insts_resume()
1056 discover_complete(client, cb_err); in discover_insts_resume()
1064 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(conn)]; in csip_set_coordinator_write_restore_cb() local
1082 client->cur_inst = lookup_instance_by_set_info(member, &active.info); in csip_set_coordinator_write_restore_cb()
1083 if (client->cur_inst == NULL) { in csip_set_coordinator_write_restore_cb()
1090 client->cur_inst, false, csip_set_coordinator_write_restore_cb); in csip_set_coordinator_write_restore_cb()
1106 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(conn)]; in csip_set_coordinator_write_lock_cb() local
1117 client->cur_inst = lookup_instance_by_set_info(member, &active.info); in csip_set_coordinator_write_lock_cb()
1118 if (client->cur_inst == NULL) { in csip_set_coordinator_write_lock_cb()
1126 client->cur_inst, false, csip_set_coordinator_write_restore_cb); in csip_set_coordinator_write_lock_cb()
1144 struct bt_csip_set_coordinator_svc_inst *prev_inst = client->cur_inst; in csip_set_coordinator_write_lock_cb()
1147 client->cur_inst = get_next_active_instance(); in csip_set_coordinator_write_lock_cb()
1148 if (client->cur_inst == NULL) { in csip_set_coordinator_write_lock_cb()
1154 csip_err = csip_set_coordinator_write_set_lock(client->cur_inst, true, in csip_set_coordinator_write_lock_cb()
1180 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(conn)]; in csip_set_coordinator_write_release_cb() local
1195 client->cur_inst = get_next_active_instance(); in csip_set_coordinator_write_release_cb()
1196 if (client->cur_inst == NULL) { in csip_set_coordinator_write_release_cb()
1203 client->cur_inst, false, csip_set_coordinator_write_release_cb); in csip_set_coordinator_write_release_cb()
1236 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(conn)]; in csip_set_coordinator_read_lock_cb() local
1250 if (data == NULL || length != sizeof(client->cur_inst->set_lock)) { in csip_set_coordinator_read_lock_cb()
1268 client->cur_inst->set_lock = value; in csip_set_coordinator_read_lock_cb()
1281 client->cur_inst = get_next_active_instance(); in csip_set_coordinator_read_lock_cb()
1282 if (client->cur_inst == NULL) { in csip_set_coordinator_read_lock_cb()
1288 csip_err = csip_set_coordinator_read_set_lock(client->cur_inst); in csip_set_coordinator_read_lock_cb()
1304 struct bt_csip_set_coordinator_inst *client = &client_insts[bt_conn_index(inst->conn)]; in csip_set_coordinator_read_set_lock() local
1309 client->cur_inst = NULL; in csip_set_coordinator_read_set_lock()
1313 client->read_params.func = csip_set_coordinator_read_lock_cb; in csip_set_coordinator_read_set_lock()
1314 client->read_params.handle_count = 1; in csip_set_coordinator_read_set_lock()
1315 client->read_params.single.handle = inst->set_lock_handle; in csip_set_coordinator_read_set_lock()
1316 client->read_params.single.offset = 0; in csip_set_coordinator_read_set_lock()
1318 client->cur_inst = inst; in csip_set_coordinator_read_set_lock()
1320 err = bt_gatt_read(inst->conn, &client->read_params); in csip_set_coordinator_read_set_lock()
1322 client->cur_inst = NULL; in csip_set_coordinator_read_set_lock()
1397 struct bt_csip_set_coordinator_inst *client; in bt_csip_set_coordinator_csis_inst_by_handle() local
1399 client = &client_insts[bt_conn_index(conn)]; in bt_csip_set_coordinator_csis_inst_by_handle()
1401 return &client->set_member.insts[svc_inst->idx]; in bt_csip_set_coordinator_csis_inst_by_handle()
1410 struct bt_csip_set_coordinator_inst *client; in bt_csip_set_coordinator_set_member_by_conn() local
1418 client = &client_insts[bt_conn_index(conn)]; in bt_csip_set_coordinator_set_member_by_conn()
1419 if (client->conn == conn) { in bt_csip_set_coordinator_set_member_by_conn()
1420 return &client->set_member; in bt_csip_set_coordinator_set_member_by_conn()
1443 struct bt_csip_set_coordinator_inst *client; in bt_csip_set_coordinator_discover() local
1450 client = &client_insts[bt_conn_index(conn)]; in bt_csip_set_coordinator_discover()
1451 if (atomic_test_and_set_bit(client->flags, SET_COORDINATOR_FLAG_BUSY)) { in bt_csip_set_coordinator_discover()
1455 csip_set_coordinator_reset(client); in bt_csip_set_coordinator_discover()
1458 (void)memset(&client->discover_params, 0, sizeof(client->discover_params)); in bt_csip_set_coordinator_discover()
1460 client->discover_params.func = primary_discover_func; in bt_csip_set_coordinator_discover()
1461 client->discover_params.uuid = &uuid.uuid; in bt_csip_set_coordinator_discover()
1462 client->discover_params.type = BT_GATT_DISCOVER_PRIMARY; in bt_csip_set_coordinator_discover()
1463 client->discover_params.start_handle = BT_ATT_FIRST_ATTRIBUTE_HANDLE; in bt_csip_set_coordinator_discover()
1464 client->discover_params.end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE; in bt_csip_set_coordinator_discover()
1466 err = bt_gatt_discover(conn, &client->discover_params); in bt_csip_set_coordinator_discover()
1468 for (size_t i = 0; i < ARRAY_SIZE(client->set_member.insts); i++) { in bt_csip_set_coordinator_discover()
1469 client->set_member.insts[i].svc_inst = (void *)&client->svc_insts[i]; in bt_csip_set_coordinator_discover()
1471 client->conn = bt_conn_ref(conn); in bt_csip_set_coordinator_discover()
1473 atomic_clear_bit(client->flags, SET_COORDINATOR_FLAG_BUSY); in bt_csip_set_coordinator_discover()
1558 struct bt_csip_set_coordinator_inst *client = in check_and_set_members_busy() local
1561 if (atomic_test_and_set_bit(client->flags, SET_COORDINATOR_FLAG_BUSY)) { in check_and_set_members_busy()
1571 struct bt_csip_set_coordinator_inst *client = CONTAINER_OF( in check_and_set_members_busy() local
1574 atomic_clear_bit(client->flags, SET_COORDINATOR_FLAG_BUSY); in check_and_set_members_busy()
1675 const struct bt_csip_set_coordinator_inst *client = in all_members_bonded() local
1680 err = bt_conn_get_info(client->conn, &info); in all_members_bonded()