Bluetooth: Audio: Rename CSIS to CSIP

Renamed the coordinated set implementation to use the
profile (CSIP) name instead of the service (CSIS) name, as
the former is more general.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2022-10-11 13:53:49 +02:00 committed by Carles Cufí
commit 93b3944a51
38 changed files with 1028 additions and 1006 deletions

View file

@ -7,4 +7,4 @@ Bluetooth Coordinated Sets
API Reference
*************
.. doxygengroup:: bt_gatt_csis
.. doxygengroup:: bt_gatt_csip

View file

@ -27,7 +27,7 @@ Using the Set Coordinator
When the Bluetooth stack has been initialized (:code:`bt init`),
and a set member device has been connected, the call control client can be
initialized by calling :code:`csis_client init`, which will start a discovery
initialized by calling :code:`csip_set_coordinator init`, which will start a discovery
for the TBS uuids and store the handles, and optionally subscribe to all
notifications (default is to subscribe to all).
@ -36,15 +36,15 @@ read the set information, which is needed to identify other set members.
The client can then scan for and connect to the remaining set members, and once
all the members has been connected to, it can lock and release the set.
It is necessary to enable :code:`BT_DEBUG_CSIS_CLIENT` to properly use the set
It is necessary to enable :code:`BT_DEBUG_CSIP_SET_COORDINATOR` to properly use the set
coordinator.
.. code-block:: console
csis_client --help
csis_client - Bluetooth CSIS_CLIENT shell commands
csip_set_coordinator --help
csip_set_coordinator - Bluetooth CSIP_SET_COORDINATOR shell commands
Subcommands:
init :Initialize CSIS_CLIENT
init :Initialize CSIP_SET_COORDINATOR
discover :Run discover for CSIS on peer device [member_index]
discover_members :Scan for set members <set_pointer>
lock_set :Lock set
@ -73,62 +73,62 @@ Discovering sets on a device:
.. code-block:: console
uart:~$ csis_client init
<dbg> bt_csis_client.primary_discover_func: [ATTRIBUTE] handle 0x0048
<dbg> bt_csis_client.primary_discover_func: Discover complete, found 1 instances
<dbg> bt_csis_client.discover_func: Setup complete for 1 / 1
uart:~$ csip_set_coordinator init
<dbg> bt_csip_set_coordinator.primary_discover_func: [ATTRIBUTE] handle 0x0048
<dbg> bt_csip_set_coordinator.primary_discover_func: Discover complete, found 1 instances
<dbg> bt_csip_set_coordinator.discover_func: Setup complete for 1 / 1
Found 1 sets on device
uart:~$ csis_client discover_sets
<dbg> bt_csis_client.Set SIRK
uart:~$ csip_set_coordinator discover_sets
<dbg> bt_csip_set_coordinator.Set SIRK
36 04 9a dc 66 3a a1 a1 |6...f:..
1d 9a 2f 41 01 73 3e 01 |../A.s>.
<dbg> bt_csis_client.csis_client_discover_sets_read_set_size_cb: 2
<dbg> bt_csis_client.csis_client_discover_sets_read_set_lock_cb: 1
<dbg> bt_csis_client.csis_client_discover_sets_read_rank_cb: 1
<dbg> bt_csip_set_coordinator.csip_set_coordinator_discover_sets_read_set_size_cb: 2
<dbg> bt_csip_set_coordinator.csip_set_coordinator_discover_sets_read_set_lock_cb: 1
<dbg> bt_csip_set_coordinator.csip_set_coordinator_discover_sets_read_rank_cb: 1
Set size 2 (pointer: 0x566fdfe8)
Discover set members, based on the set pointer above:
.. code-block:: console
uart:~$ csis_client discover_members 0x566fdfe8
<dbg> bt_csis_client.csis_found: Found CSIS advertiser with address 34:02:86:03:86:c0 (public)
<dbg> bt_csis_client.is_set_member: hash: 0x33ccb1, prand 0x5bfe6a
<dbg> bt_csis_client.is_discovered: 34:02:86:03:86:c0 (public)
<dbg> bt_csis_client.is_discovered: 34:13:e8:b3:7f:9e (public)
<dbg> bt_csis_client.csis_found: Found member (2 / 2)
uart:~$ csip_set_coordinator discover_members 0x566fdfe8
<dbg> bt_csip_set_coordinator.csip_found: Found CSIS advertiser with address 34:02:86:03:86:c0 (public)
<dbg> bt_csip_set_coordinator.is_set_member: hash: 0x33ccb1, prand 0x5bfe6a
<dbg> bt_csip_set_coordinator.is_discovered: 34:02:86:03:86:c0 (public)
<dbg> bt_csip_set_coordinator.is_discovered: 34:13:e8:b3:7f:9e (public)
<dbg> bt_csip_set_coordinator.csip_found: Found member (2 / 2)
Discovered 2/2 set members
Lock set members:
.. code-block:: console
uart:~$ csis_client lock_set
<dbg> bt_csis_client.bt_csis_client_lock_set: Connecting to 34:02:86:03:86:c0 (public)
<dbg> bt_csis_client.csis_client_connected: Connected to 34:02:86:03:86:c0 (public)
<dbg> bt_csis_client.discover_func: Setup complete for 1 / 1
<dbg> bt_csis_client.csis_client_lock_set_init_cb:
<dbg> bt_csis_client.Set SIRK
uart:~$ csip_set_coordinator lock_set
<dbg> bt_csip_set_coordinator.bt_csip_set_coordinator_lock_set: Connecting to 34:02:86:03:86:c0 (public)
<dbg> bt_csip_set_coordinator.csip_set_coordinator_connected: Connected to 34:02:86:03:86:c0 (public)
<dbg> bt_csip_set_coordinator.discover_func: Setup complete for 1 / 1
<dbg> bt_csip_set_coordinator.csip_set_coordinator_lock_set_init_cb:
<dbg> bt_csip_set_coordinator.Set SIRK
36 04 9a dc 66 3a a1 a1 |6...f:..
1d 9a 2f 41 01 73 3e 01 |../A.s>.
<dbg> bt_csis_client.csis_client_discover_sets_read_set_size_cb: 2
<dbg> bt_csis_client.csis_client_discover_sets_read_set_lock_cb: 1
<dbg> bt_csis_client.csis_client_discover_sets_read_rank_cb: 2
<dbg> bt_csis_client.csis_client_write_lowest_rank: Locking member with rank 1
<dbg> bt_csis_client.notify_func: Instance 0 lock was locked
<dbg> bt_csis_client.csis_client_write_lowest_rank: Locking member with rank 2
<dbg> bt_csis_client.notify_func: Instance 0 lock was locked
<dbg> bt_csip_set_coordinator.csip_set_coordinator_discover_sets_read_set_size_cb: 2
<dbg> bt_csip_set_coordinator.csip_set_coordinator_discover_sets_read_set_lock_cb: 1
<dbg> bt_csip_set_coordinator.csip_set_coordinator_discover_sets_read_rank_cb: 2
<dbg> bt_csip_set_coordinator.csip_set_coordinator_write_lowest_rank: Locking member with rank 1
<dbg> bt_csip_set_coordinator.notify_func: Instance 0 lock was locked
<dbg> bt_csip_set_coordinator.csip_set_coordinator_write_lowest_rank: Locking member with rank 2
<dbg> bt_csip_set_coordinator.notify_func: Instance 0 lock was locked
Set locked
Release set members:
.. code-block:: console
uart:~$ csis_client release_set
<dbg> bt_csis_client.csis_client_release_highest_rank: Releasing member with rank 2
<dbg> bt_csis_client.notify_func: Instance 0 lock was released
<dbg> bt_csis_client.csis_client_release_highest_rank: Releasing member with rank 1
<dbg> bt_csis_client.notify_func: Instance 0 lock was released
uart:~$ csip_set_coordinator release_set
<dbg> bt_csip_set_coordinator.csip_set_coordinator_release_highest_rank: Releasing member with rank 2
<dbg> bt_csip_set_coordinator.notify_func: Instance 0 lock was released
<dbg> bt_csip_set_coordinator.csip_set_coordinator_release_highest_rank: Releasing member with rank 1
<dbg> bt_csip_set_coordinator.notify_func: Instance 0 lock was released
Set released
Coordinated Set Member (Server)
@ -141,12 +141,11 @@ Using the Set Member
.. code-block:: console
csis --help
csis - Bluetooth CSIS shell commands
csip --help
csip - Bluetooth CSIP shell commands
Subcommands:
register :Initialize the service and register callbacks [size <int>]
[rank <int>] [not-lockable] [sirk <data>]
advertise :Start/stop advertising CSIS PSRIs <on/off>
update_psri :Update the advertised PSRI
lock :Lock the set
release :Release the set [force]
@ -163,5 +162,4 @@ Setup
.. code-block:: console
uart:~$ bt init
uart:~$ csis register
uart:~$ csis advertise on
uart:~$ csip register

View file

@ -132,8 +132,8 @@ Coordinated Sets is implemented by the Coordinated Sets Identification Profile
The CSIP implementation supports the following roles
* Coordinated Set Identification Service (CSIS) Server
* Coordinated Set Identification Service (CSIS) Client
* Coordinated Set Identification Service (CSIP) Server
* Coordinated Set Identification Service (CSIP) Set Coordinator
The API reference for media control can be found in
:ref:`Bluetooth Coordinated Sets <bluetooth_coordinated_sets>`.

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Before After
Before After

View file

