2021-10-21 12:04:16 +02:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Internal APIs for Bluetooth CSIS
|
|
|
|
*
|
|
|
|
* Copyright (c) 2021 Nordic Semiconductor ASA
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2021-10-26 16:36:33 +02:00
|
|
|
#include <bluetooth/audio/csis.h>
|
2021-10-21 12:04:16 +02:00
|
|
|
|
|
|
|
struct csis_pending_notifications {
|
|
|
|
bt_addr_le_t addr;
|
|
|
|
bool pending;
|
|
|
|
bool active;
|
|
|
|
|
|
|
|
/* Since there's a 1-to-1 connection between bonded devices, and devices in
|
|
|
|
* the array containing this struct, if the security manager overwrites
|
|
|
|
* the oldest keys, we also overwrite the oldest entry
|
|
|
|
*/
|
|
|
|
#if IS_ENABLED(CONFIG_BT_KEYS_OVERWRITE_OLDEST)
|
|
|
|
uint32_t age;
|
|
|
|
#endif /* CONFIG_BT_KEYS_OVERWRITE_OLDEST */
|
|
|
|
};
|
|
|
|
|
2021-11-24 11:06:13 +01:00
|
|
|
struct bt_csis_set_sirk {
|
|
|
|
uint8_t type;
|
|
|
|
uint8_t value[BT_CSIS_SET_SIRK_SIZE];
|
|
|
|
} __packed;
|
|
|
|
|
2021-11-22 14:14:10 +01:00
|
|
|
struct bt_csis_client_svc_inst {
|
|
|
|
uint8_t rank;
|
|
|
|
uint8_t set_lock;
|
|
|
|
|
|
|
|
uint16_t start_handle;
|
|
|
|
uint16_t end_handle;
|
|
|
|
uint16_t set_sirk_handle;
|
|
|
|
uint16_t set_size_handle;
|
|
|
|
uint16_t set_lock_handle;
|
|
|
|
uint16_t rank_handle;
|
|
|
|
|
|
|
|
uint8_t idx;
|
|
|
|
struct bt_gatt_subscribe_params sirk_sub_params;
|
|
|
|
struct bt_gatt_discover_params sirk_sub_disc_params;
|
|
|
|
struct bt_gatt_subscribe_params size_sub_params;
|
|
|
|
struct bt_gatt_discover_params size_sub_disc_params;
|
|
|
|
struct bt_gatt_subscribe_params lock_sub_params;
|
|
|
|
struct bt_gatt_discover_params lock_sub_disc_params;
|
|
|
|
|
|
|
|
struct bt_conn *conn;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* TODO: Rename to bt_csis_svc_inst */
|
2021-10-21 12:04:16 +02:00
|
|
|
struct bt_csis_server {
|
|
|
|
struct bt_csis_set_sirk set_sirk;
|
|
|
|
uint8_t psri[BT_CSIS_PSRI_SIZE];
|
|
|
|
uint8_t set_size;
|
|
|
|
uint8_t set_lock;
|
|
|
|
uint8_t rank;
|
|
|
|
bool adv_enabled;
|
|
|
|
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];
|
|
|
|
#if IS_ENABLED(CONFIG_BT_KEYS_OVERWRITE_OLDEST)
|
|
|
|
uint32_t age_counter;
|
|
|
|
#endif /* CONFIG_BT_KEYS_OVERWRITE_OLDEST */
|
|
|
|
#if defined(CONFIG_BT_EXT_ADV)
|
|
|
|
uint8_t conn_cnt;
|
|
|
|
struct bt_le_ext_adv *adv;
|
|
|
|
struct bt_le_ext_adv_cb adv_cb;
|
|
|
|
struct k_work work;
|
|
|
|
#endif /* CONFIG_BT_EXT_ADV */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bt_csis {
|
2021-11-22 14:14:10 +01:00
|
|
|
bool client_instance;
|
2021-10-21 12:04:16 +02:00
|
|
|
union {
|
2021-11-22 14:14:10 +01:00
|
|
|
#if defined(CONFIG_BT_CSIS)
|
2021-10-21 12:04:16 +02:00
|
|
|
struct bt_csis_server srv;
|
2021-11-22 14:14:10 +01:00
|
|
|
#endif /* CONFIG_BT_CSIS */
|
|
|
|
#if defined(CONFIG_BT_CSIS_CLIENT)
|
|
|
|
struct bt_csis_client_svc_inst cli;
|
|
|
|
#endif /* CONFIG_BT_CSIS_CLIENT */
|
2021-10-21 12:04:16 +02:00
|
|
|
};
|
|
|
|
};
|