@ -20,7 +20,7 @@
*/
#include <zephyr/types.h>
#include <zephyr/bluetooth/audio/csis.h>
#include <zephyr/bluetooth/audio/csip.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/bluetooth/audio/audio.h>
@ -40,13 +40,13 @@ extern "C" {
* is not enabled, the Common Audio Service will by statically registered.
*
* @param[in] param Coordinated Set Identification Service register parameters.
* @param[out] csis Pointer to the registered Coordinated Set Identification
* @param[out] csip Pointer to the registered Coordinated Set Identification
* Service.
*
* @return 0 if success, errno on failure.
*/
int bt_cap_acceptor_register(const struct bt_csis_register_param *param,
struct bt_csis **csis);
int bt_cap_acceptor_register(const struct bt_csip_register_param *param,
struct bt_csip **csip);
/** Callback structure for CAP procedures */
struct bt_cap_initiator_cb {
@ -63,8 +63,9 @@ struct bt_cap_initiator_cb {
* NULL on error or if remote device does not include
* Coordinated Set Identification Service.
*/
void (*unicast_discovery_complete)(struct bt_conn *conn, int err,
const struct bt_csis_client_csis_inst *csis_inst);
void (*unicast_discovery_complete)(
struct bt_conn *conn, int err,
const struct bt_csip_set_coordinator_csis_inst *csis_inst);
/**
* @brief Callback for bt_cap_initiator_unicast_audio_start().
@ -133,7 +134,7 @@ union bt_cap_set_member {
struct bt_conn *member;
/** CSIP Coordinated Set struct used if type is BT_CAP_SET_TYPE_CSIP. */
struct bt_csis_client_set_member *csip;
struct bt_csip_set_coordinator_set_member *csip;
};
struct bt_cap_stream {

View file

@ -1,16 +1,16 @@
/**
* Copyright (c) 2021 Nordic Semiconductor ASA
* Copyright (c) 2021-2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_SUBSYS_BLUETOOTH_AUDIO_CSIS_H_
#define ZEPHYR_SUBSYS_BLUETOOTH_AUDIO_CSIS_H_
#ifndef ZEPHYR_SUBSYS_BLUETOOTH_AUDIO_CSIP_H_
#define ZEPHYR_SUBSYS_BLUETOOTH_AUDIO_CSIP_H_
/**
* @brief Coordinated Set Identification Service (CSIS)
* @brief Coordinated Set Identification Profile (CSIP)
*
* @defgroup bt_gatt_csis Coordinated Set Identification Service (CSIS)
* @defgroup bt_gatt_csip Coordinated Set Identification Profile (CSIP)
*
* @ingroup bluetooth
* @{
@ -27,40 +27,40 @@ extern "C" {
#endif
/** Recommended timer for member discovery */
#define CSIS_CLIENT_DISCOVER_TIMER_VALUE K_SECONDS(10)
#define BT_CSIP_SET_COORDINATOR_DISCOVER_TIMER_VALUE K_SECONDS(10)
#if defined(CONFIG_BT_CSIS_CLIENT)
#define BT_CSIS_CLIENT_MAX_CSIS_INSTANCES CONFIG_BT_CSIS_CLIENT_MAX_CSIS_INSTANCES
#if defined(CONFIG_BT_CSIP_SET_COORDINATOR)
#define BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES CONFIG_BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES
#else
#define BT_CSIS_CLIENT_MAX_CSIS_INSTANCES 0
#endif /* CONFIG_BT_CSIS_CLIENT */
#define BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES 0
#endif /* CONFIG_BT_CSIP_SET_COORDINATOR */
/** Accept the request to read the SIRK as plaintext */
#define BT_CSIS_READ_SIRK_REQ_RSP_ACCEPT 0x00
#define BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT 0x00
/** Accept the request to read the SIRK, but return encrypted SIRK */
#define BT_CSIS_READ_SIRK_REQ_RSP_ACCEPT_ENC 0x01
#define BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT_ENC 0x01
/** Reject the request to read the SIRK */
#define BT_CSIS_READ_SIRK_REQ_RSP_REJECT 0x02
#define BT_CSIP_READ_SIRK_REQ_RSP_REJECT 0x02
/** SIRK is available only via an OOB procedure */
#define BT_CSIS_READ_SIRK_REQ_RSP_OOB_ONLY 0x03
#define BT_CSIP_READ_SIRK_REQ_RSP_OOB_ONLY 0x03
/** Size of the Set Identification Resolving Key (SIRK) */
#define BT_CSIS_SET_SIRK_SIZE 16
#define BT_CSIP_SET_SIRK_SIZE 16
/** Size of the Resolvable Set Identifier (RSI) */
#define BT_CSIS_RSI_SIZE 6
#define BT_CSIP_RSI_SIZE 6
/* Coordinate Set Identification Service Error codes */
/** Service is already locked */
#define BT_CSIS_ERROR_LOCK_DENIED 0x80
#define BT_CSIP_ERROR_LOCK_DENIED 0x80
/** Service is not locked */
#define BT_CSIS_ERROR_LOCK_RELEASE_DENIED 0x81
#define BT_CSIP_ERROR_LOCK_RELEASE_DENIED 0x81
/** Invalid lock value */
#define BT_CSIS_ERROR_LOCK_INVAL_VALUE 0x82
#define BT_CSIP_ERROR_LOCK_INVAL_VALUE 0x82
/** SIRK only available out-of-band */
#define BT_CSIS_ERROR_SIRK_OOB_ONLY 0x83
#define BT_CSIP_ERROR_SIRK_OOB_ONLY 0x83
/** Client is already owner of the lock */
#define BT_CSIS_ERROR_LOCK_ALREADY_GRANTED 0x84
#define BT_CSIP_ERROR_LOCK_ALREADY_GRANTED 0x84
/**
* @brief Helper to declare bt_data array including RSI
@ -70,24 +70,24 @@ extern "C" {
*
* @param _rsi Pointer to the RSI value
*/
#define BT_CSIS_DATA_RSI(_rsi) BT_DATA(BT_DATA_CSIS_RSI, _rsi, BT_CSIS_RSI_SIZE)
#define BT_CSIP_DATA_RSI(_rsi) BT_DATA(BT_DATA_CSIS_RSI, _rsi, BT_CSIP_RSI_SIZE)
/** @brief Opaque Coordinated Set Identification Service instance. */
struct bt_csis;
struct bt_csip;
/** Callback structure for the Coordinated Set Identification Service */
struct bt_csis_cb {
struct bt_csip_cb {
/**
* @brief Callback whenever the lock changes on the server.
*
* @param conn The connection to the client that changed the lock.
* NULL if server changed it, either by calling
* bt_csis_lock() or by timeout.
* @param csis Pointer to the Coordinated Set Identification Service.
* bt_csip_lock() or by timeout.
* @param csip Pointer to the Coordinated Set Identification Service.
* @param locked Whether the lock was locked or released.
*
*/
void (*lock_changed)(struct bt_conn *conn, struct bt_csis *csis,
void (*lock_changed)(struct bt_conn *conn, struct bt_csip *csip,
bool locked);
/**
@ -98,15 +98,15 @@ struct bt_csis_cb {
*
* @param conn The connection to the client that requested to read the
* SIRK.
* @param csis Pointer to the Coordinated Set Identification Service.
* @param csip Pointer to the Coordinated Set Identification Service.
*
* @return A BT_CSIS_READ_SIRK_REQ_RSP_* response code.
* @return A BT_CSIP_READ_SIRK_REQ_RSP_* response code.
*/
uint8_t (*sirk_read_req)(struct bt_conn *conn, struct bt_csis *csis);
uint8_t (*sirk_read_req)(struct bt_conn *conn, struct bt_csip *csip);
};
/** Register structure for Coordinated Set Identification Service */
struct bt_csis_register_param {
struct bt_csip_register_param {
/**
* @brief Size of the set.
*
@ -120,7 +120,7 @@ struct bt_csis_register_param {
* This shall be unique between different sets, and shall be the same
* for each set member for each set.
*/
uint8_t set_sirk[BT_CSIS_SET_SIRK_SIZE];
uint8_t set_sirk[BT_CSIP_SET_SIRK_SIZE];
/**
* @brief Boolean to set whether the set is lockable by clients
@ -139,20 +139,20 @@ struct bt_csis_register_param {
uint8_t rank;
/** Pointer to the callback structure. */
struct bt_csis_cb *cb;
struct bt_csip_cb *cb;
#if CONFIG_BT_CSIS_MAX_INSTANCE_COUNT > 1
#if CONFIG_BT_CSIP_MAX_INSTANCE_COUNT > 1
/**
* @brief Parent service pointer
*
* Mandatory parent service pointer if this CSIS instance is included
* by another service. All CSIS instances when
* @kconfig{CONFIG_BT_CSIS_MAX_INSTANCE_COUNT} is above 1 shall
* @kconfig{CONFIG_BT_CSIP_MAX_INSTANCE_COUNT} is above 1 shall
* be included by another service, as per the
* Coordinated Set Identification Profile (CSIP).
*/
const struct bt_gatt_service *parent;
#endif /* CONFIG_BT_CSIS_MAX_INSTANCE_COUNT > 1 */
#endif /* CONFIG_BT_CSIP_MAX_INSTANCE_COUNT > 1 */
};
/**
@ -160,11 +160,11 @@ struct bt_csis_register_param {
*
* The first service attribute can be included in any other GATT service.
*
* @param csis Pointer to the Coordinated Set Identification Service.
* @param csip Pointer to the Coordinated Set Identification Service.
*
* @return The first CSIS attribute instance.
*/
void *bt_csis_svc_decl_get(const struct bt_csis *csis);
void *bt_csip_svc_decl_get(const struct bt_csip *csip);
/**
* @brief Register a Coordinated Set Identification Service instance.
@ -175,37 +175,37 @@ void *bt_csis_svc_decl_get(const struct bt_csis *csis);
* This shall only be done as a server.
*
* @param param Coordinated Set Identification Service register parameters.
* @param[out] csis Pointer to the registered Coordinated Set Identification
* @param[out] csip Pointer to the registered Coordinated Set Identification
* Service.
*
* @return 0 if success, errno on failure.
*/
int bt_csis_register(const struct bt_csis_register_param *param,
struct bt_csis **csis);
int bt_csip_register(const struct bt_csip_register_param *param,
struct bt_csip **csip);
/**
* @brief Print the SIRK to the debug output
*
* @param csis Pointer to the Coordinated Set Identification Service.
* @param csip Pointer to the Coordinated Set Identification Service.
*/
void bt_csis_print_sirk(const struct bt_csis *csis);
void bt_csip_print_sirk(const struct bt_csip *csip);
/**
* @brief Generate the Resolvable Set Identifier (RSI) value.
*
* This will generate RSI for given @p csis instance.
* This will generate RSI for given @p csip instance.
*
* @param csis Pointer to the Coordinated Set Identification Service.
* @param csip Pointer to the Coordinated Set Identification Service.
* @param rsi Pointer to the 6-octet newly generated RSI data.
*
* @return int 0 if on success, errno on error.
*/
int bt_csis_generate_rsi(const struct bt_csis *csis, uint8_t rsi[BT_CSIS_RSI_SIZE]);
int bt_csip_generate_rsi(const struct bt_csip *csip, uint8_t rsi[BT_CSIP_RSI_SIZE]);
/**
* @brief Locks a specific Coordinated Set Identification Service instance on the server.
*
* @param csis Pointer to the Coordinated Set Identification Service.
* @param csip Pointer to the Coordinated Set Identification Service.
* @param lock If true lock the set, if false release the set.
* @param force This argument only have meaning when @p lock is false
* (release) and will force release the lock, regardless of who
@ -213,17 +213,17 @@ int bt_csis_generate_rsi(const struct bt_csis *csis, uint8_t rsi[BT_CSIS_RSI_SIZ
*
* @return 0 on success, GATT error on error.
*/
int bt_csis_lock(struct bt_csis *csis, bool lock, bool force);
int bt_csip_lock(struct bt_csip *csip, bool lock, bool force);
/** Information about a specific set */
struct bt_csis_client_set_info {
struct bt_csip_set_coordinator_set_info {
/**
* @brief The 16 octet set Set Identity Resolving Key (SIRK)
*
* The Set SIRK may not be exposed by the server over Bluetooth, and
* may require an out-of-band solution.
*/
uint8_t set_sirk[BT_CSIS_SET_SIRK_SIZE];
uint8_t set_sirk[BT_CSIP_SET_SIRK_SIZE];
/**
* @brief The size of the set
@ -244,23 +244,23 @@ struct bt_csis_client_set_info {
* @brief Struct representing a coordinated set instance on a remote device
*
* The values in this struct will be populated during discovery of sets
* (bt_csis_client_discover()).
* (bt_csip_set_coordinator_discover()).
*/
struct bt_csis_client_csis_inst {
struct bt_csis_client_set_info info;
struct bt_csip_set_coordinator_csis_inst {
struct bt_csip_set_coordinator_set_info info;
/** Internally used pointer value */
struct bt_csis *csis;
struct bt_csip *csip;
};
/** Struct representing a remote device as a set member */
struct bt_csis_client_set_member {
struct bt_csip_set_coordinator_set_member {
/** Array of Coordinated Set Identification Service instances for the remote device */
struct bt_csis_client_csis_inst insts[BT_CSIS_CLIENT_MAX_CSIS_INSTANCES];
struct bt_csip_set_coordinator_csis_inst insts[BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES];
};
/**
* @typedef bt_csis_client_discover_cb
* @typedef bt_csip_set_coordinator_discover_cb
* @brief Callback for discovering Coordinated Set Identification Services.
*
* @param conn Pointer to the remote device.
@ -268,30 +268,31 @@ struct bt_csis_client_set_member {
* @param err 0 on success, or an errno value on error.
* @param set_count Number of sets on the member.
*/
typedef void (*bt_csis_client_discover_cb)(struct bt_conn *conn,
const struct bt_csis_client_set_member *member,
typedef void (*bt_csip_set_coordinator_discover_cb)(
struct bt_conn *conn,
const struct bt_csip_set_coordinator_set_member *member,
int err, size_t set_count);
/**
* @brief Initialise the csis_client instance for a connection. This will do a
* @brief Initialise the csip_set_coordinator instance for a connection. This will do a
* discovery on the device and prepare the instance for following commands.
*
* @param conn Pointer to remote device to perform discovery on.
*
* @return int Return 0 on success, or an errno value on error.
*/
int bt_csis_client_discover(struct bt_conn *conn);
int bt_csip_set_coordinator_discover(struct bt_conn *conn);
/**
* @typedef bt_csis_client_lock_set_cb
* @typedef bt_csip_set_coordinator_lock_set_cb
* @brief Callback for locking a set across one or more devices
*
* @param err 0 on success, or an errno value on error.
*/
typedef void (*bt_csis_client_lock_set_cb)(int err);
typedef void (*bt_csip_set_coordinator_lock_set_cb)(int err);
/**
* @typedef bt_csis_client_lock_changed_cb
* @typedef bt_csip_set_coordinator_lock_changed_cb
* @brief Callback when the lock value on a set of a connected device changes.
*
* @param inst The Coordinated Set Identification Service instance that was
@ -300,14 +301,14 @@ typedef void (*bt_csis_client_lock_set_cb)(int err);
*
* @return int Return 0 on success, or an errno value on error.
*/
typedef void (*bt_csis_client_lock_changed_cb)(struct bt_csis_client_csis_inst *inst,
bool locked);
typedef void (*bt_csip_set_coordinator_lock_changed_cb)(
struct bt_csip_set_coordinator_csis_inst *inst, bool locked);
/**
* @typedef bt_csis_client_ordered_access_cb_t
* @brief Callback for bt_csis_client_ordered_access()
* @typedef bt_csip_set_coordinator_ordered_access_cb_t
* @brief Callback for bt_csip_set_coordinator_ordered_access()
*
* If any of the set members supplied to bt_csis_client_ordered_access() is
* If any of the set members supplied to bt_csip_set_coordinator_ordered_access() is
* in the locked state, this will be called with @p locked true and @p member
* will be the locked member, and the ordered access procedure is cancelled.
* Likewise, if any error occurs, the procedure will also be aborted.
@ -317,19 +318,20 @@ typedef void (*bt_csis_client_lock_changed_cb)(struct bt_csis_client_csis_inst *
* @param locked Whether the lock is locked or release.
* @param member The locked member if @p locked is true, otherwise NULL.
*/
typedef void (*bt_csis_client_ordered_access_cb_t)(const struct bt_csis_client_set_info *set_info,
typedef void (*bt_csip_set_coordinator_ordered_access_cb_t)(
const struct bt_csip_set_coordinator_set_info *set_info,
int err, bool locked,
struct bt_csis_client_set_member *member);
struct bt_csip_set_coordinator_set_member *member);
struct bt_csis_client_cb {
struct bt_csip_set_coordinator_cb {
/* Set callbacks */
bt_csis_client_lock_set_cb lock_set;
bt_csis_client_lock_set_cb release_set;
bt_csis_client_lock_changed_cb lock_changed;
bt_csip_set_coordinator_lock_set_cb lock_set;
bt_csip_set_coordinator_lock_set_cb release_set;
bt_csip_set_coordinator_lock_changed_cb lock_changed;
/* Device specific callbacks */
bt_csis_client_discover_cb discover;
bt_csis_client_ordered_access_cb_t ordered_access;
bt_csip_set_coordinator_discover_cb discover;
bt_csip_set_coordinator_ordered_access_cb_t ordered_access;
/** Internally used field for list handling */
sys_snode_t _node;
@ -343,20 +345,20 @@ struct bt_csis_client_cb {
*
* @return true if the advertising data indicates a set member, false otherwise
*/
bool bt_csis_client_is_set_member(const uint8_t set_sirk[BT_CSIS_SET_SIRK_SIZE],
bool bt_csip_set_coordinator_is_set_member(const uint8_t set_sirk[BT_CSIP_SET_SIRK_SIZE],
struct bt_data *data);
/**
* @brief Registers callbacks for csis_client.
* @brief Registers callbacks for csip_set_coordinator.
*
* @param cb Pointer to the callback structure.
*
* @return Return 0 on success, or an errno value on error.
*/
int bt_csis_client_register_cb(struct bt_csis_client_cb *cb);
int bt_csip_set_coordinator_register_cb(struct bt_csip_set_coordinator_cb *cb);
/**
* @brief Callback function definition for bt_csis_client_ordered_access()
* @brief Callback function definition for bt_csip_set_coordinator_ordered_access()
*
* @param set_info Pointer to the a specific set_info struct.
* @param members Array of members ordered by rank. The procedure shall be
@ -366,8 +368,9 @@ int bt_csis_client_register_cb(struct bt_csis_client_cb *cb);
* @return true if the procedures can be successfully done, or false to stop the
* procedure.
*/
typedef bool (*bt_csis_client_ordered_access_t)(const struct bt_csis_client_set_info *set_info,
struct bt_csis_client_set_member *members[],
typedef bool (*bt_csip_set_coordinator_ordered_access_t)(
const struct bt_csip_set_coordinator_set_info *set_info,
struct bt_csip_set_coordinator_set_member *members[],
size_t count);
/**
@ -377,7 +380,7 @@ typedef bool (*bt_csis_client_ordered_access_t)(const struct bt_csis_client_set_
* in the unlocked state, then @p cb will be called with the same members as
* provided by @p members, but where the members are ordered by rank
* (if present). Once this procedure is finished or an error occurs,
* @ref bt_csis_client_cb.ordered_access will be called.
* @ref bt_csip_set_coordinator_cb.ordered_access will be called.
*
* This procedure only works if all the members have the lock characterstic,
* and all either has rank = 0 or unique ranks.
@ -393,10 +396,11 @@ typedef bool (*bt_csis_client_ordered_access_t)(const struct bt_csis_client_set_
* be part of multiple sets.
* @param cb The callback function to be called for each member.
*/
int bt_csis_client_ordered_access(const struct bt_csis_client_set_member *members[],
int bt_csip_set_coordinator_ordered_access(
const struct bt_csip_set_coordinator_set_member *members[],
uint8_t count,
const struct bt_csis_client_set_info *set_info,
bt_csis_client_ordered_access_t cb);
const struct bt_csip_set_coordinator_set_info *set_info,
bt_csip_set_coordinator_ordered_access_t cb);
/**
* @brief Lock an array of set members
@ -412,9 +416,9 @@ int bt_csis_client_ordered_access(const struct bt_csis_client_set_member *member
*
* @return Return 0 on success, or an errno value on error.
*/
int bt_csis_client_lock(const struct bt_csis_client_set_member **members,
int bt_csip_set_coordinator_lock(const struct bt_csip_set_coordinator_set_member **members,
uint8_t count,
const struct bt_csis_client_set_info *set_info);
const struct bt_csip_set_coordinator_set_info *set_info);
/**
* @brief Release an array of set members
@ -428,9 +432,9 @@ int bt_csis_client_lock(const struct bt_csis_client_set_member **members,
*
* @return Return 0 on success, or an errno value on error.
*/
int bt_csis_client_release(const struct bt_csis_client_set_member **members,
int bt_csip_set_coordinator_release(const struct bt_csip_set_coordinator_set_member **members,
uint8_t count,
const struct bt_csis_client_set_info *set_info);
const struct bt_csip_set_coordinator_set_info *set_info);
#ifdef __cplusplus
@ -441,4 +445,4 @@ int bt_csis_client_release(const struct bt_csis_client_set_member **members,
* @}
*/
#endif /* ZEPHYR_SUBSYS_BLUETOOTH_AUDIO_CSIS_H_ */
#endif /* ZEPHYR_SUBSYS_BLUETOOTH_AUDIO_CSIP_H_ */

View file

@ -14,7 +14,7 @@ menu "Hearing Aid"
config HAP_HA_SET_RANK
int "Device rank in set"
depends on BT_CSIS
depends on BT_CSIP
range 1 2
help
Rank of this device in set.

View file

@ -1,3 +1,3 @@
CONFIG_BT_CSIS=y
CONFIG_BT_CSIP=y
CONFIG_BT_HAS_HEARING_AID_BINAURAL=y
CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER=y

View file

@ -10,50 +10,50 @@
#include <zephyr/sys/printk.h>
#include <zephyr/bluetooth/audio/cap.h>
#include <zephyr/bluetooth/audio/csis.h>
#include <zephyr/bluetooth/audio/csip.h>
#define CSIS_SIRK_DEBUG { 0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, \
#define CSIP_SIRK_DEBUG { 0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce, \
0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45 }
static struct bt_csis *csis;
static struct bt_csip *csip;
static void csis_lock_changed_cb(struct bt_conn *conn, struct bt_csis *csis, bool locked)
static void csip_lock_changed_cb(struct bt_conn *conn, struct bt_csip *csip, bool locked)
{
printk("Client %p %s the lock\n", conn, locked ? "locked" : "released");
}
static uint8_t sirk_read_req_cb(struct bt_conn *conn, struct bt_csis *csis)
static uint8_t sirk_read_req_cb(struct bt_conn *conn, struct bt_csip *csip)
{
return BT_CSIS_READ_SIRK_REQ_RSP_ACCEPT;
return BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT;
}
static struct bt_csis_cb csis_cb = {
.lock_changed = csis_lock_changed_cb,
static struct bt_csip_cb csip_cb = {
.lock_changed = csip_lock_changed_cb,
.sirk_read_req = sirk_read_req_cb,
};
int csip_set_member_init(void)
{
struct bt_csis_register_param param = {
struct bt_csip_register_param param = {
.set_size = 2,
.rank = CONFIG_HAP_HA_SET_RANK,
.lockable = false,
.set_sirk = CSIS_SIRK_DEBUG,
.cb = &csis_cb,
.set_sirk = CSIP_SIRK_DEBUG,
.cb = &csip_cb,
};
return bt_cap_acceptor_register(&param, &csis);
return bt_cap_acceptor_register(&param, &csip);
}
int csip_generate_rsi(uint8_t *rsi)
{
int err;
if (csis == NULL) {
if (csip == NULL) {
return -ENODEV;
}
err = bt_csis_generate_rsi(csis, rsi);
err = bt_csip_generate_rsi(csip, rsi);
if (err) {
printk("Failed to generate RSI (err %d)\n", err);
return err;

View file

@ -23,8 +23,6 @@ int csip_set_member_init(void);
/**
* @brief Generate the Resolvable Set Identifier (RSI) value.
*
* This will generate RSI for given @p csis instance.
*
* @param rsi Pointer to place the 6-octet newly generated RSI data.
*
* @return 0 if on success, errno on error.

View file

@ -12,7 +12,7 @@
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/pacs.h>
#include <zephyr/bluetooth/audio/csis.h>
#include <zephyr/bluetooth/audio/csip.h>
#include <zephyr/bluetooth/services/ias.h>
#include "hap_ha.h"
@ -38,15 +38,15 @@ static uint8_t unicast_server_addata[] = {
0x00, /* Metadata length */
};
static uint8_t csis_rsi_addata[BT_CSIS_RSI_SIZE];
static uint8_t csis_rsi_addata[BT_CSIP_RSI_SIZE];
/* TODO: Expand with BAP data */
static const struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
BT_DATA_BYTES(BT_DATA_UUID16_ALL, BT_UUID_16_ENCODE(BT_UUID_ASCS_VAL)),
#if defined(CONFIG_BT_CSIS)
#if defined(CONFIG_BT_CSIP)
BT_DATA(BT_DATA_CSIS_RSI, csis_rsi_addata, ARRAY_SIZE(csis_rsi_addata)),
#endif /* CONFIG_BT_CSIS */
#endif /* CONFIG_BT_CSIP */
BT_DATA(BT_DATA_SVC_DATA16, unicast_server_addata, ARRAY_SIZE(unicast_server_addata)),
};
@ -63,7 +63,7 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
.disconnected = disconnected,
};
#if defined(CONFIG_BT_PRIVACY) && defined(CONFIG_BT_CSIS)
#if defined(CONFIG_BT_PRIVACY) && defined(CONFIG_BT_CSIP)
static bool adv_rpa_expired_cb(struct bt_le_ext_adv *adv)
{
char rsi_str[13];
@ -89,12 +89,12 @@ static bool adv_rpa_expired_cb(struct bt_le_ext_adv *adv)
return true;
}
#endif /* CONFIG_BT_PRIVACY && CONFIG_BT_CSIS */
#endif /* CONFIG_BT_PRIVACY && CONFIG_BT_CSIP */
static const struct bt_le_ext_adv_cb adv_cb = {
#if defined(CONFIG_BT_PRIVACY) && defined(CONFIG_BT_CSIS)
#if defined(CONFIG_BT_PRIVACY) && defined(CONFIG_BT_CSIP)
.rpa_expired = adv_rpa_expired_cb,
#endif /* CONFIG_BT_PRIVACY && CONFIG_BT_CSIS */
#endif /* CONFIG_BT_PRIVACY && CONFIG_BT_CSIP */
};
static void adv_work_handler(struct k_work *work)

View file

@ -30,10 +30,10 @@ zephyr_library_sources_ifdef(CONFIG_BT_CCID ccid.c)
zephyr_library_link_libraries(subsys__bluetooth)
zephyr_library_sources_ifdef(CONFIG_BT_CSIS csis.c)
zephyr_library_sources_ifdef(CONFIG_BT_CSIS_CLIENT csis_client.c)
if (CONFIG_BT_CSIS OR CONFIG_BT_CSIS_CLIENT)
zephyr_library_sources(csis_crypto.c)
zephyr_library_sources_ifdef(CONFIG_BT_CSIP csip.c)
zephyr_library_sources_ifdef(CONFIG_BT_CSIP_SET_COORDINATOR csip_set_coordinator.c)
if (CONFIG_BT_CSIP OR CONFIG_BT_CSIP_SET_COORDINATOR)
zephyr_library_sources(csip_crypto.c)
endif()
zephyr_library_sources_ifdef(CONFIG_BT_TBS tbs.c)

View file

@ -30,7 +30,7 @@ rsource "Kconfig.vocs"
rsource "Kconfig.aics"
rsource "Kconfig.vcs"
rsource "Kconfig.micp"
rsource "Kconfig.csis"
rsource "Kconfig.csip"
rsource "Kconfig.tbs"
rsource "Kconfig.mcs"
rsource "Kconfig.bass"

View file

@ -19,12 +19,12 @@ config BT_CAP_ACCEPTOR
config BT_CAP_ACCEPTOR_SET_MEMBER
bool "Common Audio Profile Acceptor Role Set Member support"
depends on BT_CAP_ACCEPTOR
depends on BT_CSIS
depends on BT_CSIP
help
Enabling this will allow a CAP acceptor to be a set member.
Enabling this will require a manual register of the CAS service.
Enabling will take one of the allocated CSIS instances
(BT_CSIS_MAX_INSTANCE_COUNT).
(BT_CSIP_MAX_INSTANCE_COUNT).
config BT_DEBUG_CAP_ACCEPTOR
bool "Common Audio Profile debug"
@ -35,7 +35,7 @@ config BT_DEBUG_CAP_ACCEPTOR
config BT_CAP_INITIATOR
bool "Common Audio Profile Initiator Role Support [EXPERIMENTAL]"
depends on (BT_AUDIO_UNICAST_CLIENT && BT_CSIS_CLIENT) || BT_AUDIO_BROADCAST_SOURCE
depends on (BT_AUDIO_UNICAST_CLIENT && BT_CSIP_SET_COORDINATOR) || BT_AUDIO_BROADCAST_SOURCE
select EXPERIMENTAL
help
Enabling this will enable the CAP Initiator role.

View file

@ -8,7 +8,7 @@
#################### Coordinated Set Identification Service ####################
config BT_CSIS
config BT_CSIP
bool "Coordinated Set Identification Service Support [EXPERIMENTAL]"
imply BT_EXT_ADV if BT_PRIVACY
select EXPERIMENTAL
@ -16,9 +16,9 @@ config BT_CSIS
This option enables support for Coordinated Set Identification
Service.
if BT_CSIS
if BT_CSIP
config BT_CSIS_TEST_SAMPLE_DATA
config BT_CSIP_TEST_SAMPLE_DATA
bool "Coordinated Set Identification Service Test Sample Data"
help
Enable the use of the sample data defined by the CSIS spec SIRK.
@ -28,13 +28,13 @@ config BT_CSIS_TEST_SAMPLE_DATA
(if encrypted) using public sample data.
Should not be used for production builds.
config BT_CSIS_ENC_SIRK_SUPPORT
config BT_CSIP_ENC_SIRK_SUPPORT
bool "Support for encrypted SIRK"
default y
help
Enables support encrypting the SIRK.
config BT_CSIS_MAX_INSTANCE_COUNT
config BT_CSIP_MAX_INSTANCE_COUNT
int "Coordinated Set Identification Service max instance count"
default 1
range 1 255
@ -48,28 +48,28 @@ config BT_CSIS_MAX_INSTANCE_COUNT
############### DEBUG ###############
config BT_DEBUG_CSIS
config BT_DEBUG_CSIP
bool "Coordinated Set Identification Service debug"
help
Use this option to enable Coordinated Set Identification Service debug
logs for the Bluetooth Audio functionality.
endif # BT_CSIS
endif # BT_CSIP
#################### Coordinated Set Identification Client ####################
config BT_CSIS_CLIENT
bool "Coordinated Set Identification Profile Support [EXPERIMENTAL]"
config BT_CSIP_SET_COORDINATOR
bool "Coordinated Set Identification Profile Set Coordinator Support [EXPERIMENTAL]"
select BT_GATT_CLIENT
select BT_GATT_AUTO_DISCOVER_CCC
select EXPERIMENTAL
help
This option enables support for Coordinated Set Identification
Profile.
Profile Set Coordinator.
if BT_CSIS_CLIENT
if BT_CSIP_SET_COORDINATOR
config BT_CSIS_CLIENT_TEST_SAMPLE_DATA
config BT_CSIP_SET_COORDINATOR_TEST_SAMPLE_DATA
bool "Coordinated Set Identification Service Test Sample Data"
help
Enable the use of the sample data defined by the CSIS spec.
@ -80,7 +80,7 @@ config BT_CSIS_CLIENT_TEST_SAMPLE_DATA
with set members that are not using the sample data.
Should not be used for production builds.
config BT_CSIS_CLIENT_MAX_CSIS_INSTANCES
config BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES
int "Coordinated Set Identification Service Count"
default 1
range 1 3
@ -88,7 +88,7 @@ config BT_CSIS_CLIENT_MAX_CSIS_INSTANCES
Sets the number of service instances, which corresponds to the number
of different sets the peer device may be in.
config BT_CSIS_CLIENT_ENC_SIRK_SUPPORT
config BT_CSIP_SET_COORDINATOR_ENC_SIRK_SUPPORT
bool "Support for encrypted SIRK"
default y
help
@ -96,17 +96,17 @@ config BT_CSIS_CLIENT_ENC_SIRK_SUPPORT
############### DEBUG ###############
config BT_DEBUG_CSIS_CLIENT
config BT_DEBUG_CSIP_SET_COORDINATOR
bool "Coordinated Set Identification Profile debug"
help
Use this option to enable Coordinated Set Identification Profile debug
logs for the Bluetooth Audio functionality.
endif # BT_CSIS_CLIENT
endif # BT_CSIP_SET_COORDINATOR
config BT_DEBUG_CSIS_CRYPTO
bool "Coordinated Set Identification Service crypto functions debug"
depends on BT_CSIS_CLIENT || BT_CSIS
config BT_DEBUG_CSIP_CRYPTO
bool "Coordinated Set Identification Profile crypto functions debug"
depends on BT_CSIP_SET_COORDINATOR || BT_CSIP
help
Use this option to enable Coordinated Set Identification Service
Use this option to enable Coordinated Set Identification Profile
crypto functions debug logs for the Bluetooth Audio functionality.

View file

@ -23,7 +23,7 @@ config BT_HAS_HEARING_AID_MONAURAL
bool "Monaural Hearing Aid"
config BT_HAS_HEARING_AID_BINAURAL
depends on BT_CSIS
depends on BT_CSIP
bool "Binaural Hearing Aid"
config BT_HAS_HEARING_AID_BANDED

View file

@ -7,7 +7,7 @@
#include <zephyr/sys/check.h>
#include <zephyr/bluetooth/gatt.h>
#include <zephyr/bluetooth/audio/tbs.h>
#include <zephyr/bluetooth/audio/csis.h>
#include <zephyr/bluetooth/audio/csip.h>
#include "cap_internal.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_CAP_ACCEPTOR)
@ -21,22 +21,22 @@ static struct bt_gatt_attr svc_attrs[] = {
BT_GATT_INCLUDE_SERVICE(NULL) /* To be overwritten */
};
int bt_cap_acceptor_register(const struct bt_csis_register_param *param,
struct bt_csis **csis)
int bt_cap_acceptor_register(const struct bt_csip_register_param *param,
struct bt_csip **csip)
{
static struct bt_gatt_service cas;
int err;
err = bt_csis_register(param, csis);
err = bt_csip_register(param, csip);
if (err != 0) {
BT_DBG("Failed to register CSIS");
BT_DBG("Failed to register CSIP");
return err;
}
cas = (struct bt_gatt_service)BT_GATT_SERVICE(svc_attrs);
/* Overwrite the include definition with the CSIS */
cas.attrs[1].user_data = bt_csis_svc_decl_get(*csis);
/* Overwrite the include definition with the CSIP */
cas.attrs[1].user_data = bt_csip_svc_decl_get(*csip);
err = bt_gatt_service_register(&cas);
if (err) {
@ -51,7 +51,7 @@ int bt_cap_acceptor_register(const struct bt_csis_register_param *param,
BT_GATT_SERVICE_DEFINE(cas_svc,
BT_GATT_PRIMARY_SERVICE(BT_UUID_CAS)
/* TODO: Add support for included CSIS */
/* TODO: Add support for included CSIP */
);
#endif /* CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER */

View file

@ -9,7 +9,7 @@
#include <zephyr/bluetooth/audio/tbs.h>
#include <zephyr/bluetooth/audio/cap.h>
#include "cap_internal.h"
#include "csis_internal.h"
#include "csip_internal.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_CAP_INITIATOR)
#define LOG_MODULE_NAME bt_cap_initiator
@ -62,13 +62,13 @@ static const struct bt_uuid *cas_uuid = BT_UUID_CAS;
struct cap_unicast_client {
struct bt_gatt_discover_params param;
uint16_t csis_start_handle;
const struct bt_csis_client_csis_inst *csis_inst;
const struct bt_csip_set_coordinator_csis_inst *csis_inst;
};
static struct cap_unicast_client bt_cap_unicast_clients[CONFIG_BT_MAX_CONN];
static void csis_client_discover_cb(struct bt_conn *conn,
const struct bt_csis_client_set_member *member,
const struct bt_csip_set_coordinator_set_member *member,
int err, size_t set_count)
{
struct cap_unicast_client *client;
@ -84,7 +84,7 @@ static void csis_client_discover_cb(struct bt_conn *conn,
}
client = &bt_cap_unicast_clients[bt_conn_index(conn)];
client->csis_inst = bt_csis_client_csis_inst_by_handle(
client->csis_inst = bt_csip_set_coordinator_csis_inst_by_handle(
conn, client->csis_start_handle);
if (member == NULL || set_count == 0 || client->csis_inst == NULL) {
@ -127,11 +127,11 @@ static uint8_t cap_unicast_discover_included_cb(struct bt_conn *conn,
* CSIS discovery
*/
client->csis_start_handle = included_service->start_handle;
client->csis_inst = bt_csis_client_csis_inst_by_handle(
client->csis_inst = bt_csip_set_coordinator_csis_inst_by_handle(
conn, client->csis_start_handle);
if (client->csis_inst == NULL) {
static struct bt_csis_client_cb csis_client_cb = {
static struct bt_csip_set_coordinator_cb csis_client_cb = {
.discover = csis_client_discover_cb
};
static bool csis_cbs_registered;
@ -140,11 +140,11 @@ static uint8_t cap_unicast_discover_included_cb(struct bt_conn *conn,
BT_DBG("CAS CSIS not known, discovering");
if (!csis_cbs_registered) {
bt_csis_client_register_cb(&csis_client_cb);
bt_csip_set_coordinator_register_cb(&csis_client_cb);
csis_cbs_registered = true;
}
err = bt_csis_client_discover(conn);
err = bt_csip_set_coordinator_discover(conn);
if (err != 0) {
BT_DBG("Discover failed (err %d)", err);
if (cap_cb && cap_cb->unicast_discovery_complete) {

View file

@ -1,8 +1,8 @@
/* Bluetooth CSIS - Coordinated Set Identification Service */
/* Bluetooth CSIP - Coordinated Set Identification Profile */
/*
* Copyright (c) 2019 Bose Corporation
* Copyright (c) 2020-2021 Nordic Semiconductor ASA
* Copyright (c) 2020-2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -22,65 +22,65 @@
#include <zephyr/sys/check.h>
#include "audio_internal.h"
#include "csis_internal.h"
#include "csis_crypto.h"
#include "csip_internal.h"
#include "csip_crypto.h"
#include "../host/conn_internal.h"
#include "../host/hci_core.h"
#include "../host/keys.h"
#define BT_CSIS_SIH_PRAND_SIZE 3
#define BT_CSIS_SIH_HASH_SIZE 3
#define CSIS_SET_LOCK_TIMER_VALUE K_SECONDS(60)
#define BT_CSIP_SIH_PRAND_SIZE 3
#define BT_CSIP_SIH_HASH_SIZE 3
#define CSIP_SET_LOCK_TIMER_VALUE K_SECONDS(60)
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_CSIS)
#define LOG_MODULE_NAME bt_csis
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_CSIP)
#define LOG_MODULE_NAME bt_csip
#include "common/log.h"
#include "common/bt_str.h"
static struct bt_csis csis_insts[CONFIG_BT_CSIS_MAX_INSTANCE_COUNT];
static struct bt_csip csip_insts[CONFIG_BT_CSIP_MAX_INSTANCE_COUNT];
static bt_addr_le_t server_dummy_addr; /* 0'ed address */
struct csis_notify_foreach {
struct csip_notify_foreach {
struct bt_conn *excluded_client;
struct bt_csis *csis;
struct bt_csip *csip;
};
static bool is_last_client_to_write(const struct bt_csis *csis,
static bool is_last_client_to_write(const struct bt_csip *csip,
const struct bt_conn *conn)
{
if (conn != NULL) {
return bt_addr_le_eq(bt_conn_get_dst(conn),
&csis->srv.lock_client_addr);
&csip->srv.lock_client_addr);
} else {
return bt_addr_le_eq(&server_dummy_addr,
&csis->srv.lock_client_addr);
&csip->srv.lock_client_addr);
}
}
static void notify_lock_value(const struct bt_csis *csis, struct bt_conn *conn)
static void notify_lock_value(const struct bt_csip *csip, struct bt_conn *conn)
{
bt_gatt_notify_uuid(conn, BT_UUID_CSIS_SET_LOCK,
csis->srv.service_p->attrs,
&csis->srv.set_lock,
sizeof(csis->srv.set_lock));
csip->srv.service_p->attrs,
&csip->srv.set_lock,
sizeof(csip->srv.set_lock));
}
static void notify_client(struct bt_conn *conn, void *data)
{
struct csis_notify_foreach *csis_data = (struct csis_notify_foreach *)data;
struct bt_csis *csis = csis_data->csis;
struct bt_conn *excluded_conn = csis_data->excluded_client;
struct csip_notify_foreach *csip_data = (struct csip_notify_foreach *)data;
struct bt_csip *csip = csip_data->csip;
struct bt_conn *excluded_conn = csip_data->excluded_client;
if (excluded_conn != NULL && conn == excluded_conn) {
return;
}
notify_lock_value(csis, conn);
notify_lock_value(csip, conn);
for (int i = 0; i < ARRAY_SIZE(csis->srv.pend_notify); i++) {
struct csis_pending_notifications *pend_notify;
for (int i = 0; i < ARRAY_SIZE(csip->srv.pend_notify); i++) {
struct csip_pending_notifications *pend_notify;
pend_notify = &csis->srv.pend_notify[i];
pend_notify = &csip->srv.pend_notify[i];
if (pend_notify->pending &&
bt_addr_le_eq(bt_conn_get_dst(conn), &pend_notify->addr)) {
@ -90,21 +90,21 @@ static void notify_client(struct bt_conn *conn, void *data)
}
}
static void notify_clients(struct bt_csis *csis,
static void notify_clients(struct bt_csip *csip,
struct bt_conn *excluded_client)
{
struct csis_notify_foreach data = {
struct csip_notify_foreach data = {
.excluded_client = excluded_client,
.csis = csis,
.csip = csip,
};
/* Mark all bonded devices as pending notifications, and clear those
* that are notified in `notify_client`
*/
for (int i = 0; i < ARRAY_SIZE(csis->srv.pend_notify); i++) {
struct csis_pending_notifications *pend_notify;
for (int i = 0; i < ARRAY_SIZE(csip->srv.pend_notify); i++) {
struct csip_pending_notifications *pend_notify;
pend_notify = &csis->srv.pend_notify[i];
pend_notify = &csip->srv.pend_notify[i];
if (pend_notify->active) {
if (excluded_client != NULL &&
@ -120,13 +120,13 @@ static void notify_clients(struct bt_csis *csis,
}
static int sirk_encrypt(struct bt_conn *conn,
const struct bt_csis_set_sirk *sirk,
struct bt_csis_set_sirk *enc_sirk)
const struct bt_csip_set_sirk *sirk,
struct bt_csip_set_sirk *enc_sirk)
{
int err;
uint8_t *k;
if (IS_ENABLED(CONFIG_BT_CSIS_TEST_SAMPLE_DATA)) {
if (IS_ENABLED(CONFIG_BT_CSIP_TEST_SAMPLE_DATA)) {
/* test_k is from the sample data from A.2 in the CSIS spec */
static uint8_t test_k[] = {0x67, 0x6e, 0x1b, 0x9b,
0xd4, 0x48, 0x69, 0x6f,
@ -145,13 +145,13 @@ static int sirk_encrypt(struct bt_conn *conn,
k = conn->le.keys->ltk.val;
}
err = bt_csis_sef(k, sirk->value, enc_sirk->value);
err = bt_csip_sef(k, sirk->value, enc_sirk->value);
if (err != 0) {
return err;
}
enc_sirk->type = BT_CSIS_SIRK_TYPE_ENCRYPTED;
enc_sirk->type = BT_CSIP_SIRK_TYPE_ENCRYPTED;
return 0;
}
@ -164,7 +164,7 @@ static int generate_prand(uint32_t *dest)
int res;
*dest = 0;
res = bt_rand(dest, BT_CSIS_SIH_PRAND_SIZE);
res = bt_rand(dest, BT_CSIP_SIH_PRAND_SIZE);
if (res != 0) {
return res;
}
@ -181,13 +181,13 @@ static int generate_prand(uint32_t *dest)
return 0;
}
int bt_csis_generate_rsi(const struct bt_csis *csis, uint8_t rsi[BT_CSIS_RSI_SIZE])
int bt_csip_generate_rsi(const struct bt_csip *csip, uint8_t rsi[BT_CSIP_RSI_SIZE])
{
int res = 0;
uint32_t prand;
uint32_t hash;
if (IS_ENABLED(CONFIG_BT_CSIS_TEST_SAMPLE_DATA)) {
if (IS_ENABLED(CONFIG_BT_CSIP_TEST_SAMPLE_DATA)) {
/* prand is from the sample data from A.2 in the CSIS spec */
prand = 0x69f563;
} else {
@ -199,14 +199,14 @@ int bt_csis_generate_rsi(const struct bt_csis *csis, uint8_t rsi[BT_CSIS_RSI_SIZ
}
}
res = bt_csis_sih(csis->srv.set_sirk.value, prand, &hash);
res = bt_csip_sih(csip->srv.set_sirk.value, prand, &hash);
if (res != 0) {
BT_WARN("Could not generate new RSI");
return res;
}
(void)memcpy(rsi, &hash, BT_CSIS_SIH_HASH_SIZE);
(void)memcpy(rsi + BT_CSIS_SIH_HASH_SIZE, &prand, BT_CSIS_SIH_PRAND_SIZE);
(void)memcpy(rsi, &hash, BT_CSIP_SIH_HASH_SIZE);
(void)memcpy(rsi + BT_CSIP_SIH_HASH_SIZE, &prand, BT_CSIP_SIH_PRAND_SIZE);
return res;
}
@ -215,23 +215,23 @@ static ssize_t read_set_sirk(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset)
{
struct bt_csis_set_sirk enc_sirk;
struct bt_csis_set_sirk *sirk;
struct bt_csis *csis = BT_AUDIO_CHRC_USER_DATA(attr);
struct bt_csip_set_sirk enc_sirk;
struct bt_csip_set_sirk *sirk;
struct bt_csip *csip = BT_AUDIO_CHRC_USER_DATA(attr);
if (csis->srv.cb != NULL && csis->srv.cb->sirk_read_req != NULL) {
if (csip->srv.cb != NULL && csip->srv.cb->sirk_read_req != NULL) {
uint8_t cb_rsp;
/* Ask higher layer for what SIRK to return, if any */
cb_rsp = csis->srv.cb->sirk_read_req(conn, &csis_insts[0]);
cb_rsp = csip->srv.cb->sirk_read_req(conn, &csip_insts[0]);
if (cb_rsp == BT_CSIS_READ_SIRK_REQ_RSP_ACCEPT) {
sirk = &csis->srv.set_sirk;
} else if (IS_ENABLED(CONFIG_BT_CSIS_ENC_SIRK_SUPPORT) &&
cb_rsp == BT_CSIS_READ_SIRK_REQ_RSP_ACCEPT_ENC) {
if (cb_rsp == BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT) {
sirk = &csip->srv.set_sirk;
} else if (IS_ENABLED(CONFIG_BT_CSIP_ENC_SIRK_SUPPORT) &&
cb_rsp == BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT_ENC) {
int err;
err = sirk_encrypt(conn, &csis->srv.set_sirk,
err = sirk_encrypt(conn, &csip->srv.set_sirk,
&enc_sirk);
if (err != 0) {
BT_ERR("Could not encrypt SIRK: %d",
@ -242,22 +242,23 @@ static ssize_t read_set_sirk(struct bt_conn *conn,
sirk = &enc_sirk;
LOG_HEXDUMP_DBG(enc_sirk.value, sizeof(enc_sirk.value),
"Encrypted Set SIRK");
} else if (cb_rsp == BT_CSIS_READ_SIRK_REQ_RSP_REJECT) {
} else if (cb_rsp == BT_CSIP_READ_SIRK_REQ_RSP_REJECT) {
return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION);
} else if (cb_rsp == BT_CSIS_READ_SIRK_REQ_RSP_OOB_ONLY) {
return BT_GATT_ERR(BT_CSIS_ERROR_SIRK_OOB_ONLY);
} else if (cb_rsp == BT_CSIP_READ_SIRK_REQ_RSP_OOB_ONLY) {
return BT_GATT_ERR(BT_CSIP_ERROR_SIRK_OOB_ONLY);
} else {
BT_ERR("Invalid callback response: %u", cb_rsp);
return BT_GATT_ERR(BT_ATT_ERR_UNLIKELY);
}
} else {
sirk = &csis->srv.set_sirk;
sirk = &csip->srv.set_sirk;
}
BT_DBG("Set sirk %sencrypted",
sirk->type == BT_CSIS_SIRK_TYPE_PLAIN ? "not " : "");
LOG_HEXDUMP_DBG(csis->srv.set_sirk.value, sizeof(csis->srv.set_sirk.value), "Set SIRK");
sirk->type == BT_CSIP_SIRK_TYPE_PLAIN ? "not " : "");
LOG_HEXDUMP_DBG(csip->srv.set_sirk.value,
sizeof(csip->srv.set_sirk.value), "Set SIRK");
return bt_gatt_attr_read(conn, attr, buf, len, offset,
sirk, sizeof(*sirk));
}
@ -272,13 +273,13 @@ static ssize_t read_set_size(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset)
{
struct bt_csis *csis = BT_AUDIO_CHRC_USER_DATA(attr);
struct bt_csip *csip = BT_AUDIO_CHRC_USER_DATA(attr);
BT_DBG("%u", csis->srv.set_size);
BT_DBG("%u", csip->srv.set_size);
return bt_gatt_attr_read(conn, attr, buf, len, offset,
&csis->srv.set_size,
sizeof(csis->srv.set_size));
&csip->srv.set_size,
sizeof(csip->srv.set_size));
}
static void set_size_cfg_changed(const struct bt_gatt_attr *attr,
@ -291,62 +292,62 @@ static ssize_t read_set_lock(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset)
{
struct bt_csis *csis = BT_AUDIO_CHRC_USER_DATA(attr);
struct bt_csip *csip = BT_AUDIO_CHRC_USER_DATA(attr);
BT_DBG("%u", csis->srv.set_lock);
BT_DBG("%u", csip->srv.set_lock);
return bt_gatt_attr_read(conn, attr, buf, len, offset,
&csis->srv.set_lock,
sizeof(csis->srv.set_lock));
&csip->srv.set_lock,
sizeof(csip->srv.set_lock));
}
/**
* @brief Set the lock value of a CSIS instance.
* @brief Set the lock value of a CSIP instance.
*
* @param conn The connection locking the instance.
* Will be NULL if the server locally sets the lock.
* @param csis The CSIS instance to change the lock value of
* @param val The lock value (BT_CSIS_LOCK_VALUE or BT_CSIS_RELEASE_VALUE)
* @param csip The CSIP instance to change the lock value of
* @param val The lock value (BT_CSIP_LOCK_VALUE or BT_CSIP_RELEASE_VALUE)
*
* @return BT_CSIS_ERROR_* on failure or 0 if success
* @return BT_CSIP_ERROR_* on failure or 0 if success
*/
static uint8_t set_lock(struct bt_conn *conn, struct bt_csis *csis, uint8_t val)
static uint8_t set_lock(struct bt_conn *conn, struct bt_csip *csip, uint8_t val)
{
bool notify;
if (val != BT_CSIS_RELEASE_VALUE && val != BT_CSIS_LOCK_VALUE) {
return BT_CSIS_ERROR_LOCK_INVAL_VALUE;
if (val != BT_CSIP_RELEASE_VALUE && val != BT_CSIP_LOCK_VALUE) {
return BT_CSIP_ERROR_LOCK_INVAL_VALUE;
}
if (csis->srv.set_lock == BT_CSIS_LOCK_VALUE) {
if (val == BT_CSIS_LOCK_VALUE) {
if (is_last_client_to_write(csis, conn)) {
return BT_CSIS_ERROR_LOCK_ALREADY_GRANTED;
if (csip->srv.set_lock == BT_CSIP_LOCK_VALUE) {
if (val == BT_CSIP_LOCK_VALUE) {
if (is_last_client_to_write(csip, conn)) {
return BT_CSIP_ERROR_LOCK_ALREADY_GRANTED;
} else {
return BT_CSIS_ERROR_LOCK_DENIED;
return BT_CSIP_ERROR_LOCK_DENIED;
}
} else if (!is_last_client_to_write(csis, conn)) {
return BT_CSIS_ERROR_LOCK_RELEASE_DENIED;
} else if (!is_last_client_to_write(csip, conn)) {
return BT_CSIP_ERROR_LOCK_RELEASE_DENIED;
}
}
notify = csis->srv.set_lock != val;
notify = csip->srv.set_lock != val;
csis->srv.set_lock = val;
if (csis->srv.set_lock == BT_CSIS_LOCK_VALUE) {
csip->srv.set_lock = val;
if (csip->srv.set_lock == BT_CSIP_LOCK_VALUE) {
if (conn != NULL) {
bt_addr_le_copy(&csis->srv.lock_client_addr,
bt_addr_le_copy(&csip->srv.lock_client_addr,
bt_conn_get_dst(conn));
}
(void)k_work_reschedule(&csis->srv.set_lock_timer,
CSIS_SET_LOCK_TIMER_VALUE);
(void)k_work_reschedule(&csip->srv.set_lock_timer,
CSIP_SET_LOCK_TIMER_VALUE);
} else {
(void)memset(&csis->srv.lock_client_addr, 0,
sizeof(csis->srv.lock_client_addr));
(void)k_work_cancel_delayable(&csis->srv.set_lock_timer);
(void)memset(&csip->srv.lock_client_addr, 0,
sizeof(csip->srv.lock_client_addr));
(void)k_work_cancel_delayable(&csip->srv.set_lock_timer);
}
BT_DBG("%u", csis->srv.set_lock);
BT_DBG("%u", csip->srv.set_lock);
if (notify) {
/*
@ -354,12 +355,12 @@ static uint8_t set_lock(struct bt_conn *conn, struct bt_csis *csis, uint8_t val)
* client writing the value, shall be notified
* (if subscribed)
*/
notify_clients(csis, conn);
notify_clients(csip, conn);
if (csis->srv.cb != NULL && csis->srv.cb->lock_changed != NULL) {
bool locked = csis->srv.set_lock == BT_CSIS_LOCK_VALUE;
if (csip->srv.cb != NULL && csip->srv.cb->lock_changed != NULL) {
bool locked = csip->srv.set_lock == BT_CSIP_LOCK_VALUE;
csis->srv.cb->lock_changed(conn, csis, locked);
csip->srv.cb->lock_changed(conn, csip, locked);
}
}
@ -373,7 +374,7 @@ static ssize_t write_set_lock(struct bt_conn *conn,
{
ssize_t res;
uint8_t val;
struct bt_csis *csis = BT_AUDIO_CHRC_USER_DATA(attr);
struct bt_csip *csip = BT_AUDIO_CHRC_USER_DATA(attr);
if (offset != 0) {
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
@ -383,7 +384,7 @@ static ssize_t write_set_lock(struct bt_conn *conn,
(void)memcpy(&val, buf, len);
res = set_lock(conn, csis, val);
res = set_lock(conn, csip, val);
if (res != BT_ATT_ERR_SUCCESS) {
return BT_GATT_ERR(res);
}
@ -400,38 +401,38 @@ static void set_lock_cfg_changed(const struct bt_gatt_attr *attr,
static ssize_t read_rank(struct bt_conn *conn, const struct bt_gatt_attr *attr,
void *buf, uint16_t len, uint16_t offset)
{
struct bt_csis *csis = BT_AUDIO_CHRC_USER_DATA(attr);
struct bt_csip *csip = BT_AUDIO_CHRC_USER_DATA(attr);
BT_DBG("%u", csis->srv.rank);
BT_DBG("%u", csip->srv.rank);
return bt_gatt_attr_read(conn, attr, buf, len, offset,
&csis->srv.rank,
sizeof(csis->srv.rank));
&csip->srv.rank,
sizeof(csip->srv.rank));
}
static void set_lock_timer_handler(struct k_work *work)
{
struct k_work_delayable *delayable;
struct bt_csis_server *server;
struct bt_csis *csis;
struct bt_csip_server *server;
struct bt_csip *csip;
delayable = CONTAINER_OF(work, struct k_work_delayable, work);
server = CONTAINER_OF(delayable, struct bt_csis_server, set_lock_timer);
csis = CONTAINER_OF(server, struct bt_csis, srv);
server = CONTAINER_OF(delayable, struct bt_csip_server, set_lock_timer);
csip = CONTAINER_OF(server, struct bt_csip, srv);
BT_DBG("Lock timeout, releasing");
csis->srv.set_lock = BT_CSIS_RELEASE_VALUE;
notify_clients(csis, NULL);
csip->srv.set_lock = BT_CSIP_RELEASE_VALUE;
notify_clients(csip, NULL);
if (csis->srv.cb != NULL && csis->srv.cb->lock_changed != NULL) {
bool locked = csis->srv.set_lock == BT_CSIS_LOCK_VALUE;
if (csip->srv.cb != NULL && csip->srv.cb->lock_changed != NULL) {
bool locked = csip->srv.set_lock == BT_CSIP_LOCK_VALUE;
csis->srv.cb->lock_changed(NULL, csis, locked);
csip->srv.cb->lock_changed(NULL, csip, locked);
}
}
static void csis_security_changed(struct bt_conn *conn, bt_security_t level,
static void csip_security_changed(struct bt_conn *conn, bt_security_t level,
enum bt_security_err err)
{
if (err != 0 || conn->encrypt == 0) {
@ -442,17 +443,17 @@ static void csis_security_changed(struct bt_conn *conn, bt_security_t level,
return;
}
for (int i = 0; i < ARRAY_SIZE(csis_insts); i++) {
struct bt_csis *csis = &csis_insts[i];
for (int i = 0; i < ARRAY_SIZE(csip_insts); i++) {
struct bt_csip *csip = &csip_insts[i];
for (int j = 0; j < ARRAY_SIZE(csis->srv.pend_notify); j++) {
struct csis_pending_notifications *pend_notify;
for (int j = 0; j < ARRAY_SIZE(csip->srv.pend_notify); j++) {
struct csip_pending_notifications *pend_notify;
pend_notify = &csis->srv.pend_notify[j];
pend_notify = &csip->srv.pend_notify[j];
if (pend_notify->pending &&
bt_addr_le_eq(bt_conn_get_dst(conn), &pend_notify->addr)) {
notify_lock_value(csis, conn);
notify_lock_value(csip, conn);
pend_notify->pending = false;
break;
}
@ -460,29 +461,29 @@ static void csis_security_changed(struct bt_conn *conn, bt_security_t level,
}
}
static void handle_csis_disconnect(struct bt_csis *csis, struct bt_conn *conn)
static void handle_csip_disconnect(struct bt_csip *csip, struct bt_conn *conn)
{
BT_DBG("Non-bonded device");
if (is_last_client_to_write(csis, conn)) {
(void)memset(&csis->srv.lock_client_addr, 0,
sizeof(csis->srv.lock_client_addr));
csis->srv.set_lock = BT_CSIS_RELEASE_VALUE;
notify_clients(csis, NULL);
if (is_last_client_to_write(csip, conn)) {
(void)memset(&csip->srv.lock_client_addr, 0,
sizeof(csip->srv.lock_client_addr));
csip->srv.set_lock = BT_CSIP_RELEASE_VALUE;
notify_clients(csip, NULL);
if (csis->srv.cb != NULL && csis->srv.cb->lock_changed != NULL) {
bool locked = csis->srv.set_lock == BT_CSIS_LOCK_VALUE;
if (csip->srv.cb != NULL && csip->srv.cb->lock_changed != NULL) {
bool locked = csip->srv.set_lock == BT_CSIP_LOCK_VALUE;
csis->srv.cb->lock_changed(conn, csis, locked);
csip->srv.cb->lock_changed(conn, csip, locked);
}
}
/* Check if the disconnected device once was bonded and stored
* here as a bonded device
*/
for (int i = 0; i < ARRAY_SIZE(csis->srv.pend_notify); i++) {
struct csis_pending_notifications *pend_notify;
for (int i = 0; i < ARRAY_SIZE(csip->srv.pend_notify); i++) {
struct csip_pending_notifications *pend_notify;
pend_notify = &csis->srv.pend_notify[i];
pend_notify = &csip->srv.pend_notify[i];
if (bt_addr_le_eq(bt_conn_get_dst(conn), &pend_notify->addr)) {
(void)memset(pend_notify, 0, sizeof(*pend_notify));
@ -491,60 +492,60 @@ static void handle_csis_disconnect(struct bt_csis *csis, struct bt_conn *conn)
}
}
static void csis_disconnected(struct bt_conn *conn, uint8_t reason)
static void csip_disconnected(struct bt_conn *conn, uint8_t reason)
{
BT_DBG("Disconnected: %s (reason %u)",
bt_addr_le_str(bt_conn_get_dst(conn)), reason);
for (int i = 0; i < ARRAY_SIZE(csis_insts); i++) {
handle_csis_disconnect(&csis_insts[i], conn);
for (int i = 0; i < ARRAY_SIZE(csip_insts); i++) {
handle_csip_disconnect(&csip_insts[i], conn);
}
}
static void handle_csis_auth_complete(struct bt_csis *csis,
static void handle_csip_auth_complete(struct bt_csip *csip,
struct bt_conn *conn)
{
/* Check if already in list, and do nothing if it is */
for (int i = 0; i < ARRAY_SIZE(csis->srv.pend_notify); i++) {
struct csis_pending_notifications *pend_notify;
for (int i = 0; i < ARRAY_SIZE(csip->srv.pend_notify); i++) {
struct csip_pending_notifications *pend_notify;
pend_notify = &csis->srv.pend_notify[i];
pend_notify = &csip->srv.pend_notify[i];
if (pend_notify->active &&
bt_addr_le_eq(bt_conn_get_dst(conn), &pend_notify->addr)) {
#if IS_ENABLED(CONFIG_BT_KEYS_OVERWRITE_OLDEST)
pend_notify->age = csis->srv.age_counter++;
pend_notify->age = csip->srv.age_counter++;
#endif /* CONFIG_BT_KEYS_OVERWRITE_OLDEST */
return;
}
}
/* Copy addr to list over devices to save notifications for */
for (int i = 0; i < ARRAY_SIZE(csis->srv.pend_notify); i++) {
struct csis_pending_notifications *pend_notify;
for (int i = 0; i < ARRAY_SIZE(csip->srv.pend_notify); i++) {
struct csip_pending_notifications *pend_notify;
pend_notify = &csis->srv.pend_notify[i];
pend_notify = &csip->srv.pend_notify[i];
if (!pend_notify->active) {
bt_addr_le_copy(&pend_notify->addr,
bt_conn_get_dst(conn));
pend_notify->active = true;
#if IS_ENABLED(CONFIG_BT_KEYS_OVERWRITE_OLDEST)
pend_notify->age = csis->srv.age_counter++;
pend_notify->age = csip->srv.age_counter++;
#endif /* CONFIG_BT_KEYS_OVERWRITE_OLDEST */
return;
}
}
#if IS_ENABLED(CONFIG_BT_KEYS_OVERWRITE_OLDEST)
struct csis_pending_notifications *oldest;
struct csip_pending_notifications *oldest;
oldest = &csis->srv.pend_notify[0];
oldest = &csip->srv.pend_notify[0];
for (int i = 1; i < ARRAY_SIZE(csis->srv.pend_notify); i++) {
struct csis_pending_notifications *pend_notify;
for (int i = 1; i < ARRAY_SIZE(csip->srv.pend_notify); i++) {
struct csip_pending_notifications *pend_notify;
pend_notify = &csis->srv.pend_notify[i];
pend_notify = &csip->srv.pend_notify[i];
if (pend_notify->age < oldest->age) {
oldest = pend_notify;
@ -553,7 +554,7 @@ static void handle_csis_auth_complete(struct bt_csis *csis,
(void)memset(oldest, 0, sizeof(*oldest));
bt_addr_le_copy(&oldest->addr, &conn->le.dst);
oldest->active = true;
oldest->age = csis->srv.age_counter++;
oldest->age = csip->srv.age_counter++;
#else
BT_WARN("Could not add device to pending notification list");
#endif /* CONFIG_BT_KEYS_OVERWRITE_OLDEST */
@ -580,20 +581,20 @@ static void auth_pairing_complete(struct bt_conn *conn, bool bonded)
return;
}
for (int i = 0; i < ARRAY_SIZE(csis_insts); i++) {
handle_csis_auth_complete(&csis_insts[i], conn);
for (int i = 0; i < ARRAY_SIZE(csip_insts); i++) {
handle_csip_auth_complete(&csip_insts[i], conn);
}
}
static void csis_bond_deleted(uint8_t id, const bt_addr_le_t *peer)
static void csip_bond_deleted(uint8_t id, const bt_addr_le_t *peer)
{
for (int i = 0; i < ARRAY_SIZE(csis_insts); i++) {
struct bt_csis *csis = &csis_insts[i];
for (int i = 0; i < ARRAY_SIZE(csip_insts); i++) {
struct bt_csip *csip = &csip_insts[i];
for (int j = 0; j < ARRAY_SIZE(csis->srv.pend_notify); j++) {
struct csis_pending_notifications *pend_notify;
for (int j = 0; j < ARRAY_SIZE(csip->srv.pend_notify); j++) {
struct csip_pending_notifications *pend_notify;
pend_notify = &csis->srv.pend_notify[j];
pend_notify = &csip->srv.pend_notify[j];
if (pend_notify->active &&
bt_addr_le_eq(peer, &pend_notify->addr)) {
@ -606,49 +607,49 @@ static void csis_bond_deleted(uint8_t id, const bt_addr_le_t *peer)
}
static struct bt_conn_cb conn_callbacks = {
.disconnected = csis_disconnected,
.security_changed = csis_security_changed,
.disconnected = csip_disconnected,
.security_changed = csip_security_changed,
};
static struct bt_conn_auth_info_cb auth_callbacks = {
.pairing_complete = auth_pairing_complete,
.bond_deleted = csis_bond_deleted
.bond_deleted = csip_bond_deleted
};
#define BT_CSIS_SERVICE_DEFINITION(_csis) {\
#define BT_CSIP_SERVICE_DEFINITION(_csip) {\
BT_GATT_PRIMARY_SERVICE(BT_UUID_CSIS), \
BT_AUDIO_CHRC(BT_UUID_CSIS_SET_SIRK, \
BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, \
BT_GATT_PERM_READ_ENCRYPT, \
read_set_sirk, NULL, &_csis), \
read_set_sirk, NULL, &_csip), \
BT_AUDIO_CCC(set_sirk_cfg_changed), \
BT_AUDIO_CHRC(BT_UUID_CSIS_SET_SIZE, \
BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, \
BT_GATT_PERM_READ_ENCRYPT, \
read_set_size, NULL, &_csis), \
read_set_size, NULL, &_csip), \
BT_AUDIO_CCC(set_size_cfg_changed), \
BT_AUDIO_CHRC(BT_UUID_CSIS_SET_LOCK, \
BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY | BT_GATT_CHRC_WRITE, \
BT_GATT_PERM_READ_ENCRYPT | BT_GATT_PERM_WRITE_ENCRYPT, \
read_set_lock, write_set_lock, &_csis), \
read_set_lock, write_set_lock, &_csip), \
BT_AUDIO_CCC(set_lock_cfg_changed), \
BT_AUDIO_CHRC(BT_UUID_CSIS_RANK, \
BT_GATT_CHRC_READ, \
BT_GATT_PERM_READ_ENCRYPT, \
read_rank, NULL, &_csis) \
read_rank, NULL, &_csip) \
}
BT_GATT_SERVICE_INSTANCE_DEFINE(csis_service_list, csis_insts,
CONFIG_BT_CSIS_MAX_INSTANCE_COUNT,
BT_CSIS_SERVICE_DEFINITION);
BT_GATT_SERVICE_INSTANCE_DEFINE(csip_service_list, csip_insts,
CONFIG_BT_CSIP_MAX_INSTANCE_COUNT,
BT_CSIP_SERVICE_DEFINITION);
/****************************** Public API ******************************/
void *bt_csis_svc_decl_get(const struct bt_csis *csis)
void *bt_csip_svc_decl_get(const struct bt_csip *csip)
{
return csis->srv.service_p->attrs;
return csip->srv.service_p->attrs;
}
static bool valid_register_param(const struct bt_csis_register_param *param)
static bool valid_register_param(const struct bt_csip_register_param *param)
{
if (param->lockable && param->rank == 0) {
BT_DBG("Rank cannot be 0 if service is lockable");
@ -661,24 +662,24 @@ static bool valid_register_param(const struct bt_csis_register_param *param)
return false;
}
#if CONFIG_BT_CSIS_MAX_INSTANCE_COUNT > 1
#if CONFIG_BT_CSIP_MAX_INSTANCE_COUNT > 1
if (param->parent == NULL) {
BT_DBG("Parent service not provided");
return false;
}
#endif /* CONFIG_BT_CSIS_MAX_INSTANCE_COUNT > 1 */
#endif /* CONFIG_BT_CSIP_MAX_INSTANCE_COUNT > 1 */
return true;
}
int bt_csis_register(const struct bt_csis_register_param *param,
struct bt_csis **csis)
int bt_csip_register(const struct bt_csip_register_param *param,
struct bt_csip **csip)
{
static uint8_t instance_cnt;
struct bt_csis *inst;
struct bt_csip *inst;
int err;
if (instance_cnt == ARRAY_SIZE(csis_insts)) {
if (instance_cnt == ARRAY_SIZE(csip_insts)) {
return -ENOMEM;
}
@ -692,8 +693,8 @@ int bt_csis_register(const struct bt_csis_register_param *param,
return -EINVAL;
}
inst = &csis_insts[instance_cnt];
inst->srv.service_p = &csis_service_list[instance_cnt];
inst = &csip_insts[instance_cnt];
inst->srv.service_p = &csip_service_list[instance_cnt];
instance_cnt++;
bt_conn_cb_register(&conn_callbacks);
@ -709,11 +710,11 @@ int bt_csis_register(const struct bt_csis_register_param *param,
set_lock_timer_handler);
inst->srv.rank = param->rank;
inst->srv.set_size = param->set_size;
inst->srv.set_lock = BT_CSIS_RELEASE_VALUE;
inst->srv.set_sirk.type = BT_CSIS_SIRK_TYPE_PLAIN;
inst->srv.set_lock = BT_CSIP_RELEASE_VALUE;
inst->srv.set_sirk.type = BT_CSIP_SIRK_TYPE_PLAIN;
inst->srv.cb = param->cb;
if (IS_ENABLED(CONFIG_BT_CSIS_TEST_SAMPLE_DATA)) {
if (IS_ENABLED(CONFIG_BT_CSIP_TEST_SAMPLE_DATA)) {
uint8_t test_sirk[] = {
0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce,
0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45,
@ -721,36 +722,36 @@ int bt_csis_register(const struct bt_csis_register_param *param,
(void)memcpy(inst->srv.set_sirk.value, test_sirk,
sizeof(test_sirk));
BT_DBG("CSIS SIRK was overwritten by sample data SIRK");
BT_DBG("CSIP SIRK was overwritten by sample data SIRK");
} else {
(void)memcpy(inst->srv.set_sirk.value, param->set_sirk,
sizeof(inst->srv.set_sirk.value));
}
*csis = inst;
*csip = inst;
return 0;
}
int bt_csis_lock(struct bt_csis *csis, bool lock, bool force)
int bt_csip_lock(struct bt_csip *csip, bool lock, bool force)
{
uint8_t lock_val;
int err = 0;
if (lock) {
lock_val = BT_CSIS_LOCK_VALUE;
lock_val = BT_CSIP_LOCK_VALUE;
} else {
lock_val = BT_CSIS_RELEASE_VALUE;
lock_val = BT_CSIP_RELEASE_VALUE;
}
if (!lock && force) {
csis->srv.set_lock = BT_CSIS_RELEASE_VALUE;
notify_clients(csis, NULL);
csip->srv.set_lock = BT_CSIP_RELEASE_VALUE;
notify_clients(csip, NULL);
if (csis->srv.cb != NULL && csis->srv.cb->lock_changed != NULL) {
csis->srv.cb->lock_changed(NULL, &csis_insts[0], false);
if (csip->srv.cb != NULL && csip->srv.cb->lock_changed != NULL) {
csip->srv.cb->lock_changed(NULL, &csip_insts[0], false);
}
} else {
err = set_lock(NULL, csis, lock_val);
err = set_lock(NULL, csip, lock_val);
}
if (err < 0) {
@ -760,7 +761,8 @@ int bt_csis_lock(struct bt_csis *csis, bool lock, bool force)
}
}
void bt_csis_print_sirk(const struct bt_csis *csis)
void bt_csip_print_sirk(const struct bt_csip *csip)
{
LOG_HEXDUMP_DBG(&csis->srv.set_sirk, sizeof(csis->srv.set_sirk), "Set SIRK");
LOG_HEXDUMP_DBG(&csip->srv.set_sirk, sizeof(csip->srv.set_sirk),
"Set SIRK");
}

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2020 Bose Corporation
* Copyright (c) 2021 Nordic Semiconductor ASA
* Copyright (c) 2021-2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*
@ -9,7 +9,7 @@
* in the CSIS spec is also provided as BE, and logging values as BE will make
* it easier to compare.
*/
#include "csis_crypto.h"
#include "csip_crypto.h"
#include <zephyr/bluetooth/crypto.h>
#include <tinycrypt/constants.h>
#include <tinycrypt/utils.h>
@ -18,16 +18,16 @@
#include <tinycrypt/ccm_mode.h>
#include <zephyr/sys/byteorder.h>
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_CSIS_CRYPTO)
#define LOG_MODULE_NAME bt_csis_crypto
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_CSIP_CRYPTO)
#define LOG_MODULE_NAME bt_csip_crypto
#include "common/log.h"
#include "common/bt_str.h"
#define BT_CSIS_CRYPTO_PADDING_SIZE 13
#define BT_CSIS_R_SIZE 3 /* r is 24 bit / 3 octet */
#define BT_CSIS_R_MASK BIT_MASK(24) /* r is 24 bit / 3 octet */
#define BT_CSIP_CRYPTO_PADDING_SIZE 13
#define BT_CSIP_R_SIZE 3 /* r is 24 bit / 3 octet */
#define BT_CSIP_R_MASK BIT_MASK(24) /* r is 24 bit / 3 octet */
static int aes_cmac(const uint8_t key[BT_CSIS_CRYPTO_KEY_SIZE],
static int aes_cmac(const uint8_t key[BT_CSIP_CRYPTO_KEY_SIZE],
const uint8_t *in, size_t in_len, uint8_t *out)
{
struct tc_aes_key_sched_struct sched;
@ -60,31 +60,31 @@ static void xor_128(const uint8_t a[16], const uint8_t b[16], uint8_t out[16])
}
}
int bt_csis_sih(const uint8_t sirk[BT_CSIS_SET_SIRK_SIZE], uint32_t r,
int bt_csip_sih(const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE], uint32_t r,
uint32_t *out)
{
uint8_t res[16]; /* need to store 128 bit */
int err;
uint8_t sirk_tmp[BT_CSIS_SET_SIRK_SIZE];
uint8_t sirk_tmp[BT_CSIP_SET_SIRK_SIZE];
if ((r & BIT(23)) || ((r & BIT(22)) == 0)) {
BT_DBG("Invalid r %0x06x", (uint32_t)(r & BT_CSIS_R_MASK));
BT_DBG("Invalid r %0x06x", (uint32_t)(r & BT_CSIP_R_MASK));
}
BT_DBG("SIRK %s", bt_hex(sirk, BT_CSIS_SET_SIRK_SIZE));
BT_DBG("SIRK %s", bt_hex(sirk, BT_CSIP_SET_SIRK_SIZE));
BT_DBG("r 0x%06x", r);
/* r' = padding || r */
(void)memset(res, 0, BT_CSIS_CRYPTO_PADDING_SIZE);
sys_put_be24(r, res + BT_CSIS_CRYPTO_PADDING_SIZE);
(void)memset(res, 0, BT_CSIP_CRYPTO_PADDING_SIZE);
sys_put_be24(r, res + BT_CSIP_CRYPTO_PADDING_SIZE);
BT_DBG("BE: r' %s", bt_hex(res, sizeof(res)));
if (IS_ENABLED(CONFIG_LITTLE_ENDIAN)) {
/* Swap to Big Endian (BE) */
sys_memcpy_swap(sirk_tmp, sirk, BT_CSIS_SET_SIRK_SIZE);
sys_memcpy_swap(sirk_tmp, sirk, BT_CSIP_SET_SIRK_SIZE);
} else {
(void)memcpy(sirk_tmp, sirk, BT_CSIS_SET_SIRK_SIZE);
(void)memcpy(sirk_tmp, sirk, BT_CSIP_SET_SIRK_SIZE);
}
err = bt_encrypt_be(sirk_tmp, res, res);
@ -126,7 +126,7 @@ int bt_csis_sih(const uint8_t sirk[BT_CSIS_SET_SIRK_SIZE], uint32_t r,
* @return int 0 on success, any other value indicates a failure.
*/
static int k1(const uint8_t *n, size_t n_size,
const uint8_t salt[BT_CSIS_CRYPTO_SALT_SIZE],
const uint8_t salt[BT_CSIP_CRYPTO_SALT_SIZE],
const uint8_t *p, size_t p_size, uint8_t out[16])
{
/* TODO: This is basically a duplicate of bt_mesh_k1 - Perhaps they can
@ -142,7 +142,7 @@ static int k1(const uint8_t *n, size_t n_size,
*/
BT_DBG("BE: n %s", bt_hex(n, n_size));
BT_DBG("BE: salt %s", bt_hex(salt, BT_CSIS_CRYPTO_SALT_SIZE));
BT_DBG("BE: salt %s", bt_hex(salt, BT_CSIP_CRYPTO_SALT_SIZE));
BT_DBG("BE: p %s", bt_hex(p, p_size));
err = aes_cmac(salt, n, n_size, t);
@ -169,7 +169,7 @@ static int k1(const uint8_t *n, size_t n_size,
* @return int 0 on success, any other value indicates a failure.
*/
static int s1(const uint8_t *m, size_t m_size,
uint8_t out[BT_CSIS_CRYPTO_SALT_SIZE])
uint8_t out[BT_CSIP_CRYPTO_SALT_SIZE])
{
uint8_t zero[16];
int err;
@ -189,22 +189,22 @@ static int s1(const uint8_t *m, size_t m_size,
return err;
}
int bt_csis_sef(const uint8_t k[BT_CSIS_CRYPTO_KEY_SIZE],
const uint8_t sirk[BT_CSIS_SET_SIRK_SIZE],
uint8_t out_sirk[BT_CSIS_SET_SIRK_SIZE])
int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE],
const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE],
uint8_t out_sirk[BT_CSIP_SET_SIRK_SIZE])
{
const uint8_t m[] = {'S', 'I', 'R', 'K', 'e', 'n', 'c'};
const uint8_t p[] = {'c', 's', 'i', 's'};
uint8_t s1_out[BT_CSIS_CRYPTO_SALT_SIZE];
uint8_t k1_out[BT_CSIS_CRYPTO_KEY_SIZE];
uint8_t k1_tmp[BT_CSIS_CRYPTO_KEY_SIZE];
uint8_t s1_out[BT_CSIP_CRYPTO_SALT_SIZE];
uint8_t k1_out[BT_CSIP_CRYPTO_KEY_SIZE];
uint8_t k1_tmp[BT_CSIP_CRYPTO_KEY_SIZE];
int err;
/*
* sef(K, SIRK) = k1(K, s1("SIRKenc"), "csis") ^ SIRK
*/
BT_DBG("SIRK %s", bt_hex(sirk, BT_CSIS_SET_SIRK_SIZE));
BT_DBG("SIRK %s", bt_hex(sirk, BT_CSIP_SET_SIRK_SIZE));
if (IS_ENABLED(CONFIG_LITTLE_ENDIAN)) {
/* Swap because aes_cmac is big endian
@ -236,14 +236,14 @@ int bt_csis_sef(const uint8_t k[BT_CSIS_CRYPTO_KEY_SIZE],
}
xor_128(k1_out, sirk, out_sirk);
BT_DBG("out %s", bt_hex(out_sirk, BT_CSIS_SET_SIRK_SIZE));
BT_DBG("out %s", bt_hex(out_sirk, BT_CSIP_SET_SIRK_SIZE));
return 0;
}
int bt_csis_sdf(const uint8_t k[BT_CSIS_CRYPTO_KEY_SIZE],
const uint8_t enc_sirk[BT_CSIS_SET_SIRK_SIZE],
uint8_t out_sirk[BT_CSIS_SET_SIRK_SIZE])
int bt_csip_sdf(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE],
const uint8_t enc_sirk[BT_CSIP_SET_SIRK_SIZE],
uint8_t out_sirk[BT_CSIP_SET_SIRK_SIZE])
{
/* SIRK encryption is currently symmetric, which means that we can
* simply apply the sef function to decrypt it.
@ -254,5 +254,5 @@ int bt_csis_sdf(const uint8_t k[BT_CSIS_CRYPTO_KEY_SIZE],
*/
BT_DBG("Running SDF as SEF");
return bt_csis_sef(k, enc_sirk, out_sirk);
return bt_csip_sef(k, enc_sirk, out_sirk);
}

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2019 Bose Corporation
* Copyright (c) 2021 Nordic Semiconductor ASA
* Copyright (c) 2021-2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -8,10 +8,10 @@
#include <stddef.h>
#include <zephyr/types.h>
#include <zephyr/bluetooth/audio/csis.h>
#include <zephyr/bluetooth/audio/csip.h>
#define BT_CSIS_CRYPTO_KEY_SIZE 16
#define BT_CSIS_CRYPTO_SALT_SIZE 16
#define BT_CSIP_CRYPTO_KEY_SIZE 16
#define BT_CSIP_CRYPTO_SALT_SIZE 16
/**
* @brief Private Set Unique identifier hash function sih.
@ -25,7 +25,7 @@
* @param out The 3 byte output buffer
* @return int 0 on success, any other value indicates a failure.
*/
int bt_csis_sih(const uint8_t sirk[BT_CSIS_SET_SIRK_SIZE], uint32_t r,
int bt_csip_sih(const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE], uint32_t r,
uint32_t *out);
/**
@ -51,9 +51,9 @@ int bt_csis_sih(const uint8_t sirk[BT_CSIS_SET_SIRK_SIZE], uint32_t r,
* @param out_sirk The encrypted SIRK.
* @return int 0 on success, any other value indicates a failure.
*/
int bt_csis_sef(const uint8_t k[BT_CSIS_CRYPTO_KEY_SIZE],
const uint8_t sirk[BT_CSIS_SET_SIRK_SIZE],
uint8_t out_sirk[BT_CSIS_SET_SIRK_SIZE]);
int bt_csip_sef(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE],
const uint8_t sirk[BT_CSIP_SET_SIRK_SIZE],
uint8_t out_sirk[BT_CSIP_SET_SIRK_SIZE]);
/**
* @brief SIRK decryption function sdf
@ -78,6 +78,6 @@ int bt_csis_sef(const uint8_t k[BT_CSIS_CRYPTO_KEY_SIZE],
* @param out_sirk The decrypted SIRK.
* @return int 0 on success, any other value indicates a failure.
*/
int bt_csis_sdf(const uint8_t k[BT_CSIS_CRYPTO_KEY_SIZE],
const uint8_t enc_sirk[BT_CSIS_SET_SIRK_SIZE],
uint8_t out_sirk[BT_CSIS_SET_SIRK_SIZE]);
int bt_csip_sdf(const uint8_t k[BT_CSIP_CRYPTO_KEY_SIZE],
const uint8_t enc_sirk[BT_CSIP_SET_SIRK_SIZE],
uint8_t out_sirk[BT_CSIP_SET_SIRK_SIZE]);

View file

@ -1,22 +1,22 @@
/**
* @file
* @brief Internal APIs for Bluetooth CSIS
* @brief Internal APIs for Bluetooth CSIP
*
* Copyright (c) 2021 Nordic Semiconductor ASA
* Copyright (c) 2021-2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/bluetooth/audio/csis.h>
#include <zephyr/bluetooth/audio/csip.h>
#define BT_CSIS_SIRK_TYPE_ENCRYPTED 0x00
#define BT_CSIS_SIRK_TYPE_PLAIN 0x01
#define BT_CSIP_SIRK_TYPE_ENCRYPTED 0x00
#define BT_CSIP_SIRK_TYPE_PLAIN 0x01
#define BT_CSIS_RELEASE_VALUE 0x01
#define BT_CSIS_LOCK_VALUE 0x02
#define BT_CSIP_RELEASE_VALUE 0x01
#define BT_CSIP_LOCK_VALUE 0x02
struct csis_pending_notifications {
struct csip_pending_notifications {
bt_addr_le_t addr;
bool pending;
bool active;
@ -30,12 +30,12 @@ struct csis_pending_notifications {
#endif /* CONFIG_BT_KEYS_OVERWRITE_OLDEST */
};
struct bt_csis_set_sirk {
struct bt_csip_set_sirk {
uint8_t type;
uint8_t value[BT_CSIS_SET_SIRK_SIZE];
uint8_t value[BT_CSIP_SET_SIRK_SIZE];
} __packed;
struct bt_csis_client_svc_inst {
struct bt_csip_set_coordinator_svc_inst {
uint8_t rank;
uint8_t set_lock;
@ -55,36 +55,36 @@ struct bt_csis_client_svc_inst {
struct bt_gatt_discover_params lock_sub_disc_params;
struct bt_conn *conn;
struct bt_csis_client_set_member *member;
struct bt_csip_set_coordinator_set_member *member;
};
/* TODO: Rename to bt_csis_svc_inst */
struct bt_csis_server {
struct bt_csis_set_sirk set_sirk;
/* TODO: Rename to bt_csip_svc_inst */
struct bt_csip_server {
struct bt_csip_set_sirk set_sirk;
uint8_t set_size;
uint8_t set_lock;
uint8_t rank;
struct bt_csis_cb *cb;
struct bt_csip_cb *cb;
struct k_work_delayable set_lock_timer;
bt_addr_le_t lock_client_addr;
struct bt_gatt_service *service_p;
struct csis_pending_notifications pend_notify[CONFIG_BT_MAX_PAIRED];
struct csip_pending_notifications pend_notify[CONFIG_BT_MAX_PAIRED];
#if IS_ENABLED(CONFIG_BT_KEYS_OVERWRITE_OLDEST)
uint32_t age_counter;
#endif /* CONFIG_BT_KEYS_OVERWRITE_OLDEST */
};
struct bt_csis {
struct bt_csip {
bool client_instance;
union {
#if defined(CONFIG_BT_CSIS)
struct bt_csis_server srv;
#endif /* CONFIG_BT_CSIS */
#if defined(CONFIG_BT_CSIS_CLIENT)
struct bt_csis_client_svc_inst cli;
#endif /* CONFIG_BT_CSIS_CLIENT */
#if defined(CONFIG_BT_CSIP)
struct bt_csip_server srv;
#endif /* CONFIG_BT_CSIP */
#if defined(CONFIG_BT_CSIP_SET_COORDINATOR)
struct bt_csip_set_coordinator_svc_inst cli;
#endif /* CONFIG_BT_CSIP_SET_COORDINATOR */
};
};
struct bt_csis_client_csis_inst *bt_csis_client_csis_inst_by_handle(struct bt_conn *conn,
uint16_t start_handle);
struct bt_csip_set_coordinator_csis_inst *bt_csip_set_coordinator_csis_inst_by_handle(
struct bt_conn *conn, uint16_t start_handle);

View file

@ -42,12 +42,12 @@ zephyr_library_sources_ifdef(
micp_mic_ctlr.c
)
zephyr_library_sources_ifdef(
CONFIG_BT_CSIS
csis.c
CONFIG_BT_CSIP
csip.c
)
zephyr_library_sources_ifdef(
CONFIG_BT_CSIS_CLIENT
csis_client.c
CONFIG_BT_CSIP_SET_COORDINATOR
csip_set_coordinator.c
)
zephyr_library_sources_ifdef(
CONFIG_BT_TBS

View file

@ -33,7 +33,7 @@
#include <zephyr/bluetooth/iso.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/pacs.h>
#include <zephyr/bluetooth/audio/csis.h>
#include <zephyr/bluetooth/audio/csip.h>
#include <zephyr/shell/shell.h>
@ -1245,7 +1245,7 @@ static ssize_t ad_init(struct bt_data *data_array, const size_t data_array_size,
/* A privacy-enabled Set Member should advertise RSI values only when in
* the GAP Limited Discoverable mode.
*/
if (IS_ENABLED(CONFIG_BT_PRIVACY) && IS_ENABLED(CONFIG_BT_CSIS) && csis != NULL) {
if (IS_ENABLED(CONFIG_BT_PRIVACY) && IS_ENABLED(CONFIG_BT_CSIP) && csip != NULL) {
ad_flags |= BT_LE_AD_LIMITED;
} else {
ad_flags |= BT_LE_AD_GENERAL;
@ -1272,7 +1272,7 @@ static ssize_t ad_init(struct bt_data *data_array, const size_t data_array_size,
ad_len++;
}
if (IS_ENABLED(CONFIG_BT_CSIS)) {
if (IS_ENABLED(CONFIG_BT_CSIP)) {
ssize_t csis_ad_len;
csis_ad_len = csis_ad_data_add(&data_array[ad_len],

View file

@ -18,7 +18,7 @@
extern const struct shell *ctx_shell;
extern struct bt_conn *default_conn;
extern struct bt_csis *csis;
extern struct bt_csip *csip;
#if defined(CONFIG_BT_ISO)
extern struct bt_iso_chan iso_chan;

View file

@ -16,10 +16,10 @@
#include "bt.h"
extern const struct shell *ctx_shell;
static struct bt_csis *cap_csis;
static uint8_t sirk_read_rsp = BT_CSIS_READ_SIRK_REQ_RSP_ACCEPT;
static struct bt_csip *cap_csip;
static uint8_t sirk_read_rsp = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT;
static void locked_cb(struct bt_conn *conn, struct bt_csis *csis, bool locked)
static void locked_cb(struct bt_conn *conn, struct bt_csip *csip, bool locked)
{
if (conn == NULL) {
shell_error(ctx_shell, "Server %s the device",
@ -34,7 +34,7 @@ static void locked_cb(struct bt_conn *conn, struct bt_csis *csis, bool locked)
}
}
static uint8_t sirk_read_req_cb(struct bt_conn *conn, struct bt_csis *csis)
static uint8_t sirk_read_req_cb(struct bt_conn *conn, struct bt_csip *csip)
{
char addr[BT_ADDR_LE_STR_LEN];
static const char *const rsp_strings[] = {
@ -49,7 +49,7 @@ static uint8_t sirk_read_req_cb(struct bt_conn *conn, struct bt_csis *csis)
return sirk_read_rsp;
}
static struct bt_csis_cb csis_cbs = {
static struct bt_csip_cb csip_cbs = {
.lock_changed = locked_cb,
.sirk_read_req = sirk_read_req_cb,
};
@ -58,14 +58,14 @@ static int cmd_cap_acceptor_init(const struct shell *sh, size_t argc,
char **argv)
{
int err;
struct bt_csis_register_param param = {
struct bt_csip_register_param param = {
.set_size = 2,
.rank = 1,
.lockable = true,
/* Using the CSIS test sample SIRK */
.set_sirk = { 0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce,
0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45 },
.cb = &csis_cbs
.cb = &csip_cbs
};
for (size_t argn = 1; argn < argc; argn++) {
@ -95,7 +95,7 @@ static int cmd_cap_acceptor_init(const struct shell *sh, size_t argc,
}
}
err = bt_cap_acceptor_register(&param, &cap_csis);
err = bt_cap_acceptor_register(&param, &cap_csip);
if (err != 0) {
shell_error(sh, "Could not register CAS: %d", err);
@ -108,7 +108,7 @@ static int cmd_cap_acceptor_init(const struct shell *sh, size_t argc,
static int cmd_cap_acceptor_print_sirk(const struct shell *sh, size_t argc,
char *argv[])
{
bt_csis_print_sirk(cap_csis);
bt_csip_print_sirk(cap_csip);
return 0;
}
@ -118,7 +118,7 @@ static int cmd_cap_acceptor_lock(const struct shell *sh, size_t argc,
{
int err;
err = bt_csis_lock(cap_csis, true, false);
err = bt_csip_lock(cap_csip, true, false);
if (err != 0) {
shell_error(sh, "Failed to set lock: %d", err);
@ -146,7 +146,7 @@ static int cmd_cap_acceptor_release(const struct shell *sh, size_t argc,
}
}
err = bt_csis_lock(cap_csis, false, force);
err = bt_csip_lock(cap_csip, false, force);
if (err != 0) {
shell_error(sh, "Failed to release lock: %d", err);
@ -163,13 +163,13 @@ static int cmd_cap_acceptor_set_sirk_rsp(const struct shell *sh, size_t argc,
char *argv[])
{
if (strcmp(argv[1], "accept") == 0) {
sirk_read_rsp = BT_CSIS_READ_SIRK_REQ_RSP_ACCEPT;
sirk_read_rsp = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT;
} else if (strcmp(argv[1], "accept_enc") == 0) {
sirk_read_rsp = BT_CSIS_READ_SIRK_REQ_RSP_ACCEPT_ENC;
sirk_read_rsp = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT_ENC;
} else if (strcmp(argv[1], "reject") == 0) {
sirk_read_rsp = BT_CSIS_READ_SIRK_REQ_RSP_REJECT;
sirk_read_rsp = BT_CSIP_READ_SIRK_REQ_RSP_REJECT;
} else if (strcmp(argv[1], "oob") == 0) {
sirk_read_rsp = BT_CSIS_READ_SIRK_REQ_RSP_OOB_ONLY;
sirk_read_rsp = BT_CSIP_READ_SIRK_REQ_RSP_OOB_ONLY;
} else {
shell_error(sh, "Unknown parameter: %s", argv[1]);
return -ENOEXEC;

View file

@ -20,7 +20,7 @@
#if defined(CONFIG_BT_AUDIO_UNICAST_CLIENT)
static void cap_discover_cb(struct bt_conn *conn, int err,
const struct bt_csis_client_csis_inst *csis_inst)
const struct bt_csip_set_coordinator_csis_inst *csis_inst)
{
if (err != 0) {
shell_error(ctx_shell, "discover failed (%d)", err);

View file

@ -1,6 +1,6 @@
/**
* @file
* @brief Shell APIs for Bluetooth CSIS
* @brief Shell APIs for Bluetooth CSIP
*
* Copyright (c) 2020 Bose Corporation
* Copyright (c) 2021 Nordic Semiconductor ASA
@ -16,14 +16,14 @@
#include <stdlib.h>
#include <zephyr/bluetooth/gatt.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/audio/csis.h>
#include <zephyr/bluetooth/audio/csip.h>
#include "bt.h"
extern const struct shell *ctx_shell;
struct bt_csis *csis;
static uint8_t sirk_read_rsp = BT_CSIS_READ_SIRK_REQ_RSP_ACCEPT;
struct bt_csip *csip;
static uint8_t sirk_read_rsp = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT;
static void locked_cb(struct bt_conn *conn, struct bt_csis *csis, bool locked)
static void locked_cb(struct bt_conn *conn, struct bt_csip *csip, bool locked)
{
if (conn == NULL) {
shell_error(ctx_shell, "Server %s the device",
@ -38,7 +38,7 @@ static void locked_cb(struct bt_conn *conn, struct bt_csis *csis, bool locked)
}
}
static uint8_t sirk_read_req_cb(struct bt_conn *conn, struct bt_csis *csis)
static uint8_t sirk_read_req_cb(struct bt_conn *conn, struct bt_csip *csip)
{
char addr[BT_ADDR_LE_STR_LEN];
static const char *const rsp_strings[] = {
@ -53,22 +53,22 @@ static uint8_t sirk_read_req_cb(struct bt_conn *conn, struct bt_csis *csis)
return sirk_read_rsp;
}
static struct bt_csis_cb csis_cbs = {
static struct bt_csip_cb csip_cbs = {
.lock_changed = locked_cb,
.sirk_read_req = sirk_read_req_cb,
};
static int cmd_csis_register(const struct shell *sh, size_t argc, char **argv)
static int cmd_csip_register(const struct shell *sh, size_t argc, char **argv)
{
int err;
struct bt_csis_register_param param = {
struct bt_csip_register_param param = {
.set_size = 2,
.rank = 1,
.lockable = true,
/* Using the CSIS test sample SIRK */
.set_sirk = { 0xcd, 0xcc, 0x72, 0xdd, 0x86, 0x8c, 0xcd, 0xce,
0x22, 0xfd, 0xa1, 0x21, 0x09, 0x7d, 0x7d, 0x45 },
.cb = &csis_cbs
.cb = &csip_cbs
};
for (size_t argn = 1; argn < argc; argn++) {
@ -96,27 +96,27 @@ static int cmd_csis_register(const struct shell *sh, size_t argc, char **argv)
}
}
err = bt_csis_register(&param, &csis);
err = bt_csip_register(&param, &csip);
if (err != 0) {
shell_error(sh, "Could not register CSIS: %d", err);
shell_error(sh, "Could not register CSIP: %d", err);
return err;
}
return 0;
}
static int cmd_csis_print_sirk(const struct shell *sh, size_t argc,
static int cmd_csip_print_sirk(const struct shell *sh, size_t argc,
char *argv[])
{
bt_csis_print_sirk(csis);
bt_csip_print_sirk(csip);
return 0;
}
static int cmd_csis_lock(const struct shell *sh, size_t argc, char *argv[])
static int cmd_csip_lock(const struct shell *sh, size_t argc, char *argv[])
{
int err;
err = bt_csis_lock(csis, true, false);
err = bt_csip_lock(csip, true, false);
if (err != 0) {
shell_error(sh, "Failed to set lock: %d", err);
return -ENOEXEC;
@ -127,7 +127,7 @@ static int cmd_csis_lock(const struct shell *sh, size_t argc, char *argv[])
return 0;
}
static int cmd_csis_release(const struct shell *sh, size_t argc,
static int cmd_csip_release(const struct shell *sh, size_t argc,
char *argv[])
{
bool force = false;
@ -142,7 +142,7 @@ static int cmd_csis_release(const struct shell *sh, size_t argc,
}
}
err = bt_csis_lock(csis, false, force);
err = bt_csip_lock(csip, false, force);
if (err != 0) {
shell_error(sh, "Failed to release lock: %d", err);
@ -154,17 +154,17 @@ static int cmd_csis_release(const struct shell *sh, size_t argc,
return 0;
}
static int cmd_csis_set_sirk_rsp(const struct shell *sh, size_t argc,
static int cmd_csip_set_sirk_rsp(const struct shell *sh, size_t argc,
char *argv[])
{
if (strcmp(argv[1], "accept") == 0) {
sirk_read_rsp = BT_CSIS_READ_SIRK_REQ_RSP_ACCEPT;
sirk_read_rsp = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT;
} else if (strcmp(argv[1], "accept_enc") == 0) {
sirk_read_rsp = BT_CSIS_READ_SIRK_REQ_RSP_ACCEPT_ENC;
sirk_read_rsp = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT_ENC;
} else if (strcmp(argv[1], "reject") == 0) {
sirk_read_rsp = BT_CSIS_READ_SIRK_REQ_RSP_REJECT;
sirk_read_rsp = BT_CSIP_READ_SIRK_REQ_RSP_REJECT;
} else if (strcmp(argv[1], "oob") == 0) {
sirk_read_rsp = BT_CSIS_READ_SIRK_REQ_RSP_OOB_ONLY;
sirk_read_rsp = BT_CSIP_READ_SIRK_REQ_RSP_OOB_ONLY;
} else {
shell_error(sh, "Unknown parameter: %s", argv[1]);
return -ENOEXEC;
@ -173,36 +173,36 @@ static int cmd_csis_set_sirk_rsp(const struct shell *sh, size_t argc,
return 0;
}
static int cmd_csis(const struct shell *sh, size_t argc, char **argv)
static int cmd_csip(const struct shell *sh, size_t argc, char **argv)
{
shell_error(sh, "%s unknown parameter: %s", argv[0], argv[1]);
return -ENOEXEC;
}
SHELL_STATIC_SUBCMD_SET_CREATE(csis_cmds,
SHELL_STATIC_SUBCMD_SET_CREATE(csip_cmds,
SHELL_CMD_ARG(register, NULL,
"Initialize the service and register callbacks "
"[size <int>] [rank <int>] [not-lockable] [sirk <data>]",
cmd_csis_register, 1, 4),
cmd_csip_register, 1, 4),
SHELL_CMD_ARG(lock, NULL,
"Lock the set",
cmd_csis_lock, 1, 0),
cmd_csip_lock, 1, 0),
SHELL_CMD_ARG(release, NULL,
"Release the set [force]",
cmd_csis_release, 1, 1),
cmd_csip_release, 1, 1),
SHELL_CMD_ARG(print_sirk, NULL,
"Print the currently used SIRK",
cmd_csis_print_sirk, 1, 0),
cmd_csip_print_sirk, 1, 0),
SHELL_CMD_ARG(set_sirk_rsp, NULL,
"Set the response used in SIRK requests "
"<accept, accept_enc, reject, oob>",
cmd_csis_set_sirk_rsp, 2, 0),
cmd_csip_set_sirk_rsp, 2, 0),
SHELL_SUBCMD_SET_END
);
SHELL_CMD_ARG_REGISTER(csis, &csis_cmds, "Bluetooth CSIS shell commands",
cmd_csis, 1, 1);
SHELL_CMD_ARG_REGISTER(csip, &csip_cmds, "Bluetooth CSIP shell commands",
cmd_csip, 1, 1);
ssize_t csis_ad_data_add(struct bt_data *data_array, const size_t data_array_size,
const bool discoverable)
@ -210,19 +210,19 @@ ssize_t csis_ad_data_add(struct bt_data *data_array, const size_t data_array_siz
size_t ad_len = 0;
/* Advertise RSI in discoverable mode only */
if (csis != NULL && discoverable) {
static uint8_t ad_rsi[BT_CSIS_RSI_SIZE];
if (csip != NULL && discoverable) {
static uint8_t ad_rsi[BT_CSIP_RSI_SIZE];
int err;
/* A privacy-enabled Set Member should only advertise RSI values derived
* from a SIRK that is exposed in encrypted form.
*/
if (IS_ENABLED(CONFIG_BT_PRIVACY) &&
!IS_ENABLED(CONFIG_BT_CSIS_ENC_SIRK_SUPPORT)) {
!IS_ENABLED(CONFIG_BT_CSIP_ENC_SIRK_SUPPORT)) {
shell_warn(ctx_shell, "RSI derived from unencrypted SIRK");
}
err = bt_csis_generate_rsi(csis, ad_rsi);
err = bt_csip_generate_rsi(csip, ad_rsi);
if (err != 0) {
shell_error(ctx_shell, "Failed to generate RSI (err %d)", err);
return err;

View file

@ -1,9 +1,9 @@
/**
* @file
* @brief Shell APIs for Bluetooth CSIS client
* @brief Shell APIs for Bluetooth CSIP set coordinator
*
* Copyright (c) 2020 Bose Corporation
* Copyright (c) 2021 Nordic Semiconductor ASA
* Copyright (c) 2021-2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -20,15 +20,15 @@
#include "bt.h"
#include <zephyr/bluetooth/audio/csis.h>
#include <zephyr/bluetooth/audio/csip.h>
static uint8_t members_found;
static struct k_work_delayable discover_members_timer;
static struct bt_conn *conns[CONFIG_BT_MAX_CONN];
static const struct bt_csis_client_set_member *set_members[CONFIG_BT_MAX_CONN];
struct bt_csis_client_csis_inst *cur_inst;
static const struct bt_csip_set_coordinator_set_member *set_members[CONFIG_BT_MAX_CONN];
struct bt_csip_set_coordinator_csis_inst *cur_inst;
static bt_addr_le_t addr_found[CONFIG_BT_MAX_CONN];
static const struct bt_csis_client_set_member *locked_members[CONFIG_BT_MAX_CONN];
static const struct bt_csip_set_coordinator_set_member *locked_members[CONFIG_BT_MAX_CONN];
static bool is_discovered(const bt_addr_le_t *addr)
{
@ -76,8 +76,8 @@ static struct bt_conn_cb conn_callbacks = {
.disconnected = disconnected_cb
};
static void csis_discover_cb(struct bt_conn *conn,
const struct bt_csis_client_set_member *member,
static void csip_discover_cb(struct bt_conn *conn,
const struct bt_csip_set_coordinator_set_member *member,
int err, size_t set_count)
{
uint8_t conn_index;
@ -104,7 +104,7 @@ static void csis_discover_cb(struct bt_conn *conn,
set_members[conn_index] = member;
}
static void csis_client_lock_set_cb(int err)
static void csip_set_coordinator_lock_set_cb(int err)
{
if (err != 0) {
shell_error(ctx_shell, "Lock sets failed (%d)", err);
@ -114,7 +114,7 @@ static void csis_client_lock_set_cb(int err)
shell_print(ctx_shell, "Set locked");
}
static void csis_client_release_set_cb(int err)
static void csip_set_coordinator_release_set_cb(int err)
{
if (err != 0) {
shell_error(ctx_shell, "Lock sets failed (%d)", err);
@ -124,9 +124,9 @@ static void csis_client_release_set_cb(int err)
shell_print(ctx_shell, "Set released");
}
static void csis_client_ordered_access_cb(const struct bt_csis_client_set_info *set_info,
int err, bool locked,
struct bt_csis_client_set_member *member)
static void csip_set_coordinator_ordered_access_cb(
const struct bt_csip_set_coordinator_set_info *set_info, int err,
bool locked, struct bt_csip_set_coordinator_set_member *member)
{
if (err) {
printk("Ordered access failed with err %d\n", err);
@ -138,15 +138,15 @@ static void csis_client_ordered_access_cb(const struct bt_csis_client_set_info *
}
}
static struct bt_csis_client_cb cbs = {
.lock_set = csis_client_lock_set_cb,
.release_set = csis_client_release_set_cb,
.discover = csis_discover_cb,
.ordered_access = csis_client_ordered_access_cb
static struct bt_csip_set_coordinator_cb cbs = {
.lock_set = csip_set_coordinator_lock_set_cb,
.release_set = csip_set_coordinator_release_set_cb,
.discover = csip_discover_cb,
.ordered_access = csip_set_coordinator_ordered_access_cb
};
static bool csis_client_oap_cb(const struct bt_csis_client_set_info *set_info,
struct bt_csis_client_set_member *members[],
static bool csip_set_coordinator_oap_cb(const struct bt_csip_set_coordinator_set_info *set_info,
struct bt_csip_set_coordinator_set_member *members[],
size_t count)
{
for (size_t i = 0; i < count; i++) {
@ -156,14 +156,14 @@ static bool csis_client_oap_cb(const struct bt_csis_client_set_info *set_info,
return true;
}
static bool csis_found(struct bt_data *data, void *user_data)
static bool csip_found(struct bt_data *data, void *user_data)
{
if (bt_csis_client_is_set_member(cur_inst->info.set_sirk, data)) {
if (bt_csip_set_coordinator_is_set_member(cur_inst->info.set_sirk, data)) {
bt_addr_le_t *addr = user_data;
char addr_str[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(addr, addr_str, sizeof(addr_str));
shell_print(ctx_shell, "Found CSIS advertiser with address %s",
shell_print(ctx_shell, "Found CSIP advertiser with address %s",
addr_str);
if (is_discovered(addr)) {
@ -197,19 +197,19 @@ static bool csis_found(struct bt_data *data, void *user_data)
return true;
}
static void csis_client_scan_recv(const struct bt_le_scan_recv_info *info,
static void csip_set_coordinator_scan_recv(const struct bt_le_scan_recv_info *info,
struct net_buf_simple *ad)
{
/* We're only interested in connectable events */
if (info->adv_props & BT_GAP_ADV_PROP_CONNECTABLE) {
if (cur_inst != NULL) {
bt_data_parse(ad, csis_found, (void *)info->addr);
bt_data_parse(ad, csip_found, (void *)info->addr);
}
}
}
static struct bt_le_scan_cb csis_client_scan_callbacks = {
.recv = csis_client_scan_recv
static struct bt_le_scan_cb csip_set_coordinator_scan_callbacks = {
.recv = csip_set_coordinator_scan_recv
};
static void discover_members_timer_handler(struct k_work *work)
@ -225,7 +225,7 @@ static void discover_members_timer_handler(struct k_work *work)
}
}
static int cmd_csis_client_init(const struct shell *sh, size_t argc,
static int cmd_csip_set_coordinator_init(const struct shell *sh, size_t argc,
char *argv[])
{
static bool initialized;
@ -236,8 +236,8 @@ static int cmd_csis_client_init(const struct shell *sh, size_t argc,
k_work_init_delayable(&discover_members_timer,
discover_members_timer_handler);
bt_le_scan_cb_register(&csis_client_scan_callbacks);
bt_csis_client_register_cb(&cbs);
bt_le_scan_cb_register(&csip_set_coordinator_scan_callbacks);
bt_csip_set_coordinator_register_cb(&cbs);
bt_conn_cb_register(&conn_callbacks);
initialized = true;
@ -245,8 +245,8 @@ static int cmd_csis_client_init(const struct shell *sh, size_t argc,
return 0;
}
static int cmd_csis_client_discover(const struct shell *sh, size_t argc,
char *argv[])
static int cmd_csip_set_coordinator_discover(const struct shell *sh,
size_t argc, char *argv[])
{
char addr[BT_ADDR_LE_STR_LEN];
long member_index = 0;
@ -270,9 +270,10 @@ static int cmd_csis_client_discover(const struct shell *sh, size_t argc,
conn = conns[member_index];
bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
shell_print(sh, "Discovering for member[%u] (%s)",
(uint8_t)member_index, addr);
err = bt_csis_client_discover(conn);
err = bt_csip_set_coordinator_discover(conn);
if (err != 0) {
shell_error(sh, "Fail: %d", err);
}
@ -280,12 +281,12 @@ static int cmd_csis_client_discover(const struct shell *sh, size_t argc,
return err;
}
static int cmd_csis_client_discover_members(const struct shell *sh, size_t argc,
char *argv[])
static int cmd_csip_set_coordinator_discover_members(const struct shell *sh,
size_t argc, char *argv[])
{
int err;
cur_inst = (struct bt_csis_client_csis_inst *)strtol(argv[1], NULL, 0);
cur_inst = (struct bt_csip_set_coordinator_csis_inst *)strtol(argv[1], NULL, 0);
if (cur_inst == NULL) {
shell_error(sh, "NULL set");
@ -308,7 +309,7 @@ static int cmd_csis_client_discover_members(const struct shell *sh, size_t argc,
}
err = k_work_reschedule(&discover_members_timer,
CSIS_CLIENT_DISCOVER_TIMER_VALUE);
BT_CSIP_SET_COORDINATOR_DISCOVER_TIMER_VALUE);
if (err < 0) { /* Can return 0, 1 and 2 for success */
shell_error(sh,
"Could not schedule discover_members_timer %d",
@ -324,8 +325,8 @@ static int cmd_csis_client_discover_members(const struct shell *sh, size_t argc,
return err;
}
static int cmd_csis_client_lock_set(const struct shell *sh, size_t argc,
char *argv[])
static int cmd_csip_set_coordinator_lock_set(const struct shell *sh,
size_t argc, char *argv[])
{
int err;
int conn_count = 0;
@ -341,7 +342,8 @@ static int cmd_csis_client_lock_set(const struct shell *sh, size_t argc,
}
}
err = bt_csis_client_lock(locked_members, conn_count, &cur_inst->info);
err = bt_csip_set_coordinator_lock(locked_members, conn_count,
&cur_inst->info);
if (err != 0) {
shell_error(sh, "Fail: %d", err);
}
@ -349,8 +351,8 @@ static int cmd_csis_client_lock_set(const struct shell *sh, size_t argc,
return err;
}
static int cmd_csis_client_release_set(const struct shell *sh, size_t argc,
char *argv[])
static int cmd_csip_set_coordinator_release_set(const struct shell *sh,
size_t argc, char *argv[])
{
int err;
int conn_count = 0;
@ -366,7 +368,8 @@ static int cmd_csis_client_release_set(const struct shell *sh, size_t argc,
}
}
err = bt_csis_client_release(locked_members, conn_count, &cur_inst->info);
err = bt_csip_set_coordinator_release(locked_members, conn_count,
&cur_inst->info);
if (err != 0) {
shell_error(sh, "Fail: %d", err);
}
@ -374,12 +377,12 @@ static int cmd_csis_client_release_set(const struct shell *sh, size_t argc,
return err;
}
static int cmd_csis_client_ordered_access(const struct shell *sh, size_t argc,
char *argv[])
static int cmd_csip_set_coordinator_ordered_access(const struct shell *sh,
size_t argc, char *argv[])
{
int err;
long member_count = (long)ARRAY_SIZE(set_members);
const struct bt_csis_client_set_member *members[ARRAY_SIZE(set_members)];
const struct bt_csip_set_coordinator_set_member *members[ARRAY_SIZE(set_members)];
if (argc > 1) {
member_count = strtol(argv[1], NULL, 0);
@ -395,9 +398,10 @@ static int cmd_csis_client_ordered_access(const struct shell *sh, size_t argc,
members[i] = set_members[i];
}
err = bt_csis_client_ordered_access(members, ARRAY_SIZE(members),
err = bt_csip_set_coordinator_ordered_access(members,
ARRAY_SIZE(members),
&cur_inst->info,
csis_client_oap_cb);
csip_set_coordinator_oap_cb);
if (err != 0) {
shell_error(sh, "Fail: %d", err);
}
@ -405,12 +409,12 @@ static int cmd_csis_client_ordered_access(const struct shell *sh, size_t argc,
return err;
}
static int cmd_csis_client_lock(const struct shell *sh, size_t argc,
static int cmd_csip_set_coordinator_lock(const struct shell *sh, size_t argc,
char *argv[])
{
int err;
long member_index = 0;
const struct bt_csis_client_set_member *lock_member[1];
const struct bt_csip_set_coordinator_set_member *lock_member[1];
if (cur_inst == NULL) {
shell_error(sh, "No set selected");
@ -430,7 +434,7 @@ static int cmd_csis_client_lock(const struct shell *sh, size_t argc,
lock_member[0] = set_members[member_index];
err = bt_csis_client_lock(lock_member, 1, &cur_inst->info);
err = bt_csip_set_coordinator_lock(lock_member, 1, &cur_inst->info);
if (err != 0) {
shell_error(sh, "Fail: %d", err);
}
@ -438,12 +442,12 @@ static int cmd_csis_client_lock(const struct shell *sh, size_t argc,
return err;
}
static int cmd_csis_client_release(const struct shell *sh, size_t argc,
static int cmd_csip_set_coordinator_release(const struct shell *sh, size_t argc,
char *argv[])
{
int err;
long member_index = 0;
const struct bt_csis_client_set_member *lock_member[1];
const struct bt_csip_set_coordinator_set_member *lock_member[1];
if (cur_inst == NULL) {
shell_error(sh, "No set selected");
@ -463,7 +467,7 @@ static int cmd_csis_client_release(const struct shell *sh, size_t argc,
lock_member[0] = set_members[member_index];
err = bt_csis_client_release(lock_member, 1, &cur_inst->info);
err = bt_csip_set_coordinator_release(lock_member, 1, &cur_inst->info);
if (err != 0) {
shell_error(sh, "Fail: %d", err);
}
@ -471,7 +475,8 @@ static int cmd_csis_client_release(const struct shell *sh, size_t argc,
return err;
}
static int cmd_csis_client(const struct shell *sh, size_t argc, char **argv)
static int cmd_csip_set_coordinator(const struct shell *sh, size_t argc,
char **argv)
{
if (argc > 1) {
shell_error(sh, "%s unknown parameter: %s",
@ -483,34 +488,34 @@ static int cmd_csis_client(const struct shell *sh, size_t argc, char **argv)
return -ENOEXEC;
}
SHELL_STATIC_SUBCMD_SET_CREATE(csis_client_cmds,
SHELL_STATIC_SUBCMD_SET_CREATE(csip_set_coordinator_cmds,
SHELL_CMD_ARG(init, NULL,
"Initialize CSIS_CLIENT",
cmd_csis_client_init, 1, 1),
"Initialize csip_set_coordinator",
cmd_csip_set_coordinator_init, 1, 1),
SHELL_CMD_ARG(discover, NULL,
"Run discover for CSIS on peer device [member_index]",
cmd_csis_client_discover, 1, 1),
cmd_csip_set_coordinator_discover, 1, 1),
SHELL_CMD_ARG(discover_members, NULL,
"Scan for set members <set_pointer>",
cmd_csis_client_discover_members, 2, 0),
cmd_csip_set_coordinator_discover_members, 2, 0),
SHELL_CMD_ARG(lock_set, NULL,
"Lock set",
cmd_csis_client_lock_set, 1, 0),
cmd_csip_set_coordinator_lock_set, 1, 0),
SHELL_CMD_ARG(release_set, NULL,
"Release set",
cmd_csis_client_release_set, 1, 0),
cmd_csip_set_coordinator_release_set, 1, 0),
SHELL_CMD_ARG(lock, NULL,
"Lock specific member [member_index]",
cmd_csis_client_lock, 1, 1),
cmd_csip_set_coordinator_lock, 1, 1),
SHELL_CMD_ARG(release, NULL,
"Release specific member [member_index]",
cmd_csis_client_release, 1, 1),
cmd_csip_set_coordinator_release, 1, 1),
SHELL_CMD_ARG(ordered_access, NULL,
"Perform dummy ordered access procedure [member_count]",
cmd_csis_client_ordered_access, 1, 1),
cmd_csip_set_coordinator_ordered_access, 1, 1),
SHELL_SUBCMD_SET_END
);
SHELL_CMD_ARG_REGISTER(csis_client, &csis_client_cmds,
"Bluetooth CSIS_CLIENT shell commands",
cmd_csis_client, 1, 1);
SHELL_CMD_ARG_REGISTER(csip_set_coordinator, &csip_set_coordinator_cmds,
"Bluetooth csip_set_coordinator shell commands",
cmd_csip_set_coordinator, 1, 1);

View file

@ -60,10 +60,10 @@ CONFIG_BT_MICP_MIC_CTLR=y
CONFIG_BT_MICP_MIC_CTLR_MAX_AICS_INST=2
# Coordinated Set Identification
CONFIG_BT_CSIS=y
CONFIG_BT_CSIS_TEST_SAMPLE_DATA=y
CONFIG_BT_CSIS_CLIENT=y
CONFIG_BT_CSIS_CLIENT_TEST_SAMPLE_DATA=y
CONFIG_BT_CSIP=y
CONFIG_BT_CSIP_TEST_SAMPLE_DATA=y
CONFIG_BT_CSIP_SET_COORDINATOR=y
CONFIG_BT_CSIP_SET_COORDINATOR_TEST_SAMPLE_DATA=y
# Telephone bearer service
CONFIG_BT_TBS=y
@ -132,9 +132,9 @@ CONFIG_BT_DEBUG_MCC=y
CONFIG_BT_OTS_LOG_LEVEL_DBG=y
CONFIG_BT_DEBUG_OTS_CLIENT=y
CONFIG_MCTL_DEBUG=y
CONFIG_BT_DEBUG_CSIS=y
CONFIG_BT_DEBUG_CSIS_CLIENT=y
CONFIG_BT_DEBUG_CSIS_CRYPTO=y
CONFIG_BT_DEBUG_CSIP=y
CONFIG_BT_DEBUG_CSIP_SET_COORDINATOR=y
CONFIG_BT_DEBUG_CSIP_CRYPTO=y
CONFIG_BT_AUDIO_DEBUG_UNICAST_CLIENT=y
CONFIG_BT_AUDIO_DEBUG_UNICAST_SERVER=y
CONFIG_BT_AUDIO_DEBUG_BROADCAST_SINK=y

View file

@ -19,7 +19,7 @@ static const struct bt_data cap_acceptor_ad[] = {
BT_DATA_BYTES(BT_DATA_UUID16_ALL, BT_UUID_16_ENCODE(BT_UUID_CAS_VAL)),
};
static struct bt_csis *csis;
static struct bt_csip *csis;
CREATE_FLAG(flag_connected);
@ -45,7 +45,7 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
static void init(void)
{
struct bt_csis_register_param csis_param = {
struct bt_csip_register_param csis_param = {
.set_size = 3,
.rank = 1,
.lockable = true,

View file

@ -18,7 +18,7 @@ CREATE_FLAG(flag_discovered);
CREATE_FLAG(flag_mtu_exchanged);
static void cap_discovery_complete_cb(struct bt_conn *conn, int err,
const struct bt_csis_client_csis_inst *csis_inst)
const struct bt_csip_set_coordinator_csis_inst *csis_inst)
{
if (err != 0) {
FAIL("Failed to discover CAS: %d", err);

View file

@ -1,12 +1,12 @@
/*
* Copyright (c) 2019 Bose Corporation
* Copyright (c) 2020-2021 Nordic Semiconductor ASA
* Copyright (c) 2020-2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifdef CONFIG_BT_CSIS_CLIENT
#ifdef CONFIG_BT_CSIP_SET_COORDINATOR
#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/audio/csis.h>
#include <zephyr/bluetooth/audio/csip.h>
#include "common.h"
extern enum bst_result_t bst_result;
@ -17,17 +17,17 @@ static volatile bool set_locked;
static volatile bool set_unlocked;
static volatile bool ordered_access_locked;
static volatile bool ordered_access_unlocked;
static const struct bt_csis_client_csis_inst *inst;
static const struct bt_csip_set_coordinator_csis_inst *inst;
static uint8_t members_found;
static struct k_work_delayable discover_members_timer;
static bt_addr_le_t addr_found[CONFIG_BT_MAX_CONN];
static struct bt_conn *conns[CONFIG_BT_MAX_CONN];
static const struct bt_csis_client_set_member *set_members[CONFIG_BT_MAX_CONN];
static const struct bt_csip_set_coordinator_set_member *set_members[CONFIG_BT_MAX_CONN];
static void csis_client_lock_set_cb(int err);
static void csip_set_coordinator_lock_set_cb(int err);
static void csis_client_lock_release_cb(int err)
static void csip_set_coordinator_lock_release_cb(int err)
{
printk("%s\n", __func__);
@ -39,7 +39,7 @@ static void csis_client_lock_release_cb(int err)
set_unlocked = true;
}
static void csis_client_lock_set_cb(int err)
static void csip_set_coordinator_lock_set_cb(int err)
{
printk("%s\n", __func__);
@ -51,8 +51,8 @@ static void csis_client_lock_set_cb(int err)
set_locked = true;
}
static void csis_discover_cb(struct bt_conn *conn,
const struct bt_csis_client_set_member *member,
static void csip_discover_cb(struct bt_conn *conn,
const struct bt_csip_set_coordinator_set_member *member,
int err, size_t set_count)
{
uint8_t conn_index;
@ -71,15 +71,15 @@ static void csis_discover_cb(struct bt_conn *conn,
discovered = true;
}
static void csis_lock_changed_cb(struct bt_csis_client_csis_inst *inst,
static void csip_lock_changed_cb(struct bt_csip_set_coordinator_csis_inst *inst,
bool locked)
{
printk("Inst %p %s\n", inst, locked ? "locked" : "released");
}
static void csis_client_ordered_access_cb(const struct bt_csis_client_set_info *set_info,
int err, bool locked,
struct bt_csis_client_set_member *member)
static void csip_set_coordinator_ordered_access_cb(
const struct bt_csip_set_coordinator_set_info *set_info, int err,
bool locked, struct bt_csip_set_coordinator_set_member *member)
{
if (err) {
FAIL("Ordered access failed with err %d\n", err);
@ -117,16 +117,16 @@ static struct bt_conn_cb conn_callbacks = {
.connected = connected,
};
static struct bt_csis_client_cb cbs = {
.lock_set = csis_client_lock_set_cb,
.release_set = csis_client_lock_release_cb,
.discover = csis_discover_cb,
.lock_changed = csis_lock_changed_cb,
.ordered_access = csis_client_ordered_access_cb
static struct bt_csip_set_coordinator_cb cbs = {
.lock_set = csip_set_coordinator_lock_set_cb,
.release_set = csip_set_coordinator_lock_release_cb,
.discover = csip_discover_cb,
.lock_changed = csip_lock_changed_cb,
.ordered_access = csip_set_coordinator_ordered_access_cb
};
static bool csis_client_oap_cb(const struct bt_csis_client_set_info *set_info,
struct bt_csis_client_set_member *members[],
static bool csip_set_coordinator_oap_cb(const struct bt_csip_set_coordinator_set_info *set_info,
struct bt_csip_set_coordinator_set_member *members[],
size_t count)
{
for (size_t i = 0; i < count; i++) {
@ -146,14 +146,14 @@ static bool is_discovered(const bt_addr_le_t *addr)
return false;
}
static bool csis_found(struct bt_data *data, void *user_data)
static bool csip_found(struct bt_data *data, void *user_data)
{
if (bt_csis_client_is_set_member(inst->info.set_sirk, data)) {
if (bt_csip_set_coordinator_is_set_member(inst->info.set_sirk, data)) {
const bt_addr_le_t *addr = user_data;
char addr_str[BT_ADDR_LE_STR_LEN];
bt_addr_le_to_str(addr, addr_str, sizeof(addr_str));
printk("Found CSIS advertiser with address %s\n", addr_str);
printk("Found CSIP advertiser with address %s\n", addr_str);
if (is_discovered(addr)) {
printk("Set member already found\n");
@ -173,7 +173,7 @@ static bool csis_found(struct bt_data *data, void *user_data)
return true;
}
static void csis_client_scan_recv(const struct bt_le_scan_recv_info *info,
static void csip_set_coordinator_scan_recv(const struct bt_le_scan_recv_info *info,
struct net_buf_simple *ad)
{
/* We're only interested in connectable events */
@ -185,13 +185,13 @@ static void csis_client_scan_recv(const struct bt_le_scan_recv_info *info,
info->addr);
}
} else { /* Scanning for set members */
bt_data_parse(ad, csis_found, (void *)info->addr);
bt_data_parse(ad, csip_found, (void *)info->addr);
}
}
}
static struct bt_le_scan_cb csis_client_scan_callbacks = {
.recv = csis_client_scan_recv
static struct bt_le_scan_cb csip_set_coordinator_scan_callbacks = {
.recv = csip_set_coordinator_scan_recv
};
static void discover_members_timer_handler(struct k_work *work)
@ -200,7 +200,7 @@ static void discover_members_timer_handler(struct k_work *work)
members_found, inst->info.set_size);
}
static void ordered_access(const struct bt_csis_client_set_member **members,
static void ordered_access(const struct bt_csip_set_coordinator_set_member **members,
size_t count, bool expect_locked)
{
int err;
@ -214,10 +214,12 @@ static void ordered_access(const struct bt_csis_client_set_member **members,
ordered_access_unlocked = false;
}
err = bt_csis_client_ordered_access(members, count, &inst->info,
csis_client_oap_cb);
err = bt_csip_set_coordinator_ordered_access(members, count,
&inst->info,
csip_set_coordinator_oap_cb);
if (err != 0) {
FAIL("Failed to do CSIS client ordered access (%d)", err);
FAIL("Failed to do CSIP set coordinator ordered access (%d)",
err);
return;
}
@ -232,7 +234,7 @@ static void test_main(void)
{
int err;
char addr[BT_ADDR_LE_STR_LEN];
const struct bt_csis_client_set_member *locked_members[CONFIG_BT_MAX_CONN];
const struct bt_csip_set_coordinator_set_member *locked_members[CONFIG_BT_MAX_CONN];
uint8_t connected_member_count = 0;
err = bt_enable(NULL);
@ -244,10 +246,10 @@ static void test_main(void)
printk("Audio Client: Bluetooth initialized\n");
bt_conn_cb_register(&conn_callbacks);
bt_csis_client_register_cb(&cbs);
bt_csip_set_coordinator_register_cb(&cbs);
k_work_init_delayable(&discover_members_timer,
discover_members_timer_handler);
bt_le_scan_cb_register(&csis_client_scan_callbacks);
bt_le_scan_cb_register(&csip_set_coordinator_scan_callbacks);
err = bt_le_scan_start(BT_LE_SCAN_PASSIVE, NULL);
if (err != 0) {
@ -278,9 +280,9 @@ static void test_main(void)
WAIT_FOR_COND(is_connected);
connected_member_count++;
err = bt_csis_client_discover(conns[0]);
err = bt_csip_set_coordinator_discover(conns[0]);
if (err != 0) {
FAIL("Failed to initialize CSIS client for connection %d\n",
FAIL("Failed to initialize set coordinator for connection %d\n",
err);
return;
}
@ -294,7 +296,7 @@ static void test_main(void)
}
err = k_work_reschedule(&discover_members_timer,
CSIS_CLIENT_DISCOVER_TIMER_VALUE);
BT_CSIP_SET_COORDINATOR_DISCOVER_TIMER_VALUE);
if (err < 0) { /* Can return 0, 1 and 2 for success */
FAIL("Could not schedule discover_members_timer %d", err);
return;
@ -329,9 +331,9 @@ static void test_main(void)
discovered = false;
printk("Doing discovery on member[%u]", i);
err = bt_csis_client_discover(conns[i]);
err = bt_csip_set_coordinator_discover(conns[i]);
if (err != 0) {
FAIL("Failed to initialize CSIS client for connection %d\n",
FAIL("Failed to initialize set coordinator for connection %d\n",
err);
return;
}
@ -346,10 +348,10 @@ static void test_main(void)
ordered_access(locked_members, connected_member_count, false);
printk("Locking set\n");
err = bt_csis_client_lock(locked_members, connected_member_count,
err = bt_csip_set_coordinator_lock(locked_members, connected_member_count,
&inst->info);
if (err != 0) {
FAIL("Failed to do CSIS client lock (%d)", err);
FAIL("Failed to do set coordinator lock (%d)", err);
return;
}
@ -360,10 +362,10 @@ static void test_main(void)
k_sleep(K_MSEC(1000)); /* Simulate doing stuff */
printk("Releasing set\n");
err = bt_csis_client_release(locked_members, connected_member_count,
err = bt_csip_set_coordinator_release(locked_members, connected_member_count,
&inst->info);
if (err != 0) {
FAIL("Failed to do CSIS client release (%d)", err);
FAIL("Failed to do set coordinator release (%d)", err);
return;
}
@ -376,10 +378,10 @@ static void test_main(void)
set_unlocked = false;
printk("Locking set\n");
err = bt_csis_client_lock(locked_members, connected_member_count,
err = bt_csip_set_coordinator_lock(locked_members, connected_member_count,
&inst->info);
if (err != 0) {
FAIL("Failed to do CSIS client lock (%d)", err);
FAIL("Failed to do set coordinator lock (%d)", err);
return;
}
@ -388,10 +390,10 @@ static void test_main(void)
k_sleep(K_MSEC(1000)); /* Simulate doing stuff */
printk("Releasing set\n");
err = bt_csis_client_release(locked_members, connected_member_count,
err = bt_csip_set_coordinator_release(locked_members, connected_member_count,
&inst->info);
if (err != 0) {
FAIL("Failed to do CSIS client release (%d)", err);
FAIL("Failed to do set coordinator release (%d)", err);
return;
}
@ -414,7 +416,7 @@ static void test_main(void)
static const struct bst_test_instance test_connect[] = {
{
.test_id = "csis_client",
.test_id = "csip_set_coordinator",
.test_post_init_f = test_init,
.test_tick_f = test_tick,
.test_main_f = test_main
@ -423,14 +425,14 @@ static const struct bst_test_instance test_connect[] = {
BSTEST_END_MARKER
};
struct bst_test_list *test_csis_client_install(struct bst_test_list *tests)
struct bst_test_list *test_csip_set_coordinator_install(struct bst_test_list *tests)
{
return bst_add_tests(tests, test_connect);
}
#else
struct bst_test_list *test_csis_client_install(struct bst_test_list *tests)
struct bst_test_list *test_csip_set_coordinator_install(struct bst_test_list *tests)
{
return tests;
}
#endif /* CONFIG_BT_CSIS_CLIENT */
#endif /* CONFIG_BT_CSIP_SET_COORDINATOR */

View file

@ -1,20 +1,20 @@
/*
* Copyright (c) 2019 Bose Corporation
* Copyright (c) 2020-2021 Nordic Semiconductor ASA
* Copyright (c) 2020-2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifdef CONFIG_BT_CSIS
#include <zephyr/bluetooth/audio/csis.h>
#ifdef CONFIG_BT_CSIP
#include <zephyr/bluetooth/audio/csip.h>
#include "common.h"
static struct bt_csis *csis;
static struct bt_csip *csip;
static struct bt_conn_cb conn_callbacks;
extern enum bst_result_t bst_result;
static volatile bool g_locked;
static uint8_t sirk_read_req_rsp = BT_CSIS_READ_SIRK_REQ_RSP_ACCEPT;
struct bt_csis_register_param param = {
static uint8_t sirk_read_req_rsp = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT;
struct bt_csip_register_param param = {
.set_size = 3,
.rank = 1,
.lockable = true,
@ -36,7 +36,7 @@ static void connected(struct bt_conn *conn, uint8_t err)
printk("Connected\n");
}
static void csis_disconnected(struct bt_conn *conn, uint8_t reason)
static void csip_disconnected(struct bt_conn *conn, uint8_t reason)
{
printk("Disconnected (reason %u)\n", reason);
@ -47,29 +47,29 @@ static void csis_disconnected(struct bt_conn *conn, uint8_t reason)
}
}
static void csis_lock_changed_cb(struct bt_conn *conn, struct bt_csis *csis,
static void csip_lock_changed_cb(struct bt_conn *conn, struct bt_csip *csip,
bool locked)
{
printk("Client %p %s the lock\n", conn, locked ? "locked" : "released");
g_locked = locked;
}
static uint8_t sirk_read_req_cb(struct bt_conn *conn, struct bt_csis *csis)
static uint8_t sirk_read_req_cb(struct bt_conn *conn, struct bt_csip *csip)
{
return sirk_read_req_rsp;
}
static struct bt_csis_cb csis_cbs = {
.lock_changed = csis_lock_changed_cb,
static struct bt_csip_cb csip_cbs = {
.lock_changed = csip_lock_changed_cb,
.sirk_read_req = sirk_read_req_cb,
};
static void bt_ready(int err)
{
uint8_t rsi[BT_CSIS_RSI_SIZE];
uint8_t rsi[BT_CSIP_RSI_SIZE];
struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
BT_CSIS_DATA_RSI(rsi),
BT_CSIP_DATA_RSI(rsi),
};
if (err != 0) {
@ -79,15 +79,15 @@ static void bt_ready(int err)
printk("Audio Server: Bluetooth initialized\n");
param.cb = &csis_cbs;
param.cb = &csip_cbs;
err = bt_csis_register(&param, &csis);
err = bt_csip_register(&param, &csip);
if (err != 0) {
FAIL("Could not register CSIS (err %d)\n", err);
FAIL("Could not register CSIP (err %d)\n", err);
return;
}
err = bt_csis_generate_rsi(csis, rsi);
err = bt_csip_generate_rsi(csip, rsi);
if (err != 0) {
FAIL("Failed to generate RSI (err %d)\n", err);
return;
@ -101,7 +101,7 @@ static void bt_ready(int err)
static struct bt_conn_cb conn_callbacks = {
.connected = connected,
.disconnected = csis_disconnected,
.disconnected = csip_disconnected,
};
static void test_main(void)
@ -133,13 +133,13 @@ static void test_force_release(void)
WAIT_FOR_COND(g_locked);
printk("Force releasing set\n");
bt_csis_lock(csis, false, true);
bt_csip_lock(csip, false, true);
}
static void test_csis_enc(void)
static void test_csip_enc(void)
{
printk("Running %s\n", __func__);
sirk_read_req_rsp = BT_CSIS_READ_SIRK_REQ_RSP_ACCEPT_ENC;
sirk_read_req_rsp = BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT_ENC;
test_main();
}
@ -173,39 +173,39 @@ static void test_args(int argc, char *argv[])
static const struct bst_test_instance test_connect[] = {
{
.test_id = "csis",
.test_id = "csip",
.test_post_init_f = test_init,
.test_tick_f = test_tick,
.test_main_f = test_main,
.test_args_f = test_args,
},
{
.test_id = "csis_release",
.test_id = "csip_release",
.test_post_init_f = test_init,
.test_tick_f = test_tick,
.test_main_f = test_force_release,
.test_args_f = test_args,
},
{
.test_id = "csis_enc",
.test_id = "csip_enc",
.test_post_init_f = test_init,
.test_tick_f = test_tick,
.test_main_f = test_csis_enc,
.test_main_f = test_csip_enc,
.test_args_f = test_args,
},
BSTEST_END_MARKER
};
struct bst_test_list *test_csis_install(struct bst_test_list *tests)
struct bst_test_list *test_csip_install(struct bst_test_list *tests)
{
return bst_add_tests(tests, test_connect);
}
#else
struct bst_test_list *test_csis_install(struct bst_test_list *tests)
struct bst_test_list *test_csip_install(struct bst_test_list *tests)
{
return tests;
}
#endif /* CONFIG_BT_CSIS */
#endif /* CONFIG_BT_CSIP */

View file

@ -10,8 +10,8 @@ extern struct bst_test_list *test_vcs_install(struct bst_test_list *tests);
extern struct bst_test_list *test_vcs_client_install(struct bst_test_list *tests);
extern struct bst_test_list *test_micp_install(struct bst_test_list *tests);
extern struct bst_test_list *test_micp_mic_ctlr_install(struct bst_test_list *tests);
extern struct bst_test_list *test_csis_install(struct bst_test_list *tests);
extern struct bst_test_list *test_csis_client_install(struct bst_test_list *tests);
extern struct bst_test_list *test_csip_install(struct bst_test_list *tests);
extern struct bst_test_list *test_csip_set_coordinator_install(struct bst_test_list *tests);
extern struct bst_test_list *test_tbs_install(struct bst_test_list *tests);
extern struct bst_test_list *test_tbs_client_install(struct bst_test_list *tests);
extern struct bst_test_list *test_mcs_install(struct bst_test_list *tests);
@ -36,8 +36,8 @@ bst_test_install_t test_installers[] = {
test_vcs_client_install,
test_micp_install,
test_micp_mic_ctlr_install,
test_csis_install,
test_csis_client_install,
test_csip_install,
test_csip_set_coordinator_install,
test_tbs_install,
test_tbs_client_install,
test_mcs_install,

View file

@ -1,12 +1,12 @@
#!/usr/bin/env bash
#
# Copyright (c) 2020-2021 Nordic Semiconductor ASA
# Copyright (c) 2020-2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
# Basic CSIS test. A set coordinator (CSIS client) connects to multiple set
# devices (CSIS), lock thems, unlocks them and disconnects.
SIMULATION_ID="csis_csip"
# Basic CSIP test. A set coordinator connects to multiple set members
# lock thems, unlocks them and disconnects.
SIMULATION_ID="csip"
VERBOSITY_LEVEL=2
PROCESS_IDS=""; EXIT_CODE=0
@ -29,19 +29,19 @@ cd ${BSIM_OUT_PATH}/bin
# NORMAL TEST
printf "\n\n======== Running normal test ========\n\n"
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=csis_client \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=csip_set_coordinator \
-RealEncryption=1 -rs=1
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=1 -testid=csis \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=1 -testid=csip \
-RealEncryption=1 -rs=2 -argstest rank 1
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=2 -testid=csis \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=2 -testid=csip \
-RealEncryption=1 -rs=3 -argstest rank 2
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=3 -testid=csis \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=3 -testid=csip \
-RealEncryption=1 -rs=4 -argstest rank 3
# Simulation time should be larger than the WAIT_TIME in common.h
@ -57,19 +57,19 @@ PROCESS_IDS="";
# TEST WITH FORCE RELEASE
printf "\n\n======== Running test with forced release of lock ========\n\n"
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=csis_client \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=csip_set_coordinator \
-RealEncryption=1 -rs=1
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=1 -testid=csis \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=1 -testid=csip \
-RealEncryption=1 -rs=2 -argstest rank 1
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=2 -testid=csis \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=2 -testid=csip \
-RealEncryption=1 -rs=3 -argstest rank 2
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=3 -testid=csis_release \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=3 -testid=csip_release \
-RealEncryption=1 -rs=4 -argstest rank 3
# Simulation time should be larger than the WAIT_TIME in common.h
@ -83,19 +83,19 @@ done
# TEST WITH SIRK ENC
printf "\n\n======== Running test with SIRK encrypted ========\n\n"
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=csis_client \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=csip_set_coordinator \
-RealEncryption=1 -rs=1
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=1 -testid=csis_enc \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=1 -testid=csip_enc \
-RealEncryption=1 -rs=2 -argstest rank 1
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=2 -testid=csis_enc \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=2 -testid=csip_enc \
-RealEncryption=1 -rs=3 -argstest rank 2
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=3 -testid=csis_enc \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=3 -testid=csip_enc \
-RealEncryption=1 -rs=4 -argstest rank 3
# Simulation time should be larger than the WAIT_TIME in common.h

View file

@ -83,9 +83,9 @@ CONFIG_BT_MICP_MIC_CTLR=y
CONFIG_BT_MICP_MIC_CTLR_MAX_AICS_INST=1
# Coordinated Set Identification
CONFIG_BT_CSIS=y
CONFIG_BT_CSIS_CLIENT=y
CONFIG_BT_CSIS_CLIENT_MAX_CSIS_INSTANCES=2
CONFIG_BT_CSIP=y
CONFIG_BT_CSIP_SET_COORDINATOR=y
CONFIG_BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES=2
CONFIG_MCTL=y
CONFIG_MCTL_LOCAL_PLAYER_CONTROL=y
@ -162,4 +162,4 @@ CONFIG_BT_DEBUG_VOCS_CLIENT=y
CONFIG_BT_DEBUG_AICS=y
CONFIG_BT_DEBUG_VOCS=y
CONFIG_BT_AUDIO_DEBUG_STREAM=y
CONFIG_BT_DEBUG_CSIS_CLIENT=y
CONFIG_BT_DEBUG_CSIP_SET_COORDINATOR=y