hpw422移植新的sdk

This commit is contained in:
xushaoxiang
2026-07-03 18:08:25 +08:00
commit 945a5a5b0b
2583 changed files with 713209 additions and 0 deletions
+133
View File
@@ -0,0 +1,133 @@
/**
****************************************************************************************
*
* @file ahi.h
*
* @brief This file contains definitions related to the Application Host Interface
*
* Copyright (C) RivieraWaves 2009-2015
*
*
****************************************************************************************
*/
#ifndef AHI_H_
#define AHI_H_
/**
****************************************************************************************
* @addtogroup AHI Application Host Interface
* @ingroup AHI
* @brief Application Host Interface, based on AHI functionality.
*
*@{
*
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // SW configuration
#if (AHI_TL_SUPPORT)
#include <stdint.h>
/*
* Defines
****************************************************************************************
*/
/// Kernel message type
#define AHI_KE_MSG_TYPE 0x10
/// Kernel message header length for transport through interface between App and SW stack.
#define AHI_KE_MSG_HDR_LEN 8
/// Maximum number of advertising reports that can be queued
#define AHI_MAX_ADV_REPORT 10
/// GAPM Reset size (LC + KE_HEADER + Reset_operation code)
#define AHI_RESET_MSG_LEN (1+AHI_KE_MSG_HDR_LEN+1)
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/*
* GLOBAL VARIABLE DECLARATIONS
****************************************************************************************
*/
extern const uint8_t ahi_reset_msg[AHI_RESET_MSG_LEN];
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief AHI initialization function: initializes states and transport.
*****************************************************************************************
*/
void ahi_init(void);
/**
****************************************************************************************
* @brief Handle received AHI header through transport layer
*
* @param[in] p_hdr_data Pointer to received header
* @param[out] p_rem_length Pointer to returned remaining length to receive.
*
* @return Pointer to data buffer where remaining data can be pushed.
****************************************************************************************
*/
uint8_t* ahi_rx_hdr_handle(uint8_t* p_hdr_data, uint16_t* p_rem_length);
/**
****************************************************************************************
* @brief Inform AHI that payload data has been received
*
* @param[in] p_data Pointer to received payload
****************************************************************************************
*/
void ahi_rx_done(uint8_t* p_data);
/**
****************************************************************************************
* @brief Reset pattern received, handle it at AHI level
****************************************************************************************
*/
void ahi_reset(void);
/**
****************************************************************************************
* @brief Retrieve Task Identifier from Task number
* (automatically update index of task in returned task id)
*
* @param task Task number
* @return Task Identifier
****************************************************************************************
*/
uint16_t ahi_get_id_from_task(uint16_t task);
/**
****************************************************************************************
* @brief Retrieve Task Number from Task Identifier
* (automatically update index of task in returned task id)
*
* @param id Task Identifier
* @return Task Number
****************************************************************************************
*/
uint16_t ahi_get_task_from_id(uint16_t id);
#endif //AHI_TL_SUPPORT
/// @} AHI
#endif // AHI_H_
+468
View File
@@ -0,0 +1,468 @@
/**
****************************************************************************************
* @file xc_gap_api.c
* @brief GAP APIs source code
* Copyright (c) 2022 - 2025, XinChip
* All rights reserved.
****************************************************************************************
*/
#include "rwip_config.h"
#if BLE_APP_PRESENT
#include "xc_gap_api.h"
//void xc_ble_gapm_reset(void)
//{
// // Reset the stack
// struct gapm_reset_cmd *p_cmd =
// KE_MSG_ALLOC(GAPM_RESET_CMD, TASK_GAPM, TASK_APP, gapm_reset_cmd);
// p_cmd->operation = GAPM_RESET;
// ke_msg_send(p_cmd);
//}
//void xc_ble_set_dev_config(struct gapm_set_dev_config_cmd *cfg_param)
//{
// struct gapm_set_dev_config_cmd *p_cmd = KE_MSG_ALLOC(
// GAPM_SET_DEV_CONFIG_CMD, TASK_GAPM, TASK_APP, gapm_set_dev_config_cmd);
// memcpy(p_cmd, cfg_param, sizeof(struct gapm_set_dev_config_cmd));
// p_cmd->operation = GAPM_SET_DEV_CONFIG;
// ke_msg_send(p_cmd);
//}
void xc_ble_get_dev_info(struct gapm_get_dev_info_cmd *cmd)
{
struct gapm_get_dev_info_cmd *p_cmd = KE_MSG_ALLOC(
GAPM_GET_DEV_INFO_CMD, TASK_GAPM, TASK_APP, gapm_get_dev_info_cmd);
p_cmd->operation = cmd->operation;
ke_msg_send(p_cmd);
}
void xc_ble_resolve_addr(uint8_t nb_key, gap_addr_t *addr, uint8_t *irk)
{
struct gapm_resolv_addr_cmd *p_cmd = KE_MSG_ALLOC_DYN(
GAPM_RESOLV_ADDR_CMD, TASK_GAPM, TASK_APP, gapm_resolv_addr_cmd,
(nb_key * sizeof(struct gap_sec_key)));
memcpy(&p_cmd->addr.addr[0], &addr->addr[0], GAP_BD_ADDR_LEN);
memcpy(&p_cmd->irk[0].key[0], &irk[0], GAP_KEY_LEN * nb_key);
p_cmd->nb_key = nb_key;
p_cmd->operation = GAPM_RESOLV_ADDR;
ke_msg_send(p_cmd);
}
void xc_ble_gen_random_addr(struct gapm_gen_rand_addr_cmd *p_param)
{
struct gapm_gen_rand_addr_cmd *p_cmd = KE_MSG_ALLOC(
GAPM_GEN_RAND_ADDR_CMD, TASK_GAPM, TASK_APP, gapm_gen_rand_addr_cmd);
memcpy(p_cmd, p_param, sizeof(struct gapm_gen_rand_addr_cmd));
p_cmd->operation = GAPM_GEN_RAND_ADDR;
ke_msg_send(p_cmd);
}
#if (BLE_SEC_CON)
void xc_ble_get_pub_key(void)
{
struct gapm_get_pub_key_cmd *p_cmd = KE_MSG_ALLOC(
GAPM_GET_PUB_KEY_CMD, TASK_GAPM, TASK_APP, gapm_get_pub_key_cmd);
p_cmd->operation = GAPM_GET_PUB_KEY;
ke_msg_send(p_cmd);
}
#endif // (BLE_SEC_CON)
void xc_ble_gen_random_nb(void)
{
struct gapm_gen_rand_nb_cmd *p_cmd = KE_MSG_ALLOC(
GAPM_GEN_RAND_NB_CMD, TASK_GAPM, TASK_APP, gapm_gen_rand_nb_cmd);
p_cmd->operation = GAPM_GEN_RAND_NB;
ke_msg_send(p_cmd);
}
void xc_ble_set_irk(gap_sec_key_t *irk)
{
struct gapm_set_irk_cmd *p_cmd =
KE_MSG_ALLOC(GAPM_SET_IRK_CMD, TASK_GAPM, TASK_APP, gapm_set_irk_cmd);
p_cmd->operation = GAPM_SET_IRK;
memcpy(p_cmd->irk.key, irk->key, GAP_KEY_LEN);
ke_msg_send(p_cmd);
}
void xc_ble_get_ral_addr(struct gapm_get_ral_addr_cmd *p_param)
{
struct gapm_get_ral_addr_cmd *p_cmd = KE_MSG_ALLOC(
GAPM_GET_RAL_ADDR_CMD, TASK_GAPM, TASK_APP, gapm_get_ral_addr_cmd);
memcpy(p_cmd, p_param, sizeof(struct gapm_get_ral_addr_cmd));
p_cmd->operation = p_param->operation;
ke_msg_send(p_cmd);
}
void xc_ble_set_ral_list(uint8_t size, struct gap_ral_dev_info *ral_info)
{
struct gapm_list_set_ral_cmd *p_cmd = KE_MSG_ALLOC_DYN(
GAPM_LIST_SET_CMD, TASK_GAPM, TASK_APP, gapm_list_set_ral_cmd,
(size * sizeof(struct gap_ral_dev_info)));
p_cmd->size = size;
memcpy(&p_cmd->ral_info, ral_info, sizeof(struct gap_ral_dev_info) * size);
p_cmd->operation = GAPM_SET_RAL;
ke_msg_send(p_cmd);
}
void xc_ble_set_white_list(uint8_t size, gap_bdaddr_t *wl_info)
{
struct gapm_list_set_wl_cmd *p_cmd = KE_MSG_ALLOC_DYN(
GAPM_LIST_SET_CMD, TASK_GAPM, TASK_APP, gapm_list_set_wl_cmd,
(size * sizeof(struct gap_bdaddr)));
p_cmd->size = size;
memcpy(&p_cmd->wl_info, wl_info, sizeof(struct gap_bdaddr) * size);
p_cmd->operation = GAPM_SET_WL;
ke_msg_send(p_cmd);
}
//void xc_ble_advertise_create(
// struct gapm_activity_create_adv_cmd *adv_creat_param)
//{
// struct gapm_activity_create_adv_cmd *p_cmd =
// KE_MSG_ALLOC(GAPM_ACTIVITY_CREATE_CMD, TASK_GAPM, TASK_APP,
// gapm_activity_create_adv_cmd);
// memcpy(p_cmd, adv_creat_param, sizeof(struct gapm_activity_create_adv_cmd));
// p_cmd->operation = GAPM_CREATE_ADV_ACTIVITY;
// ke_msg_send(p_cmd);
//}
//void xc_ble_set_adv_data(uint8_t actv_idx, uint16_t adv_data_length,
// uint8_t *p_adv_data)
//{
// struct gapm_set_adv_data_cmd *p_cmd =
// KE_MSG_ALLOC_DYN(GAPM_SET_ADV_DATA_CMD, TASK_GAPM, TASK_APP,
// gapm_set_adv_data_cmd, adv_data_length);
// p_cmd->operation = GAPM_SET_ADV_DATA;
// p_cmd->actv_idx = actv_idx;
// p_cmd->length = adv_data_length;
// memcpy(&p_cmd->data[0], p_adv_data, adv_data_length);
// ke_msg_send(p_cmd);
//}
void xc_ble_set_scan_rsp_data(uint8_t actv_idx, uint16_t scan_rsp_data_length,
uint8_t *p_scan_rsp_data)
{
struct gapm_set_adv_data_cmd *p_cmd =
KE_MSG_ALLOC_DYN(GAPM_SET_ADV_DATA_CMD, TASK_GAPM, TASK_APP,
gapm_set_adv_data_cmd, scan_rsp_data_length);
p_cmd->operation = GAPM_SET_SCAN_RSP_DATA;
p_cmd->actv_idx = actv_idx;
p_cmd->length = scan_rsp_data_length;
memcpy(&p_cmd->data[0], p_scan_rsp_data, scan_rsp_data_length);
ke_msg_send(p_cmd);
}
//void xc_ble_advertise_start(struct gapm_activity_start_cmd *adv_start_param)
//{
// struct gapm_activity_start_cmd *p_cmd = KE_MSG_ALLOC(
// GAPM_ACTIVITY_START_CMD, TASK_GAPM, TASK_APP, gapm_activity_start_cmd);
// memcpy(p_cmd, adv_start_param, sizeof(struct gapm_activity_start_cmd));
// p_cmd->operation = GAPM_START_ACTIVITY;
// ke_msg_send(p_cmd);
//}
void xc_ble_scan_create(struct gapm_activity_create_cmd *scan_creat_param)
{
struct gapm_activity_create_cmd *p_cmd =
KE_MSG_ALLOC(GAPM_ACTIVITY_CREATE_CMD, TASK_GAPM, TASK_APP,
gapm_activity_create_cmd);
memcpy(p_cmd, scan_creat_param, sizeof(struct gapm_activity_create_cmd));
p_cmd->operation = GAPM_CREATE_SCAN_ACTIVITY;
ke_msg_send(p_cmd);
}
void xc_ble_scan_start(struct gapm_activity_start_cmd *scan_start_param)
{
struct gapm_activity_start_cmd *p_cmd = KE_MSG_ALLOC(
GAPM_ACTIVITY_START_CMD, TASK_GAPM, TASK_APP, gapm_activity_start_cmd);
memcpy(p_cmd, scan_start_param, sizeof(struct gapm_activity_start_cmd));
p_cmd->operation = GAPM_START_ACTIVITY;
ke_msg_send(p_cmd);
}
void xc_ble_init_create(struct gapm_activity_create_cmd *init_creat_param)
{
struct gapm_activity_create_cmd *p_cmd =
KE_MSG_ALLOC(GAPM_ACTIVITY_CREATE_CMD, TASK_GAPM, TASK_APP,
gapm_activity_create_cmd);
memcpy(p_cmd, init_creat_param, sizeof(struct gapm_activity_create_cmd));
p_cmd->operation = GAPM_CREATE_INIT_ACTIVITY;
ke_msg_send(p_cmd);
}
void xc_ble_init_start(struct gapm_activity_start_cmd *init_start_param)
{
struct gapm_activity_start_cmd *p_cmd = KE_MSG_ALLOC(
GAPM_ACTIVITY_START_CMD, TASK_GAPM, TASK_APP, gapm_activity_start_cmd);
memcpy(p_cmd, init_start_param, sizeof(struct gapm_activity_start_cmd));
p_cmd->operation = GAPM_START_ACTIVITY;
p_cmd->u_param.init_param.conn_param_1m.ce_len_min = CE_LEN_MIN;
p_cmd->u_param.init_param.conn_param_1m.ce_len_max = CE_LEN_MAX;
p_cmd->u_param.init_param.conn_param_2m.ce_len_min = CE_LEN_MIN;
p_cmd->u_param.init_param.conn_param_2m.ce_len_max = CE_LEN_MAX;
p_cmd->u_param.init_param.conn_param_coded.ce_len_min = CE_LEN_MIN;
p_cmd->u_param.init_param.conn_param_coded.ce_len_max = CE_LEN_MAX;
ke_msg_send(p_cmd);
}
void xc_ble_activity_stop(int actv_idx)
{
struct gapm_activity_stop_cmd *p_cmd = KE_MSG_ALLOC(
GAPM_ACTIVITY_STOP_CMD, TASK_GAPM, TASK_APP, gapm_activity_stop_cmd);
if (actv_idx >= 0) {
p_cmd->operation = GAPM_STOP_ACTIVITY;
} else {
p_cmd->operation = GAPM_STOP_ALL_ACTIVITIES;
}
p_cmd->actv_idx = actv_idx;
ke_msg_send(p_cmd);
}
void xc_ble_activity_delete(int actv_idx)
{
struct gapm_activity_delete_cmd *p_cmd =
KE_MSG_ALLOC(GAPM_ACTIVITY_DELETE_CMD, TASK_GAPM, TASK_APP,
gapm_activity_delete_cmd);
if (actv_idx >= 0) {
p_cmd->operation = GAPM_DELETE_ACTIVITY;
} else {
p_cmd->operation = GAPM_DELETE_ALL_ACTIVITIES;
}
p_cmd->actv_idx = actv_idx;
ke_msg_send(p_cmd);
}
void xc_ble_disconnect(int conidx, uint32_t reason)
{
struct gapc_disconnect_cmd *p_cmd =
KE_MSG_ALLOC(GAPC_DISCONNECT_CMD, KE_BUILD_ID(TASK_GAPC, conidx),
TASK_APP, gapc_disconnect_cmd);
p_cmd->operation = GAPC_DISCONNECT;
p_cmd->reason = reason;
ke_msg_send(p_cmd);
}
//void xc_ble_update_param(int conidx, uint16_t intv_min, uint16_t intv_max,
// uint16_t latency, uint16_t time_out)
//{
// struct gapc_param_update_cmd *p_cmd =
// KE_MSG_ALLOC(GAPC_PARAM_UPDATE_CMD, KE_BUILD_ID(TASK_GAPC, conidx),
// TASK_APP, gapc_param_update_cmd);
// p_cmd->operation = GAPC_UPDATE_PARAMS;
// p_cmd->intv_min = intv_min;
// p_cmd->intv_max = intv_max;
// p_cmd->latency = latency;
// p_cmd->time_out = time_out;
// // not used by a slave device
// p_cmd->ce_len_min = CE_LEN_MIN;
// // p_cmd->ce_len_min = 0xFFFF;
// p_cmd->ce_len_max = CE_LEN_MAX;
// ke_msg_send(p_cmd);
//}
//void xc_ble_conn_cfm(int conidx, struct gapc_connection_cfm *p_cfm)
//{
// struct gapc_connection_cfm *p_cmd =
// KE_MSG_ALLOC(GAPC_CONNECTION_CFM, KE_BUILD_ID(TASK_GAPC, conidx),
// TASK_APP, gapc_connection_cfm);
// memcpy(p_cmd, p_cfm, sizeof(struct gapc_connection_cfm));
// ke_msg_send(p_cmd);
//}
#if (MIN_STACK)
void xc_ble_get_peer_info(int conidx, struct gapc_get_info_cmd *get_info)
{
struct gapc_get_info_cmd *p_cmd =
KE_MSG_ALLOC(GAPC_GET_INFO_CMD, KE_BUILD_ID(TASK_GAPC, conidx),
TASK_APP, gapc_get_info_cmd);
p_cmd->operation = get_info->operation;
ke_msg_send(p_cmd);
}
#endif // (MIN_STACK)
//void xc_ble_param_update_cfm(int conidx,
// struct gapc_param_update_cfm *update_cfm)
//{
// struct gapc_param_update_cfm *p_cmd =
// KE_MSG_ALLOC(GAPC_PARAM_UPDATE_CFM, KE_BUILD_ID(TASK_GAPC, conidx),
// TASK_APP, gapc_param_update_cfm);
// memcpy(p_cmd, update_cfm, sizeof(struct gapc_param_update_cfm));
// p_cmd->ce_len_min = CE_LEN_MIN;
// p_cmd->ce_len_max = CE_LEN_MAX;
// ke_msg_send(p_cmd);
//}
void xc_ble_bond(int conidx, struct gapc_bond_cmd *p_param)
{
struct gapc_bond_cmd *p_cmd = KE_MSG_ALLOC(
GAPC_BOND_CMD, KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP, gapc_bond_cmd);
memcpy(p_cmd, p_param, sizeof(struct gapc_bond_cmd));
p_cmd->operation = GAPC_BOND;
ke_msg_send(p_cmd);
}
void xc_ble_bond_cfm(int conidx, struct gapc_bond_cfm *p_param)
{
struct gapc_bond_cfm *p_cmd = KE_MSG_ALLOC(
GAPC_BOND_CFM, KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP, gapc_bond_cfm);
memcpy(p_cmd, p_param, sizeof(struct gapc_bond_cfm));
ke_msg_send(p_cmd);
}
//void xc_ble_get_dev_info_cfm(int conidx, struct gapc_get_dev_info_cfm *p_param)
//{
// if ((p_param->req == GAPC_DEV_NAME) ||
// (p_param->req == GAPC_DEV_APPEARANCE) ||
// (p_param->req == GAPC_DEV_SLV_PREF_PARAMS)) {
// ke_msg_send(p_param);
// } else {
// // do nothing;
// }
//}
//void xc_ble_set_dev_info_cfm(int conidx, struct gapc_set_dev_info_cfm *p_param)
//{
// struct gapc_set_dev_info_cfm *p_cmd =
// KE_MSG_ALLOC(GAPC_SET_DEV_INFO_CFM, KE_BUILD_ID(TASK_GAPC, conidx),
// TASK_APP, gapc_set_dev_info_cfm);
// memcpy(p_cmd, p_param, sizeof(struct gapc_set_dev_info_cfm));
// ke_msg_send(p_cmd);
//}
void xc_ble_encrypt(int conidx, struct gapc_encrypt_cmd *p_param)
{
struct gapc_encrypt_cmd *p_cmd =
KE_MSG_ALLOC(GAPC_ENCRYPT_CMD, KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP,
gapc_encrypt_cmd);
memcpy(p_cmd, p_param, sizeof(struct gapc_encrypt_cmd));
p_cmd->operation = GAPC_ENCRYPT;
ke_msg_send(p_cmd);
}
/// issue from master
void xc_ble_encrypt_cfm(int conidx, struct gapc_encrypt_cfm *p_param)
{
struct gapc_encrypt_cfm *p_cmd =
KE_MSG_ALLOC(GAPC_ENCRYPT_CFM, KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP,
gapc_encrypt_cfm);
memcpy(p_cmd, p_param, sizeof(struct gapc_encrypt_cfm));
ke_msg_send(p_cmd);
}
/// issue from slave
void xc_ble_req_security(int conidx, uint8_t sec_auth)
{
struct gapc_security_cmd *p_cmd =
KE_MSG_ALLOC(GAPC_SECURITY_CMD, KE_BUILD_ID(TASK_GAPC, conidx),
TASK_APP, gapc_security_cmd);
p_cmd->operation = GAPC_SECURITY_REQ;
p_cmd->auth = sec_auth;
ke_msg_send(p_cmd);
}
void xc_ble_set_pkt_size(int conidx, uint16_t tx_octets, uint16_t tx_time)
{
struct gapc_set_le_pkt_size_cmd *p_cmd =
KE_MSG_ALLOC(GAPC_SET_LE_PKT_SIZE_CMD, KE_BUILD_ID(TASK_GAPC, conidx),
TASK_APP, gapc_set_le_pkt_size_cmd);
p_cmd->operation = GAPC_SET_LE_PKT_SIZE;
p_cmd->tx_octets = tx_octets;
p_cmd->tx_time = tx_time;
// Send the message
ke_msg_send(p_cmd);
}
void xc_ble_set_rx_pkt_size(int conidx, uint16_t rx_octets, uint16_t rx_time)
{
struct gapc_set_max_rx_size_and_time_cmd *p_cmd = KE_MSG_ALLOC(
GAPC_SET_MAX_RX_SIZE_AND_TIME_CMD, KE_BUILD_ID(TASK_GAPC, conidx),
TASK_APP, gapc_set_max_rx_size_and_time_cmd);
p_cmd->operation = GAPC_SET_MAX_RX_SIZE_AND_TIME;
p_cmd->rx_octets = rx_octets;
p_cmd->rx_time = rx_time;
// Send the message
ke_msg_send(p_cmd);
}
void xc_ble_set_channel_map(struct gapm_set_channel_map_cmd *p_param)
{
struct gapm_set_channel_map_cmd *p_cmd =
KE_MSG_ALLOC(GAPM_SET_CHANNEL_MAP_CMD, TASK_GAPM, TASK_APP,
gapm_set_channel_map_cmd);
memcpy(p_cmd, p_param, sizeof(struct gapm_set_channel_map_cmd));
p_cmd->operation = GAPM_SET_CHANNEL_MAP;
ke_msg_send(p_cmd);
}
#endif // (BLE_APP_PRESENT)
+630
View File
@@ -0,0 +1,630 @@
/**
****************************************************************************************
* @file xc_gap_api.h
* @brief GAP API.
* Copyright (c) 2022 - 2025, XinChip
* All rights reserved.
****************************************************************************************
*/
#ifndef __XC_GAP_API_H__
#define __XC_GAP_API_H__
#include "gapc_msg.h"
#include "gapm_msg.h"
#include "ke_msg.h"
/*
* DEFINES
****************************************************************************************
*/
#define CE_LEN_MIN 2
#define CE_LEN_MAX 4
#define DEVICE_NAME_MAX_LEN 18
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Called only in the app_init(). It's used to reset the device but setting\n
* device configuration is still required to use host stack.\n
* Software reset: This will initialize the RW-BLE Host stack rearrange to default settings the ATT, GAP, GATT,\n
* L2CAP and SMP blocks. Furthermore, this will cause the host to send a reset command down to the link\n
* layer part.
* Platform reset: Use platform mechanism to reset hardware.
* @note Trigger GAPM_CMP_EVT, operation is GAPM_RESET
*****************************************************************************************
*/
void xc_ble_gapm_reset(void);
/**
****************************************************************************************
* @brief Set the device configuration such as:\n
* Device role\n
* Manage device address type: Public, Private static or Generated for Privacy\n
* Internal IRK used to generate resolvable random address.\n
* Set Internal GAP / GATT service start.\n
* Set specific write permissions on the appearance and name attributes in internal GAP database.\n
* Manage presence of some attribute.\n
* Configure Data Length Extension features.\n
* The set device configuration first resets the device to close all active link and configured profiles.\n
* This command must be sent before adding profiles and start air activities.
* @note
* Trigger GAPM_CMP_EVT, operation is GAPM_SET_DEV_CONFIG.
*
* @param[in] cfg_param Pointer to the device configurtion
* structure.
*
****************************************************************************************
*/
void xc_ble_set_dev_config(struct gapm_set_dev_config_cmd *cfg_param);
/**
****************************************************************************************
* @brief Get information about local device such as:\n
* Local Device Name\n
* Local Device Version\n
* Local Device Public BD Address\n
* Data Length Extension parameters\n
* Antenna information
*
* @note
* operation is:\n
* GAPM_DEV_VERSION_IND: If local device version is requested.\n
* GAPM_DEV_BDADDR_IND: if local device public BD Address is requested.\n
* GAPM_DEV_ADV_TX_POWER_IND: If advertising TX power level is requested.\n
* GAPM_DBG_MEM_INFO_IND: if memory information are requested (DEBUG ONLY).\n
* GAPM_SUGG_DFLT_DATA_LEN_IND: if suggested Default Data Length is requested.\n
* GAPM_MAX_DATA_LEN_IND: if Maximum Data Length is requested.\n
* GAPM_NB_ADV_SETS_IND: if number of advertising sets is requested.\n
* GAPM_MAX_ADV_DATA_LEN_IND: if maximum advertising data length is requested.\n
* GAPM_ANTENNA_INF_IND: if antenna information requested.\n
* GAPM_CMP_EVT: When operation completed.\n
*
* @param[in] cmd Command for information
*
****************************************************************************************
*/
void xc_ble_get_dev_info(struct gapm_get_dev_info_cmd *cmd);
/**
****************************************************************************************
* @brief Resolve provided random address using array of Identity Resolution Key (IRK) exchanged and bonded with\n
* devices during pairing operations.\n
* Operation will complete successfully if address has been correctly resolved and GAPM_ADDR_SOLVED_IND\n
* message will be triggered to inform which key has been used to perform resolution.\n
* Else operation complete with GAP_ERR_NOT_FOUND error status code.
*
* @note
* GAPM_ADDR_SOLVED_IND: triggered if address correctly resolved.\n
* GAPM_CMP_EVT: When operation completed, operation is GAPM_RESOLV_ADDR.
*
* @param[in] nb_key Number of provided IRK (sahlle be > 0).
* @param[in] addr Pointer to resolvable random address to solve.
* @param[in] irk Pointer to array of IRK used for address resolution (MSB -> LSB).
*
****************************************************************************************
*/
void xc_ble_resolve_addr(uint8_t nb_key,gap_addr_t *addr,uint8_t *irk);
/**
****************************************************************************************
* @brief Generate a random device address without starting any air operation. This can be useful for privacy in order\n
* to generate the reconnection address on demand.
*
* @note
* GAPM_DEV_BDADDR_IND: triggered when address generated.\n
* GAPM_CMP_EVT: When operation completed, operation is GAPM_GEN_RAND_ADDR.
*
* @param[in] p_param random address type. @see enum random_addr_type
****************************************************************************************
*/
void xc_ble_gen_random_addr(struct gapm_gen_rand_addr_cmd *p_param);
/**
****************************************************************************************
* @brief Read the local P-256 Public Key. This key is renewed each time this command is called by\n
* requester and so each pairing using secure connection.
*
* @note
* GAPM_PUB_KEY_IND: triggered when P-256 Public Key properly read\n
* GAPM_CMP_EVT: When operation completed, operation is GAPM_GET_PUB_KEY.
*
****************************************************************************************
*/
void xc_ble_get_pub_key(void);
/**
****************************************************************************************
* @brief Used to generate an 8-byte random number. This can be useful to generate LTK\n
* random number before distributing it.
*
* @note
* GAPM_GEN_RAND_NB_IND: triggered when random number is generated.\n
* GAPM_CMP_EVT: When operation completed, operation is GAPM_GEN_RAND_NB.
*
****************************************************************************************
*/
void xc_ble_gen_random_nb(void);
/**
****************************************************************************************
* @brief Command to change the current IRK for a renewed one, it can be used every time\n
* no air operation is being performed.
* @note
* GAPM_CMP_EVT: When operation completed,
*
* @note This can only be called during no air operation, operation is GAPM_SET_IRK.
*
* @param[out] p_param Pointer to a security key data structure.
*
****************************************************************************************
*/
void xc_ble_set_irk(gap_sec_key_t *irk);
/**
****************************************************************************************
* @brief Get local or peer resolvable private address
*
* @note operation is:\n
* GAPM_GET_RAL_LOC_ADDR: Get resolving local address\n
* GAPM_GET_RAL_PEER_ADDR: Get resolving peer address\n
*
* @note
* GAPM_RAL_ADDR_IND: Return requested address.\n
* GAPM_CMP_EVT: When operation has been completed.
*
* @param[in] p_param Pointer Read local or peer address cmd ptr.
*
****************************************************************************************
*/
void xc_ble_get_ral_addr(struct gapm_get_ral_addr_cmd *p_param);
/**
****************************************************************************************
* @brief Request to set the content of the Resolving List. The current content of the indicated list will be cleared\n
* and replaced by the indicated content.\n
* If number of addresses to be added in the list is greater than list size, a GAP_ERR_INSUFF_RESOURCES status\n
* is returned in the GAPM_CMP_EVT message.\n
* A device can be present only once in the list. If not the case a GAP_ERR_INVALID_PARAM status is returned.
*
* @note
* GAPM_CMP_EVT: When operation has been completed, operation is GAPM_SET_RAL.
*
* @note This will overwrite the current resolving list.
*
* @param[in] size Number of entries to be added in the list. 0 means that list content has to be cleared.
* @param[in] ral_info Pointer to list of entries to be added in the list.
*
****************************************************************************************
*/
void xc_ble_set_ral_list(uint8_t size, struct gap_ral_dev_info *ral_info);
/**
****************************************************************************************
* @brief Request to set the content of the White List. The current content of the indicated list will be cleared\n
* and replaced by the indicated content.\n
* If number of addresses to be added in the list is greater than list size, a GAP_ERR_INSUFF_RESOURCES status\n
* is returned in the GAPM_CMP_EVT message.\n
* A device can be present only once in the list. If not the case a GAP_ERR_INVALID_PARAM status is returned.
*
* @note
* GAPM_CMP_EVT: When operation has been completed, operation is GAPM_SET_WL.
*
* @note This will overwrite the current white list.
*
* @param[in] size Number of entries to be added in the list. 0 means that list content has to be cleared.
* @param[in] wl_info Pointer to list of entries to be added in the list.
*
****************************************************************************************
*/
void xc_ble_set_white_list(uint8_t size, gap_bdaddr_t *wl_info);
/**
****************************************************************************************
* @brief Create an advertising activity.
* @note The number of activities that can be created in parallel is limited. If the limit has been reached and a new\n
* activity cannot be created, a GAP_ERR_INSUFF_RESOURCES status will be returned in the GAPM_CMT_EVT message.
* @note
* GAPM_ACTIVITY_CREATED_IND: Once the requested activity has been successfully created.\n
* GAPM_CMP_EVT: When operation has been completed, operation is GAPM_CREATE_ADV_ACTIVITY.
*
* @param[in] adv_creat_param Pointer to activity create
*structure.
*
****************************************************************************************
*/
void xc_ble_advertise_create(struct gapm_activity_create_adv_cmd *adv_creat_param);
/**
****************************************************************************************
* @brief Set advertising data for a given previously created advertising activity identified by its\n
* activity identifier.
* @note If the provided identifier appears not to identify an existing advertising activity, GAPM_CMP_EVT message\n
* will be returned with a GAP_ERR_INVALID_PARAM status.
*
* @note
* GAPM_CMP_EVT: When operation completed, operation is GAPM_SET_ADV_DATA.
*
* @param[in] actv_idx Activity identifier
* @param[in] adv_data_length ADV data length
* @param[in] p_adv_data Pointer to adv data
*
****************************************************************************************
*/
void xc_ble_set_adv_data(uint8_t actv_idx, uint16_t adv_data_length, uint8_t *p_adv_data);
/**
****************************************************************************************
* @brief Set Scan response data for a given previously created advertising activity identified by its\n
* activity identifier.
* @note If the provided identifier appears not to identify an existing advertising activity, GAPM_CMP_EVT message\n
* will be returned with a GAP_ERR_INVALID_PARAM status.
*
* @note
* GAPM_CMP_EVT: When operation completed, operation is GAPM_SET_SCAN_RSP_DATA.
*
* @param[in] actv_idx Activity identifier
* @param[in] scan_rsp_data_length Scan response data length
* @param[in] p_scan_rsp_data Pointer to scan response data.
*
*
****************************************************************************************
*/
void xc_ble_set_scan_rsp_data(uint8_t actv_idx, uint16_t scan_rsp_data_length, uint8_t *p_scan_rsp_data);
/**
****************************************************************************************
* @brief Start an advertising activity.
* @note Several advertising activities can be started in parallel.
*
* @note
* GAPM_CMP_EVT: When operation has well been started or if an error has been detected, operation is GAPM_START_ACTIVITY.
* @param[in] adv_start_param Pointer to activity start structure.
*
****************************************************************************************
*/
void xc_ble_advertise_start(struct gapm_activity_start_cmd *adv_start_param);
/**
****************************************************************************************
* @brief Create a scanning activity.
* @note
* The number of activities that can be created in parallel is limited. If the limit has been reached and a new\n
* activity cannot be created, a GAP_ERR_INSUFF_RESOURCES status will be returned in the GAPM_CMT_EVT message.
* @note
* GAPM_ACTIVITY_CREATED_IND: Once the requested activity has been successfully created.\n
* GAPM_CMP_EVT: When operation has been completed, operation is GAPM_CREATE_SCAN_ACTIVITY.
*
* @param[in] scan_creat_param Pointer to activity create
*structure.
*
****************************************************************************************
*/
void xc_ble_scan_create(struct gapm_activity_create_cmd *scan_creat_param);
/**
****************************************************************************************
* @brief Start a scanning activity.
*
* @note it is not possible to start several scanning or several initiating activities as controller only\n
* supports one scanning and one initiating procedure to be run in parallel.\n
* It is then application responsibility to decide which scanning/initiating activity can be started.\n
* If this rule is not respected, GAPM_CMP_EVT message will be returned with a\n
* GAP_ERR_COMMAND_DISALLOWED status.
*
* @note
* GAPM_CMP_EVT: When operation has well been started or if an error has been detected, operation is GAPM_START_ACTIVITY.
* @param[in] scan_start_param Pointer to activity start structure.
*
****************************************************************************************
*/
void xc_ble_scan_start(struct gapm_activity_start_cmd *scan_start_param);
/**
****************************************************************************************
* @brief Create a initiating activity.
*
* @note
* GAPM_ACTIVITY_CREATED_IND: Once the requested activity has been successfully created.\n
* GAPM_CMP_EVT: When operation has been completed, operation is GAPM_CREATE_INIT_ACTIVITY.\n
* The number of activities that can be created in parallel is limited. If the limit has been reached and a new\n
* activity cannot be created, a GAP_ERR_INSUFF_RESOURCES status will be returned in the GAPM_CMT_EVT message.
* @param[in] init_creat_param Pointer to activity create
*structure.
*
****************************************************************************************
*/
void xc_ble_init_create(struct gapm_activity_create_cmd *init_create_param);
/**
****************************************************************************************
* @brief Start a initiating activity.
*
* @note
* GAPM_CMP_EVT: When operation has well been started or if an error has been detected, operation is GAPM_ACTIVITY_START_CMD.\n
* it is not possible to start several scanning or\n
* several initiating activities as controller only supports one scanning and one initiating procedure to be run in parallel.\n
* It is then application responsibility to decide which scanning/initiating activity can be started.\n
* If this rule is not respected, GAPM_CMP_EVT message will be returned with a\n
* GAP_ERR_COMMAND_DISALLOWED status.
* @param[in] init_start_param Pointer to activity start structure.
*
****************************************************************************************
*/
void xc_ble_init_start(struct gapm_activity_start_cmd *init_start_param);
/**
****************************************************************************************
* @brief Stop an activity or all activities.
*
* @note Request the host to stop a started activity identified by its activity identifier.\n
* If the requested activity does not exist, GAPM_CMP_EVT message is returned with a\n
* GAP_ERR_INVALID_PARAM status. If the activity exists but was not started, error GAP_ERR_COMMAND_DISALLOWED\n
* is and no GAPM_ACTIVITY_STOPPED_IND message is sent.
*
* @note
* GAPM_ACTIVITY_STOPPED_IND: Once the requested activity has been successfully stopped.\n
* GAPM_CMP_EVT: When operation has been completed, operation is GAPM_ACTIVITY_START_CMD or GAPM_STOP_ALL_ACTIVITIES.
*
* @param[in] actv_idx Activity index ,If less than 0, stop all
*activities
*
****************************************************************************************
*/
void xc_ble_activity_stop(int actv_idx);
/**
****************************************************************************************
* @brief Delete an activity or all activities
*
* @note Request the host to delete either an activity identified by its activity identifier or all currently existing\n
* activities.\n
* If selected activity is not stopped (GAPM_DELETE_ACTIVITY operation) or if at least one activity is still\n
* running (GAPM_DELETE_ALL_ACTIVITIES), a GAP_ERR_COMMAND_DISALLOWED status will be returned in the\n
* GAPM_CMP_EVT message.
*
* @note
* GAPM_CMP_EVT: When operation has been completed, operation is GAPM_DELETE_ACTIVITY or GAPM_DELETE_ALL_ACTIVITIES.
*
* @param[in] actv_idx Activity index , If less than 0, stop all activities.
*activities
*
****************************************************************************************
*/
void xc_ble_activity_delete(int actv_idx);
/**
****************************************************************************************
* @brief Request for disconnection of the link. This can be requested by master or slave of the connection.
* @note
* Reason of disconnection shall be a valid disconnection reason @see enum co_error
* @note
* Either master or slave can call this function.
*
* @param[in] conidx Connection index.
* @param[in] reason Reason of disconnection, 0x13:User on the remote device terminated the connnection
*
****************************************************************************************
*/
void xc_ble_disconnect(int conidx, uint32_t reason);
/**
****************************************************************************************
* @brief Update connection paramters
*
* @note
* GAPC_PARAM_UPDATED_IND: event triggered if connection parameters are updated.\n
* GAPC_CMP_EVT: When operation completed, operation is GAPC_UPDATE_PARAMS.
*
* @note: Can be used by both master and slave
*
* @param[in] conidx Connection index
* @param[in] p_conn_param Pointer to update parameters structure.
*
****************************************************************************************
*/
void xc_ble_update_param(int conidx, uint16_t intv_min, uint16_t intv_max,
uint16_t latency, uint16_t time_out);
/**
****************************************************************************************
* @brief Confirm connection request\n
* Set specific link security configuration and bonding data,\n
* Set connection bond data,\n
* Authentication and authorization link configuration.\n
* This confirmation message shall be sent by application after receiving a GAPC_CONNECTION_REQ_IND in\n
* order to enables local attribute tasks and security manager for the connection.\n
* It can be resent later if peer device information is retrieved later (for instance when a master initiates an\n
* encryption, information of the LTK can be used to identify peer device). In fact, when encryption is initiated\n
* by master device, it uses a couple of encryption diversifier (ediv) and random number (rand_nb) that can be\n
* used to retrieve corresponding encryption Long Term Key (LTK) that has been exchanged during a previous\n
* connection. By retrieving the LTK, we retrieve a known device and in that case before terminating encryption\n
* procedure, application shall update connection parameters.
* @note This is to response to the event "GAP_EVT_CONN_REQ". Application can\n
* call this API in the call back.\n
* If authentication parameter is marked has “Not Bonded”, other parameters are ignored and peer\n
* device is considered as an unknown device.
*
* @param[in] conidx Connection index
* @param[in] p_cfm Pointer to comfirm parameters structure.
*
****************************************************************************************
*/
void xc_ble_conn_cfm(int conidx, struct gapc_connection_cfm *p_cfm);
/**
****************************************************************************************
* @brief Retrieve information about peer device or about the current active link.
*
* @note
* Getting rssi information about peer device:\n
* operation is :
* GAPC_PEER_ATT_INFO_IND: Event triggered when peer device attribute DB info such as device name,\n
* appearance, slave preferred parameters or address resolution supported is requested.\n
* GAPC_PEER_VERSION_IND: Event triggered when peer device version is requested\n
* GAPC_PEER_FEATURES_IND: Event triggered when peer device features are requested\n
* GAPC_CON_RSSI_IND: Event triggered when connection RSSI is requested\n
* GAPC_CON_CHANNEL_MAP_IND: Event triggered when connection channel map is requested\n
* GAPC_LE_PING_TO_VAL_IND: Event triggered when LE Ping timeout value is requested\n
* GAPC_LE_PHY_IND: Event triggered when RX/TX PHYs are requested\n
* GAPC_CHAN_SEL_ALGO_IND: Event triggered when current channel selection algorithm is requested.\n
* GAPC_LOC_TX_PWR_IND: Event trigger when reading local TX power value\n
* GAPC_PEER_TX_PWR_IND: Event trigger when reading peer TX power value\n
* GAPC_CMP_EVT: When operation completed.
*
* @param[in] conidx Connection index
* @param[in] get_info Pointer to parameters structure operation
*
****************************************************************************************
*/
void xc_ble_get_peer_info(int conidx, struct gapc_get_info_cmd *get_info);
/**
****************************************************************************************
* @brief Used by to accept or refuse connection parameters proposed by peer device.
*
* @param[in] conidx Connection index
* @param[in] update_cfm Pointer to parameters structure.
*
****************************************************************************************
*/
void xc_ble_param_update_cfm(int conidx, struct gapc_param_update_cfm *update_cfm);
/**
****************************************************************************************
* @brief Requested by master of the link in order to initiate the bond procedure. It\n
* contains pairing requirement of initiator.
*
* @note
* GAPC_BOND_REQ_IND: Triggered if some information should be provided by device during the pairing.\n
* GAPC_BOND_IND: Triggered in order to receive key exchanged by peer device and get pairing status.\n
* GAPC_CMP_EVT: When operation completed, operation is GAPC_BOND.
*
* @param[in] conidx Connection index
* @param[in] p_bond Pointer to pairing requirement of initiator.
*
****************************************************************************************
*/
void xc_ble_bond(int conidx, struct gapc_bond_cmd *p_param);
/**
****************************************************************************************
* @brief Confirm bond request.
* @note
* Confirmation message to send after receiving a GAPC_BOND_REQ_IND message\n
* This message can contain:\n
* Slave pairing information\n
* Pairing temporary key (TK)\n
* Key to provide to the peer device during key exchange.
*
* @param[in] conidx Connection index
* @param[in] p_cfm Pointer to bond confirm data structure.
*
****************************************************************************************
*/
void xc_ble_bond_cfm(int conidx, struct gapc_bond_cfm *p_param);
/**
****************************************************************************************
* @brief Called when the peer device obtains information about the local device.\n
* Device Name,\n
* Device Appearance,\n
* Icon Device Slave preferred parameters,\n
* Device Central address resolution,\n
* Device database hash value,\n
* Resolvable Private address only after bond.\n
*
* @param[in] conidx Connection index
* @param[in] p_param Pointer to data structure.
****************************************************************************************
*/
void xc_ble_get_dev_info_cfm(int conidx, struct gapc_get_dev_info_cfm *p_param);
/**
****************************************************************************************
* @brief Send the write confirmation to the stack.
*
* @param[in] conidx Connection index
* @param[in] p_param Pointer to data structure.
****************************************************************************************
*/
void xc_ble_set_dev_info_cfm(int conidx, struct gapc_set_dev_info_cfm *p_param);
/**
****************************************************************************************
* @brief This operation can be requested only by master of the link in order to initiate encryption procedure. It\n
* contains Long Term Key that should be used during the encryption.
*
* @note
* GAPC_ENCRYPT_IND: Triggered if encryption operation succeed.\n
* GAPC_CMP_EVT: When operation completed. operation is GAPC_ENCRYPT.
*
* @param[in] conidx Connection index
* @param[in] p_param Pointer to data structure.
****************************************************************************************
*/
void xc_ble_encrypt(int conidx, struct gapc_encrypt_cmd *p_param);
/**
****************************************************************************************
* @brief Confirmation message to send after receiving a GAPC_ENCRYPT_REQ_IND message\n
* This message can is used to inform if encryption key has been found, if yes found Long Term Key and its size\n
* shall be provided.
*
* @param[in] conidx Connection index
* @param[in] p_param Pointer to data structure
****************************************************************************************
*/
void xc_ble_encrypt_cfm(int conidx, struct gapc_encrypt_cfm *p_param);
/**
****************************************************************************************
* @brief This operation can be requested only by slave of the link in order to initiate security request procedure. It\n
* contains authentication level requested by current device.
*
* @note
* GAPC_CMP_EVT: When operation completed. operation is GAPC_SECURITY_REQ.
*
* @param[in] conidx Connection index
* @param[in] p_param Pointer to data structure.
****************************************************************************************
*/
void xc_ble_req_security(int conidx, uint8_t sec_auth);
/**
****************************************************************************************
* @brief This operation to define the preferred packet length to be used by the controller\n
*
* @note
* GAPC_CMP_EVT: When operation completed. operation is GAPC_SECURITY_REQ.
* GAPC_LE_PKT_SIZE_IND: Event triggered with the new values
*
* @param[in] conidx Connection index
* @param[in] tx_octets Preferred maximum number of payload octets that the local Controller should include in\n
* a single Link Layer Data Channel PDU.
* @param[in] tx_time Preferred maximum number of microseconds that the local Controller should use to transmit\n
* a single Link Layer Data Channel PDU
****************************************************************************************
*/
void xc_ble_set_pkt_size(int conidx, uint16_t tx_octets, uint16_t tx_time);
/**
****************************************************************************************
* @brief This operation can be requested only by master of the link in order to set the channel map of the device.\n
*
* @note
* GAPC_CMP_EVT: When operation completed. operation is GAPC_SECURITY_REQ.
*
* @param[in] p_param Pointer to data structure.
****************************************************************************************
*/
void xc_ble_set_channel_map(struct gapm_set_channel_map_cmd *p_param);
#endif // __XC_GAP_API_H__
@@ -0,0 +1,130 @@
/**
****************************************************************************************
* @file xc_gatt_client_api.c
* @brief GATT client APIs source code
* Copyright (c) 2022 - 2025, XinChip
* All rights reserved.
****************************************************************************************
*/
#include "rwip_config.h"
#include "stdint.h"
#include "xc_gatt_client_api.h"
#include "gatt.h"
#if (BLE_GATT_CLI)
uint16_t xc_ble_gatt_user_cli_register(uint16_t pref_mtu, uint8_t prio_level,
const gatt_cli_cb_t *p_cb,
uint8_t *p_user_lid)
{
return gatt_user_cli_register(pref_mtu, prio_level, p_cb, p_user_lid);
}
#if (MIN_STACK)
uint16_t xc_ble_gatt_user_unregister(uint8_t user_lid)
{
return gatt_user_unregister(user_lid);
}
#endif // (MIN_STACK)
uint16_t xc_ble_gatt_cli_discover_svc(uint8_t conidx, uint8_t user_lid,
uint16_t dummy, uint8_t disc_type, bool full,
uint16_t start_hdl, uint16_t end_hdl,
uint8_t uuid_type, const uint8_t *p_uuid)
{
return gatt_cli_discover_svc(conidx, user_lid, dummy, disc_type, full,
start_hdl, end_hdl, uuid_type, p_uuid);
}
#if (MIN_STACK_MASTER)
uint16_t xc_ble_gatt_cli_discover_inc_svc(uint8_t conidx, uint8_t user_lid,
uint16_t dummy, uint16_t start_hdl,
uint16_t end_hdl)
{
return gatt_cli_discover_inc_svc(conidx, user_lid, dummy, start_hdl,
end_hdl);
}
#endif // (MIN_STACK_MASTER)
uint16_t xc_ble_gatt_cli_discover_char(uint8_t conidx, uint8_t user_lid,
uint16_t dummy, uint8_t disc_type,
uint16_t start_hdl, uint16_t end_hdl,
uint8_t uuid_type, const uint8_t *p_uuid)
{
return gatt_cli_discover_char(conidx, user_lid, dummy, disc_type, start_hdl,
end_hdl, uuid_type, p_uuid);
}
uint16_t xc_ble_gatt_cli_discover_desc(uint8_t conidx, uint8_t user_lid,
uint16_t dummy, uint16_t start_hdl,
uint16_t end_hdl)
{
return gatt_cli_discover_desc(conidx, user_lid, dummy, start_hdl, end_hdl);
}
uint16_t xc_ble_gatt_cli_discover_cancel(uint8_t conidx, uint8_t user_lid,
uint16_t dummy)
{
return gatt_cli_discover_cancel(conidx, user_lid, dummy);
}
uint16_t xc_ble_gatt_cli_read(uint8_t conidx, uint8_t user_lid, uint16_t dummy,
uint16_t hdl, uint16_t offset, uint16_t length)
{
return gatt_cli_read(conidx, user_lid, dummy, hdl, offset, length);
}
uint16_t xc_ble_gatt_cli_read_by_uuid(uint8_t conidx, uint8_t user_lid,
uint16_t dummy, uint16_t start_hdl,
uint16_t end_hdl, uint8_t uuid_type,
const uint8_t *p_uuid)
{
return gatt_cli_read_by_uuid(conidx, user_lid, dummy, start_hdl, end_hdl,
uuid_type, p_uuid);
}
uint16_t xc_ble_gatt_cli_write(uint8_t conidx, uint8_t user_lid, uint16_t dummy,
uint8_t write_type, uint16_t hdl, uint16_t length,
const uint8_t* p_data)
{
co_buf_t* p_buf = NULL;
uint16_t status;
if(co_buf_alloc(&p_buf, GATT_BUFFER_HEADER_LEN, length, GATT_BUFFER_TAIL_LEN) == CO_BUF_ERR_NO_ERROR)
{
co_buf_copy_data_from_mem(p_buf, p_data, length);
status = gatt_cli_write(conidx, user_lid, dummy, write_type, hdl, 0, p_buf);
co_buf_release(p_buf);
}
else
{
status = GAP_ERR_INSUFF_RESOURCES;
}
return (status);
}
uint16_t xc_ble_gatt_cli_event_register(uint8_t conidx, uint8_t user_lid,
uint16_t start_hdl, uint16_t end_hdl)
{
return gatt_cli_event_register(conidx, user_lid, start_hdl, end_hdl);
}
#if (MIN_STACK_MASTER)
uint16_t xc_ble_gatt_cli_event_unregister(uint8_t conidx, uint8_t user_lid,
uint16_t start_hdl, uint16_t end_hdl)
{
return gatt_cli_event_unregister(conidx, user_lid, start_hdl, end_hdl);
}
#endif // (MIN_STACK_MASTER)
uint16_t xc_ble_gatt_cli_indicate_cfm(uint8_t conidx, uint8_t user_lid,
uint16_t token)
{
return gatt_cli_att_event_cfm(conidx, user_lid, token);
}
#endif // (BLE_GATT_CLI)
//uint16_t xc_ble_gatt_cli_mtu_exch(uint8_t conidx, uint8_t user_lid)
//{
// return gatt_cli_mtu_exch(conidx, user_lid);
//}
@@ -0,0 +1,320 @@
/**
****************************************************************************************
* @file xc_gatt_client_api.h
* @brief GATT client API.
* Copyright (c) 2022 - 2025, XinChip
* All rights reserved.
****************************************************************************************
*/
#ifndef __XC_GATT_CLIENT_API_H__
#define __XC_GATT_CLIENT_API_H__
#include "gatt_db.h" // GATT Database access
#include "gatt.h"
#include "co_buf.h"
#include "rwble_hl_error.h"
/**
****************************************************************************************
* @brief Command used to register a GATT user. This must be done prior to any GATT
* procedure execution.
*
* A GATT client user can initiate any client procedure, and shall be able to
* handle all client initiated message events
*
* Same module can register multiple GATT users.
*
* @param[in] pref_mtu Preferred MTU for attribute exchange.
* @param[in] prio_level User attribute priority level
* @param[in] p_cb Pointer to set of callback functions to be used for communication
* with the GATT server user
* @param[out] p_user_lid Pointer where GATT user local identifier will be set
*
* @return Status of the function execution (@see enum hl_err)
****************************************************************************************
*/
uint16_t xc_ble_gatt_user_cli_register(uint16_t pref_mtu, uint8_t prio_level, const gatt_cli_cb_t* p_cb, uint8_t* p_user_lid);
/**
****************************************************************************************
* @brief Command used to unregister a GATT user (client or server).
*
* @param[in] user_lid GATT User Local identifier
*
* @return Status of the function execution (@see enum hl_err)
****************************************************************************************
*/
uint16_t xc_ble_gatt_user_unregister(uint8_t user_lid);
/**
****************************************************************************************
* @brief Command used by a GATT client user to discover primary or secondary services,
* exposed by peer device in its attribute database.
*
* All services can be discovered or filtering services having a specific UUID.
* The discovery is done between start handle and end handle range.
* For a complete discovery start handle must be set to 0x0001 and end handle to
* 0xFFFF.
*
* Wait for @see cb_discover_cmp execution before starting a new procedure
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] dummy Dummy parameter whose meaning is upper layer dependent and
* which is returned in command complete.
* @param[in] disc_type GATT Service discovery type (@see enum gatt_svc_discovery_type)
* @param[in] full Perform discovery of all information present in the service
* (True: enable, False: disable)
* @param[in] start_hdl Search start handle
* @param[in] end_hdl Search end handle
* @param[in] uuid_type UUID Type (@see enum gatt_uuid_type)
* @param[in] p_uuid Pointer to searched Service UUID (meaningful only for
* discovery by UUID)
*
* @return Status of the function execution (@see enum hl_err)
* Consider status only if an error occurs; else wait for execution completion
****************************************************************************************
*/
uint16_t xc_ble_gatt_cli_discover_svc(uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint8_t disc_type, bool full,
uint16_t start_hdl, uint16_t end_hdl, uint8_t uuid_type, const uint8_t* p_uuid);
/**
****************************************************************************************
* @brief Command used by a GATT client user to discover included services, exposed
* by peer device in its attribute database.
*
* The discovery is done between start handle and end handle range.
* For a complete discovery start handle must be set to 0x0001 and end handle to
* 0xFFFF.
*
* Wait for @see cb_discover_cmp execution before starting a new procedure
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] dummy Dummy parameter whose meaning is upper layer dependent and
* which is returned in command complete.
* @param[in] start_hdl Search start handle
* @param[in] end_hdl Search end handle
*
* @return Status of the function execution (@see enum hl_err)
* Consider status only if an error occurs; else wait for execution completion
****************************************************************************************
*/
uint16_t xc_ble_gatt_cli_discover_inc_svc(uint8_t conidx, uint8_t user_lid, uint16_t dummy,
uint16_t start_hdl, uint16_t end_hdl);
/**
****************************************************************************************
* @brief Command used by a GATT client user to discover all or according to a specific
* UUID characteristics exposed by peer device in its attribute database.
*
* The discovery is done between start handle and end handle range.
* For a complete discovery start handle must be set to 0x0001 and end handle to
* 0xFFFF.
*
* Wait for @see cb_discover_cmp execution before starting a new procedure
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] dummy Dummy parameter whose meaning is upper layer dependent and
* which is returned in command complete.
* @param[in] disc_type GATT characteristic discovery type (@see enum gatt_char_discovery_type)
* @param[in] start_hdl Search start handle
* @param[in] end_hdl Search end handle
* @param[in] uuid_type UUID Type (@see enum gatt_uuid_type)
* @param[in] p_uuid Pointer to searched Attribute Value UUID (meaningful only
* for discovery by UUID)
*
* @return Status of the function execution (@see enum hl_err)
* Consider status only if an error occurs; else wait for execution completion
****************************************************************************************
*/
uint16_t xc_ble_gatt_cli_discover_char(uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint8_t disc_type,
uint16_t start_hdl, uint16_t end_hdl, uint8_t uuid_type, const uint8_t* p_uuid);
/**
****************************************************************************************
* @brief Command used by a GATT client user to discover characteristic descriptor
* exposed by peer device in its attribute database.
*
* The discovery is done between start handle and end handle range.
* For a complete discovery start handle must be set to 0x0001 and end handle to
* 0xFFFF.
*
* Wait for @see cb_discover_cmp execution before starting a new procedure
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] dummy Dummy parameter whose meaning is upper layer dependent and
* which is returned in command complete.
* @param[in] start_hdl Search start handle
* @param[in] end_hdl Search end handle
*
* @return Status of the function execution (@see enum hl_err)
* Consider status only if an error occurs; else wait for execution completion
****************************************************************************************
*/
uint16_t xc_ble_gatt_cli_discover_desc(uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint16_t start_hdl, uint16_t end_hdl);
/**
****************************************************************************************
* @brief Command used by a GATT client user to cancel an on-going discovery procedure.
* The dummy parameter in the request must be equals to dummy parameter used for
* service discovery command.
*
* The discovery is aborted as soon as on-going discovery attribute transaction
* is over.
*
* Wait for @see cb_discover_cmp execution before starting a new procedure
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] dummy Dummy parameter whose meaning is upper layer dependent and
* which is returned in command complete.
*
* @return Status of the function execution (@see enum hl_err)
* Consider status only if an error occurs; else wait for execution completion
****************************************************************************************
*/
uint16_t xc_ble_gatt_cli_discover_cancel(uint8_t conidx, uint8_t user_lid, uint16_t dummy);
/**
****************************************************************************************
* @brief Command used by a GATT client user to read value of an attribute (identified
* by its handle) present in peer database.
*
* Wait for @see cb_read_cmp execution before starting a new procedure
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] dummy Dummy parameter whose meaning is upper layer dependent and
* which is returned in command complete.
* @param[in] hdl Attribute handle
* @param[in] offset Value offset
* @param[in] length Value length to read (0 = read all)
*
* @return Status of the function execution (@see enum hl_err)
* Consider status only if an error occurs; else wait for execution completion
****************************************************************************************
*/
uint16_t xc_ble_gatt_cli_read(uint8_t conidx, uint8_t user_lid, uint16_t dummy,
uint16_t hdl, uint16_t offset, uint16_t length);
/**
****************************************************************************************
* @brief Command used by a GATT client user to read value of an attribute with a given
* UUID in peer database.
*
* Wait for @see cb_read_cmp execution before starting a new procedure
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] dummy Dummy parameter whose meaning is upper layer dependent and
* which is returned in command complete.
* @param[in] start_hdl Search start handle
* @param[in] end_hdl Search end handle
* @param[in] uuid_type UUID Type (@see enum gatt_uuid_type)
* @param[in] p_uuid Pointer to searched attribute UUID (LSB First)
*
* @return Status of the function execution (@see enum hl_err)
* Consider status only if an error occurs; else wait for execution completion
****************************************************************************************
*/
uint16_t xc_ble_gatt_cli_read_by_uuid(uint8_t conidx, uint8_t user_lid, uint16_t dummy,
uint16_t start_hdl, uint16_t end_hdl, uint8_t uuid_type, const uint8_t* p_uuid);
/**
****************************************************************************************
* @brief Command used by a GATT client user to request to write value of an attribute
* in peer database.
*
* Since user is not aware of MTU size of the bearer used for attribute
* transmission it cannot be considered reliable.
*
* For a GATT_WRITE_NO_RESP if attribute bearer max transmission size isn't sufficient,
* a GATT_WRITE (with response) procedure will be used.
*
* For a GATT_WRITE_SIGNED, if attribute bearer max transmission size isn't sufficient,
* the procedure is aborted with L2CAP_ERR_INVALID_MTU error code.
*
* Wait for @see cb_write_cmp execution before starting a new procedure
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] dummy Dummy parameter whose meaning is upper layer dependent and
* which is returned in command complete.
* @param[in] write_type GATT write type (@see enum gatt_write_type)
* @param[in] hdl Attribute handle
* @param[in] length Value length
* @param[in] p_data Pointer to data value
*
* @return Status of the function execution (@see enum hl_err)
* Consider status only if an error occurs; else wait for execution completion
****************************************************************************************
*/
uint16_t xc_ble_gatt_cli_write(uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint8_t write_type,
uint16_t hdl, uint16_t length, const uint8_t* p_data);
/**
****************************************************************************************
* @brief Command used by a GATT client user to register for reception of events
* (notification / indication) for a given handle range.
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] start_hdl Attribute start handle
* @param[in] end_hdl Attribute end handle
*
* @return Status of the function execution (@see enum hl_err)
****************************************************************************************
*/
uint16_t xc_ble_gatt_cli_event_register(uint8_t conidx, uint8_t user_lid, uint16_t start_hdl, uint16_t end_hdl);
/**
****************************************************************************************
* @brief Command used by a GATT client user to stop reception of events (notification /
* indication) onto a specific handle range.
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] start_hdl Attribute start handle
* @param[in] end_hdl Attribute end handle
*
* @return Status of the function execution (@see enum hl_err)
****************************************************************************************
*/
uint16_t xc_ble_gatt_cli_event_unregister(uint8_t conidx, uint8_t user_lid, uint16_t start_hdl, uint16_t end_hdl);
/**
****************************************************************************************
* @brief Request a MTU exchange on legacy attribute bearer.
* There is no callback executed when the procedure is over.
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
*
* @return Status of the function execution (@see enum hl_err)
****************************************************************************************
*/
uint16_t xc_ble_gatt_cli_mtu_exch(uint8_t conidx, uint8_t user_lid);
/**
****************************************************************************************
* @brief Upper layer provide status of attribute event handled by GATT client user.
* confirmation of indicate by GATT client.
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] token Procedure token provided in corresponding callback
*
* @return Status of the function execution (@see enum hl_err)
****************************************************************************************
*/
uint16_t xc_ble_gatt_cli_indicate_cfm(uint8_t conidx, uint8_t user_lid, uint16_t token);
uint16_t xc_ble_gatt_cli_mtu_exch(uint8_t conidx, uint8_t user_lid);
#endif // __XC_GATT_CLIENT_API_H__
@@ -0,0 +1,130 @@
/**
****************************************************************************************
* @file xc_gatt_server_api.c
* @brief GATT server APIs source code
* Copyright (c) 2022 - 2025, XinChip
* All rights reserved.
****************************************************************************************
*/
#include "rwip_config.h"
#if (BLE_APP_PRESENT)
#include "xc_gatt_server_api.h"
//uint16_t xc_ble_gatt_user_srv_register(uint16_t pref_mtu, uint8_t prio_level,
// const gatt_srv_cb_t *p_cb,
// uint8_t *p_user_lid)
//{
// return gatt_user_srv_register(pref_mtu, prio_level, p_cb, p_user_lid);
//}
uint16_t xc_ble_gatt_service_add(uint8_t user_lid, uint8_t info,
const uint8_t *p_uuid, uint8_t nb_att,
const uint8_t *p_att_mask,
const gatt_att_desc_t *p_atts,
uint8_t nb_att_rsvd, uint16_t *p_start_hdl)
{
return gatt_db_svc_add(user_lid, info, p_uuid, nb_att, p_att_mask, p_atts,
nb_att_rsvd, p_start_hdl);
}
//uint16_t xc_ble_gatt_service16_add(uint8_t user_lid, uint8_t info,
// uint16_t uuid16, uint8_t nb_att,
// const uint8_t *p_att_mask,
// const gatt_att16_desc_t *p_atts,
// uint8_t nb_att_rsvd, uint16_t *p_start_hdl)
//{
// return gatt_db_svc16_add(user_lid, info, uuid16, nb_att, p_att_mask, p_atts,
// nb_att_rsvd, p_start_hdl);
//}
#if (MIN_STACK)
uint16_t xc_ble_gatt_service_remove(uint8_t user_lid, uint16_t start_hdl)
{
return gatt_db_svc_remove(user_lid, start_hdl);
}
#endif // (MIN_STACK)
//uint16_t xc_ble_gatt_srv_notify(uint8_t conidx, uint8_t user_lid,
// uint16_t dummy, uint16_t hdl, uint16_t length,
// const uint8_t *p_value)
//{
// co_buf_t *p_data;
// uint16_t status;
// // allocate a buffer for event transmission
// if (co_buf_alloc(&p_data, GATT_BUFFER_HEADER_LEN, length,
// GATT_BUFFER_TAIL_LEN) != CO_BUF_ERR_NO_ERROR) {
// status = ATT_ERR_INSUFF_RESOURCE;
// } else {
// // copy data into buffer
// co_buf_copy_data_from_mem(p_data, p_value, length);
// // request event to be sent
// status = gatt_srv_event_send(conidx, user_lid, dummy, GATT_NOTIFY, hdl,
// p_data);
// co_buf_release(p_data);
// }
// return status;
//}
uint16_t xc_ble_gatt_srv_indicate(uint8_t conidx, uint8_t user_lid,
uint16_t dummy, uint16_t hdl, uint16_t length,
const uint8_t *p_value)
{
co_buf_t *p_data;
uint16_t status;
// allocate a buffer for event transmission
if (co_buf_alloc(&p_data, GATT_BUFFER_HEADER_LEN, length,
GATT_BUFFER_TAIL_LEN) != CO_BUF_ERR_NO_ERROR) {
status = ATT_ERR_INSUFF_RESOURCE;
} else {
// copy data into buffer
co_buf_copy_data_from_mem(p_data, p_value, length);
// request event to be sent
status = gatt_srv_event_send(conidx, user_lid, dummy, GATT_INDICATE,
hdl, p_data);
co_buf_release(p_data);
}
return status;
}
//uint16_t xc_ble_gatt_srv_read_cfm(uint8_t conidx, uint8_t user_lid,
// uint16_t token, uint16_t status,
// uint16_t att_length, uint16_t length,
// const uint8_t *p_value)
//{
// co_buf_t *p_data = NULL;
// uint8_t state;
// if (status == GAP_ERR_NO_ERROR) {
// // allocate a buffer for event transmission
// if (co_buf_alloc(&p_data, GATT_BUFFER_HEADER_LEN, length,
// GATT_BUFFER_TAIL_LEN) != CO_BUF_ERR_NO_ERROR) {
// status = ATT_ERR_INSUFF_RESOURCE;
// } else {
// // copy data into buffer
// co_buf_copy_data_from_mem(p_data, p_value, length);
// }
// }
// // execute confirmation native function
// state = gatt_srv_att_read_get_cfm(conidx, user_lid, token, status,
// att_length, p_data);
// // release buffer
// if (p_data != NULL) {
// co_buf_release(p_data);
// }
// return state;
//}
//uint16_t xc_ble_gatt_srv_write_cfm(uint8_t conidx, uint8_t user_lid,
// uint16_t token, uint16_t status)
//{
// return gatt_srv_att_val_set_cfm(conidx, user_lid, token, status);
//}
#endif // (BLE_APP_PRESENT)
@@ -0,0 +1,225 @@
/**
****************************************************************************************
* @file xc_gatt_server_api.h
* @brief GATT server API.
* Copyright (c) 2022 - 2025, XinChip
* All rights reserved.
****************************************************************************************
*/
#ifndef __XC_GATT_SERVER_API_H__
#define __XC_GATT_SERVER_API_H__
#include "gatt_db.h" // GATT Database access
#include "gatt.h"
#include "co_buf.h"
#include "rwble_hl_error.h"
enum gatt_err
{
/// No error
GATT_NO_ERROR = 0x00,
};
enum gatt_switch
{
GATT_DISABLE = 0,
GATT_ENABLE = 1
};
/**
****************************************************************************************
* @brief Command used to register a GATT user. This must be done prior to any GATT
* procedure execution.
*
* A GATT server can manipulate local attribute database and initiate server
* procedures. It shall be able to handle all server initiated events
*
* Same module can register multiple GATT users.
*
* @param[in] pref_mtu Preferred MTU for attribute exchange.
* @param[in] prio_level User attribute priority level
* @param[in] p_cb Pointer to set of callback functions to be used for communication
* with the GATT server user
* @param[out] p_user_lid Pointer where GATT user local identifier will be set
*
* @return Status of the function execution (@see enum hl_err)
****************************************************************************************
*/
uint16_t xc_ble_gatt_user_srv_register(uint16_t pref_mtu, uint8_t prio_level, const gatt_srv_cb_t* p_cb, uint8_t* p_user_lid);
/**
****************************************************************************************
* @brief Command used to add a service into local attribute database.
*
* If start handle is set to zero (invalid attribute handle), GATT looks for a
* free handle block matching with number of attributes to reserve.
* Else, according to start handle, GATT checks if attributes to reserve are
* not overlapping part of existing database.
*
* An added service is automatically visible for peer device.
*
* @note First attribute in attribute array must be a Primary or a Secondary service
*
* @param[in] user_lid GATT User Local identifier
* @param[in] info Service Information bit field (@see enum gatt_svc_info_bf)
* @param[in] p_uuid Pointer to service UUID (LSB first)
* @param[in] nb_att Number of attribute(s) in service
* @param[in] p_att_mask Pointer to mask of attribute to insert in database:
* - If NULL insert all attributes
* - If bit set to 1: attribute inserted
* - If bit set to 0: attribute not inserted
* @param[in] p_atts Pointer to List of attribute description present in service.
* @param[in] nb_att_rsvd Number of attribute(s) reserved for the service (shall be equals or greater nb_att)
* Prevent any services to be inserted between start_hdl and (start_hdl + nb_att_rsvd -1)
* @param[in|out] p_start_hdl Pointer to Service Start Handle (0 = chosen by GATT module)
* Pointer updated with service start handle associated to
* created service.
*
* @return Status of the function execution (@see enum hl_err)
****************************************************************************************
*/
uint16_t xc_ble_gatt_service_add(uint8_t user_lid, uint8_t info, const uint8_t* p_uuid, uint8_t nb_att, const uint8_t* p_att_mask,
const gatt_att_desc_t* p_atts, uint8_t nb_att_rsvd, uint16_t* p_start_hdl);
/**
****************************************************************************************
* @brief Command used to add a service into local attribute database.
*
* Service and attributes UUIDs in service must be 16-bit
*
* If start handle is set to zero (invalid attribute handle), GATT looks for a
* free handle block matching with number of attributes to reserve.
* Else, according to start handle, GATT checks if attributes to reserve are
* not overlapping part of existing database.
*
* An added service is automatically visible for peer device.
*
* @note First attribute in attribute array must be a Primary or a Secondary service
*
* @param[in] user_lid GATT User Local identifier
* @param[in] info Service Information bit field (@see enum gatt_svc_info_bf)
* @param[in] uuid16 Service UUID (16-bit UUID - LSB First)
* @param[in] nb_att Number of attribute(s) in service
* @param[in] p_att_mask Pointer to mask of attribute to insert in database:
* - If NULL insert all attributes
* - If bit set to 1: attribute inserted
* - If bit set to 0: attribute not inserted
* @param[in] p_atts Pointer to List of attribute (with 16-bit uuid) description present in service.
* @param[in] nb_att_rsvd Number of attribute(s) reserved for the service (shall be equals or greater nb_att)
* Prevent any services to be inserted between start_hdl and (start_hdl + nb_att_rsvd - 1)
* @param[in|out] p_start_hdl Pointer to Service Start Handle (0 = chosen by GATT module)
* Pointer updated with service start handle associated to
* created service.
*
* @return Status of the function execution (@see enum hl_err)
****************************************************************************************
*/
uint16_t xc_ble_gatt_service16_add(uint8_t user_lid, uint8_t info, uint16_t uuid16, uint8_t nb_att, const uint8_t* p_att_mask,
const gatt_att16_desc_t* p_atts, uint8_t nb_att_rsvd, uint16_t* p_start_hdl);
/**
****************************************************************************************
* @brief Command used to remove a service from local attribute database.
*
* Only GATT user responsible of service can remove it.
*
* @param[in] user_lid GATT User Local identifier
* @param[in] start_hdl Service Start Handle
*
* @return Status of the function execution (@see enum hl_err)
****************************************************************************************
*/
uint16_t xc_ble_gatt_service_remove(uint8_t user_lid, uint16_t start_hdl);
/**
****************************************************************************************
* @brief Command used by a GATT server user to send notifications
*
* Since user is not aware of MTU size of the bearer used for attribute
* transmission it cannot be considered reliable. If size of the data buffer is too
* big, data is truncated to max supported length.
*
* Wait for @see cb_event_sent execution before starting a new procedure
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] dummy Dummy parameter whose meaning is upper layer dependent and
* which is returned in command complete.
* @param[in] hdl Attribute handle
* @param[in] length Value length
* @param[in] p_value Pointer to Value to transmit
*
* @return Status of the function execution (@see enum hl_err)
* Consider status only if an error occurs; else wait for execution completion
****************************************************************************************
*/
uint16_t xc_ble_gatt_srv_notify(uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint16_t hdl,
uint16_t length, const uint8_t *p_value);
/**
****************************************************************************************
* @brief Command used by a GATT server user to send indication
*
* Since user is not aware of MTU size of the bearer used for attribute
* transmission it cannot be considered reliable. If size of the data buffer is too
* big, data is truncated to max supported length.
*
* Wait for @see cb_event_sent execution before starting a new procedure
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] dummy Dummy parameter whose meaning is upper layer dependent and
* which is returned in command complete.
* @param[in] hdl Attribute handle
* @param[in] length Value length
* @param[in] p_value Pointer to Value to transmit
*
* @return Status of the function execution (@see enum hl_err)
* Consider status only if an error occurs; else wait for execution completion
****************************************************************************************
*/
uint16_t xc_ble_gatt_srv_indicate(uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint16_t hdl,
uint16_t length, const uint8_t *p_value);
/**
****************************************************************************************
* @brief Upper layer provide attribute value requested by GATT Layer for a read procedure
* If rejected, value is not used.
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] token Procedure token provided in corresponding callback
* @param[in] status Status of attribute value get (@see enum hl_err)
* @param[in] att_length Complete Length of the attribute value
* @param[in] length Value length
* @param[in] p_value Pointer to buffer attribute data
*
*
* @return Status of the function execution (@see enum hl_err)
****************************************************************************************
*/
uint16_t xc_ble_gatt_srv_read_cfm(uint8_t conidx, uint8_t user_lid, uint16_t token, uint16_t status,
uint16_t att_length, uint16_t length, const uint8_t *p_value);
/**
****************************************************************************************
* @brief Upper layer provide status of attribute value modification by GATT server user.
* Confirmation server user when an attribute value has been written by a
* peer device.
*
* @param[in] conidx Connection index
* @param[in] user_lid GATT User Local identifier
* @param[in] token Procedure token provided in corresponding callback
* @param[in] status Status of attribute value set (@see enum hl_err)
*
* @return Status of the function execution (@see enum hl_err)
****************************************************************************************
*/
uint16_t xc_ble_gatt_srv_write_cfm(uint8_t conidx, uint8_t user_lid, uint16_t token, uint16_t status);
#endif // __XC_GATT_SERVER_API_H__
+72
View File
@@ -0,0 +1,72 @@
/**
****************************************************************************************
*
* @file acc.h
*
* @brief Audio Content Control - Header file
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_H_
#define ACC_H_
/**
****************************************************************************************
* @addtogroup ACC Audio Content Control
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf_cfg.h" // GAF Configuration
#include "gaf.h" // GAF API
/*
* MACROS
****************************************************************************************
*/
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Module type values
enum acc_module_type
{
/// Common
ACC_MODULE_COMMON = 0,
/// Telephone Bearer Server
ACC_MODULE_TBS = 1,
/// Telephone Bearer Client
ACC_MODULE_TBC = 2,
/// Media Control Server
ACC_MODULE_MCS = 3,
/// Media Control Client
ACC_MODULE_MCC = 4,
/// Object Transfer Server
ACC_MODULE_OTS = 5,
/// Object Transfer Client
ACC_MODULE_OTC = 6,
ACC_MODULE_MAX,
};
/// List of GAF_REQ request codes
enum acc_msg_req_codes
{
ACC_GET_FEATURES = GAF_CODE(ACC, COMMON, 0),
};
/// @}
#endif // ACC_H_
@@ -0,0 +1,95 @@
/**
****************************************************************************************
*
* @file acc_msg.h
*
* @brief Audio Content Control - Definition of Kernel Messages
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_MSG_H_
#define ACC_MSG_H_
/**
****************************************************************************************
* @addtogroup ACC Audio Content Control - Definition of Kernel Messages
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "acc.h" // ACC Definitions
#if (GAF_ACC)
#include "gaf_msg.h" // Generic Audio Framework API Message Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Features bit field meaning
enum acc_msg_feat_bf
{
/// Telephone Bearer Service Server supported
ACC_FEAT_TBS_SUPP_POS = 0,
ACC_FEAT_TBS_SUPP_BIT = CO_BIT(ACC_FEAT_TBS_SUPP_POS),
/// Telephone Bearer Service Client supported
ACC_FEAT_TBC_SUPP_POS = 1,
ACC_FEAT_TBC_SUPP_BIT = CO_BIT(ACC_FEAT_TBC_SUPP_POS),
/// Media Control Service Server supported
ACC_FEAT_MCS_SUPP_POS = 2,
ACC_FEAT_MCS_SUPP_BIT = CO_BIT(ACC_FEAT_MCS_SUPP_POS),
/// Media Control Service Client supported
ACC_FEAT_MCC_SUPP_POS = 3,
ACC_FEAT_MCC_SUPP_BIT = CO_BIT(ACC_FEAT_MCC_SUPP_POS),
/// Object Transfer Service Server supported
ACC_FEAT_OTS_SUPP_POS = 4,
ACC_FEAT_OTS_SUPP_BIT = CO_BIT(ACC_FEAT_OTS_SUPP_POS),
/// Object Transfer Service Client supported
ACC_FEAT_OTC_SUPP_POS = 5,
ACC_FEAT_OTC_SUPP_BIT = CO_BIT(ACC_FEAT_OTC_SUPP_POS),
};
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ACC_GET_FEATURES request message
typedef struct acc_get_features_req
{
/// Request code (@see enum acc_msg_req_codes)
uint16_t req_code;
} acc_get_features_req_t;
/// Structure for ACC_GET_FEATURES response message
typedef struct acc_get_features_rsp
{
/// Request code (@see enum acc_msg_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
/// Features bit field
uint32_t feat_bf;
} acc_get_features_rsp_t;
#endif //(GAF_ACC)
/// @}
#endif // ACC_MSG_H_
@@ -0,0 +1,378 @@
/**
****************************************************************************************
*
* @file acc_mc.h
*
* @brief Audio Content Control - Media Control - Header file
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_MC_H_
#define ACC_MC_H_
/**
****************************************************************************************
* @addtogroup ACC_MC Audio Content Control - Media Control
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "acc.h" // Audio Content Control Defintiions
/*
* DEFINES
****************************************************************************************
*/
/// Length of Object ID
#define ACC_MC_OBJ_ID_LEN (6)
/// Length of Track Changed characteristic value
#define ACC_MC_TRACK_CHANGED_LEN (0)
/// Length of Media State characteristic value
#define ACC_MC_MEDIA_STATE_LEN (1)
/// Length of Track Duration characteristic value
#define ACC_MC_TRACK_DURATION_LEN (4)
/// Length of Track Position characteristic value
#define ACC_MC_TRACK_POSITION_LEN (4)
/// Length of Playback Speed characteristic value
#define ACC_MC_PLAYBACK_SPEED_LEN (1)
/// Length of Seeking Speed characteristic value
#define ACC_MC_SEEKING_SPEED_LEN (1)
/// Length of Playing Order characteristic value
#define ACC_MC_PLAYING_ORDER_LEN (1)
/// Length of Playing Order Supported characteristic value
#define ACC_MC_PLAYING_ORDER_SUPP_LEN (2)
/// Length of Media Control Point Opcodes Supported characteristic value
#define ACC_MC_MEDIA_CP_OPCODES_SUPP_LEN (4)
/// Length of Search Control Point Result Code value
#define ACC_MC_SEARCH_CP_RESULT_LEN (1)
/// Indicate that Track Duration is unknown
#define ACC_MC_TRACK_DUR_UNKNOWN (0xFFFFFFFF)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Characteristic type values
/// Values are ordered so that the notification-capable characteristic type values are equal
/// to the characteristic type values
enum acc_mc_char_type
{
/// Media Player Name characteristic
ACC_MC_CHAR_TYPE_PLAYER_NAME = 0,
/// Track Changed characteristic
ACC_MC_CHAR_TYPE_TRACK_CHANGED,
/// Track Title characteristic
ACC_MC_CHAR_TYPE_TRACK_TITLE,
/// Track Duration characteristic
ACC_MC_CHAR_TYPE_TRACK_DURATION,
/// Track Position characteristic
ACC_MC_CHAR_TYPE_TRACK_POSITION,
/// Playback Speed characteristic
ACC_MC_CHAR_TYPE_PLAYBACK_SPEED,
/// Seeking Speed characteristic
ACC_MC_CHAR_TYPE_SEEKING_SPEED,
/// Current Track Object ID characteristic
ACC_MC_CHAR_TYPE_CUR_TRACK_OBJ_ID,
/// Next Track Object ID characteristic
ACC_MC_CHAR_TYPE_NEXT_TRACK_OBJ_ID,
/// Current Group Object ID characteristic
ACC_MC_CHAR_TYPE_CUR_GROUP_OBJ_ID,
/// Parent Group Object ID characteristic
ACC_MC_CHAR_TYPE_PARENT_GROUP_OBJ_ID,
/// Playing Order characteristic
ACC_MC_CHAR_TYPE_PLAYING_ORDER,
/// Media State characteristic
ACC_MC_CHAR_TYPE_MEDIA_STATE,
/// Media Control Point
ACC_MC_CHAR_TYPE_MEDIA_CP,
/// Media Control Point Opcodes Supported
ACC_MC_CHAR_TYPE_MEDIA_CP_OPCODES_SUPP,
/// Search Results Object ID
ACC_MC_CHAR_TYPE_SEARCH_RESULTS_OBJ_ID,
/// Search Control Point
ACC_MC_CHAR_TYPE_SEARCH_CP,
/// All characteristics above are notification-capable
ACC_MC_NTF_CHAR_TYPE_MAX,
/// Current Track Segments Object ID characteristic
ACC_MC_CHAR_TYPE_CUR_TRACK_SEG_OBJ_ID = ACC_MC_NTF_CHAR_TYPE_MAX,
/// Media Player Icon Object ID characteristic
ACC_MC_CHAR_TYPE_PLAYER_ICON_OBJ_ID,
/// Media Player Icon URL characteristic
ACC_MC_CHAR_TYPE_PLAYER_ICON_URL,
/// Playing Order Supported characteristic
ACC_MC_CHAR_TYPE_PLAYING_ORDER_SUPP,
/// Content Control ID
ACC_MC_CHAR_TYPE_CCID,
ACC_MC_CHAR_TYPE_MAX,
};
/// Descriptor type values
enum acc_mc_desc_type
{
/// Client Characteristic Configuration descriptor for Media Player Name characteristic
ACC_MC_DESC_TYPE_CCC_PLAYER_NAME = 0,
/// Client Characteristic Configuration descriptor for Track Changed characteristic
ACC_MC_DESC_TYPE_CCC_TRACK_CHANGED,
/// Client Characteristic Configuration descriptor for Track Title characteristic
ACC_MC_DESC_TYPE_CCC_TRACK_TITLE,
/// Client Characteristic Configuration descriptor for Track Duration characteristic
ACC_MC_DESC_TYPE_CCC_TRACK_DURATION,
/// Client Characteristic Configuration descriptor for Track Position characteristic
ACC_MC_DESC_TYPE_CCC_TRACK_POSITION,
/// Client Characteristic Configuration descriptor for Playback Speed characteristic
ACC_MC_DESC_TYPE_CCC_PLAYBACK_SPEED,
/// Client Characteristic Configuration descriptor for Seeking Speed characteristic
ACC_MC_DESC_TYPE_CCC_SEEKING_SPEED,
/// Client Characteristic Configuration descriptor for Current Track Object ID characteristic
ACC_MC_DESC_TYPE_CCC_CUR_TRACK_OBJ_ID,
/// Client Characteristic Configuration descriptor for Next Track Object ID characteristic
ACC_MC_DESC_TYPE_CCC_NEXT_TRACK_OBJ_ID,
/// Client Characteristic Configuration descriptor for Current Group Object ID characteristic
ACC_MC_DESC_TYPE_CCC_CUR_GROUP_OBJ_ID,
/// Client Characteristic Configuration descriptor for Parent Group Object ID characteristic
ACC_MC_DESC_TYPE_CCC_PARENT_GROUP_OBJ_ID,
/// Client Characteristic Configuration descriptor for Playing Order characteristic
ACC_MC_DESC_TYPE_CCC_PLAYING_ORDER,
/// Client Characteristic Configuration descriptor for Media State characteristic
ACC_MC_DESC_TYPE_CCC_MEDIA_STATE,
/// Client Characteristic Configuration descriptor for Media Control Point
ACC_MC_DESC_TYPE_CCC_MEDIA_CP,
/// Client Characteristic Configuration descriptor for Media Control Point Opcodes Supported
ACC_MC_DESC_TYPE_CCC_MEDIA_CP_OPCODES_SUPP,
/// Client Characteristic Configuration descriptor for Search Results Object ID
ACC_MC_DESC_TYPE_CCC_SEARCH_RESULTS_OBJ_ID,
/// Client Characteristic Configuration descriptor for Search Control Point
ACC_MC_DESC_TYPE_CCC_SEARCH_CP,
ACC_MC_DESC_TYPE_MAX,
};
/// Operation code values
enum acc_mc_opcode
{
/// Start playing the current track
ACC_MC_OPCODE_PLAY = 1,
/// Pause playing the current track
ACC_MC_OPCODE_PAUSE,
/// Fast forward the current track
ACC_MC_OPCODE_FAST_FW,
/// Fast rewind the current track
ACC_MC_OPCODE_FAST_RW,
/// Stop current activity and return to inactive state
ACC_MC_OPCODE_STOP,
/// Set the current position relative to the current position
ACC_MC_OPCODE_MOVE_RELATIVE = 16,
/// Set the current position to the previous segment of the current track
ACC_MC_OPCODE_PREV_SEG = 32,
/// Set the current position to the next segment of the current track
ACC_MC_OPCODE_NEXT_SEG,
/// Set the current position to the first segment of the current track
ACC_MC_OPCODE_FIRST_SEG,
/// Set the current position to the last segment of the current track
ACC_MC_OPCODE_LAST_SEG,
/// Set the current position to the nth segment of the current track
ACC_MC_OPCODE_GOTO_SEG,
/// Set the current track to the previous track in the current group playing order
ACC_MC_OPCODE_PREV_TRACK = 48,
/// Set the current track to the next track in the current group playing order
ACC_MC_OPCODE_NEXT_TRACK,
/// Set the current track to the first track in the current group playing order
ACC_MC_OPCODE_FIRST_TRACK,
/// Set the current track to the last track in the current group playing order
ACC_MC_OPCODE_LAST_TRACK,
/// Set the current track to the nth track in the current group playing order
ACC_MC_OPCODE_GOTO_TRACK,
/// Set the current group to the previous group in the sequence of groups
ACC_MC_OPCODE_PREV_GROUP = 64,
/// Set the current group to the next group in the sequence of groups
ACC_MC_OPCODE_NEXT_GROUP,
/// Set the current group to the first group in the sequence of groups
ACC_MC_OPCODE_FIRST_GROUP,
/// Set the current group to the next group in the sequence of groups
ACC_MC_OPCODE_LAST_GROUP,
/// Set the current group to the nth group in the sequence of groups
ACC_MC_OPCODE_GOTO_GROUP,
ACC_MC_MEDIA_CP_OPCODES_SUPP_MASK = 0x001FFFFF,
};
/// Search type values
enum acc_mc_search_type
{
ACC_MC_SEARCH_TYPE_MIN = 1,
/// Track Name
ACC_MC_SEARCH_TRACK_NAME = ACC_MC_SEARCH_TYPE_MIN,
/// Artist Name
ACC_MC_SEARCH_ARTIST_NAME,
/// Album Name
ACC_MC_SEARCH_ALBUM_NAME,
/// Group Name
ACC_MC_SEARCH_GROUP_NAME,
/// Earliest Year
ACC_MC_SEARCH_EARLIEST_YEAR,
/// Latest Year
ACC_MC_SEARCH_LATEST_YEAR,
/// Genre
ACC_MC_SEARCH_GENRE,
/// Only Tracks
ACC_MC_SEARCH_ONLY_TRACKS,
/// Only Groups
ACC_MC_SEARCH_ONLY_GROUPS,
ACC_MC_SEARCH_TYPE_MAX,
};
/// Media State values
enum acc_mc_media_state
{
/// Inactive
ACC_MC_MEDIA_STATE_INACTIVE = 0,
/// Playing
ACC_MC_MEDIA_STATE_PLAYING,
/// Paused
ACC_MC_MEDIA_STATE_PAUSED,
/// Seeking
ACC_MC_MEDIA_STATE_SEEKING,
ACC_MC_MEDIA_STATE_MAX,
};
/// Playing Order values
enum acc_mc_play_order
{
ACC_MC_PLAY_ORDER_MIN = 1,
/// A single track is played once there is no next track
ACC_MC_PLAY_ORDER_SINGLE_ONCE = ACC_MC_PLAY_ORDER_MIN,
/// A single track is played repeatedly; the next track is the current track
ACC_MC_PLAY_ORDER_SINGLE_REPEAT,
/// The tracks within a group are played once in track order
ACC_MC_PLAY_ORDER_ORDER_ONCE,
/// The tracks within a group are played in track order repeatedly
ACC_MC_PLAY_ORDER_ORDER_REPEAT,
/// The tracks within a group are played once only from the oldest first
ACC_MC_PLAY_ORDER_OLDEST_ONCE,
/// The tracks within a group are played from the oldest first repeatedly
ACC_MC_PLAY_ORDER_OLDEST_REPEAT,
/// The tracks within a group are played once only from the newest first
ACC_MC_PLAY_ORDER_NEWEST_ONCE,
/// The tracks within a group are played from the newest first repeatedly
ACC_MC_PLAY_ORDER_NEWEST_REPEAT,
/// The tracks within a group are played in random order once
ACC_MC_PLAY_ORDER_SHUFFLE_ONCE,
/// The tracks within a group are played in random order repeatedly
ACC_MC_PLAY_ORDER_SHUFFLE_REPEAT,
ACC_MC_PLAY_ORDER_MAX,
/// Mask for Playing Order Supported characteristic value
ACC_MC_PLAY_ORDER_SUPP_MASK = 0x03FF,
};
/// Result code values of Media Control Point Notificaiton
enum acc_mc_media_cp_result
{
ACC_MC_MEDIA_CP_RESULT_MIN = 1,
/// Success
ACC_MC_MEDIA_CP_RESULT_SUCCESS = ACC_MC_MEDIA_CP_RESULT_MIN,
/// Operation code not supported
ACC_MC_MEDIA_CP_RESULT_NOT_SUPPORTED,
/// Operation code action unsuccessful
ACC_MC_MEDIA_CP_RESULT_ACTION_UNSUCCESSFUL,
/// Media player inactive
ACC_MC_MEDIA_CP_RESULT_PLAYER_INACTIVE,
/// Command cannot be completed
ACC_MC_MEDIA_CP_RESULT_CANNOT_COMPLETE,
ACC_MC_MEDIA_CP_RESULT_MAX,
};
/// Result code values of Search Control Point Notification
enum acc_mc_search_cp_result
{
ACC_MC_SEARCH_CP_RESULT_MIN = 1,
/// Success
ACC_MC_SEARCH_CP_RESULT_SUCCESS = ACC_MC_SEARCH_CP_RESULT_MIN,
/// Failure
ACC_MC_SEARCH_CP_RESULT_FAILURE,
ACC_MC_SEARCH_CP_RESULT_MAX,
};
/// Media Control Point characteristic value position when written
enum acc_mc_cp_pos_wr
{
/// Operation code
ACC_MC_CP_POS_WR_OPCODE_POS = 0,
/// Parameter
ACC_MC_CP_POS_WR_PARAM_POS,
/// Minimum length
ACC_MC_CP_POS_WR_LEN_MIN = 1,
/// Maximum length
ACC_MC_CP_POS_WR_LEN_MAX = 5,
};
/// Media Control Point characteristic value position when notified
enum acc_mc_cp_pos_ntf
{
/// Operation code
ACC_MC_CP_POS_NTF_OPCODE_POS = 0,
/// Result code
ACC_MC_CP_POS_NTF_RESULT_POS,
/// Length
ACC_MC_CP_POS_NTF_LEN,
};
/// Search Control Point characteristic value position
enum acc_mc_search_cp_pos
{
/// Item length
ACC_MC_SEARCH_CP_ITEM_LEN_POS = 0,
/// Type
ACC_MC_SEARCH_CP_TYPE_POS,
/// Minimum length
ACC_MC_SEARCH_CP_LEN_MIN,
/// Minimum item length
ACC_MC_SEARCH_CP_ITEM_LEN_MIN = 1,
/// Parameter
ACC_MC_SEARCH_CP_PARAM_POS = ACC_MC_SEARCH_CP_LEN_MIN,
/// Maximum length
ACC_MC_SEARCH_CP_LEN_MAX = 64,
};
/*
* TYPES DEFINITION
****************************************************************************************
*/
/// Object ID
typedef struct acc_mc_object_id
{
/// Object ID
uint8_t obj_id[ACC_MC_OBJ_ID_LEN];
} acc_mc_object_id_t;
/// @}
#endif // ACC_MC_H_
@@ -0,0 +1,556 @@
/**
****************************************************************************************
*
* @file acc_mcc.h
*
* @brief Audio Content Control - Media Control Client - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_MCC_H_
#define ACC_MCC_H_
/**
****************************************************************************************
* @addtogroup ACC_MCC Audio Content Control - Media Control Client
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "acc_mc.h" // Audio Content Control - Media Control Definition
#if (GAF_ACC_MCC)
#include "gaf.h" // Generic Audio Framework Definitions
/*
* DEFINES
****************************************************************************************
*/
/// Maximum number of Media Control Service (Generic Media COntrol Service excluded)
/// that can be handled (limited by Media local index set in dummy value provided to GATT)
#define ACC_MCC_NB_MCS_MAX (126)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes
enum acc_mcc_cmd_codes
{
ACC_MCC_DISCOVER = GAF_CODE(ACC, MCC, 0),
ACC_MCC_GET = GAF_CODE(ACC, MCC, 1),
ACC_MCC_GET_CFG = GAF_CODE(ACC, MCC, 2),
ACC_MCC_SET_CFG = GAF_CODE(ACC, MCC, 3),
ACC_MCC_SET = GAF_CODE(ACC, MCC, 4),
ACC_MCC_SET_OBJECT_ID = GAF_CODE(ACC, MCC, 5),
ACC_MCC_CONTROL = GAF_CODE(ACC, MCC, 6),
ACC_MCC_SEARCH = GAF_CODE(ACC, MCC, 7),
};
/// List of GAF_REQ request codes
enum acc_mcc_msg_req_codes
{
ACC_MCC_CONFIGURE = GAF_CODE(ACC, MCC, 0),
ACC_MCC_RESTORE_BOND_DATA = GAF_CODE(ACC, MCC, 1),
};
/// List of GAF_IND indication codes
enum acc_mcc_msg_ind_codes
{
ACC_MCC_BOND_DATA = GAF_CODE(ACC, MCC, 0),
ACC_MCC_CFG = GAF_CODE(ACC, MCC, 1),
ACC_MCC_VALUE_LONG = GAF_CODE(ACC, MCC, 2),
ACC_MCC_VALUE = GAF_CODE(ACC, MCC, 3),
ACC_MCC_OBJECT_ID = GAF_CODE(ACC, MCC, 4),
ACC_MCC_TRACK_CHANGED = GAF_CODE(ACC, MCC, 5),
ACC_MCC_INCLUDED_SVC = GAF_CODE(ACC, MCC, 6),
ACC_MCC_SVC_CHANGED = GAF_CODE(ACC, MCC, 7),
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Content description structure for Media Control Service
typedef struct acc_mcc_mcs_info
{
/// Service description
prf_svc_t svc_info;
/// UUID
uint16_t uuid;
/// Characteristics description
prf_char_t char_info[ACC_MC_CHAR_TYPE_MAX];
/// Descriptors description
prf_desc_t desc_info[ACC_MC_DESC_TYPE_MAX];
} acc_mcc_mcs_info_t;
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called when handling of a command has been completed
*
* @param[in] cmd_code Command code
* @param[in] status Status
* @param[in] con_lid Connection local index
* @param[in] media_lid Media local index
* @param[in] param Additional parameter
* - Characteristic type
* - Characteristic type
* - Operation code
* @param[in] result Result code
****************************************************************************************
*/
typedef void (*acc_mcc_cb_cmp_evt)(uint16_t cmd_code, uint16_t status,
uint8_t con_lid, uint8_t media_lid, uint8_t param,
uint8_t result);
/**
****************************************************************************************
* @brief Callback function called when Client Characteristic Configuration of a notification-capable
* characteristic has been received
*
* @param[in] con_lid Connection local index
* @param[in] media_lid Media local index
* @param[in] char_type Characteristic type
* @param[in] enabled Indicate if sending of notifications is enabled or not
****************************************************************************************
*/
typedef void (*acc_mcc_cb_cfg)(uint8_t con_lid, uint8_t media_lid, uint8_t char_type,
uint8_t enabled);
/**
****************************************************************************************
* @brief Callback function called when value of one of the following characteristic is
* received:
* - Media Player Icon Object ID characteristic
* - Current Track Segments Object ID characteristic
* - Current Track Object ID characteristic
* - Next Track Object ID characteristic
* - Current Group Object ID characteristic
* - Parent Group Object ID characteristic
* - Search Results Object ID characteristic
*
* @param[in] con_lid Connection local index
* @param[in] media_lid Media local index
* @param[in] char_type Characteristic type
* @param[in] p_obj_id Pointer to Object Id
****************************************************************************************
*/
typedef void (*acc_mcc_cb_object_id)(uint8_t con_lid, uint8_t media_lid, uint8_t char_type,
acc_mc_object_id_t* p_obj_id);
/**
****************************************************************************************
* @brief Callback function called when a notification indicating that current track has
* changed has been received
*
* @param[in] con_lid Connection local index
* @param[in] media_lid Media local index
****************************************************************************************
*/
typedef void (*acc_mcc_cb_track_changed)(uint8_t con_lid, uint8_t media_lid);
/**
****************************************************************************************
* @brief Callback function called when value of one of the following characteristic is
* received:
* - Media Player Name characteristic
* - Media Player Icon URL characteristic
* - Track Title characteristic
*
* @param[in] con_lid Connection local index
* @param[in] media_lid Bearer local index
* @param[in] char_type Characteristic type
* @param[in] val_len Length of value
* @param[in] p_val Pointer to value
****************************************************************************************
*/
typedef void (*acc_mcc_cb_value_long)(uint8_t con_lid, uint8_t media_lid, uint8_t char_type,
uint16_t val_len, uint8_t* p_val);
/**
****************************************************************************************
* @brief Callback function called when value of one of the following characteristic is
* received:
* - Track Duration characteristic
* - Track Position characteristic
* - Playback Speed characteristic
* - Seeking Speed characteristic
* - Playing Order characteristic
* - Playing Order Supported characteristic
* - Media State characteristic
* - Media Control Point Opcodes Supported characteristic
* - Content Control ID characteristic
*
* @param[in] con_lid Connection local index
* @param[in] media_lid Media local index
* @param[in] char_type Characteristic type
* @param[in] val Value to be casted as follow:
* - Playback speed (uint8_t)
* - Seeking speed (int8_t)
* - State (uint8_t)
* - Supported operation codes bit field (uint32_t)
* - Playing order (uint8_t)
* - Supported playing orders bit field (uint32_t)
* - Track duration (uint32_t)
* - Track position (uint32_t)
* - CCID (uint8_t)
****************************************************************************************
*/
typedef void (*acc_mcc_cb_value)(uint8_t con_lid, uint8_t media_lid, uint8_t char_type,
uint32_t val);
/**
****************************************************************************************
* @brief Callback function called when an instance of (Generic) Media Control Control
* Service has been discovered
*
* @param[in] con_lid Connection local index
* @param[in] media_lid Media local index
* @param[in] p_mcs_info Pointer to Content description structure
****************************************************************************************
*/
typedef void (*acc_mcc_cb_bond_data)(uint8_t con_lid, uint8_t media_lid, acc_mcc_mcs_info_t* p_mcs_info);
/**
****************************************************************************************
* @brief Callback function called when an included Object Transfer Service instance has been
* discovered
*
* @param[in] con_lid Connection local index
* @param[in] shdl Start handle
* @param[in] ehdl End handle
****************************************************************************************
*/
typedef void (*acc_mcc_cb_included_svc)(uint8_t con_lid, uint16_t shdl, uint16_t ehdl);
/**
****************************************************************************************
* @brief Callback function called when a service changed indication has been received from a Server device
*
* @param[in] con_lid Connection local index
****************************************************************************************
*/
typedef void (*acc_mcc_cb_svc_changed)(uint8_t con_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Media Control Client
typedef struct acc_mcc_cb
{
/// Callback function called when handling of a command has been completed
acc_mcc_cb_cmp_evt cb_cmp_evt;
/// Callback function called when Client Characteristic Configuration of a notification-capable
/// characteristic has been received
acc_mcc_cb_cfg cb_cfg;
/// Callback function called when value of one of the following characteristic is
/// received:
/// - Media Player Icon Object ID characteristic
/// - Current Track Segments Object ID characteristic
/// - Current Track Object ID characteristic
/// - Next Track Object ID characteristic
/// - Current Group Object ID characteristic
/// - Parent Group Object ID characteristic
/// - Search Results Object ID characteristic
acc_mcc_cb_object_id cb_object_id;
/// Callback function called when a notification indicating that current track has
/// changed has been received
acc_mcc_cb_track_changed cb_track_changed;
/// Callback function called when value of one of the following characteristic is
/// received:
/// - Media Player Name characteristic
/// - Media Player Icon URL characteristic
/// - Track Title characteristic
acc_mcc_cb_value_long cb_value_long;
/// Callback function called when value of one of the following characteristic is
/// received:
/// - Track Duration characteristic
/// - Track Position characteristic
/// - Playback Speed characteristic
/// - Seeking Speed characteristic
/// - Playing Order characteristic
/// - Playing Order Supported characteristic
/// - Media State characteristic
/// - Media Control Point Opcodes Supported characteristic
/// - Content Control ID characteristic
acc_mcc_cb_value cb_value;
/// Callback function called when an instance of (Generic) Media Control Control
/// Service has been discovered
acc_mcc_cb_bond_data cb_bond_data;
/// Callback function called when an included Object Transfer Service instance has been
/// discovered
acc_mcc_cb_included_svc cb_included_svc;
/// Callback function called when a service changed indication has been received from a Server device
acc_mcc_cb_svc_changed cb_svc_changed;
} acc_mcc_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure use of Media Control Client module as Client
*
* @param[in] p_cb Pointer to set of callback functions for communication with upper
* layers
* @param[in] pref_mtu Preferred MTU. Values from 0 to 63 are equivalent to 64
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcc_configure(const acc_mcc_cb_t* p_cb, uint16_t pref_mtu);
/**
****************************************************************************************
* @brief Enable use of Media Control Service block as Client for a Server device with which
* a bonding has been established during a previous connection.
*
* @param[in] con_lid Connection local index
* @param[in] nb_media Number of instances of the (Generic) Media Control Service
* @param[in] p_mcs_info Pointer to Content description structures
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcc_restore_bond_data(uint8_t con_lid, uint8_t nb_media, acc_mcc_mcs_info_t* p_mcs_info);
/**
****************************************************************************************
* @brief Enable use of Media Control Service block as Client for a connected device with which
* no bonding has been established during a previous connection.
*
* @param[in] con_lid Connection local index
* @param[in] nb_mcs_max Maximum number of (Generic) Media Control Service instances that can be
* found in peer device database
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcc_discover(uint8_t con_lid, uint8_t nb_tbs_max);
/**
****************************************************************************************
* @brief Get value for one of the following characteristics for a Media exposed by a Server
* device:
* - Media Player Name characteristic
* - Media Player Icon Object ID if characteristic is supported for the indicated Media
* - Media Player Icon URL characteristic if characteristic is supported for the indicated Media
* - Track Title characteristic
* - Track Duration characteristic
* - Track Position characteristic
* - Playback Speed characteristic if characteristic is supported for the indicated Media
* - Seeking Speed characteristic if characteristic is supported for the indicated Media
* - Current Track Segments Object ID characteristic if characteristic is supported for the
* indicated Media
* - Current Track Object ID characteristic if characteristic is supported for the indicated Media
* - Next Track Object ID characteristic if characteristic is supported for the indicated Media
* - Current Group Object ID characteristic if characteristic is supported for the indicated Media
* - Parent Group Object ID characteristic if characteristic is supported for the indicated Media
* - Playing Order characteristic if characteristic is supported for the indicated Media
* - Playing Order Supported characteristic if characteristic is supported for the indicated Media
* - Media State characteristic
* - Media Control Point Opcodes Supported characteristic if characteristic is supported for
* the indicated Media
* - Search Results Object ID characteristic if characteristic is supported for the indicated Media
* - Content Control ID characteristic
*
* @param[in] con_lid Connection local index
* @param[in] media_lid Media local index
* @param[in] char_type Characteristic type
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcc_get(uint8_t con_lid, uint8_t media_lid, uint8_t char_type);
/**
****************************************************************************************
* @brief Enable or disable sending of notifications for one of the following characteristics for
* a Media exposed by a Server device:
* - Media Player Name characteristic if sending of notifications is supported for the characteristic
* - Track Changed characteristic
* - Track Title characteristic if sending of notifications is supported for the characteristic
* - Track Duration characteristic if sending of notifications is supported for the characteristic
* - Track Position characteristic if sending of notifications is supported for the characteristic
* - Playback Speed characteristic if characteristic is supported for the indicated Media and if
* sending of notifications if supported for the characteristic
* - Seeking Speed characteristic if characteristic is supported for the indicated Media and if
* sending of notifications if supported for the characteristic
* - Current Track Object ID characteristic if characteristic is supported for the indicated Media
* and if sending of notifications if supported for the characteristic
* - Next Track Object ID characteristic if characteristic is supported for the indicated Media and
* if sending of notifications if supported for the characteristic
* - Current Group Object ID characteristic if characteristic is supported for the indicated Media
* and if sending of notifications if supported for the characteristic
* - Parent Group Object ID characteristic if characteristic is supported for the indicated Media and
* if sending of notifications if supported for the characteristic
* - Playing Order characteristic if characteristic is supported for the indicated Media and if
* sending of notifications if supported for the characteristic
* - Media State characteristic
* - Media Control Point characteristic if characteristic is supported for the indicated Media
* - Media Control Point Opcodes Supported characteristic if characteristic is supported for the
* indicated Media and if sending of notifications if supported for the characteristic
* - Search Results Object ID characteristic if characteristic is supported for the indicated Media
*
* @param[in] con_lid Connection local index
* @param[in] media_lid Media local index
* @param[in] char_type Characteristic type
* @param[in] enable Indicate if sending of notifications must be enabled (!= 0) or
* disabled for the indicated characteristic
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcc_set_cfg(uint8_t con_lid, uint8_t media_lid, uint8_t char_type,
uint8_t enable);
/**
****************************************************************************************
* @brief Get current client configuration for one of the following characteristics for a Media
* exposed by a Server device:
* - Media Player Name characteristic if sending of notifications is supported for the characteristic
* - Track Changed characteristic
* - Track Title characteristic if sending of notifications is supported for the characteristic
* - Track Duration characteristic if sending of notifications is supported for the characteristic
* - Track Position characteristic if sending of notifications is supported for the characteristic
* - Playback Speed characteristic if characteristic is supported for the indicated Media and if
* sending of notifications if supported for the characteristic
* - Seeking Speed characteristic if characteristic is supported for the indicated Media and if
* sending of notifications if supported for the characteristic
* - Current Track Object ID characteristic if characteristic is supported for the indicated Media
* and if sending of notifications if supported for the characteristic
* - Next Track Object ID characteristic if characteristic is supported for the indicated Media and
* if sending of notifications if supported for the characteristic
* - Current Group Object ID characteristic if characteristic is supported for the indicated Media
* and if sending of notifications if supported for the characteristic
* - Parent Group Object ID characteristic if characteristic is supported for the indicated Media and
* if sending of notifications if supported for the characteristic
* - Playing Order characteristic if characteristic is supported for the indicated Media and if
* sending of notifications if supported for the characteristic
* - Media State characteristic
* - Media Control Point characteristic if characteristic is supported for the indicated Media
* - Media Control Point Opcodes Supported characteristic if characteristic is supported for the
* indicated Media and if sending of notifications if supported for the characteristic
* - Search Results Object ID characteristic if characteristic is supported for the indicated Media
*
* @param[in] con_lid Connection local index
* @param[in] media_lid Media local index
* @param[in] char_type Characteristic type
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcc_get_cfg(uint8_t con_lid, uint8_t media_lid, uint8_t char_type);
/**
****************************************************************************************
* @brief Set value of one of the following characteristics for a Media exposed by a Server device:
* - Track Position characteristic
* - Playback Speed characteristic if characteristic is supported for the indicated Media
* - Playing Order characteristic if characteristic is supported for the indicated Media
*
* @param[in] con_lid Connection local index
* @param[in] media_lid Media local index
* @param[in] char_type Characteristic type
* @param[in] reliable Indicate if feedback from Server device is required (!= 0)
* or not
* @param[in] val Value to be casted as follow:
* - Track position (uint32_t)
* - Playback speed (int8_t)
* - Playing order (uint8_t)
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcc_set(uint8_t con_lid, uint8_t media_lid, uint8_t char_type,
uint8_t reliable, uint32_t val);
#if (GAF_ACC_OTC)
/**
****************************************************************************************
* @brief Set value of one of the following characteristics for a Media exposed by a Server device:
* - Current Track Segments Object ID characteristic if characteristic is supported
* for the indicated Media
* - Next Track Object ID characteristic if characteristic is supported for the
* indicated Media
* - Current Group Object ID characteristic if characteristic is supported for the
* indicated Media
*
* @param[in] con_lid Connection local index
* @param[in] media_lid Media local index
* @param[in] char_type Characteristic type
* @param[in] reliable Indicate if feedback from Server device is required (!= 0)
* or not
* @param[in] p_object_id Pointer to Object ID
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcc_set_object_id(uint8_t con_lid, uint8_t media_lid, uint8_t char_type,
uint8_t reliable, acc_mc_object_id_t* p_obj_id);
#endif //(GAF_ACC_OTC)
/**
****************************************************************************************
* @brief Control behavior of a Media exposed by a Server device if Media Control Point
* characteristic is supported for this Media.
*
* @param[in] con_lid Connection local index
* @param[in] media_lid Media local index
* @param[in] opcode Operation code
* @param[in] reliable Indicate if feedback from Server device is required (!= 0)
* or not
* @param[in] val Value (for Goto Segment or Move Relative or Goto Track or
* Goto Group)
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcc_control(uint8_t con_lid, uint8_t media_lid, uint8_t opcode,
uint8_t reliable, uint32_t val);
#if (GAF_ACC_OTC)
/**
****************************************************************************************
* @brief Request from a Service device to perform a search of all the media for one of its
* exposed Media.
*
* @param[in] con_lid Connection local index
* @param[in] media_lid Media local index
* @param[in] reliable Indicate if feedback from Server device is required (!= 0)
* or not
* @param[in] param_len Length of parameter value
* @param[in] p_param Pointer to parameter value
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcc_search(uint8_t con_lid, uint8_t media_lid, uint8_t reliable,
uint8_t param_len, uint8_t* p_param);
#endif //(GAF_ACC_OTC)
#endif //(GAF_ACC_MCC)
/// @}
#endif // ACC_MCC_H_
@@ -0,0 +1,369 @@
/**
****************************************************************************************
*
* @file acc_mcc_msg.h
*
* @brief Audio Content Control - Definition of Kernel Messages (Media Control Client)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_MCC_MSG_H_
#define ACC_MCC_MSG_H_
/**
****************************************************************************************
* @addtogroup ACC_MCC_MSG Audio Content Control - Definition of Kernel Messages
* (Media Control Client)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "acc_msg.h" // ACC Message Definitions
#include "rwip_task.h" // RW IP Task Definition
#include "acc_mcc.h" // Audio Content Control - Media Control Client Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ACC_MCC_DISCOVER command message
typedef struct acc_mcc_discover_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Maximum number of (Generic) Media Control Service instance that can be found
uint8_t nb_mcs_max;
} acc_mcc_discover_cmd_t;
/// Structure for ACC_MCC_GET command message
typedef struct acc_mcc_get_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
/// Characteristic type
uint8_t char_type;
} acc_mcc_get_cmd_t;
/// Structure for ACC_MCC_SET_CFG command message
typedef struct acc_mcc_set_cfg_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
/// Characteristic type
uint8_t char_type;
/// Indicate if sending of notifications must be enabled (!=0) or disabled
uint8_t enable;
} acc_mcc_set_cfg_cmd_t;
/// Structure for ACC_MCC_GET_CFG command message
typedef struct acc_mcc_get_cfg_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
/// Characteristic type
uint8_t char_type;
} acc_mcc_get_cfg_cmd_t;
/// Structure for ACC_MCC_SET command message
typedef struct acc_mcc_set_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
/// Characteristic type
uint8_t char_type;
/// Indicate if feedback from Server device is required (!= 0) or not
uint8_t reliable;
union
{
/// Value
uint32_t val;
/// Track position
int32_t track_pos;
/// Playback speed
int8_t playback_speed;
/// Playing order
uint8_t playing_order;
} u;
} acc_mcc_set_cmd_t;
/// Structure for ACC_MCC_SET_OBJECT_ID command message
typedef struct acc_mcc_set_object_id_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
/// Characteristic type
uint8_t char_type;
/// Indicate if feedback from Server device is required (!= 0) or not
uint8_t reliable;
/// Object ID
acc_mc_object_id_t obj_id;
} acc_mcc_set_object_id_cmd_t;
/// Structure for ACC_MCC_CONTROL command message
typedef struct acc_mcc_control_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
/// Operation code
uint8_t opcode;
/// Indicate if feedback from Server device is required (!= 0) or not
uint8_t reliable;
union
{
/// Value
uint32_t val;
/// Parameter for Goto Segment operation code
uint32_t segment;
/// Parameter for Move Relative operation code
uint32_t offset;
/// Parameter for Goto Track operation code
uint32_t track;
/// Parameter for Goto Group operation code
uint32_t group;
} u;
} acc_mcc_control_cmd_t;
/// Structure for ACC_MCC_SEARCH command message
typedef struct acc_mcc_search_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
/// Indicate if feedback from Server device is required (!= 0) or not
uint8_t reliable;
/// Length of parameter value
uint8_t param_len;
/// Pointer to parameter value
uint8_t param[__ARRAY_EMPTY];
} acc_mcc_search_cmd_t;
/// Structure for command complete event message
typedef struct acc_mcc_cmp_evt
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
union
{
/// Additional parameter
uint8_t param;
/// Characteristic type
uint8_t char_type;
/// Operation code
uint8_t opcode;
} u;
/// Result
uint8_t result;
} acc_mcc_cmp_evt_t;
/// Structure for ACC_MCC_CONFIGURE request message
typedef struct acc_mcc_configure_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Preferred MTU
uint16_t pref_mtu;
} acc_mcc_configure_req_t;
/// Structure for ACC_MCC_RESTORE_BOND_DATA request message
typedef struct acc_mcc_restore_bond_data_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Number of instances of the (Generic) Media Control Service discovered
uint8_t nb_media;
/// Content description of (Generic) Media Control Service instances
acc_mcc_mcs_info_t mcs_info[__ARRAY_EMPTY];
} acc_mcc_restore_bond_data_req_t;
/// Structure for response message
typedef struct acc_mcc_rsp
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
} acc_mcc_rsp_t;
/// Structure for ACC_MCC_BOND_DATA indication message
typedef struct acc_mcc_bond_data_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
/// Content description of (Generic) Media Control Service instance
acc_mcc_mcs_info_t mcs_info;
} acc_mcc_bond_data_ind_t;
/// Structure for ACC_MCC_CFG indication message
typedef struct acc_mcc_cfg_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
/// Characteristic type
uint8_t char_type;
/// Indicate if sending of notifications is enabled (!= 0) or not
uint8_t enabled;
} acc_mcc_cfg_ind_t;
/// Structure for ACC_MCC_OBJECT_ID indication message
typedef struct acc_mcc_object_id_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
/// Characteristic type
uint8_t char_type;
/// Object ID
acc_mc_object_id_t obj_id;
} acc_mcc_object_id_ind_t;
/// Structure for ACC_MCC_INCLUDED_SVC indication message
typedef struct acc_mcc_included_svc_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Start handle
uint16_t shdl;
/// End handle
uint16_t ehdl;
} acc_mcc_included_svc_ind_t;
/// Structure for ACC_MCC_TRACK_CHANGED indication message
typedef struct acc_mcc_track_changed_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
} acc_mcc_track_changed_ind_t;
/// Structure for ACC_MCC_VALUE_LONG indication message
typedef struct acc_mcc_value_long_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
/// Characteristic type
uint8_t char_type;
/// Length of value
uint16_t val_len;
/// Value
uint8_t val[__ARRAY_EMPTY];
} acc_mcc_value_long_ind_t;
/// Structure for ACC_MCC_VALUE indication message
typedef struct acc_mcc_value_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Media local index
uint8_t media_lid;
/// Characteristic type
uint8_t char_type;
/// Value
union
{
/// Value
uint32_t val;
/// Playback speed
int8_t playback_speed;
/// Seeking speed
int8_t seeking_speed;
/// Media state
uint8_t state;
/// Supported media control operation codes bit field
uint32_t opcodes_supp_bf;
/// Playing Order
uint8_t playing_order;
/// Supported Playing Order bit field
uint32_t playing_order_supp_bf;
/// Track duration of the current track in 0.01 second resolution
int32_t track_dur;
/// Track position of the current track in 0.01 second resolution
int32_t track_pos;
/// Content Control ID
uint8_t ccid;
} val;
} acc_mcc_value_ind_t;
/// Structure for ACC_MCC_SVC_CHANGED indication message
typedef struct acc_mcc_svc_changed_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
} acc_mcc_svc_changed_ind_t;
/// @}
#endif // ACC_MCC_MSG_H_
@@ -0,0 +1,529 @@
/**
****************************************************************************************
*
* @file acc_mcs.h
*
* @brief Audio Content Control - Media Control Server - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_MCS_H_
#define ACC_MCS_H_
/**
****************************************************************************************
* @addtogroup ACC_MCS Audio Content Control - Media Control Server
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "acc_mc.h" // Audio Content Control - Media Control Definition
#if (GAF_ACC_MCS)
#include "gaf.h" // Generic Audio Framework Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_REQ request codes
enum acc_mcs_msg_req_codes
{
ACC_MCS_CONFIGURE = GAF_CODE(ACC, MCS, 0),
ACC_MCS_ADD = GAF_CODE(ACC, MCS, 1),
ACC_MCS_ENABLE = GAF_CODE(ACC, MCS, 2),
ACC_MCS_RESTORE_BOND_DATA = GAF_CODE(ACC, MCS, 3),
ACC_MCS_SET = GAF_CODE(ACC, MCS, 4),
ACC_MCS_SET_OBJECT_ID = GAF_CODE(ACC, MCS, 5),
ACC_MCS_SET_PLAYER_NAME = GAF_CODE(ACC, MCS, 6),
ACC_MCS_ACTION = GAF_CODE(ACC, MCS, 7),
ACC_MCS_TRACK_CHANGE = GAF_CODE(ACC, MCS, 8),
};
/// List of GAF_IND indication codes
enum acc_mcs_msg_ind_codes
{
ACC_MCS_BOND_DATA = GAF_CODE(ACC, MCS, 0),
};
/// List of GAF_REQ_IND request indication codes
enum acc_mcs_msg_req_ind_codes
{
ACC_MCS_SET_OBJECT_ID_RI = GAF_CODE(ACC, MCS, 0),
ACC_MCS_CONTROL = GAF_CODE(ACC, MCS, 1),
ACC_MCS_SEARCH = GAF_CODE(ACC, MCS, 2),
ACC_MCS_GET = GAF_CODE(ACC, MCS, 3),
ACC_MCS_GET_POSITION = GAF_CODE(ACC, MCS, 4),
ACC_MCS_SET_RI = GAF_CODE(ACC, MCS, 5),
};
/// Media configuration bit field
enum acc_mcs_cfg_bf
{
/// Indicate if added Service if the Generic Media Control Service (= 1) or an instance
/// of the Media Control Service
ACC_MCS_CFG_GENERIC_POS = 0,
ACC_MCS_CFG_GENERIC_BIT = CO_BIT(ACC_MCS_CFG_GENERIC_POS),
/// Indicate if sending of notifications is supported (= 1) for the Media Player Name
/// characteristic
/// Meaningless for Generic Media Control Service as support is mandatory
ACC_MCS_CFG_PLAYER_NAME_NTF_SUPP_POS = 1,
ACC_MCS_CFG_PLAYER_NAME_NTF_SUPP_BIT = CO_BIT(ACC_MCS_CFG_PLAYER_NAME_NTF_SUPP_POS),
/// Indicate if Media Player Icon Object ID characteristic is supported (= 1) or not
ACC_MCS_CFG_PLAYER_ICON_OBJ_ID_SUPP_POS = 2,
ACC_MCS_CFG_PLAYER_ICON_OBJ_ID_SUPP_BIT = CO_BIT(ACC_MCS_CFG_PLAYER_ICON_OBJ_ID_SUPP_POS),
/// Indicate if Media Player Icon URL characteristic is supported
ACC_MCS_CFG_PLAYER_ICON_URL_SUPP_POS = 3,
ACC_MCS_CFG_PLAYER_ICON_URL_SUPP_BIT = CO_BIT(ACC_MCS_CFG_PLAYER_ICON_URL_SUPP_POS),
/// Indicate if sending of notifications is supported (= 1) for the Track Title characteristic
ACC_MCS_CFG_TRACK_TITLE_NTF_SUPP_POS = 4,
ACC_MCS_CFG_TRACK_TITLE_NTF_SUPP_BIT = CO_BIT(ACC_MCS_CFG_TRACK_TITLE_NTF_SUPP_POS),
/// Indicate if sending of notifications is supported (= 1) for the Track Duration characteristic
ACC_MCS_CFG_TRACK_DURATION_NTF_SUPP_POS = 5,
ACC_MCS_CFG_TRACK_DURATION_NTF_SUPP_BIT = CO_BIT(ACC_MCS_CFG_TRACK_DURATION_NTF_SUPP_POS),
/// Indicate if sending of notifications is supported (= 1) for the Track Position characteristic
ACC_MCS_CFG_TRACK_POSITION_NTF_SUPP_POS = 6,
ACC_MCS_CFG_TRACK_POSITION_NTF_SUPP_BIT = CO_BIT(ACC_MCS_CFG_TRACK_POSITION_NTF_SUPP_POS),
/// Indicate if sending of notifications is supported (= 1) for the Playback Speed characteristic
ACC_MCS_CFG_PLAYBACK_SPEED_NTF_SUPP_POS = 7,
ACC_MCS_CFG_PLAYBACK_SPEED_NTF_SUPP_BIT = CO_BIT(ACC_MCS_CFG_PLAYBACK_SPEED_NTF_SUPP_POS),
/// Indicate if sending of notifications is supported (= 1) for the Seeking Speed characteristic
ACC_MCS_CFG_SEEKING_SPEED_NTF_SUPP_POS = 8,
ACC_MCS_CFG_SEEKING_SPEED_NTF_SUPP_BIT = CO_BIT(ACC_MCS_CFG_SEEKING_SPEED_NTF_SUPP_POS),
/// Indicate if Current Track Object ID characteristic is supported (= 1) or not
/// If supported, following characteristic are also supported:
/// - Current Track Segments Object ID characteristic
/// - Next Track Object ID characteristic
/// - Current Group Object ID characteristic
/// - Parent Group Object ID characteristic
ACC_MCS_CFG_CURR_TRACK_OBJ_ID_SUPP_POS = 9,
ACC_MCS_CFG_CURR_TRACK_OBJ_ID_SUPP_BIT = CO_BIT(ACC_MCS_CFG_CURR_TRACK_OBJ_ID_SUPP_POS),
/// Indicate if sending of notifications is supported (= 1) for the Current Track Object ID
/// characteristic
ACC_MCS_CFG_CURR_TRACK_NTF_SUPP_POS = 10,
ACC_MCS_CFG_CURR_TRACK_NTF_SUPP_BIT = CO_BIT(ACC_MCS_CFG_CURR_TRACK_NTF_SUPP_POS),
/// Indicate if sending of notifications is supported (= 1) for the Next Track Object ID
/// characteristic
ACC_MCS_CFG_NEXT_TRACK_NTF_SUPP_POS = 11,
ACC_MCS_CFG_NEXT_TRACK_NTF_SUPP_BIT = CO_BIT(ACC_MCS_CFG_NEXT_TRACK_NTF_SUPP_POS),
/// Indicate if sending of notifications is supported (= 1) for the Current Group Object ID
/// characteristic
ACC_MCS_CFG_CURR_GROUP_NTF_SUPP_POS = 12,
ACC_MCS_CFG_CURR_GROUP_NTF_SUPP_BIT = CO_BIT(ACC_MCS_CFG_CURR_GROUP_NTF_SUPP_POS),
/// Indicate if sending of notifications is supported (= 1) for the Parent Group Object ID
/// characteristic
ACC_MCS_CFG_PARENT_GROUP_NTF_SUPP_POS = 13,
ACC_MCS_CFG_PARENT_GROUP_NTF_SUPP_BIT = CO_BIT(ACC_MCS_CFG_PARENT_GROUP_NTF_SUPP_POS),
/// Indicate if Player Order characteristic is supported (= 1) or not
ACC_MCS_CFG_PLAYING_ORDER_SUPP_POS = 14,
ACC_MCS_CFG_PLAYING_ORDER_SUPP_BIT = CO_BIT(ACC_MCS_CFG_PLAYING_ORDER_SUPP_POS),
/// Indicate if Player Order Supported characteristic is supported (= 1) or not
ACC_MCS_CFG_PLAYING_ORDER_SUPP_SUPP_POS = 15,
ACC_MCS_CFG_PLAYING_ORDER_SUPP_SUPP_BIT = CO_BIT(ACC_MCS_CFG_PLAYING_ORDER_SUPP_SUPP_POS),
/// Indicate if sending of notifications is supported (= 1) for the Playing Order characteristic
ACC_MCS_CFG_PLAYING_ORDER_NTF_SUPP_POS = 16,
ACC_MCS_CFG_PLAYING_ORDER_NTF_SUPP_BIT = CO_BIT(ACC_MCS_CFG_PLAYING_ORDER_NTF_SUPP_POS),
/// Indicate if Media Control Point characteristic (= 1) is supported or not
/// If supported, the Media Control Point Opcodes Supported characteristic is also supported
ACC_MCS_CFG_MEDIA_CP_SUPP_POS = 17,
ACC_MCS_CFG_MEDIA_CP_SUPP_BIT = CO_BIT(ACC_MCS_CFG_MEDIA_CP_SUPP_POS),
/// Indicate if sending of notifications is supported (= 1) for the Media Control Point
/// Opcodes Supported characteristic
ACC_MCS_CFG_MEDIA_CP_OPCODE_NTF_SUPP_POS = 18,
ACC_MCS_CFG_MEDIA_CP_OPCODE_NTF_SUPP_BIT = CO_BIT(ACC_MCS_CFG_MEDIA_CP_OPCODE_NTF_SUPP_POS),
/// Indicate if Search Results Object ID characteristic is supported (= 1) or not
/// If supported, the Search Control Point characteristic is also supported
ACC_MCS_CFG_SEARCH_RESULT_OBJ_ID_SUPP_POS = 19,
ACC_MCS_CFG_SEARCH_RESULT_OBJ_ID_SUPP_BIT = CO_BIT(ACC_MCS_CFG_SEARCH_RESULT_OBJ_ID_SUPP_POS),
/// Indicate if Seeking Speed characteristic is supported
ACC_MCS_CFG_SEEKING_SPEED_SUPP_POS = 20,
ACC_MCS_CFG_SEEKING_SPEED_SUPP_BIT = CO_BIT(ACC_MCS_CFG_SEEKING_SPEED_SUPP_POS),
/// Indicate if Playback Speed characteristic is supported
ACC_MCS_CFG_PLAYBACK_SPEED_SUPP_POS = 21,
ACC_MCS_CFG_PLAYBACK_SPEED_SUPP_BIT = CO_BIT(ACC_MCS_CFG_PLAYBACK_SPEED_SUPP_POS),
};
/// Action type values
enum acc_mcs_action
{
/// No action
ACC_MCS_ACTION_NO_ACTION = 0,
/// Play
ACC_MCS_ACTION_PLAY,
/// Pause
ACC_MCS_ACTION_PAUSE,
/// Stop
ACC_MCS_ACTION_STOP,
/// Fast Forward or Fast Rewind
ACC_MCS_ACTION_SEEK,
/// Current Track becomes invalid
ACC_MCS_ACTION_INACTIVE,
/// Change track
ACC_MCS_ACTION_CHANGE_TRACK,
ACC_MCS_ACTION_MAX
};
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called when Client Characteristic Configuration of a
* notification-capable characteristic has been updated by a peer client
*
* @param[in] media_lid Media local index
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field
****************************************************************************************
*/
typedef void (*acc_mcs_cb_bond_data)(uint8_t media_lid, uint8_t con_lid, uint32_t cli_cfg_bf);
/**
****************************************************************************************
* @brief Callback function called when either Current Track Object ID or Next Track Object
* ID or CUrrent Group Object ID characteristic value has been written by a Client device
*
* @param[in] media_lid Media local index
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] p_obj_id Pointer to Object ID
****************************************************************************************
*/
typedef void (*acc_mcs_cb_set_object_id_req)(uint8_t media_lid, uint8_t con_lid, uint8_t char_type,
acc_mc_object_id_t* p_obj_id);
/**
****************************************************************************************
* @brief Callback function called when a Client device request a control on a Media
*
* @param[in] media_lid Media local index
* @param[in] con_lid Connection local index
* @param[in] opcode Operation code
* @param[in] val Value
****************************************************************************************
*/
typedef void (*acc_mcs_cb_control_req)(uint8_t media_lid, uint8_t con_lid,
uint8_t opcode, uint32_t val);
/**
****************************************************************************************
* @brief Callback function called when a Search request has been received from Client device
*
* @param[in] media_lid Media local index
* @param[in] con_lid Connection local index
* @param[in] param_len Length of Search Parameters value
* @param[in] p_param Pointer to Search Parameters value
****************************************************************************************
*/
typedef void (*acc_mcs_cb_search_req)(uint8_t media_lid, uint8_t con_lid,
uint8_t param_len, uint8_t* p_param);
/**
****************************************************************************************
* @brief Callback function called when a Client device request to set value for either
* Media Player Name or Media Player Icon Object URL or Track Title characteristic
*
* @param[in] media_lid Media local index
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] token Token
* @param[in] offset Offset
* @param[in] length Maximum length
****************************************************************************************
*/
typedef void (*acc_mcs_cb_get_req)(uint8_t media_lid, uint8_t con_lid, uint8_t char_type,
uint16_t token, uint16_t offset, uint16_t length);
/**
****************************************************************************************
* @brief Callback function called when Client device tries to get the current Track Position
*
* @param[in] media_lid Media local index
* @param[in] con_lid Connection local index
* @param[in] token Token
****************************************************************************************
*/
typedef void (*acc_mcs_cb_get_position_req)(uint8_t media_lid, uint8_t con_lid, uint16_t token);
/**
****************************************************************************************
* @brief Callback function called when a Client device request to set value for either
* Track Position or Playback Speed or Playing Order characteristic
*
* @param[in] media_lid Media local index
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] val Value
****************************************************************************************
*/
typedef void (*acc_mcs_cb_set_req)(uint8_t media_lid, uint8_t con_lid, uint8_t char_type,
uint32_t val);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Media Control Server
typedef struct acc_mcs_cb
{
/// Callback function called when Client Characteristic Configuration of a notification-capable
/// characteristic has been updated by a peer client
acc_mcs_cb_bond_data cb_bond_data;
/// Callback function called when either Current Track Object ID or Next Track Object
/// ID or CUrrent Group Object ID characteristic value has been written by a Client device
acc_mcs_cb_set_object_id_req cb_set_object_id_req;
/// Callback function called when a Search request has been received from Client device
acc_mcs_cb_search_req cb_search_req;
/// Callback function called when a Client device request a control on a Media
acc_mcs_cb_control_req cb_control_req;
/// Callback function called when a Client device request to set value for either
/// Media Player Name or Media Player Icon Object URL or Track Title characteristic
acc_mcs_cb_get_req cb_get_req;
/// Callback function called when Client device tries to get the current Track Position
acc_mcs_cb_get_position_req cb_get_position_req;
/// Callback function called when a Client device request to set value for either
/// Track Position or Playback Speed or Playing Order characteristic
acc_mcs_cb_set_req cb_set_req;
} acc_mcs_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure use of Media Control Server module as Server
*
* @param[in] nb_mcs Number of instances of the (Generic) Media Control Service
* Value 0 is prohibited
* @param[in] p_cb Pointer to set of callback functions for communication with upper
* layer
* @param[in] pref_mtu Preferred MTU
* Values from 0 to 63 are equivalent to 64
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcs_configure(uint8_t nb_mcs, const acc_mcs_cb_t* p_cb, uint16_t pref_mtu);
/**
****************************************************************************************
* @brief Add and configure an instance of the Media Control Service in the database
*
* @param[in] cfg_bf Configuration bit field
* @param[in] playing_order_supp_bf Supported playing order bit field
* @param[in] ots_shdl Start handle of included Object Transfer Service
* @param[in] ots_ehdl End handle of included Object Transfer Service
* @param[in] ccid Content Control ID
* @param[in] p_icon_obj_id Pointer to Media Player Icon Object ID
* @param[in] nb_att_rsvd Number of attributes reserved
* @param[out] p_media_lid Pointer at which allocated Media local index is returned
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcs_add(uint32_t cfg_bf, uint32_t playing_order_supp_bf, uint16_t ots_shdl,
uint16_t ots_ehdl, uint8_t ccid, acc_mc_object_id_t* p_icon_obj_id,
uint8_t nb_att_rsvd, uint8_t* p_media_lid);
/**
****************************************************************************************
* @brief Enable use of Media Control Server module as Server
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcs_enable(void);
/**
****************************************************************************************
* @brief Set bonding information for either the Generic Media Control Service or an instance
* of the Media Control Service Service after connection with a Client device with which a
* bonded relationship had been established during a previous connection.
*
* @param[in] media_lid Media local index
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcs_restore_bond_data(uint8_t media_lid, uint8_t con_lid, uint32_t cli_cfg_bf);
/**
****************************************************************************************
* @brief Set value for either of Track Position characteristic or Playback Speed characteristic
* or Media Control Point Opcodes Supported characteristic or Playing Order characteristic
*
* @param[in] media_lid Media local index
* @param[in] char_type Characteristic type
* @param[in] val Value
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcs_set(uint8_t media_lid, uint8_t char_type, uint32_t val);
#if (GAF_ACC_OTS)
/**
****************************************************************************************
* @brief Set value for Next Track Object ID characteristic
*
* @param[in] media_lid Media local index
* @param[in] p_obj_id Pointer to Object ID
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcs_set_object_id(uint8_t media_lid, acc_mc_object_id_t* p_obj_id);
#endif //(GAF_ACC_OTS)
/**
****************************************************************************************
* @brief Indicate an update of the Media Player Name value
*
* @param[in] media_lid Media local index
* @param[in] name_len Length of Media Player Name value
* @param[in] p_name Pointer to Media Player Name value
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcs_set_player_name(uint8_t media_lid, uint8_t name_len, uint8_t* p_name);
/**
****************************************************************************************
* @brief Indicate that an action has been performed on a media (play, pause, stop, ...)
*
* @param[in] media_lid Media local index
* @param[in] action Action
* @param[in] track_pos Track Position
* @param[in] seeking_speed Seeking Speed
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcs_action(uint8_t media_lid, uint8_t action, int32_t track_pos,
int8_t seeking_speed);
/**
****************************************************************************************
* @brief Indicate that current track has changed for a media
*
* @param[in] media_lid Media local index
* @param[in] track_dur Track Duration
* @param[in] p_segments_obj_id Pointer to Current Track Segments Object ID value
* @param[in] p_current_obj_id Pointer to Current Track Object ID value
* @param[in] p_next_obj_id Pointer to Next Track Object ID value
* @param[in] p_group_obj_id Pointer to Current Group Object ID value
* @param[in] p_parent_obj_id Pointer to Parent Group Object ID value
* @param[in] title_len Length of Track Title value
* @param[in] p_title Pointer to Track Title value
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_mcs_track_change(uint8_t media_lid, int32_t track_dur,
acc_mc_object_id_t* p_segments_obj_id, acc_mc_object_id_t* p_current_obj_id,
acc_mc_object_id_t* p_next_obj_id, acc_mc_object_id_t* p_group_obj_id,
acc_mc_object_id_t* p_parent_obj_id,
uint16_t title_len, uint8_t* p_title);
/**
****************************************************************************************
* @brief Confirmation for ACC_MCS_SET_OBJECT_ID or ACC_MCS_SET request indication.
*
* @param[in] status Status
* @param[in] media_lid Media local index
* @param[in] val Track position or Playback Speed value
*
* @return An error status
****************************************************************************************
*/
void acc_mcs_cfm_set(uint16_t status, uint8_t media_lid, uint32_t val);
/**
****************************************************************************************
* @brief Confirmation for ACC_MCS_CONTROL request indication.
*
* @param[in] media_lid Media local index
* @param[in] result Result
* @param[in] action Action
* @param[in] track_pos Track Position
* @param[in] seeking_speed Seeking Speed
*
* @return An error status
****************************************************************************************
*/
void acc_mcs_cfm_control(uint8_t media_lid, uint8_t result,
uint8_t action, int32_t track_pos, int8_t seeking_speed);
#if (GAF_ACC_OTS)
/**
****************************************************************************************
* @brief Confirmation for ACC_MCS_SEARCH request indication.
*
* @param[in] status Status
* @param[in] media_lid Media local index
* @param[in] p_obj_id Pointer to Search Result Object ID value
*
* @return An error status
****************************************************************************************
*/
void acc_mcs_cfm_search(uint16_t status, uint8_t media_lid, acc_mc_object_id_t* p_obj_id);
#endif //(GAF_ACC_OTS)
/**
****************************************************************************************
* @brief Confirmation for ACC_MCS_GET request indication.
*
* @param[in] status Status
* @param[in] media_lid Media local index
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] token Token
* @param[in] length Length
* @param[in] p_val Pointer to value
*
* @return An error status
****************************************************************************************
*/
void acc_mcs_cfm_get(uint16_t status, uint8_t media_lid, uint8_t con_lid, uint8_t char_type,
uint16_t token, uint16_t length, uint8_t* p_val);
/**
****************************************************************************************
* @brief Confirmation for ACC_MCS_GET_POSITION request indication.
*
* @param[in] status Status
* @param[in] media_lid Media local index
* @param[in] con_lid Connection local index
* @param[in] token Token
* @param[in] track_pos Track Position
*
* @return An error status
****************************************************************************************
*/
void acc_mcs_cfm_get_position(uint16_t status, uint8_t media_lid, uint8_t con_lid, uint16_t token,
int32_t track_pos);
#endif //(GAF_ACC_MCS)
/// @}
#endif // ACC_MCS_H_
@@ -0,0 +1,433 @@
/**
****************************************************************************************
*
* @file acc_mcs_msg.h
*
* @brief Audio Content Control - Definition of Kernel Messages (Media Control Server)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_MCS_MSG_H_
#define ACC_MCS_MSG_H_
/**
****************************************************************************************
* @addtogroup ACC_MCS_MSG Audio Content Control - Definition of Kernel Messages
* (Media Control Server)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "acc_msg.h" // ACC Message Definitions
#include "rwip_task.h" // RW IP Task Definition
#include "acc_mcs.h" // Audio Content Control - Media Control Server Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ACC_MCS_CONFIGURE request message
typedef struct acc_mcs_configure_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Number of instances of the (Generic) Media Control Service
/// Value 0 is prohibited
uint8_t nb_mcs;
/// Preferred MTU
/// Values from 0 to 63 are equivalent to 64
uint16_t pref_mtu;
} acc_mcs_configure_req_t;
/// Structure for ACC_MCS_ADD request message
typedef struct acc_mcs_add_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Configuration bit field
uint32_t cfg_bf;
/// Supported playing order bit field
uint32_t playing_order_supp_bf;
/// Start handle of associated Object Transfer Service
uint16_t ots_shdl;
/// End handle of associated Object Transfer Service
uint16_t ots_ehdl;
/// Content Control ID
uint8_t ccid;
/// Number of attributes reserved for the service
uint8_t nb_att_rsvd;
/// Media Player Icon Object ID
acc_mc_object_id_t icon_obj_id;
} acc_mcs_add_req_t;
/// Structure for ACC_MCS_ENABLE request message
typedef struct acc_mcs_enable_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
} acc_mcs_enable_req_t;
/// Structure for ACC_MCS_RESTORE_BOND_DATA request message
typedef struct acc_mcs_restore_bond_data_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Media local index
uint8_t media_lid;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
uint32_t cli_cfg_bf;
} acc_mcs_restore_bond_data_req_t;
/// Structure for ACC_MCS_SET request message
typedef struct acc_mcs_set_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Media local index
uint8_t media_lid;
/// Characteristic type
uint8_t char_type;
union
{
/// Value
uint32_t val;
/// Track position
int32_t track_pos;
/// Playback speed
int8_t playback_speed;
/// Playing order
uint8_t play_order;
/// Supported Media Control Operation Codes bit field
uint32_t opcodes_supp_bf;
} val;
} acc_mcs_set_req_t;
/// Structure for ACC_MCS_SET_OBJECT_ID request message
typedef struct acc_mcs_set_object_id_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Media local index
uint8_t media_lid;
/// Object ID
acc_mc_object_id_t obj_id;
} acc_mcs_set_object_id_req_t;
/// Structure for ACC_MCS_SET_PLAYER_NAME request message
typedef struct acc_mcs_set_player_name_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Media local index
uint8_t media_lid;
/// Length of Media Player Name value
uint8_t name_len;
/// Media Player Name value
uint8_t name[__ARRAY_EMPTY];
} acc_mcs_set_player_name_req_t;
/// Structure for ACC_MCS_ACTION request message
typedef struct acc_mcs_action_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Media local index
uint8_t media_lid;
/// Action
uint8_t action;
/// Track Position
int32_t track_pos;
/// Seeking speed
int8_t seeking_speed;
} acc_mcs_action_req_t;
/// Structure for ACC_MCS_TRACK_CHANGE request message
typedef struct acc_mcs_track_change_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Media local index
uint8_t media_lid;
/// Track duration in multiple of 0.01 seconds
/// Shall be higher than 0
int32_t track_dur;
/// Current Track Segments Object ID
acc_mc_object_id_t segments_obj_id;
/// Current Track Object ID
acc_mc_object_id_t current_obj_id;
/// Next Track Object ID
acc_mc_object_id_t next_obj_id;
/// Current Group Object ID
acc_mc_object_id_t group_obj_id;
/// Parent Group Object ID
acc_mc_object_id_t parent_obj_id;
/// Length of Track Title value
uint8_t title_len;
/// Track title value
uint8_t title[__ARRAY_EMPTY];
} acc_mcs_track_change_req_t;
/// Structure for response message
typedef struct acc_mcs_rsp
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
/// Media local index
uint8_t media_lid;
union
{
/// Additional parameter
uint8_t param;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
/// Action
uint8_t action;
} param;
} acc_mcs_rsp_t;
/// Structure for ACC_MCS_BOND_DATA indication message
typedef struct acc_mcs_cfg_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Media local index
uint8_t media_lid;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
uint32_t cli_cfg_bf;
} acc_mcs_cfg_ind_t;
/// Structure for ACC_MCS_SET_OBJECT_ID request indication message
typedef struct acc_mcs_set_object_id_req_ind
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Media local index
uint8_t media_lid;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
/// Object ID
acc_mc_object_id_t obj_id;
} acc_mcs_set_object_id_req_ind_t;
/// Structure for ACC_MCS_CONTROL request indication message
typedef struct acc_mcs_control_req_ind
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Media local index
uint8_t media_lid;
/// Connection local index
uint8_t con_lid;
/// Operation code
uint8_t opcode;
union
{
/// Value
uint32_t val;
/// Parameter for Goto Segment operation code
uint32_t segment;
/// Parameter for Move Relative operation code
int32_t offset;
/// Parameter for Goto Track operation code
uint32_t track;
/// Parameter for Goto Group operation code
uint32_t group;
} val;
} acc_mcs_control_req_ind_t;
/// Structure for ACC_MCS_SEARCH request indication message
typedef struct acc_mcs_search_req_ind
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Media local index
uint8_t media_lid;
/// Connection local index
uint8_t con_lid;
/// Length of Search Parameters value
uint8_t param_len;
/// Search Parameters value
uint8_t param[__ARRAY_EMPTY];
} acc_mcs_search_req_ind_t;
/// Structure for ACC_MCS_GET request indication message
typedef struct acc_mcs_get_req_ind
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Media local index
uint8_t media_lid;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
/// Token
uint16_t token;
/// Offset
uint16_t offset;
/// Maximum length
uint16_t length;
} acc_mcs_get_req_ind_t;
/// Structure for ACC_MCS_GET_POSITION request indication message
typedef struct acc_mcs_get_position_req_ind
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Media local index
uint8_t media_lid;
/// Connection local index
uint8_t con_lid;
/// Token
uint16_t token;
} acc_mcs_get_position_req_ind_t;
/// Structure for ACC_MCS_SET request indication message
typedef struct acc_mcs_set_req_ind
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Media local index
uint8_t media_lid;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
union
{
/// Additional parameter
uint32_t param;
/// Track position offset
int32_t track_pos_offset;
/// Playback speed
int8_t playback_speed;
/// Playing order
uint8_t playing_order;
} param;
} acc_mcs_set_req_ind_t;
/// Structure for ACC_MCS_SET_OBJECT_ID confirmation message
typedef struct acc_mcs_set_object_id_cfm
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Media local index
uint8_t media_lid;
} acc_mcs_set_object_id_cfm_t;
/// Structure for ACC_MCS_CONTROL confirmation message
typedef struct acc_mcs_control_cfm
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Media local index
uint8_t media_lid;
/// Result
uint8_t result;
/// Action
uint8_t action;
/// Track Position
int32_t track_pos;
/// Seeking speed
int8_t seeking_speed;
} acc_mcs_control_cfm_t;
/// Structure for ACC_MCS_SEARCH confirmation message
typedef struct acc_mcs_search_cfm
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Media local index
uint8_t media_lid;
/// Object ID
acc_mc_object_id_t obj_id;
} acc_mcs_search_cfm_t;
/// Structure for ACC_MCS_GET confirmation message
typedef struct acc_mcs_get_cfm
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Media local index
uint8_t media_lid;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
/// Token
uint16_t token;
/// Length
uint16_t length;
/// Requested value
uint8_t val[__ARRAY_EMPTY];
} acc_mcs_get_cfm_t;
/// Structure for ACC_MCS_GET_POSITION confirmation message
typedef struct acc_mcs_get_position_cfm
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Media local index
uint8_t media_lid;
/// Connection local index
uint8_t con_lid;
/// Token
uint16_t token;
/// Track position
int32_t track_pos;
} acc_mcs_get_position_cfm_t;
/// Structure for ACC_MCS_SET confirmation message
typedef struct acc_mcs_set_cfm
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Media local index
uint8_t media_lid;
union
{
/// Value
uint32_t val;
/// Track position
int32_t track_pos;
/// Playback speed
int8_t playback_speed;
} val;
} acc_mcs_set_cfm_t;
/// @}
#endif // ACC_MCS_MSG_H_
@@ -0,0 +1,36 @@
/**
****************************************************************************************
*
* @file acc_ot.h
*
* @brief Audio Content Control - Object Transfer - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_OT_H_
#define ACC_OT_H_
/**
****************************************************************************************
* @addtogroup ACC_OT Audio Content Control - Object Transfer
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "acc.h" // Audio Content Control Definitions
#if (GAF_ACC_OTS || GAF_ACC_OTC)
#include "otp.h" // Object Transfer Profile Definitions
#endif //(GAF_ACC_OTS || GAF_ACC_OTC)
/// @}
#endif // ACC_OT_H_
@@ -0,0 +1,147 @@
/**
****************************************************************************************
*
* @file acc_otc.h
*
* @brief Audio Content Control - Object Transfer Client - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_OTC_H_
#define ACC_OTC_H_
/**
****************************************************************************************
* @addtogroup ACC_OTC Audio Content Control - Object Transfer Client
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "acc_ot.h" // Audio Content Control - Object Tranfer Definitions
#if (GAF_ACC_OTC)
#include "gaf.h" // GAF Defines
#include "otc.h" // Object Transfer Client Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of ACC_CMD command codes for Object Transfer Client
enum acc_otc_cmd_codes
{
ACC_OTC_DISCOVER = GAF_CODE(ACC, OTC, 0),
ACC_OTC_GET = GAF_CODE(ACC, OTC, 1),
ACC_OTC_GET_CFG = GAF_CODE(ACC, OTC, 2),
ACC_OTC_SET_CFG = GAF_CODE(ACC, OTC, 3),
ACC_OTC_SET_NAME = GAF_CODE(ACC, OTC, 4),
ACC_OTC_SET_TIME = GAF_CODE(ACC, OTC, 5),
ACC_OTC_SET_PROPERTIES = GAF_CODE(ACC, OTC, 6),
ACC_OTC_OBJECT_CREATE = GAF_CODE(ACC, OTC, 7),
ACC_OTC_OBJECT_CONTROL = GAF_CODE(ACC, OTC, 8),
ACC_OTC_OBJECT_MANIPULATE = GAF_CODE(ACC, OTC, 9),
ACC_OTC_OBJECT_EXECUTE = GAF_CODE(ACC, OTC, 10),
ACC_OTC_LIST_CONTROL = GAF_CODE(ACC, OTC, 11),
ACC_OTC_LIST_GOTO = GAF_CODE(ACC, OTC, 12),
ACC_OTC_FILTER_SET = GAF_CODE(ACC, OTC, 13),
ACC_OTC_FILTER_SET_TIME = GAF_CODE(ACC, OTC, 14),
ACC_OTC_FILTER_SET_SIZE = GAF_CODE(ACC, OTC, 15),
ACC_OTC_FILTER_SET_NAME = GAF_CODE(ACC, OTC, 16),
ACC_OTC_FILTER_SET_TYPE = GAF_CODE(ACC, OTC, 17),
ACC_OTC_COC_CONNECT = GAF_CODE(ACC, OTC, 18),
ACC_OTC_COC_DISCONNECT = GAF_CODE(ACC, OTC, 19),
ACC_OTC_COC_SEND = GAF_CODE(ACC, OTC, 20),
ACC_OTC_COC_RELEASE = GAF_CODE(ACC, OTC, 21),
};
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Object Transfer Client
typedef otc_cb_t acc_otc_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Create and configure Object Transfer Client module
*
* @param[in] p_cb Pointer to set of callback functions for communications with
* upper layers
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_otc_configure(const acc_otc_cb_t* p_cb);
/// Wrapper for functions defined in otc.h
#define acc_otc_discover(con_lid, nb_ots_max, svc_type, shdl, ehdl) \
(otc_discover(con_lid, nb_ots_max, svc_type, shdl, ehdl))
#define acc_otc_get(con_lid, transfer_lid, get_type, char_type) \
(otc_get(con_lid, transfer_lid, get_type, char_type))
#define acc_otc_get_cfg(con_lid, transfer_lid, ind_char_type) \
(otc_get_cfg(con_lid, transfer_lid, ind_char_type))
#define acc_otc_set_cfg(con_lid, transfer_lid, ind_char_type, enable) \
(otc_set_cfg(con_lid, transfer_lid, ind_char_type, enable))
#define acc_otc_set_name(con_lid, transfer_lid, name_len, p_name) \
(otc_set_name(con_lid, transfer_lid, name_len, p_name))
#define acc_otc_set_time(con_lid, transfer_lid, char_type, p_time) \
(otc_set_time(con_lid, transfer_lid, char_type, p_time))
#define acc_otc_set_properties(con_lid, transfer_lid, properties) \
(otc_set_properties(con_lid, transfer_lid, properties))
#define acc_otc_object_create(con_lid, transfer_lid, size, uuid_type, p_uuid) \
(otc_object_create(con_lid, transfer_lid, size, uuid_type, p_uuid))
#define acc_otc_object_control(con_lid, transfer_lid, opcode) \
(otc_object_control(con_lid, transfer_lid, opcode))
#define acc_otc_object_manipulate(con_lid, transfer_lid, opcode, offset, length, mode) \
(otc_object_manipulate(con_lid, transfer_lid, opcode, offset, length, mode))
#define acc_otc_object_execute(con_lid, transfer_lid, param_len, p_param) \
(otc_object_execute(con_lid, transfer_lid, param_len, p_param))
#define acc_otc_list_control(con_lid, transfer_lid, opcode, order) \
(otc_list_control(con_lid, transfer_lid, opcode, order))
#define acc_otc_list_goto(con_lid, transfer_lid, opcode, p_object_id) \
(otc_list_goto(con_lid, transfer_lid, opcode, p_object_id))
#define acc_otc_filter_set(con_lid, transfer_lid, filter_lid, filter_val) \
(otc_filter_set(con_lid, transfer_lid, filter_lid, filter_val))
#define acc_otc_filter_set_time(con_lid, transfer_lid, filter_lid, filter_val, p_time_start, p_time_end) \
(otc_filter_set_time(con_lid, transfer_lid, filter_lid, filter_val, \
p_time_start, p_time_end))
#define acc_otc_filter_set_size(con_lid, transfer_lid, filter_lid, filter_val, size_min, size_max) \
(otc_filter_set_size(con_lid, transfer_lid, filter_lid, filter_val, \
size_min, size_max))
#define acc_otc_filter_set_name(con_lid, transfer_lid, filter_lid, filter_val, name_len, p_name) \
(otc_filter_set_name(con_lid, transfer_lid, filter_lid, filter_val, \
name_len, p_name))
#define acc_otc_filter_set_type(con_lid, transfer_lid, filter_lid, uuid_type, p_uuid) \
(otc_filter_set_type(con_lid, transfer_lid, filter_lid, uuid_type, p_uuid))
#define acc_otc_coc_connect(con_lid, local_max_sdu) \
(otc_coc_connect(con_lid, local_max_sdu))
#define acc_otc_coc_disconnect(con_lid) \
(otc_coc_disconnect(con_lid))
#define acc_otc_coc_send(con_lid, length, p_sdu) \
(otc_coc_send(con_lid, length, p_sdu))
#define acc_otc_coc_release(con_lid) \
(otc_coc_release(con_lid))
#define acc_otc_restore_bond_data(con_lid, nb_ots, p_ots_info) \
(otc_restore_bond_data(con_lid, nb_ots, p_ots_info))
#endif //(GAF_ACC_OTC)
/// @}
#endif // ACC_OTC_H_
@@ -0,0 +1,212 @@
/**
****************************************************************************************
*
* @file acc_otc_msg.h
*
* @brief Audio Content Control - Definition of Kernel Messages (Object Transfer Client)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_OTC_MSG_H_
#define ACC_OTC_MSG_H_
/**
****************************************************************************************
* @addtogroup ACC_OTC_MSG Audio Content Control - Definition of Kernel Messages
* (Object Transfer Client)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "acc_msg.h" // Audio Content Control Kernel Messages Definitions
#include "otc_msg.h" // Object Transfer Client - Message API Definitions
#include "gaf.h" // GAF API
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_REQ request codes for Object Transfer Client
enum acc_otc_msg_req_codes
{
ACC_OTC_CONFIGURE = GAF_CODE(ACC, OTC, 0),
ACC_OTC_RESTORE_BOND_DATA = GAF_CODE(ACC, OTC, 1),
};
/// List of GAF_IND indication codes for Object Transfer Client
enum acc_otc_msg_ind_codes
{
ACC_OTC_BOND_DATA = GAF_CODE(ACC, OTC, 0),
ACC_OTC_EXECUTE_RSP = GAF_CODE(ACC, OTC, 1),
ACC_OTC_VALUE = GAF_CODE(ACC, OTC, 2),
ACC_OTC_TIME = GAF_CODE(ACC, OTC, 3),
ACC_OTC_OBJECT_ID = GAF_CODE(ACC, OTC, 4),
ACC_OTC_TYPE = GAF_CODE(ACC, OTC, 5),
ACC_OTC_NAME = GAF_CODE(ACC, OTC, 6),
ACC_OTC_FILTER = GAF_CODE(ACC, OTC, 7),
ACC_OTC_FILTER_TIME = GAF_CODE(ACC, OTC, 8),
ACC_OTC_FILTER_SIZE = GAF_CODE(ACC, OTC, 9),
ACC_OTC_FILTER_NAME = GAF_CODE(ACC, OTC, 10),
ACC_OTC_FILTER_TYPE = GAF_CODE(ACC, OTC, 11),
ACC_OTC_CFG = GAF_CODE(ACC, OTC, 12),
ACC_OTC_CHANGED = GAF_CODE(ACC, OTC, 13),
ACC_OTC_COC_CONNECTED = GAF_CODE(ACC, OTC, 14),
ACC_OTC_COC_DISCONNECTED = GAF_CODE(ACC, OTC, 15),
ACC_OTC_COC_DATA = GAF_CODE(ACC, OTC, 16),
ACC_OTC_SVC_CHANGED = GAF_CODE(ACC, OTC, 17),
};
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ACC_OTC_DISCOVER command message
typedef otc_discover_cmd_t acc_otc_discover_cmd_t;
/// Structure for ACC_OTC_GET command message
typedef otc_get_cmd_t acc_otc_get_cmd_t;
/// Structure for ACC_OTC_GET_CFG command message
typedef otc_get_cfg_cmd_t acc_otc_get_cfg_cmd_t;
/// Structure for ACC_OTC_SET_NAME command message
typedef otc_set_name_cmd_t acc_otc_set_name_cmd_t;
/// Structure for ACC_OTC_SET_TIME command message
typedef otc_set_time_cmd_t acc_otc_set_time_cmd_t;
/// Structure for ACC_OTC_SET_PROPERTIES command message
typedef otc_set_properties_cmd_t acc_otc_set_properties_cmd_t;
/// Structure for ACC_OTC_SET_CFG command message
typedef otc_set_cfg_cmd_t acc_otc_set_cfg_cmd_t;
/// Structure for ACC_OTC_OBJECT_CREATE command message
typedef otc_object_create_cmd_t acc_otc_object_create_cmd_t;
/// Structure for ACC_OTC_OBJECT_CONTROL command message
typedef otc_object_control_cmd_t acc_otc_object_control_cmd_t;
/// Structure for ACC_OTC_OBJECT_MANIPULATE command message
typedef otc_object_manipulate_cmd_t acc_otc_object_manipulate_cmd_t;
/// Structure for ACC_OTC_OBJECT_EXECUTE command message
typedef otc_object_execute_cmd_t acc_otc_object_execute_cmd_t;
/// Structure for ACC_OTC_LIST_CONTROL command message
typedef otc_list_control_cmd_t acc_otc_list_control_cmd_t;
/// Structure for ACC_OTC_LIST_GOTO command message
typedef otc_list_goto_cmd_t acc_otc_list_goto_cmd_t;
/// Structure for ACC_OTC_FILTER_SET command message
typedef otc_filter_set_cmd_t acc_otc_filter_set_cmd_t;
/// Structure for ACC_OTC_FILTER_SET_TIME command message
typedef otc_filter_set_time_cmd_t acc_otc_filter_set_time_cmd_t;
/// Structure for ACC_OTC_FILTER_SET_SIZE command message
typedef otc_filter_set_size_cmd_t acc_otc_filter_set_size_cmd_t;
/// Structure for ACC_OTC_FILTER_SET_NAME command message
typedef otc_filter_set_name_cmd_t acc_otc_filter_set_name_cmd_t;
/// Structure for ACC_OTC_FILTER_SET_TYPE command message
typedef otc_filter_set_type_cmd_t acc_otc_filter_set_type_cmd_t;
/// Structure for ACC_OTC_COC_CONNECT command message
typedef otc_coc_connect_cmd_t acc_otc_coc_connect_cmd_t;
/// Structure for ACC_OTC_COC_DISCONNECT command message
typedef otc_coc_disconnect_cmd_t acc_otc_coc_disconnect_cmd_t;
/// Structure for ACC_OTC_COC_SEND command message
typedef otc_coc_send_cmd_t acc_otc_coc_send_cmd_t;
/// Structure for ACC_OTC_RELEASE_SEND command message
typedef otc_coc_release_cmd_t acc_otc_coc_release_cmd_t;
/// Structure command complete event
typedef otc_cmp_evt_t acc_otc_cmp_evt_t;
/// Structure for ACC_OTC_CONFIGURE request message
typedef struct acc_otc_configure_req
{
/// Request code
uint16_t req_code;
} acc_otc_configure_req_t;
/// Structure for ACC_OTC_RESTORE_BOND_DATA request message
typedef otc_restore_bond_data_req_t acc_otc_restore_bond_data_req_t;
/// Structure for response message
typedef otc_rsp_t acc_otc_rsp_t;
/// Structure for ACC_OTC_BOND_DATA indication message
typedef otc_bond_data_ind_t acc_otc_bond_data_ind_t;
/// Structure for ACC_OTC_EXECUTE_RSP indication message
typedef otc_execute_rsp_ind_t acc_otc_execute_rsp_ind_t;
/// Structure for ACC_OTC_VALUE indication message
typedef otc_value_ind_t acc_otc_value_ind_t;
/// Structure for ACC_OTC_TIME indication message
typedef otc_time_ind_t acc_otc_time_ind_t;
/// Structure for ACC_OTC_OBJECT_ID indication message
typedef otc_object_id_ind_t acc_otc_object_id_ind_t;
/// Structure for ACC_OTC_TYPE indication message
typedef otc_type_ind_t acc_otc_type_ind_t;
/// Structure for ACC_OTC_NAME indication message
typedef otc_name_ind_t acc_otc_name_ind_t;
/// Structure for ACC_OTC_FILTER indication message
typedef otc_filter_ind_t acc_otc_filter_ind_t;
/// Structure for ACC_OTC_FILTER_TIME indication message
typedef otc_filter_time_ind_t acc_otc_filter_time_ind_t;
/// Structure for ACC_OTC_FILTER_SIZE indication message
typedef otc_filter_size_ind_t acc_otc_filter_size_ind_t;
/// Structure for ACC_OTC_FILTER_NAME indication message
typedef otc_filter_name_ind_t acc_otc_filter_name_ind_t;
/// Structure for ACC_OTC_FILTER_TYPE indication message
typedef otc_filter_type_ind_t acc_otc_filter_type_ind_t;
/// Structure for ACC_OTC_CFG indication message
typedef otc_cfg_ind_t acc_otc_cfg_ind_t;
/// Structure for ACC_OTC_CHANGED indication message
typedef otc_changed_ind_t acc_otc_changed_ind_t;
/// Structure for ACC_OTC_COC_CONNECTED indication message
typedef otc_coc_connected_ind_t acc_otc_coc_connected_ind_t;
/// Structure for ACC_OTC_COC_DISCONNECTED indication message
typedef otc_coc_disconnected_ind_t acc_otc_coc_disconnected_ind_t;
/// Structure for ACC_OTC_COC_DATA indication message
typedef otc_coc_data_ind_t acc_otc_coc_data_ind_t;
/// Structure for ACC_OTC_SVC_CHANGED indication message
typedef otc_svc_changed_ind_t acc_otc_svc_changed_ind_t;
/// @}
#endif // ACC_OTC_MSG_H_
@@ -0,0 +1,156 @@
/**
****************************************************************************************
*
* @file acc_ots.h
*
* @brief Audio Content Control - Object Transfer Server - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_OTS_H_
#define ACC_OTS_H_
/**
****************************************************************************************
* @addtogroup ACC_OTS Audio Content Control - Object Transfer Server
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "acc_ot.h" // Audio Content Control - Object Tranfer Definitions
#if (GAF_ACC_OTS)
#include "gaf.h" // GAF Defines
#include "ots.h" // Object Transfer Server Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for Object Transfer Server
enum acc_ots_cmd_codes
{
ACC_OTS_COC_DISCONNECT = GAF_CODE(ACC, OTS, 0),
ACC_OTS_COC_SEND = GAF_CODE(ACC, OTS, 1),
ACC_OTS_COC_RELEASE = GAF_CODE(ACC, OTS, 2),
};
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Object Transfer Server
typedef ots_cb_t acc_ots_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Create and configure Object Transfer Client module
*
* @param[in] nb_transfers Number of Object Transfer Service instances
* @param[in] p_cb Pointer to set of callback functions for communications with
* upper layers
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_ots_configure(uint8_t nb_transfers, const acc_ots_cb_t* p_cb);
/// Wrapper for functions defined in ots.h
#define acc_ots_coc_disconnect(con_lid) \
ots_coc_disconnect(con_lid)
#define acc_ots_coc_release(con_lid) \
ots_coc_release(con_lid)
#define acc_ots_coc_send(con_lid, length, p_sdu) \
ots_coc_send(con_lid, length, p_sdu)
#define acc_ots_add(cfg_bf, nb_att_rsvd, oacp_features, olcp_features, \
p_transfer_lid, p_start_handle, p_end_handle) \
ots_add(cfg_bf, nb_att_rsvd, oacp_features, olcp_features, \
p_transfer_lid, p_start_handle, p_end_handle)
#define acc_ots_restore_bond_data(con_lid, transfer_lid, cli_cfg_bf, evt_cfg_bf, \
nb_changes, p_changed_info) \
ots_restore_bond_data(con_lid, transfer_lid, cli_cfg_bf, \
evt_cfg_bf, nb_changes, p_changed_info)
#define acc_ots_object_add(p_object_id, current_size, allocated_size, \
p_first_created_time, p_last_modified_time, \
properties, uuid_type, p_uuid, p_object_lid) \
ots_object_add(p_object_id, current_size, allocated_size, \
p_first_created_time, p_last_modified_time, \
properties, uuid_type, p_uuid, p_object_lid)
#define acc_ots_object_remove(object_lid) \
ots_object_remove(object_lid)
#define acc_ots_object_change(con_lid, transfer_lid, object_lid) \
ots_object_change(con_lid, transfer_lid, object_lid)
#define acc_ots_object_changed(flags, p_object_id) \
ots_object_changed(flags, p_object_id)
#define acc_ots_set(object_lid, set_type, value) \
ots_set(object_lid, set_type, value)
#define acc_ots_set_time(object_lid, p_time) \
ots_set_time(object_lid, p_time)
#define acc_ots_cfm_get_name(status, con_lid, token, name_len, p_name) \
ots_cfm_get_name(status, con_lid, \
token, name_len, p_name)
#define acc_ots_cfm_set_name(status, con_lid, token) \
ots_cfm_set_name(status, con_lid, token)
#define acc_ots_cfm_object_control(status, con_lid, transfer_lid, \
token, opcode, result_code, checksum) \
ots_cfm_object_control(status, con_lid, \
transfer_lid, token, opcode, \
result_code, checksum)
#define acc_ots_cfm_object_execute(status, con_lid, transfer_lid, token, \
result_code, rsp_len, p_rsp) \
ots_cfm_object_execute(status, con_lid, transfer_lid, token, \
result_code, rsp_len, p_rsp)
#define acc_ots_cfm_filter_get(status, con_lid, transfer_lid, \
token, filter_val) \
ots_cfm_filter_get(status, con_lid, transfer_lid, \
token, filter_val)
#define acc_ots_cfm_filter_get_time(status, con_lid, transfer_lid, \
token, filter_val, p_time_start, p_time_end) \
ots_cfm_filter_get_time(status, con_lid, transfer_lid, \
token, filter_val, \
p_time_start, p_time_end)
#define acc_ots_cfm_filter_get_size(status, con_lid, transfer_lid, \
token, filter_val, size_min, size_max) \
ots_cfm_filter_get_size(status, con_lid, transfer_lid, \
token, filter_val, \
size_min, size_max)
#define acc_ots_cfm_filter_get_name(status, con_lid, transfer_lid, \
token, filter_val, name_len, p_name) \
ots_cfm_filter_get_name(status, con_lid, transfer_lid, \
token, filter_val, \
name_len, p_name)
#define acc_ots_cfm_filter_get_type(status, con_lid, transfer_lid, \
token, uuid_type, p_uuid) \
ots_cfm_filter_get_type(status, con_lid, transfer_lid, \
token, uuid_type, p_uuid)
#define acc_ots_cfm_list_control(status, con_lid, transfer_lid, \
token, opcode, result_code, nb_object) \
ots_cfm_list_control(status, con_lid, \
transfer_lid, token, opcode, result_code, \
nb_object)
#define acc_ots_cfm_filter_set(status, con_lid, transfer_lid, token) \
ots_cfm_filter_set(status, con_lid, transfer_lid, token)
#define acc_ots_cfm_coc_connect(status, con_lid, token, local_max_sdu) \
ots_cfm_coc_connect(status, con_lid, token, local_max_sdu)
#endif //(GAF_ACC_OTS)
/// @}
#endif // ACC_OTS_H_
@@ -0,0 +1,243 @@
/**
****************************************************************************************
*
* @file acc_ots_msg.h
*
* @brief Audio Content Control - Definition of Kernel Messages (Object Transfer Server)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_OTS_MSG_H_
#define ACC_OTS_MSG_H_
/**
****************************************************************************************
* @addtogroup ACC_OTS_MSG Audio Content Control - Definition of Kernel Messages
* (Object Transfer Server)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "acc_msg.h" // Audio Content Control Kernel Messages Definitions
#include "ots_msg.h" // Object Transfer Server - Message API Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_REQ request codes for Object Transfer Server
enum acc_ots_msg_req_codes
{
ACC_OTS_CONFIGURE = GAF_CODE(ACC, OTS, 0),
ACC_OTS_ADD = GAF_CODE(ACC, OTS, 1),
ACC_OTS_RESTORE_BOND_DATA = GAF_CODE(ACC, OTS, 2),
ACC_OTS_OBJECT_ADD = GAF_CODE(ACC, OTS, 3),
ACC_OTS_OBJECT_REMOVE = GAF_CODE(ACC, OTS, 4),
ACC_OTS_OBJECT_CHANGE = GAF_CODE(ACC, OTS, 5),
ACC_OTS_OBJECT_CHANGED = GAF_CODE(ACC, OTS, 6),
ACC_OTS_SET = GAF_CODE(ACC, OTS, 7),
ACC_OTS_SET_TIME = GAF_CODE(ACC, OTS, 8),
};
/// List of GAF_IND indication codes for Object Transfer Server
enum acc_ots_msg_ind_codes
{
ACC_OTS_BOND_DATA = GAF_CODE(ACC, OTS, 0),
ACC_OTS_COC_CONNECTED = GAF_CODE(ACC, OTS, 1),
ACC_OTS_COC_DISCONNECTED = GAF_CODE(ACC, OTS, 2),
ACC_OTS_COC_DATA = GAF_CODE(ACC, OTS, 3),
};
/// List of GAF_IND request indication codes for Object Transfer Server
enum acc_ots_msg_req_ind_codes
{
ACC_OTS_GET_NAME = GAF_CODE(ACC, OTS, 0),
ACC_OTS_SET_NAME = GAF_CODE(ACC, OTS, 1),
ACC_OTS_OBJECT_CREATE = GAF_CODE(ACC, OTS, 2),
ACC_OTS_OBJECT_EXECUTE = GAF_CODE(ACC, OTS, 3),
ACC_OTS_OBJECT_MANIPULATE = GAF_CODE(ACC, OTS, 4),
ACC_OTS_OBJECT_CONTROL = GAF_CODE(ACC, OTS, 5),
ACC_OTS_FILTER_GET = GAF_CODE(ACC, OTS, 6),
ACC_OTS_LIST_CONTROL = GAF_CODE(ACC, OTS, 7),
ACC_OTS_LIST_GOTO = GAF_CODE(ACC, OTS, 8),
ACC_OTS_FILTER_SET = GAF_CODE(ACC, OTS, 9),
ACC_OTS_FILTER_SET_TIME = GAF_CODE(ACC, OTS, 10),
ACC_OTS_FILTER_SET_SIZE = GAF_CODE(ACC, OTS, 11),
ACC_OTS_FILTER_SET_NAME = GAF_CODE(ACC, OTS, 12),
ACC_OTS_FILTER_SET_TYPE = GAF_CODE(ACC, OTS, 13),
ACC_OTS_COC_CONNECT = GAF_CODE(ACC, OTS, 14),
};
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ACC_OTS_COC_DISCONNECT command message
typedef ots_coc_disconnect_cmd_t acc_ots_coc_disconnect_cmd_t;
/// Structure for ACC_OTS_COC_SEND command message
typedef ots_coc_send_cmd_t acc_ots_coc_send_cmd_t;
/// Structure for ACC_OTS_COC_RELEASE command message
typedef ots_coc_release_cmd_t acc_ots_coc_release_cmd_t;
/// Structure command complete event
typedef ots_cmp_evt_t acc_ots_cmp_evt_t;
/// Structure for ACC_OTS_CONFIGURE request message
typedef struct acc_ots_configure_req
{
/// Request code
uint16_t req_code;
/// Number of Object Transfer Service instances
uint8_t nb_transfers;
} acc_ots_configure_req_t;
/// Structure for ACC_OTS_ADD request message
typedef ots_add_req_t acc_ots_add_req_t;
/// Structure for ACC_OTS_RESTORE_BOND_DATA request message
typedef ots_restore_bond_data_req_t acc_ots_restore_bond_data_req_t;
/// Structure for ACC_OTS_OBJECT_ADD request message
typedef ots_object_add_req_t acc_ots_object_add_req_t;
/// Structure for ACC_OTS_OBJECT_REMOVE request message
typedef ots_object_remove_req_t acc_ots_object_remove_req_t;
/// Structure for ACC_OTS_OBJECT_CHANGE request message
typedef ots_object_change_req_t acc_ots_object_change_req_t;
/// Structure for ACC_OTS_OBJECT_CHANGED request message
typedef ots_object_changed_req_t acc_ots_object_changed_req_t;
/// Structure for ACC_OTS_SET request message
typedef ots_set_req_t acc_ots_set_req_t;
/// Structure for ACC_OTS_SET_TIME request message
typedef ots_set_time_req_t acc_ots_set_time_req_t;
/// Structure for response message
typedef ots_rsp_t acc_ots_rsp_t;
/// Structure for response message
typedef ots_add_rsp_t acc_ots_add_rsp_t;
/// Structure for ACC_OTS_BOND_DATA indication message
typedef ots_bond_data_ind_t acc_ots_bond_data_ind_t;
/// Structure for ACC_OTS_COC_CONNECTED indication message
typedef ots_coc_connected_ind_t acc_ots_coc_connected_ind_t;
/// Structure for ACC_OTS_COC_DISCONNECTED indication message
typedef ots_coc_disconnected_ind_t acc_ots_coc_disconnected_ind_t;
/// Structure for ACC_OTS_COC_DATA indication message
typedef ots_coc_data_ind_t acc_ots_coc_data_ind_t;
/// Structure for ACC_OTS_GET_NAME request indication message
typedef ots_get_name_req_ind_t acc_ots_get_name_req_ind_t;
/// Structure for ACC_OTS_SET_NAME request indication message
typedef ots_set_name_req_ind_t acc_ots_set_name_req_ind_t;
/// Structure for ACC_OTS_OBJECT_CREATE request indication message
typedef ots_object_create_req_ind_t acc_ots_object_create_req_ind_t;
/// Structure for ACC_OTS_OBJECT_EXECUTE request indication message
typedef ots_object_execute_req_ind_t acc_ots_object_execute_req_ind_t;
/// Structure for ACC_OTS_OBJECT_MANIPULATE request indication message
typedef ots_object_manipulate_req_ind_t acc_ots_object_manipulate_req_ind_t;
/// Structure for ACC_OTS_OBJECT_CONTROL request indication message
typedef ots_object_control_req_ind_t acc_ots_object_control_req_ind_t;
/// Structure for ACC_OTS_FILTER_GET request indication message
typedef ots_filter_get_req_ind_t acc_ots_filter_get_req_ind_t;
/// Structure for ACC_OTS_LIST_CONTROL request indication message
typedef ots_list_control_req_ind_t acc_ots_list_control_req_ind_t;
/// Structure for ACC_OTS_LIST_GOTO request indication message
typedef ots_list_goto_req_ind_t acc_ots_list_goto_req_ind_t;
/// Structure for ACC_OTS_FILTER_SET request indication message
typedef ots_filter_set_req_ind_t acc_ots_filter_set_req_ind_t;
/// Structure for ACC_OTS_FILTER_SET_TIME request indication message
typedef ots_filter_set_time_req_ind_t acc_ots_filter_set_time_req_ind_t;
/// Structure for ACC_OTS_FILTER_SET_SIZE request indication message
typedef ots_filter_set_size_req_ind_t acc_ots_filter_set_size_req_ind_t;
/// Structure for ACC_OTS_FILTER_SET_NAME request indication message
typedef ots_filter_set_name_req_ind_t acc_ots_filter_set_name_req_ind_t;
/// Structure for ACC_OTS_FILTER_SET_TYPE request indication message
typedef ots_filter_set_type_req_ind_t acc_ots_filter_set_type_req_ind_t;
/// Structure for ACC_OTS_COC_CONNECT request indication message
typedef ots_coc_connect_req_ind_t acc_ots_coc_connect_req_ind_t;
/// Structure for ACC_OTS_GET_NAME confirmation message
typedef ots_get_name_cfm_t acc_ots_get_name_cfm_t;
/// Structure for ACC_OTS_SET_NAME confirmation message
typedef ots_set_name_cfm_t acc_ots_set_name_cfm_t;
/// Structure for ACC_OTS_OBJECT_CREATE/MANIPULATE/CONTROL confirmation message
typedef ots_object_control_cfm_t acc_ots_object_control_cfm_t;
/// Structure for ACC_OTS_OBJECT_EXECUTE confirmation message
typedef ots_object_execute_cfm_t acc_ots_object_execute_cfm_t;
/// Structure for ACC_OTS_FILTER_GET confirmation message
/// Used for OTP_FILTER_TYPE_NO_FILTER, OTP_FILTER_TYPE_MARKED_OBJECTS
/// filter values
typedef ots_filter_get_empty_cfm_t acc_ots_filter_get_empty_cfm_t;
/// Structure for OTS_FILTER_GET confirmation message
/// Used for OTP_FILTER_TYPE_CREATED_BETW, OTP_FILTER_TYPE_MODIFIED_BETW
/// filter values
typedef ots_filter_get_time_cfm_t acc_ots_filter_get_time_cfm_t;
/// Structure for OTS_FILTER_GET confirmation message
/// Used for OTP_FILTER_TYPE_CURRENT_SIZE_BETW, OTP_FILTER_TYPE_ALLOCATED_SIZE_BETW
/// filter values
typedef ots_filter_get_size_cfm_t acc_ots_filter_get_size_cfm_t;
/// Structure for OTS_FILTER_GET confirmation message
/// Used for OTP_FILTER_TYPE_NAME_STARTS_WITH, OTP_FILTER_TYPE_NAME_ENDS_WITH
/// OTP_FILTER_TYPE_NAME_CONTAINS, OTP_FILTER_TYPE_NAME_IS_EXACTLY
/// filter values
typedef ots_filter_get_name_cfm_t acc_ots_filter_get_name_cfm_t;
/// Structure for OTS_FILTER_GET confirmation message
/// Used for OTP_FILTER_TYPE_OBJECT_TYPE filter value
typedef ots_filter_get_type_cfm_t acc_ots_filter_get_type_cfm_t;
/// Structure for OTS_LIST_CONTROL/GOTO confirmation message
typedef ots_list_control_cfm_t acc_ots_list_control_cfm_t;
/// Structure for OTS_FILTER_SET/SET_NAME/SET_TIME/SET_SIZE/SET_TYPE confirmation message
typedef ots_filter_set_cfm_t acc_ots_filter_set_cfm_t;
/// Structure for OTS_COC_CONNECT confirmation message
typedef ots_coc_connect_cfm_t acc_ots_coc_connect_cfm_t;
/// @}
#endif // ACC_OTS_MSG_H_
@@ -0,0 +1,395 @@
/**
****************************************************************************************
*
* @file acc_tb.h
*
* @brief Audio Content Control - Bearer Control - Header file
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_TB_H_
#define ACC_TB_H_
/**
****************************************************************************************
* @addtogroup ACC_TB Audio Content Control - Bearer Control
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "acc.h" // Audio Content Control Defintiions
/*
* DEFINES
****************************************************************************************
*/
/// Length of Bearer Technology characteristic value
#define ACC_TB_TECHNO_LEN (1)
/// Length of Bearer Signal Strength characteristic value
#define ACC_TB_SIGN_STRENGTH_LEN (1)
/// Length of Bearer Signal Strength Reporting Interval characteristic value
#define ACC_TB_SIGN_STRENGTH_INTV_LEN (1)
/// Length of Call Control Point Optional Opcodes characteristic value
#define ACC_TB_OPT_OPCODES_LEN (2)
/// Length of Status Flags characteristic value
#define ACC_TB_STATUS_FLAGS_LEN (1)
/// Minimum number of Calls for Join procedure
#define ACC_TB_JOIN_NB_CALL_MIN (2)
/// Maximum Incoming or Outgoing URI length
#define ACC_TB_URI_MAX_LEN (252)
/// Maximal Signal Strength value
#define ACC_TB_SIGN_STRENGTH_MAX (100)
/// Signal Strength unavailable or meaningless
#define ACC_TB_SIGN_STRENGTH_UNAVA (255)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Characteristic type values
enum acc_tb_char_type
{
/// Bearer Provider Name characteristic
ACC_TB_CHAR_TYPE_PROV_NAME = 0,
/// Bearer Technology characteristic
ACC_TB_CHAR_TYPE_TECHNO,
/// Bearer Signal Strength characteristic
ACC_TB_CHAR_TYPE_SIGN_STRENGTH,
/// Bearer List Current Calls characteristic
ACC_TB_CHAR_TYPE_CURR_CALLS_LIST,
/// Status Flags characteristic
ACC_TB_CHAR_TYPE_STATUS_FLAGS,
/// Incoming Call Target Bearer URI characteristic
ACC_TB_CHAR_TYPE_IN_TGT_CALLER_ID,
/// Call State characteristic
ACC_TB_CHAR_TYPE_CALL_STATE,
/// Call Control Point characteristic
ACC_TB_CHAR_TYPE_CALL_CTL_PT,
/// Termination Reason characteristic
ACC_TB_CHAR_TYPE_TERM_REASON,
/// Incoming Call characteristic
ACC_TB_CHAR_TYPE_INCOMING_CALL,
/// Call Friendly Name characteristic
ACC_TB_CHAR_TYPE_CALL_FRIENDLY_NAME,
/// Bearer URI Schemes Supported List characteristic
ACC_TB_CHAR_TYPE_URI_SCHEMES_LIST,
/// All characteristics above are notification-capable
ACC_TB_NTF_CHAR_TYPE_MAX,
/// Bearer UCI characteristic
ACC_TB_CHAR_TYPE_UCI = ACC_TB_NTF_CHAR_TYPE_MAX,
/// Bearer Signal Strength Reporting Interval characteristic
ACC_TB_CHAR_TYPE_SIGN_STRENGTH_INTV,
/// Content Control ID characteristic
ACC_TB_CHAR_TYPE_CCID,
/// Call Control Point Optional Opcodes characteristic
ACC_TB_CHAR_TYPE_CALL_CTL_PT_OPT_OPCODES,
ACC_TB_CHAR_TYPE_MAX,
};
/// Descriptor type values
enum acc_tb_desc_type
{
/// Client Characteristic Configuration descriptor for Bearer Provider Name characteristic
ACC_TB_DESC_TYPE_CCC_PROV_NAME = 0,
/// Client Characteristic Configuration descriptor for Bearer Technology characteristic
ACC_TB_DESC_TYPE_CCC_TECHNO,
/// Client Characteristic Configuration descriptor for Bearer Signal Strength characteristic
ACC_TB_DESC_TYPE_CCC_SIGN_STRENGTH,
/// Client Characteristic Configuration descriptor for Bearer List Current Calls characteristic
ACC_TB_DESC_TYPE_CCC_CURR_CALLS_LIST,
/// Client Characteristic Configuration descriptor for Status Flags characteristic
ACC_TB_DESC_TYPE_CCC_STATUS_FLAGS,
/// Client Characteristic Configuration descriptor for Incoming Call Target Bearer
/// URI characteristic
ACC_TB_DESC_TYPE_CCC_IN_TGT_CALLER_ID,
/// Client Characteristic Configuration descriptor for Call State characteristic
ACC_TB_DESC_TYPE_CCC_CALL_STATE,
/// Client Characteristic Configuration descriptor for Call Control Point characteristic
ACC_TB_DESC_TYPE_CCC_CALL_CTL_PT,
/// Client Characteristic Configuration descriptor for Termination Reason characteristic
ACC_TB_DESC_TYPE_CCC_TERM_REASON,
/// Client Characteristic Configuration descriptor for Incoming Call characteristic
ACC_TB_DESC_TYPE_CCC_INCOMING_CALL,
/// Client Characteristic Configuration descriptor for Call Friendly Name characteristic
ACC_TB_DESC_TYPE_CCC_CALL_FRIENDLY_NAME,
/// Client Characteristic Configuration descriptor for Bearer URI Schemes Supported
/// List characteristic
ACC_TB_DESC_TYPE_CCC_URI_SCHEMES_LIST,
ACC_TB_DESC_TYPE_MAX,
};
/// Bearer technology values
enum acc_tb_techno
{
/// 3G technology
ACC_TB_TECHNO_3G = 0,
/// 4G technology
ACC_TB_TECHNO_4G,
/// LTE technology
ACC_TB_TECHNO_LTE,
/// Wi-Fi technology
ACC_TB_TECHNO_WIFI,
/// 5G technology
ACC_TB_TECHNO_5G,
/// GSM technology
ACC_TB_TECHNO_GSM,
/// CDMA technology
ACC_TB_TECHNO_CDMA,
/// 2G technology
ACC_TB_TECHNO_2G,
/// WCDMA technology
ACC_TB_TECHNO_WCDMA,
/// IP technology
ACC_TB_TECHNO_IP,
ACC_TB_TECHNO_MAX,
};
/// Call state values
enum acc_tb_call_state
{
/// Incoming
ACC_TB_CALL_STATE_INCOMING = 0,
/// Dialing
ACC_TB_CALL_STATE_DIALING,
/// Alerting
ACC_TB_CALL_STATE_ALERTING,
/// Active
ACC_TB_CALL_STATE_ACTIVE,
/// Locally Held
ACC_TB_CALL_STATE_LOC_HELD,
/// Remotely Held
ACC_TB_CALL_STATE_REMOTE_HELD,
/// Locally and Remotely Held
ACC_TB_CALL_STATE_LOC_REMOTE_HELD,
ACC_TB_CALL_STATE_MAX,
};
/// Termination reason values
enum acc_tb_term_reason
{
/// URI value improperly formed
ACC_TB_TERM_REASON_URI = 0,
/// Call fail
ACC_TB_TERM_REASON_CALL_FAIL,
/// Remote party ended Call
ACC_TB_TERM_REASON_REMOTE_END,
/// Call ended from the Server
ACC_TB_TERM_REASON_SRV_END,
/// Line Busy
ACC_TB_TERM_REASON_BUSY,
/// Network Congestion
ACC_TB_TERM_REASON_CONGESTION,
/// Call ended from the Client
ACC_TB_TERM_REASON_CLI_END,
/// No service
ACC_TB_TERM_REASON_NO_SVC,
/// No answer
ACC_TB_TERM_REASON_NO_ANSWER,
/// Unspecified
ACC_TB_TERM_REASON_UNSPECIFIED,
ACC_TB_TERM_REASON_MAX,
};
/// Operation code values
enum acc_tb_opcode
{
/// Accept
ACC_TB_OPCODE_ACCEPT = 0,
/// Terminate
ACC_TB_OPCODE_TERMINATE,
/// Hold
ACC_TB_OPCODE_HOLD,
/// Retrieve
ACC_TB_OPCODE_RETRIEVE,
/// Originate
ACC_TB_OPCODE_ORIGINATE,
/// Join
ACC_TB_OPCODE_JOIN,
ACC_TB_OPCODE_MAX
};
/// Direction values
enum acc_tb_direction
{
/// Incoming
ACC_TB_DIRECTION_INCOMING = 0,
/// Outgoing
ACC_TB_DIRECTION_OUTGOING,
};
/// Call control point notification result code values
enum acc_tb_cp_ntf_result
{
/// Opcode write was successful
ACC_TB_CP_NTF_RESULT_SUCCESS = 0,
/// An invalid opcode was used for the Call Control Point write
ACC_TB_CP_NTF_RESULT_OPCODE_NOT_SUPPORTED,
/// Requested operation cannot be completed
ACC_TB_CP_NTF_RESULT_OP_NOT_POSSIBLE,
/// The Call Index used for the Call Control Point write is invalid
ACC_TB_CP_NTF_RESULT_INVALID_CALL_INDEX,
/// The opcode written to the Call Control Point was received when the current Call State
/// for the Call Index is not in the expected state
ACC_TB_CP_NTF_RESULT_STATE_MISMATCH,
/// Lack of internal resources to complete the requested action
ACC_TB_CP_NTF_RESULT_LACK_OF_RESSOURCES,
/// The Outgoing URI is incorrect or invalid when an Originate opcode is sent
ACC_TB_CP_NTF_RESULT_INVALID_URI,
ACC_TB_CP_NTF_RESULT_MAX,
};
/// Call Control Point Optional Opcodes bit field meaning
enum acc_tb_opt_opcodes_bf
{
/// Indicate if Local Hold and Local Retrieve operation codes are supported (= 1) or not
ACC_TB_OPT_OPCODES_LOCAL_HOLD_POS = 0,
ACC_TB_OPT_OPCODES_LOCAL_HOLD_BIT = CO_BIT(ACC_TB_OPT_OPCODES_LOCAL_HOLD_POS),
/// Indicate if Join operation code is supported (= 1) or not
ACC_TB_OPT_OPCODES_JOIN_POS = 1,
ACC_TB_OPT_OPCODES_JOIN_BIT = CO_BIT(ACC_TB_OPT_OPCODES_JOIN_POS),
ACC_TB_OPT_OPCODES_MASK = (ACC_TB_OPT_OPCODES_LOCAL_HOLD_BIT | ACC_TB_OPT_OPCODES_JOIN_BIT),
};
/// Status Flags bit field meaning
enum acc_tb_status_flags_bf
{
/// Inband Ringtone
ACC_TB_STATUS_FLAGS_INBAND_RINGTONE_POS = 0,
ACC_TB_STATUS_FLAGS_INBAND_RINGTONE_BIT = CO_BIT(ACC_TB_STATUS_FLAGS_INBAND_RINGTONE_POS),
/// Silent Mode
ACC_TB_STATUS_FLAGS_SILENT_POS = 1,
ACC_TB_STATUS_FLAGS_SILENT_BIT = CO_BIT(ACC_TB_STATUS_FLAGS_SILENT_POS),
ACC_TB_STATUS_FLAGS_MASK = (ACC_TB_STATUS_FLAGS_INBAND_RINGTONE_BIT | ACC_TB_STATUS_FLAGS_SILENT_BIT),
};
/// Bearer List Current Calls characteristic value description
enum acc_tb_curr_call_pos
{
/// Position of List Item length field
ACC_TB_CURR_CALL_LIST_ITEM_LEN_POS = 0,
/// Position of Call Index field
ACC_TB_CURR_CALL_INDEX_POS,
/// Position of Call State field
ACC_TB_CURR_CALL_STATE_POS,
/// Position of Call Flags field
ACC_TB_CURR_CALL_FLAGS_POS,
/// Minimum length
ACC_TB_CURR_CALL_MIN_LEN,
/// Minimum List Item length value
ACC_TB_CURR_CALL_MIN_LIST_ITEM_LEN = ACC_TB_CURR_CALL_MIN_LEN - 1,
/// Position of URI field
ACC_TB_CURR_CALL_URI_POS = ACC_TB_CURR_CALL_MIN_LEN
};
/// Call State characteristic value description
enum acc_tb_call_state_pos
{
/// Position of Call Index field
ACC_TB_CALL_STATE_INDEX_POS = 0,
/// Position of Call State field
ACC_TB_CALL_STATE_STATE_POS,
/// Position of Call Flags field
ACC_TB_CALL_STATE_FLAGS_POS,
/// Minimum length
ACC_TB_CALL_STATE_MIN_LEN,
};
/// Incoming Call characteristic value description
enum acc_tb_incoming_call_pos
{
/// Position of Call Index field
ACC_TB_INCOMING_CALL_INDEX_POS = 0,
/// Minimum length
ACC_TB_INCOMING_CALL_MIN_LEN,
/// Position of URI field
ACC_TB_INCOMING_CALL_URI_POS = ACC_TB_INCOMING_CALL_MIN_LEN,
};
/// Call Control Point characteristic value description
enum acc_tb_cp_pos
{
/// Position of Opcode field
ACC_TB_CP_OPCODE_POS = 0,
/// Minimum length
ACC_TB_CP_MIN_LEN,
/// Position of Parameter field
ACC_TB_CP_PARAM_POS = ACC_TB_CP_MIN_LEN,
/// Position of Call Index field for Accept, Terminate, Local Hold, Local Retrieve
/// and Join operations
ACC_TB_CP_CALL_ID_POS = ACC_TB_CP_PARAM_POS,
/// Position of URI field for Originate field
ACC_TB_CP_URI_POS = ACC_TB_CP_PARAM_POS,
/// Length when only Call Index is provided
ACC_TB_CP_CALL_ID_LEN = ACC_TB_CP_CALL_ID_POS + 1,
};
/// Termination Reason characteristic value description
enum acc_tb_term_reason_pos
{
/// Position of Call Index field
ACC_TB_TERM_REASON_INDEX_POS = 0,
/// Position of Reason Code field
ACC_TB_TERM_REASON_CODE_POS,
/// Length
ACC_TB_TERM_REASON_LEN,
};
/// Call Control Point characteristic notification value description
enum acc_tb_cp_ntf_pos
{
/// Requested opcode
ACC_TB_CP_NTF_OPCODE_POS = 0,
/// Call index
ACC_TB_CP_NTF_CALL_INDEX_POS,
/// Result
ACC_TB_CP_NTF_RESULT_POS,
ACC_TB_CP_NTF_LEN,
};
/// Call Flags bit field meaning
enum acc_tb_call_flags_bf
{
/// Indicate if call is an outgoing call
ACC_TB_CALL_FLAGS_OUTGOING_POS = 0,
ACC_TB_CALL_FLAGS_OUTGOING_BIT = CO_BIT(ACC_TB_CALL_FLAGS_OUTGOING_POS),
ACC_TB_CALL_FLAGS_MASK = ACC_TB_CALL_FLAGS_OUTGOING_BIT,
};
/// @}
#endif // ACC_TB_H_
@@ -0,0 +1,499 @@
/**
****************************************************************************************
*
* @file acc_tbc.h
*
* @brief Audio Content Control - Telephone Bearer Client - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_TBC_H_
#define ACC_TBC_H_
/**
****************************************************************************************
* @addtogroup ACC_TBC Audio Content Control - Telephone Bearer Client
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "acc_tb.h" // Audio Content Control - Telephone Bearer Definition
#if (GAF_ACC_TBC)
/*
* DEFINES
****************************************************************************************
*/
/// Maximum number of Telephone Bearer Service (Generic Telephone Bearer Service excluded)
/// that can be handled (limited by Bearer local index set in dummy value provided to GATT)
#define ACC_TBC_NB_TBS_MAX (126)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes
enum acc_tbc_cmd_codes
{
ACC_TBC_DISCOVER = GAF_CODE(ACC, TBC, 0),
ACC_TBC_GET = GAF_CODE(ACC, TBC, 1),
ACC_TBC_SET_CFG = GAF_CODE(ACC, TBC, 2),
ACC_TBC_GET_CFG = GAF_CODE(ACC, TBC, 3),
ACC_TBC_SET_REPORT_INTV = GAF_CODE(ACC, TBC, 4),
ACC_TBC_CALL_OUTGOING = GAF_CODE(ACC, TBC, 5),
ACC_TBC_CALL_ACTION = GAF_CODE(ACC, TBC, 6),
ACC_TBC_CALL_JOIN = GAF_CODE(ACC, TBC, 7),
};
/// List of GAF_REQ request codes
enum acc_tbc_msg_req_codes
{
ACC_TBC_CONFIGURE = GAF_CODE(ACC, TBC, 0),
ACC_TBC_RESTORE_BOND_DATA = GAF_CODE(ACC, TBC, 1),
};
/// List of GAF_IND indication codes
enum acc_tbc_msg_ind_codes
{
ACC_TBC_BOND_DATA = GAF_CODE(ACC, TBC, 0),
ACC_TBC_CFG = GAF_CODE(ACC, TBC, 1),
ACC_TBC_CALL_STATE = GAF_CODE(ACC, TBC, 2),
ACC_TBC_CALL_STATE_LONG = GAF_CODE(ACC, TBC, 3),
ACC_TBC_VALUE_LONG = GAF_CODE(ACC, TBC, 4),
ACC_TBC_VALUE = GAF_CODE(ACC, TBC, 5),
ACC_TBC_SVC_CHANGED = GAF_CODE(ACC, TBC, 6),
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Content description structure for Telephone Bearer Service
typedef struct acc_tbc_tbs_info
{
/// Service description
prf_svc_t svc_info;
/// Characteristics description
prf_char_t char_info[ACC_TB_CHAR_TYPE_MAX];
/// Descriptors description
prf_desc_t desc_info[ACC_TB_DESC_TYPE_MAX];
} acc_tbc_tbs_info_t;
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called when handling of a command has been completed
*
* @param[in] cmd_code Command code
* @param[in] status Status
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* Meaningless for ACC_TBC_DISCOVER command
* @param[in] param Characteristic type for ACC_TBC_GET command
* Characteristic type for ACC_TBC_SET_CFG/GET_CFG commands
* Operation code for ACC_TBC_CALL_OUTGOING/ACTION/JOIN commands
* Meaningless for ACC_TBC_SET_REPORT_INTV command
* @param[in] call_id Call index for ACC_TBC_CALL_OUTGOING/ACTION/JOIN commands.
* Meaningless for ACC_TBC_CALL_OUTGOING command if sending of notifications
* not enabled for Call Control Point characteristic
* @param[in] result Control point result for ACC_TBC_CALL_OUTGOING/ACTION/JOIN commands.
* Meaningless if sending of notifications not enabled for Call Control
* Point characteristic
****************************************************************************************
*/
typedef void (*acc_tbc_cb_cmp_evt)(uint16_t cmd_code, uint16_t status,
uint8_t con_lid, uint8_t bearer_lid, uint8_t param,
uint8_t call_id, uint8_t result);
/**
****************************************************************************************
* @brief Callback function called when Client Characteristic Configuration of a notification-capable
* characteristic has been received
*
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* @param[in] char_type Characteristic type
* @param[in] enabled Indicate if sending of notifications is enabled or not
****************************************************************************************
*/
typedef void (*acc_tbc_cb_cfg)(uint8_t con_lid, uint8_t bearer_lid, uint8_t char_type,
uint8_t enabled);
/**
****************************************************************************************
* @brief Callback function called when Call state has been received through Call State
* characteristic
*
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* @param[in] call_id Call Index
* @param[in] flags Call Flags
* @param[in] state Call State
****************************************************************************************
*/
typedef void (*acc_tbc_cb_call_state)(uint8_t con_lid, uint8_t bearer_lid, uint8_t call_id,
uint8_t flags, uint8_t state);
/**
****************************************************************************************
* @brief Callback function called when Call state has been received through Bearer List
* Current Calls characteristic
*
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* @param[in] call_id Call Index
* @param[in] flags Call Flags
* @param[in] state Call State
* @param[in] uri_len Length of Incoming or Outgoing Call URI value
* @param[in] p_uri Pointer to Incoming or Outgoing Call URI value
****************************************************************************************
*/
typedef void (*acc_tbc_cb_call_state_long)(uint8_t con_lid, uint8_t bearer_lid, uint8_t call_id,
uint8_t flags, uint8_t state, uint8_t uri_len,
uint8_t* p_uri);
/**
****************************************************************************************
* @brief Callback function called when value of one of the following characteristic is
* received:
* - Bearer Provider Name characteristic
* - Bearer UCI characteristic
* - Bearer URI Schemes Supported List characteristic
* - Incoming Call Target Bearer URI characteristic
* - Incoming Call characteristic
* - Call Friendly Name characteristic
*
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* @param[in] call_id Call ID
* @param[in] char_type Characteristic type
* @param[in] val_len Length of value
* @param[in] p_val Pointer to value
****************************************************************************************
*/
typedef void (*acc_tbc_cb_value_long)(uint8_t con_lid, uint8_t bearer_lid, uint8_t call_id,
uint8_t char_type, uint16_t val_len, uint8_t* p_val);
/**
****************************************************************************************
* @brief Callback function called when value of one of the following characteristic is
* received:
* - Bearer Technology characteristic
* - Bearer Signal Strength characteristic
* - Bearer Signal Strength Reporting Interval characteristic
* - Content Control ID characteristic
* - Status Flags characteristic
* - Call Control Point Optional Opcodes characteristic
* - Termination Reason characteristic
*
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* @param[in] call_id Call index
* @param[in] char_type Characteristic type
* @param[in] val Value
****************************************************************************************
*/
typedef void (*acc_tbc_cb_value)(uint8_t con_lid, uint8_t bearer_lid, uint8_t call_id,
uint8_t char_type, uint16_t val);
/**
****************************************************************************************
* @brief Callback function called when an instance of (Generic) Telephone Bearer Control
* Service has been discovered
*
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* @param[in] uuid UUID
* @param[in] p_tbs_info Pointer to Content description structure
****************************************************************************************
*/
typedef void (*acc_tbc_cb_bond_data)(uint8_t con_lid, uint8_t bearer_lid, uint16_t uuid,
acc_tbc_tbs_info_t* p_tbs_info);
/**
****************************************************************************************
* @brief Callback function called when a service changed indicated is received from a Server device
*
* @param[in] con_lid Connection local index
****************************************************************************************
*/
typedef void (*acc_tbc_cb_svc_changed)(uint8_t con_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Telephone Bearer Client
typedef struct acc_tbc_cb
{
/// Callback function called when handling of a command has been completed
acc_tbc_cb_cmp_evt cb_cmp_evt;
/// Callback function called when Client Characteristic Configuration of a notification-capable
/// characteristic has been received
acc_tbc_cb_cfg cb_cfg;
/// Callback function called when Call state has been received through Call State
/// characteristic
acc_tbc_cb_call_state cb_call_state;
/// Callback function called when Call state has been received through Bearer List
/// Current Calls characteristic
acc_tbc_cb_call_state_long cb_call_state_long;
/// Callback function called when value of one of the following characteristic is
/// received:
/// - Bearer Provider Name characteristic
/// - Bearer UCI characteristic
/// - Bearer URI Schemes Supported List characteristic
/// - Incoming Call Target Bearer URI characteristic
/// - Incoming Call characteristic
/// - Call Friendly Name characteristic
acc_tbc_cb_value_long cb_value_long;
/// Callback function called when value of one of the following characteristic is
/// received:
/// - Bearer Technology characteristic
/// - Bearer Signal Strength characteristic
/// - Bearer Signal Strength Reporting Interval characteristic
/// - Content Control ID characteristic
/// - Status Flags characteristic
/// - Call Control Point Optional Opcodes characteristic
/// - Termination Reason characteristic
acc_tbc_cb_value cb_value;
/// Callback function called when an instance of (Generic) Telephone Bearer Control
/// Service has been discovered
acc_tbc_cb_bond_data cb_bond_data;
/// Callback function called when a service changed indicated is received from a Server device
acc_tbc_cb_svc_changed cb_svc_changed;
} acc_tbc_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure use of Telephone Bearer Client module as Client
*
* @param[in] p_cb Pointer to set of callback functions for communication with upper
* layers
* @param[in] pref_mtu Preferred MTU. Values from 0 to 63 are equivalent to 64
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbc_configure(const acc_tbc_cb_t* p_cb, uint16_t pref_mtu);
/**
****************************************************************************************
* @brief Enable use of Telephone Bearer Service block as Client for a Server device with which
* a bonding has been established during a previous connection.
*
* @param[in] con_lid Connection local index
* @param[in] nb_bearers Number of instances of the (Generic) Telephone Bearer Service
* @param[in] p_tbs_info Pointer to Content description structures
* Generic Telephone Bearer Service first
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbc_restore_bond_data(uint8_t con_lid, uint8_t nb_bearers, acc_tbc_tbs_info_t* p_tbs_info);
/**
****************************************************************************************
* @brief Enable use of Telephone Bearer Service block as Client for a connected device with which
* no bonding has been established during a previous connection.
* Sending of notifications for Termination Reason characteristic of each discovered (Generic)
* Telephone Bearer Service instance is enabled during the discovery procedure.
*
* @param[in] con_lid Connection local index
* @param[in] nb_tbs_max Maximum number of Telephone Bearer Service instances that can be found
* in peer device database additionally to the Generic Telephone Bearer
* Service
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbc_discover(uint8_t con_lid, uint8_t nb_tbs_max);
/**
****************************************************************************************
* @brief Get value for one of the following characteristics for a Bearer exposed by a Server device:
* - Bearer Provider Name characteristic
* - Bearer UCI characteristic
* - Bearer Technology characteristic
* - Bearer URI Schemes Supported List characteristic
* - Bearer Signal Strength characteristic if characteristic is supported for the indicated Bearer
* - Bearer Signal Strength Reporting Interval characteristic if characteristic is supported for the
* indicated Bearer
* - Bearer List Current Calles characteristic
* - Content Control ID characteristic
* - Status Flags characteristic
* - Incoming Call Target Bearer URI characteristic if characteristic is supported for the indicated Bearer
* - Call State characteristic
* - Call Control Point Optional Opcodes characteristic
* - Incoming Call characteristic
* - Call Friendly Name if characteristic is supported for the indicated Bearer
*
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* @param[in] char_type Characteristic type
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbc_get(uint8_t con_lid, uint8_t bearer_lid, uint8_t char_type);
/**
****************************************************************************************
* @brief Enable or disable sending of notifications for one of the following characteristics for
* a Bearer exposed by a Server device:
* - Bearer Provider Name characteristic
* - Bearer Technology characteristic
* - Bearer Signal Strength characteristic if characteristic is supported for the indicated Bearer
* - Bearer List Current Calls characteristic
* - Status Flags characteristic
* - Incoming Call Target Bearer URI characteristic if characteristic is supported for the indicated
* Bearer
* - Call State characteristic
* - Termination Reason characteristic
* - Incoming Call characteristic
* - Call Friendly Name if characteristic is supported for the indicated Bearer
*
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* @param[in] char_type Characteristic type
* @param[in] enable Indicate if sending of notifications must be enabled (!= 0) or
* disabled for the indicated characteristic
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbc_set_cfg(uint8_t con_lid, uint8_t bearer_lid, uint8_t char_type,
uint8_t enable);
/**
****************************************************************************************
* @brief Get current client configuration for one of the following characteristics for a Bearer
* exposed by a Server device:
* - Bearer Provider Name characteristic
* - Bearer Technology characteristic
* - Bearer Signal Strength characteristic if characteristic is supported for the indicated Bearer
* - Bearer List Current Calls characteristic
* - Status Flags characteristic
* - Incoming Call Target Bearer URI characteristic if characteristic is supported for the indicated
* Bearer
* - Call State characteristic
* - Termination Reason characteristic
* - Incoming Call characteristic
* - Call Friendly Name if characteristic is supported for the indicated Bearer
*
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* @param[in] char_type Characteristic type
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbc_get_cfg(uint8_t con_lid, uint8_t bearer_lid, uint8_t char_type);
/**
****************************************************************************************
* @brief Configure Signal Strength Reporting Interval (by setting Bearer Signal Strength Reporting
* Interval characteristic value) for a Bearer exposed by a Service device if reporting of signal
* strength is supported by the Bearer.
* Upper layer can require use of either a Write Request or a Write Command by using the reliable
* parameter.
*
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* @param[in] reliable Indicate if feedback from Server device is required (!= 0)
* or not
* @param[in] sign_strength_intv_s Signal Strength Reporting Interval in seconds
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbc_set_report_intv(uint8_t con_lid, uint8_t bearer_lid, uint8_t reliable,
uint8_t sign_strength_intv_s);
/**
****************************************************************************************
* @brief Require Server device to originate an outgoing call on one of its exposed Bearer
* (by setting Call Control Point characteristic value on the indicated Bearer).
* Upper layer can require use of either a Write Request or a Write Command by using the reliable
* parameter.
*
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* @param[in] reliable Indicate if feedback from Server device is required (!= 0)
* or not
* @param[in] uri_len Length of Outgoing URI value
* @param[in] p_uri Pointer to Outgoing URI value
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbc_call_outgoing(uint8_t con_lid, uint8_t bearer_lid, uint8_t reliable,
uint8_t uri_len, uint8_t* p_uri);
/**
****************************************************************************************
* @brief Accept, terminate, hold or retrieve a call currently existing on a Bearer exposed
* by a Server device (by setting Call Control Point characteristic value on the indicated Bearer).
* Upper layer can require use of either a Write Request or a Write Command by using the reliable
* parameter.
*
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* @param[in] reliable Indicate if feedback from Server device is required (!= 0)
* or not
* @param[in] call_id Call index
* @param[in] opcode Operation code
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbc_call_action(uint8_t con_lid, uint8_t bearer_lid, uint8_t reliable,
uint8_t call_id, uint8_t opcode);
/**
****************************************************************************************
* @brief Join two or more calls currently existing on a Bearer exposed by a Server device
* (by setting Call Control Point characteristic value on the indicated Bearer).
* Note that only the first provided Call index is returned in the command complete event.
* Upper layer can require use of either a Write Request or a Write Command by using the
* reliable parameter.
*
* @param[in] con_lid Connection local index
* @param[in] bearer_lid Bearer local index
* @param[in] reliable Indicate if feedback from Server device is required (!= 0)
* or not
* @param[in] nb_calls Number of calls to join
* @param[in] p_call_ids Pointer to lisst of Call indexes of calls to join
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbc_call_join(uint8_t con_lid, uint8_t bearer_lid, uint8_t reliable,
uint8_t nb_calls, uint8_t* p_call_ids);
#endif //(GAF_ACC_TBC)
/// @}
#endif // ACC_TBC_H_
@@ -0,0 +1,350 @@
/**
****************************************************************************************
*
* @file acc_tbc_msg.h
*
* @brief Audio Content Control - Definition of Kernel Messages (Telephone Bearer Client)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_TBC_MSG_H_
#define ACC_TBC_MSG_H_
/**
****************************************************************************************
* @addtogroup ACC_TBC_MSG Audio Content Control - Definition of Kernel Messages
* (Telephone Bearer Client)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "acc_msg.h" // ACC Message Definitions
#include "rwip_task.h" // RW IP Task Definition
#include "acc_tbc.h" // Audio Content Control - Telephone Bearer Client Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ACC_TBC_DISCOVER command message
typedef struct acc_tbc_discover_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Maximum number of Telephone Bearer Servie instance that can be found
uint8_t nb_tbs_max;
} acc_tbc_discover_cmd_t;
/// Structure for ACC_TBC_GET command message
typedef struct acc_tbc_get_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// Characteristic type
uint8_t char_type;
} acc_tbc_get_cmd_t;
/// Structure for ACC_TBC_SET_CFG command message
typedef struct acc_tbc_set_cfg_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// Characteristic type
uint8_t char_type;
/// Indicate if sending of notifications must be enabled (!=0) or disabled
uint8_t enable;
} acc_tbc_set_cfg_cmd_t;
/// Structure for ACC_TBC_GET_CFG command message
typedef struct acc_tbc_get_cfg_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// Characteristic type
uint8_t char_type;
} acc_tbc_get_cfg_cmd_t;
/// Structure for ACC_TBC_SET_REPORT_INTV command message
typedef struct acc_tbc_set_report_intv_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// Indicate if feedback from Server device is required (!= 0) or not
uint8_t reliable;
/// Signal Strength Reporting Interval in seconds
uint8_t sign_strength_intv_s;
} acc_tbc_set_report_intv_cmd_t;
/// Structure for ACC_TBC_CALL_OUTGOING command message
typedef struct acc_tbc_call_outgoing_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// Indicate if feedback from Server device is required (!= 0) or not
uint8_t reliable;
/// Length of Outgoing URI value
uint8_t uri_len;
/// Outgoing URI value
uint8_t uri[__ARRAY_EMPTY];
} acc_tbc_call_outgoing_cmd_t;
/// Structure for ACC_TBC_CALL_ACTION command message
typedef struct acc_tbc_call_action_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// Indicate if feedback from Server device is required (!= 0) or not
uint8_t reliable;
/// Call index
uint8_t call_id;
/// Operation code
uint8_t opcode;
} acc_tbc_call_action_cmd_t;
/// Structure for ACC_TBC_CALL_JOIN command message
typedef struct acc_tbc_call_join_cmd
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// Indicate if feedback from Server device is required (!= 0) or not
uint8_t reliable;
/// Number of joined calls
uint8_t nb_calls;
/// Call index of calls to join
uint8_t call_ids[__ARRAY_EMPTY];
} acc_tbc_call_join_cmd_t;
/// Structure for command complete event message
typedef struct acc_tbc_cmp_evt
{
/// Command code (@see enum acc_cmd_codes)
uint16_t cmd_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
union
{
/// Value
uint8_t val;
/// Characteristic type
uint8_t char_type;
/// Operation code
uint8_t opcode;
} u;
/// Call index
uint8_t call_id;
/// Result
uint8_t result;
} acc_tbc_cmp_evt_t;
/// Structure for ACC_TBC_CONFIGURE request message
typedef struct acc_tbc_configure_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Preferred MTU
uint16_t pref_mtu;
} acc_tbc_configure_req_t;
/// Structure for ACC_TBC_RESTORE_BOND_DATA request message
typedef struct acc_tbc_restore_bond_data_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Number of instances of the (Generic) Telephone Bearer Service discovered
uint8_t nb_bearers;
/// Content description of (Generic) Telephone Bearer Service instances
/// Generic Telephone Bearer Service is first service
acc_tbc_tbs_info_t tbs_info[__ARRAY_EMPTY];
} acc_tbc_restore_bond_data_req_t;
/// Structure for response message
typedef struct acc_tbc_rsp
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
} acc_tbc_rsp_t;
/// Structure for ACC_TBC_BOND_DATA indication message
typedef struct acc_tbc_bond_data_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// UUID
uint16_t uuid;
/// Content description of (Generic) Telephone Bearer Service instance
acc_tbc_tbs_info_t tbs_info;
} acc_tbc_bond_data_ind_t;
/// Structure for ACC_TBC_CFG indication message
typedef struct acc_tbc_cfg_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// Characteristic type
uint8_t char_type;
/// Indicate if sending of notifications is enabled (!= 0) or not
uint8_t enabled;
} acc_tbc_cfg_ind_t;
/// Structure for ACC_TBC_CALL_STATE indication message
typedef struct acc_tbc_call_state_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// Call index
uint8_t id;
/// Call flags
uint8_t flags;
/// Call state
uint8_t state;
} acc_tbc_call_state_ind_t;
/// Structure for ACC_TBC_CALL_STATE_LONG indication message
typedef struct acc_tbc_call_state_long_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// Call index
uint8_t id;
/// Call flags
uint8_t flags;
/// Call state
uint8_t state;
/// Length of Incoming or Outgoing Call URI value
uint8_t uri_len;
/// Incoming or Outgoing Call URI value
uint8_t uri[__ARRAY_EMPTY];
} acc_tbc_call_state_long_ind_t;
/// Structure for ACC_TBC_VALUE_LONG indication message
typedef struct acc_tbc_value_long_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// Call index
uint8_t call_id;
/// Characteristic type
uint8_t char_type;
/// Length of value
uint16_t val_len;
/// Value
uint8_t val[__ARRAY_EMPTY];
} acc_tbc_value_long_ind_t;
/// Structure for ACC_TBC_VALUE indication message
typedef struct acc_tbc_value_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// Call index
/// Meaningful only for Termination Reason characteristic
uint8_t call_id;
/// Characteristic type
uint8_t char_type;
/// Value
union
{
/// Value
uint16_t val;
/// Bearer Technology
uint8_t techno;
/// Signal Strength
uint8_t sign_strength;
/// Signal Strength Reporting Interval in seconds
uint8_t sign_strength_intv_s;
/// Content Control ID
uint8_t ccid;
/// Status Flags bit field
uint16_t status_flags_bf;
/// Call Control Point Optional Opcodes bit field
uint16_t opt_opcodes_bf;
/// Termination Reason
uint8_t term_reason;
} val;
} acc_tbc_value_ind_t;
/// Structure for ACC_TBC_SVC_CHANGED indication message
typedef struct acc_tbc_svc_changed_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
} acc_tbc_svc_changed_ind_t;
/// @}
#endif // ACC_TBC_MSG_H_
@@ -0,0 +1,402 @@
/**
****************************************************************************************
*
* @file acc_tbs.h
*
* @brief Audio Content Control - Telephone Bearer Server - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_TBS_H_
#define ACC_TBS_H_
/**
****************************************************************************************
* @addtogroup ACC_TBS Audio Content Control - Telephone Bearer Server
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "acc_tb.h" // Audio Content Control - Telephone Bearer Definition
#if (GAF_ACC_TBS)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Bearer configuration bit field
enum acc_tbs_cfg_bf
{
/// Indicate if Bearer Signal Strength can be measured and reported to a Client device
ACC_TBS_CFG_SIGNAL_STRENGTH_SUPP_POS = 0,
ACC_TBS_CFG_SIGNAL_STRENGTH_SUPP_BIT = CO_BIT(ACC_TBS_CFG_SIGNAL_STRENGTH_SUPP_POS),
/// Indicate if Incoming Call Target Bearer URI characteristic is supported or not
ACC_TBS_CFG_INCOMING_TARGET_URI_SUPP_POS = 1,
ACC_TBS_CFG_INCOMING_TARGET_URI_SUPP_BIT = CO_BIT(ACC_TBS_CFG_INCOMING_TARGET_URI_SUPP_POS),
/// Indicate if Call Friendly Name characteristic is supported or not
ACC_TBS_CFG_FRIENDLY_NAME_SUPP_POS = 2,
ACC_TBS_CFG_FRIENDLY_NAME_SUPP_BIT = CO_BIT(ACC_TBS_CFG_FRIENDLY_NAME_SUPP_POS),
/// Indicate if sending of notifications is supported or not for Bearer URI Schemes
/// Supported List characteristic
ACC_TBS_CFG_URI_SCHEMES_NTF_SUPP_POS = 3,
ACC_TBS_CFG_URI_SCHEMES_NTF_SUPP_BIT = CO_BIT(ACC_TBS_CFG_URI_SCHEMES_NTF_SUPP_POS),
};
/// Call action values
enum acc_tbs_call_action
{
/// Accept call
ACC_TBS_ACTION_ACCEPT = 0,
/// Terminate call
ACC_TBS_ACTION_TERMINATE,
/// Hold call (local)
ACC_TBS_ACTION_HOLD_LOCAL,
/// Retrieve call (local)
ACC_TBS_ACTION_RETRIEVE_LOCAL,
/// Hold call (remote)
ACC_TBS_ACTION_HOLD_REMOTE,
/// Retrieve call (remote)
ACC_TBS_ACTION_RETRIEVE_REMOTE,
/// Remote alert started for a call
ACC_TBS_ACTION_ALERT_START,
/// Remote answer for a call
ACC_TBS_ACTION_ANSWER,
ACC_TBS_ACTION_MAX
};
/// Status type values
enum acc_tbs_status_type
{
/// Inband ringtone
ACC_TBS_STATUS_TYPE_INBAND_RINGTONE = 0,
/// Silent mode
ACC_TBS_STATUS_TYPE_SILENT_MODE,
ACC_TBS_STATUS_TYPE_MAX,
};
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called when Client Characteristic Configuration of a notification-capable
* characteristic has been updated by a peer client
*
* @param[in] bearer_lid Bearer local index
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field
****************************************************************************************
*/
typedef void (*acc_tbs_cb_bond_data)(uint8_t bearer_lid, uint8_t con_lid, uint16_t cli_cfg_bf);
/**
****************************************************************************************
* @brief Callback function called when Input State characteristic value has been updated
*
* @param[in] bearer_lid Bearer local index
* @param[in] con_lid Connection local index
* @param[in] sign_strength_intv_s Signal Strength Reporting Interval in seconds
****************************************************************************************
*/
typedef void (*acc_tbs_cb_report_intv)(uint8_t bearer_lid, uint8_t con_lid, uint8_t sign_strength_intv_s);
/**
****************************************************************************************
* @brief Callback function called to request from upper layer complete or piece of value for
* one of the following characteristics:
* - Bearer Provider Name characteristic
* - Incoming Call Target Bearer URI characteristic
* - Call Friendly Name characteristic
*
* @param[in] bearer_lid Bearer local index
* @param[in] call_id Call index
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] token Token
* @param[in] offset Offset
* @param[in] length Length
****************************************************************************************
*/
typedef void (*acc_tbs_cb_get_req)(uint8_t bearer_lid, uint8_t call_id, uint8_t con_lid,
uint8_t char_type, uint16_t token, uint16_t offset,
uint16_t length);
/**
****************************************************************************************
* @brief Callback function called to inform upper layer that a client device has requested creation
* of an outgoing call
*
* @param[in] bearer_lid Bearer local index
* @param[in] con_lid Connection local index
* @param[in] opcode Operation code
* @param[in] call_id Call index
* @param[in] len Number of calls to join or Outgoing URI length
* @param[in] p_val Pointer to list of calls to join or to Outgoing URI value
****************************************************************************************
*/
typedef void (*acc_tbs_cb_call_req)(uint8_t bearer_lid, uint8_t con_lid, uint8_t opcode,
uint8_t call_id, uint8_t len, uint8_t* p_val);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Telephone Bearer Server
typedef struct acc_tbs_cb
{
/// Callback function called when Client Characteristic Configuration of a notification-capable
/// characteristic has been updated by a peer client
acc_tbs_cb_bond_data cb_bond_data;
/// Callback function called when Input State characteristic value has been updated
acc_tbs_cb_report_intv cb_report_intv;
/// Callback function called to request from upper layer complete or piece of value for
/// either Bearer Provider Name characteristic or Incoming Call Target Bearer URI characteristic
/// or Call Friendly Name characteristic
acc_tbs_cb_get_req cb_get_req;
/// Callback function called to inform upper layer that a client device has requested an action
/// for a call
acc_tbs_cb_call_req cb_call_req;
} acc_tbs_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure use of Telephone Bearer Server module as Server
*
* @param[in] nb_tbs Number of instances of the Telephone Bearer Service
* 0 means that only the Generic Telephone Bearer Service is
* supported
* @param[in] call_pool_size Size of pool containing pre-allocated structures used to manage
* Calls
* @param[in] call_pool_uri_len Maximum URI length allowed for pre-allocated Call structures
* @param[in] uri_len_max Maximum URI length for a Call. 0 means this is no limitation
* @param[in] p_cb Pointer to set of callback functions for communication with upper
* layer
* @param[in] pref_mtu Preferred MTU
* Values from 0 to 63 are equivalent to 64
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbs_configure(uint8_t nb_tbs, uint8_t call_pool_size, uint8_t call_pool_uri_len,
uint8_t uri_len_max, const acc_tbs_cb_t* p_cb, uint16_t pref_mtu);
/**
****************************************************************************************
* @brief Add and configure an instance of the Telephone Bearer Service in the database
*
* @param[in] cfg_bf Configuration bit field
* @param[in] nb_att_rsvd Number of attributes reserved for the service
* @param[in] ccid Content Control ID
* @param[in] opt_opcodes_bf Optional operation codes bit field
* @param[in] bearer_uci_len Length of Bearer UCI value
* @param[in] p_bearer_uci Pointer to Bearer UCI value
* @param[in] p_bearer_lid Pointer at which allocated Bearer local index is returned
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbs_add(uint8_t cfg_bf, uint8_t nb_att_rsvd, uint8_t ccid, uint8_t opt_opcodes_bf,
uint8_t bearer_uci_len, uint8_t* p_bearer_uci, uint8_t* p_bearer_lid);
/**
****************************************************************************************
* @brief Enable use of Telephone Bearer Server module as Server
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbs_enable(void);
/**
****************************************************************************************
* @brief Set bonding information for either the Generic Telephone Bearer Service or an instance
* of the Telephone Bearer Service Service after connection with a Client device with which a
* bonded relationship had been established during a previous connection.
*
* @param[in] bearer_lid Bearer local index
* @param[in] con_lid Connection local index
* @param[in] sign_strength_intv_s Signal strength reporting interval in seconds
* @param[in] cli_cfg_bf Client configuration bit field
* @param[in] evt_cfg_bf Event configuration bit field
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbs_restore_bond_data(uint8_t bearer_lid, uint8_t con_lid, uint8_t sign_strength_intv_s,
uint16_t cli_cfg_bf, uint16_t evt_cfg_bf);
/**
****************************************************************************************
* @brief Set value of one of the following characteristics for a specific bearer.
*
* @param[in] bearer_lid Bearer local index
* @param[in] char_type Characteristic type
* @param[in] val Bearer technology
* or Signal Strength (from 0 to 100 or 255)
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbs_set(uint8_t bearer_lid, uint8_t char_type, uint8_t val);
/**
****************************************************************************************
* @brief Enable or disable Silent Mode or Inband Ringtone for a Bearer.
*
* @param[in] bearer_lid Bearer local index
* @param[in] status_type Status type
* @param[in] val Value
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbs_set_status(uint8_t bearer_lid, uint8_t status_type, uint8_t val);
/**
****************************************************************************************
* @brief Indicate an update of the Bearer Provider Name or the Bearer URI Scheme Supported
* List characteristic
*
* @param[in] bearer_lid Bearer local index
* @param[in] char_type Characteristic type
* @param[in] len Length of value
* @param[in] name Pointer to value
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbs_set_long(uint8_t bearer_lid, uint8_t char_type, uint8_t len, uint8_t* p_val);
/**
****************************************************************************************
* @brief Add an incoming call.
*
* @param[in] bearer_lid Bearer local index
* @param[in] uri_len Length of Incoming URI value
* @param[in] tgt_uri_len Length of Incoming Call Target URI value
* Meaningful only if Incoming Call Target Bearer URI characteristic is supported
* @param[in] friendly_name_len Length of Friendly Name value
* Meaningful only if Call Friendly Name characteristic is supported
* @param[in] p_uri Pointer to Incoming URI value
* @param[in] p_tgt_uri Pointer to Incoming Call Target URI value
* @param[in] p_friendly_name Pointer to Friendly Name value
* @param[out] p_call_id Pointer at which allocated Call index is returned
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbs_call_incoming(uint8_t bearer_lid, uint8_t uri_len, uint8_t tgt_uri_len,
uint8_t friendly_name_len, uint8_t* p_uri, uint8_t* p_tgt_uri,
uint8_t* p_friendly_name, uint8_t* p_call_id);
/**
****************************************************************************************
* @brief Add an outgoing call.
*
* @param[in] bearer_lid Bearer local index
* @param[in] uri_len Length of Outgoing URI value
* @param[in] friendly_name_len Length of Friendly Name value
* Meaningful only if Call Friendly Name characteristic is supported
* @param[in] p_uri Pointer to Outgoing URI value
* @param[in] p_friendly_name Pointer to Friendly Name value
* @param[out] p_call_id Pointer at which allocated Call index is returned
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbs_call_outgoing(uint8_t bearer_lid, uint8_t uri_len,
uint8_t friendly_name_len, uint8_t* p_uri,
uint8_t* p_friendly_name, uint8_t* p_call_id);
/**
****************************************************************************************
* @brief Update state of a call existing a Bearer.
*
* @param[in] bearer_lid Bearer local index
* @param[in] call_id Call index
* @param[in] action Action
* @param[in] reason Termination reason
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbs_call_action(uint8_t bearer_lid, uint8_t call_id, uint8_t action, uint8_t reason);
/**
****************************************************************************************
* @brief Join two or more calls currently existing on a Bearer.
* Note that only the first provided Call index is returned in the response.
*
* @param[in] bearer_lid Bearer local index
* @param[in] nb_calls Number of calls to join
* @param[in] p_call_lids Pointer to list of Call indexes of call to join
*
* @return An error status
****************************************************************************************
*/
uint16_t acc_tbs_call_join(uint8_t bearer_lid, uint8_t nb_calls, uint8_t* p_call_ids);
/**
****************************************************************************************
* @brief Confirmation for ACC_TBS_GET request indication
*
* @param[in] status Status
* @param[in] bearer_lid Bearer local index
* @param[in] call_id Call index
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] token Token
* @param[in] offset Offset
* @param[in] length Length
* @param[in] p_val Pointer to requested value
*
* @return An error status
****************************************************************************************
*/
void acc_tbs_cfm_get(uint16_t status, uint8_t bearer_lid, uint8_t call_id, uint8_t con_lid,
uint8_t char_type, uint16_t token, uint16_t offset, uint16_t length, uint8_t* p_val);
/**
****************************************************************************************
* @brief Confirmation for ACC_TBS_CALL_OUTGOING or ACC_TBS_CALL_ACTION or
* ACC_TBS_CALL_JOIN request indication.
*
* @param[in] status Status
* @param[in] bearer_lid Bearer local index
* @param[in] friendly_name_len Length of friendly name value for Originate action
* @param[in] p_friendly_name Pointer to friendly name value
*
* @return An error status
****************************************************************************************
*/
void acc_tbs_cfm_call(uint16_t status, uint8_t bearer_lid,
uint8_t friendly_name_len, uint8_t* p_friendly_name);
#endif //(GAF_ACC_TBS)
/// @}
#endif // ACC_TBS_H_
@@ -0,0 +1,427 @@
/**
****************************************************************************************
*
* @file acc_tbs_msg.h
*
* @brief Audio Content Control - Definition of Kernel Messages (Telephone Bearer Server)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ACC_TBS_MSG_H_
#define ACC_TBS_MSG_H_
/**
****************************************************************************************
* @addtogroup ACC_TBS_MSG Audio Content Control - Definition of Kernel Messages
* (Telephone Bearer Server)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "acc_msg.h" // ACC Message Definitions
#include "rwip_task.h" // RW IP Task Definition
#include "acc_tbs.h" // Audio Content Control - Telephone Bearer Server Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_REQ request codes
enum acc_tbs_msg_req_codes
{
ACC_TBS_CONFIGURE = GAF_CODE(ACC, TBS, 0),
ACC_TBS_ADD = GAF_CODE(ACC, TBS, 1),
ACC_TBS_ENABLE = GAF_CODE(ACC, TBS, 2),
ACC_TBS_RESTORE_BOND_DATA = GAF_CODE(ACC, TBS, 3),
ACC_TBS_SET = GAF_CODE(ACC, TBS, 4),
ACC_TBS_SET_STATUS = GAF_CODE(ACC, TBS, 5),
ACC_TBS_SET_LONG = GAF_CODE(ACC, TBS, 6),
ACC_TBS_CALL_INCOMING = GAF_CODE(ACC, TBS, 7),
ACC_TBS_CALL_OUTGOING = GAF_CODE(ACC, TBS, 8),
ACC_TBS_CALL_ACTION = GAF_CODE(ACC, TBS, 9),
ACC_TBS_CALL_JOIN = GAF_CODE(ACC, TBS, 10),
};
/// List of GAF_IND indication codes
enum acc_tbs_msg_ind_codes
{
ACC_TBS_BOND_DATA = GAF_CODE(ACC, TBS, 0),
ACC_TBS_REPORT_INTV = GAF_CODE(ACC, TBS, 1),
};
/// List of GAF_REQ_IND request indication codes
enum acc_tbs_msg_req_ind_codes
{
ACC_TBS_GET = GAF_CODE(ACC, TBS, 0),
ACC_TBS_CALL_OUTGOING_RI = GAF_CODE(ACC, TBS, 1),
ACC_TBS_CALL_ACTION_RI = GAF_CODE(ACC, TBS, 2),
ACC_TBS_CALL_JOIN_RI = GAF_CODE(ACC, TBS, 3),
};
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ACC_TBS_CONFIGURE request message
typedef struct acc_tbs_configure_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Number of instances of the Telephone Bearer Service
/// 0 means that only the Generic Telephone Bearer Service is supported
uint8_t nb_tbs;
/// Size of pool containing pre-allocated structures used to manage calls
uint8_t call_pool_size;
/// Maximum URI length allowed for pre-allocated call structure
uint8_t call_pool_uri_len;
/// Maximum URI length for a call
uint8_t uri_len_max;
/// Preferred MTU
/// Values from 0 to 63 are equivalent to 64
uint16_t pref_mtu;
} acc_tbs_configure_req_t;
/// Structure for ACC_TBS_ADD request message
typedef struct acc_tbs_add_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Configuration bit field
uint8_t cfg_bf;
/// Number of attributes reserved for the service
uint8_t nb_att_rsvd;
/// Content Control ID
uint8_t ccid;
/// Optional operation codes bit field
uint8_t opt_opcodes_bf;
/// Length of Bearer UCI value
uint8_t bearer_uci_len;
/// Bearer UCI value
uint8_t val[__ARRAY_EMPTY];
} acc_tbs_add_req_t;
/// Structure for ACC_TBS_ENABLE request message
typedef struct acc_tbs_enable_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
} acc_tbs_enable_req_t;
/// Structure for ACC_TBS_RESTORE_BOND_DATA request message
typedef struct acc_tbs_restore_bond_data_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Bearer local index
uint8_t bearer_lid;
/// Connection local index
uint8_t con_lid;
/// Signal strength reporting interval in seconds
/// Meaningful only if Bearer Signal Strength characteristic is supported for the indication bearer
uint8_t sign_strength_intv_s;
/// Client configuration bit field
uint16_t cli_cfg_bf;
/// Event configuration bit field
uint16_t evt_cfg_bf;
} acc_tbs_restore_bond_data_req_t;
/// Structure for ACC_TBS_SET request message
typedef struct acc_tbs_set_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Bearer local index
uint8_t bearer_lid;
/// Characteristic type
uint8_t char_type;
union
{
/// Value
uint8_t val;
/// Bearer technology
uint8_t techno;
/// Signal strength. Value from 101 to 254 are prohibited
/// 255 means that signal strength values cannot be measured or has no meaning
uint8_t signal_strength;
} val;
} acc_tbs_set_req_t;
/// Structure for ACC_TBS_SET_STATUS request message
typedef struct acc_tbs_set_status_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Bearer local index
uint8_t bearer_lid;
/// Status type
uint8_t status_type;
/// Value
uint8_t val;
} acc_tbs_set_status_req_t;
/// Structure for ACC_TBS_SET_LONG request message
typedef struct acc_tbs_set_long_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Bearer local index
uint8_t bearer_lid;
/// Characteristic type
uint8_t char_type;
/// Length of value
uint8_t len;
/// Value
uint8_t val[__ARRAY_EMPTY];
} acc_tbs_set_long_req_t;
/// Structure for ACC_TBS_CALL_INCOMING request message
typedef struct acc_tbs_call_incoming_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Bearer local index
uint8_t bearer_lid;
/// Length of Incoming URI value
uint8_t uri_len;
/// Length of Incoming Call Target URI value
/// Meaningful only if Incoming Call Target Bearer URI characteristic is supported
uint8_t tgt_uri_len;
/// Length of Friendly Name value
/// Meaningful only if Call Friendly Name characteristic is supported
uint8_t friendly_name_len;
/// Incoming URI value followed by Incoming Call Target URI value followed by
/// Friendly Name value
uint8_t val[__ARRAY_EMPTY];
} acc_tbs_call_incoming_req_t;
/// Structure for ACC_TBS_CALL_OUTGOING request message
typedef struct acc_tbs_call_outgoing_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Bearer local index
uint8_t bearer_lid;
/// Length of Outgoing URI value
uint8_t uri_len;
/// Length of Friendly Name value
/// Meaningful only if Call Friendly Name characteristic is supported
uint8_t friendly_name_len;
/// Incoming URI value followed by Outgoing URI value followed by Friendly Name value
uint8_t val[__ARRAY_EMPTY];
} acc_tbs_call_outgoing_req_t;
/// Structure for ACC_TBS_CALL_ACTION request message
typedef struct acc_tbs_call_action_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Bearer local index
uint8_t bearer_lid;
/// Call index
uint8_t call_id;
/// Action
uint8_t action;
/// Termination reason
uint8_t reason;
} acc_tbs_call_action_req_t;
/// Structure for ACC_TBS_CALL_JOIN request message
typedef struct acc_tbs_call_join_req
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Bearer local index
uint8_t bearer_lid;
/// Number of joined calls
uint8_t nb_calls;
/// Call index of calls to join
uint8_t call_ids[__ARRAY_EMPTY];
} acc_tbs_call_join_req_t;
/// Structure for response message
typedef struct acc_tbs_rsp
{
/// Request code (@see enum acc_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
/// Bearer local index
uint8_t bearer_lid;
/// Union
union
{
/// Value
uint8_t val;
/// Characteristic type for ACC_TBS_SET request
uint8_t char_type;
/// Status type for ACC_TBS_SET_STATUS request
uint8_t status_type;
/// Connection local index for ACC_TBS_RESTORE_BOND_DATA request
uint8_t con_lid;
/// Allocated Call index
uint8_t call_id;
} u;
/// Action for ACC_TBS_CALL_ACTION request
uint8_t action;
} acc_tbs_rsp_t;
/// Structure for ACC_TBS_BOND_DATA indication message
typedef struct acc_tbs_cfg_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Bearer local index
uint8_t bearer_lid;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
uint16_t cli_cfg_bf;
} acc_tbs_cfg_ind_t;
/// Structure for ACC_TBS_REPORT_INTV indication message
typedef struct acc_tbs_report_intv_ind
{
/// Indication code (@see enum acc_ind_codes)
uint16_t ind_code;
/// Bearer local index
uint8_t bearer_lid;
/// Connection local index
uint8_t con_lid;
/// Signal Strength Reporting Interval in seconds
uint8_t sign_strength_intv_s;
} acc_tbs_report_intv_ind_t;
/// Structure for ACC_TBS_GET request indication message
typedef struct acc_tbs_get_req_ind
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Bearer local index
uint8_t bearer_lid;
/// Call index
uint8_t call_id;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
/// Token value to return in the confirmation
uint16_t token;
/// Offset
uint16_t offset;
/// Maximum length
uint16_t length;
} acc_tbs_get_req_ind_t;
/// Structure for ACC_TBS_CALL_OUTGOING request indication message
typedef struct acc_tbs_call_out_req_ind
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Bearer local index
uint8_t bearer_lid;
/// Connection local index
uint8_t con_lid;
/// Call index
uint8_t call_id;
/// Length of Outgoing URI value
uint8_t uri_len;
/// Outgoing URI value
uint8_t uri[__ARRAY_EMPTY];
} acc_tbs_call_out_req_ind_t;
/// Structure for ACC_TBS_CALL_ACTION request indication message
typedef struct acc_tbs_call_action_req_ind
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Bearer local index
uint8_t bearer_lid;
/// Connection local index
uint8_t con_lid;
/// Operation code
uint8_t opcode;
/// Call index
uint8_t call_id;
} acc_tbs_call_action_req_ind_t;
/// Structure for ACC_TBS_CALL_JOIN request indication message
typedef struct acc_tbs_call_join_req_ind
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Connection local index
uint8_t con_lid;
/// Bearer local index
uint8_t bearer_lid;
/// Number of calls
uint8_t nb_calls;
/// List of call indexes
uint8_t call_ids[__ARRAY_EMPTY];
} acc_tbs_call_join_req_ind_t;
/// Structure for ACC_TBS_GET confirmation message
typedef struct acc_tbs_get_cfm
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Bearer local index
uint8_t bearer_lid;
/// Call index
uint8_t call_id;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
/// Token value to return in the confirmation
uint16_t token;
/// Offset
uint16_t offset;
/// Length
uint16_t length;
/// Request value
uint8_t val[__ARRAY_EMPTY];
} acc_tbs_get_cfm_t;
/// Structure for ACC_TBS_CALL_ACTION/JOIN confirmation message
typedef struct acc_tbs_call_cfm
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Bearer local index
uint8_t bearer_lid;
} acc_tbs_call_cfm_t;
/// Structure for ACC_TBS_CALL_OUTGOING confirmation message
typedef struct acc_tbs_call_out_cfm
{
/// Request Indication code (@see enum acc_req_ind_codes)
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Bearer local index
uint8_t bearer_lid;
/// Length of Call Friendly Name value
uint8_t friendly_name_len;
/// Call Friendly Name value
uint8_t friendly_name[__ARRAY_EMPTY];
} acc_tbs_call_out_cfm_t;
/// @}
#endif // ACC_TBS_MSG_H_
@@ -0,0 +1,244 @@
/**
****************************************************************************************
*
* @file arc_aic.h
*
* @brief Audio Rendering Control - Audio Input Control - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_AIC_H_
#define ARC_AIC_H_
/**
****************************************************************************************
* @addtogroup ARC_AIC Audio Rendering Control - Audio Input Control
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "arc.h" // Audio Rendering Control Defintiions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Position of fields in Input State characteristic value
enum arc_aic_state_pos
{
/// Gain Setting field
ARC_AIC_STATE_POS_GAIN = 0,
/// Mute field
ARC_AIC_STATE_POS_MUTE,
/// Gain Mode field
ARC_AIC_STATE_POS_GAIN_MODE,
/// Change Counter field
ARC_AIC_STATE_POS_CHANGE_CNT,
/// Length of Input State characteristic value
ARC_AIC_STATE_LEN
};
/// Position of fields in Gain Setting Properties characteristic value
enum arc_aic_gain_prop_pos
{
/// Gain Settings Units field
ARC_AIC_GAIN_PROP_POS_UNITS = 0,
/// Gain Settings Minimum field
ARC_AIC_GAIN_PROP_POS_MIN,
/// Gain Settings Maximum field
ARC_AIC_GAIN_PROP_POS_MAX,
/// Length of Gain Setting Properties characteristic value
ARC_AIC_GAIN_PROP_LEN
};
/// Position of fields in Input Type characteristic value
enum arc_aic_type_pos
{
/// Input Type
ARC_AIC_TYPE_POS_TYPE = 0,
/// Length of Input Type characteristic value
ARC_AIC_TYPE_LEN,
};
/// Position of fields in Input Status characteristic value
enum arc_aic_status_pos
{
/// Input Status
ARC_AIC_STATUS_POS_STATUS = 0,
/// Length of Input Status characteristic value
ARC_AIC_STATUS_LEN,
};
/// Position of fields in value written in Audio Input Control Point characteristic
enum arc_aic_cp_pos
{
/// Operation Code field
ARC_AIC_CP_POS_OPCODE = 0,
/// Change Counter field
ARC_AIC_CP_POS_CHANGE_CNT,
/// Gain Setting field
ARC_AIC_CP_POS_GAIN,
/// Minimal length of Audio Input Control Point characteristic value
ARC_AIC_CP_LEN_MIN = ARC_AIC_CP_POS_CHANGE_CNT + 1,
ARC_AIC_CP_LEN_MAX = ARC_AIC_CP_POS_GAIN + 1,
};
/// Operation Code values for Audio Input Control Point characteristic
enum arc_aic_opcode
{
/// Set Gain Setting
ARC_AIC_OPCODE_SET_GAIN = 1,
/// Unmute
ARC_AIC_OPCODE_UNMUTE,
/// Mute
ARC_AIC_OPCODE_MUTE,
/// Set Manual Gain Mode
ARC_AIC_OPCODE_SET_MANUAL_MODE,
/// Set Automatic Gain Mode
ARC_AIC_OPCODE_SET_AUTO_MODE,
};
/// Application error codes
enum arc_aic_err
{
/// Invalid Change Counter
ARC_AIC_ERR_INVALID_CHANGE_CNT = 0x80,
/// Opcode Not Supported
ARC_AIC_ERR_OPCODE_NOT_SUPP,
/// Mute Disabled
ARC_AIC_ERR_MUTE_DISABLED,
/// Value Out of Range
ARC_AIC_ERR_OUT_OF_RANGE,
/// Gain Mode Change Not Allowed
ARC_AIC_ERR_GAIN_MODE_CHANGE_NOT_ALLOWED,
};
/// List of Audio Input Control Service characteristics
enum arc_aic_char_type
{
/// Input State characteristic
ARC_AIC_CHAR_TYPE_STATE = 0,
/// Input Status characteristic
ARC_AIC_CHAR_TYPE_STATUS,
/// Audio Input Description characteristic
ARC_AIC_CHAR_TYPE_DESC,
ARC_AIC_NTF_CHAR_TYPE_MAX,
/// Gain Setting Properties characteristic
ARC_AIC_CHAR_TYPE_GAIN_PROP = ARC_AIC_NTF_CHAR_TYPE_MAX,
/// Input Type characteristic
ARC_AIC_CHAR_TYPE_TYPE,
/// Audio Input Control Point characteristic
ARC_AIC_CHAR_TYPE_CP,
ARC_AIC_CHAR_TYPE_MAX,
};
/// List of Audio Input Control Service descriptors
enum arc_aic_desc_type
{
/// Input State characteristic
ARC_AIC_DESC_TYPE_CCC_STATE = 0,
/// Input Status characteristic
ARC_AIC_DESC_TYPE_CCC_STATUS,
/// Audio Input Description characteristic
ARC_AIC_DESC_TYPE_CCC_DESC,
ARC_AIC_DESC_TYPE_MAX,
};
/// Mute values
enum arc_aic_mute
{
/// Not muted
ARC_AIC_MUTE_NOT_MUTED = 0,
/// Muted
ARC_AIC_MUTE_MUTED,
/// Disabled
ARC_AIC_MUTE_DISABLED,
ARC_AIC_MUTE_MAX,
};
/// Gain Mode values
enum arc_aic_gain_mode
{
/// Manual only
ARC_AIC_GAIN_MODE_MANUAL_ONLY = 0,
/// Automatic only
ARC_AIC_GAIN_MODE_AUTO_ONLY,
/// Manual
ARC_AIC_GAIN_MODE_MANUAL,
/// Automatic
ARC_AIC_GAIN_MODE_AUTO,
ARC_AIC_GAIN_MODE_MAX
};
/// Input Status values
enum arc_aic_input_status
{
/// Inactive
ARC_AIC_INPUT_STATUS_INACTIVE = 0,
/// Active
ARC_AIC_INPUT_STATUS_ACTIVE,
ARC_AIC_INPUT_STATUS_MAX,
};
/// Input Type values
enum arc_aic_input_type
{
/// Microphone
ARC_AIC_INPUT_TYPE_MICROPHONE = 0,
/// Other
ARC_AIC_INPUT_TYPE_OTHER,
ARC_AIC_INPUT_TYPE_MAX,
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Input state structure
typedef struct arc_aic_state
{
/// Gain
int8_t gain;
/// Mute
uint8_t mute;
/// Gain mode
uint8_t gain_mode;
} arc_aic_state_t;
/// Gain Setting Properties structure
typedef struct arc_aic_gain_prop
{
/// Gain Units
uint8_t gain_units;
/// Gain Minimum
int8_t gain_min;
/// Gain Maximum
int8_t gain_max;
} arc_aic_gain_prop_t;
/// @}
#endif // ARC_AIC_H_
@@ -0,0 +1,340 @@
/**
****************************************************************************************
*
* @file arc_aicc.h
*
* @brief Audio Rendering Control - Audio Input Control Client - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_AICC_H_
#define ARC_AICC_H_
/**
****************************************************************************************
* @addtogroup ARC_AICC Audio Rendering Control - Audio Input Control Client
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "arc_aic.h" // Audio Rendering Control - Audio Input Control Definitions
#if (GAF_ARC_AICC)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for Audio Input Control Client
enum arc_aicc_cmd_code
{
ARC_AICC_DISCOVER = GAF_CODE(ARC, AICC, 0),
ARC_AICC_GET = GAF_CODE(ARC, AICC, 1),
ARC_AICC_CONTROL = GAF_CODE(ARC, AICC, 2),
ARC_AICC_SET_DESCRIPTION = GAF_CODE(ARC, AICC, 3),
ARC_AICC_GET_CFG = GAF_CODE(ARC, AICC, 4),
ARC_AICC_SET_CFG = GAF_CODE(ARC, AICC, 5),
};
/// List of GAF_REQ request codes for Audio Input Control Client
enum arc_aicc_req_code
{
ARC_AICC_CONFIGURE = GAF_CODE(ARC, AICC, 0),
ARC_AICC_RESTORE_BOND_DATA = GAF_CODE(ARC, AICC, 1),
};
/// List of GAF_IND indication codes for Audio Input Control Client
enum arc_aicc_ind_code
{
/// Audio Input Control Client indications
ARC_AICC_BOND_DATA = GAF_CODE(ARC, AICC, 0),
ARC_AICC_GAIN = GAF_CODE(ARC, AICC, 1),
ARC_AICC_GAIN_PROP = GAF_CODE(ARC, AICC, 2),
ARC_AICC_VALUE = GAF_CODE(ARC, AICC, 3),
ARC_AICC_DESCRIPTION = GAF_CODE(ARC, AICC, 4),
ARC_AICC_CFG = GAF_CODE(ARC, AICC, 5),
ARC_AICC_SVC_CHANGED = GAF_CODE(ARC, AICC, 6),
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Audio Input Control Service content description structure
typedef struct arc_aicc_aics
{
/// Service description
prf_svc_t svc_info;
/// Characteristics description
prf_char_t char_info[ARC_AIC_CHAR_TYPE_MAX];
/// Descriptors description
prf_desc_t desc_info[ARC_AIC_DESC_TYPE_MAX];
} arc_aicc_aics_t;
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called each time a command has been completed
*
* @param[in] cmd_code Command code (@see enum arc_cmd_codes)
* @param[in] status Status
* @param[in] con_lid Connection local index
* @param[in] input_lid Input local index
* @param[in] param Additional parameter
****************************************************************************************
*/
typedef void (*arc_aicc_cb_cmp_evt)(uint16_t cmd_code, uint16_t status, uint8_t con_lid, uint8_t input_lid,
uint8_t param);
/**
****************************************************************************************
* @brief Callback function called when Audio Input Control Service instance has been discovered in a peer server
* database
*
* @param[in] con_lid Connection local index
* @param[in] input_lid Input local index
* @param[in] p_aics_info Pointer to service content description
****************************************************************************************
*/
typedef void (*arc_aicc_cb_bond_data)(uint8_t con_lid, uint8_t input_lid, arc_aicc_aics_t* p_aics_info);
/**
****************************************************************************************
* @brief Callback function called when value for Input State characteristic has been received from a peer server
* device
*
* @param[in] con_lid Connection local index
* @param[in] input_lid Input local index
* @param[in] gain Gain
* @param[in] mute Mute
* @param[in] mode Gain Mode
****************************************************************************************
*/
typedef void (*arc_aicc_cb_gain)(uint8_t con_lid, uint8_t input_lid, int8_t gain, uint8_t mute, uint8_t mode);
/**
****************************************************************************************
* @brief Callback function called when value for Gain Setting Properties characteristic has been received from a peer
* server device
*
* @param[in] con_lid Connection local index
* @param[in] input_lid Input local index
* @param[in] units Gain Setting Units
* @param[in] min Gain Setting Minimum
* @param[in] max Gain Setting Maximum
****************************************************************************************
*/
typedef void (*arc_aicc_cb_gain_prop)(uint8_t con_lid, uint8_t input_lid, uint8_t units, int8_t min, int8_t max);
/**
****************************************************************************************
* @brief Callback function called when value for Audio Input Description characteristic has been received from a peer
* server device
*
* @param[in] con_lid Connection local index
* @param[in] input_lid Input local index
* @param[in] desc_len Audio input description length
* @param[in] p_desc Pointer to audio input description value
****************************************************************************************
*/
typedef void (*arc_aicc_cb_description)(uint8_t con_lid, uint8_t input_lid, uint16_t desc_len, uint8_t* p_desc);
/**
****************************************************************************************
* @brief Callback function called when value for Input Type or Input Status characteristic has been received from a
* peer server device
*
* @param[in] con_lid Connection local index
* @param[in] input_lid Input local index
* @param[in] char_type Characteristic type
* @param[in] val Value
****************************************************************************************
*/
typedef void (*arc_aicc_cb_value)(uint8_t con_lid, uint8_t input_lid, uint8_t char_type, uint8_t val);
/**
****************************************************************************************
* @brief Callback function called when Client Characteristic Configuration value has been received for a
* characteristic
*
* @param[in] con_lid Connection local index
* @param[in] input_lid Input local index
* @param[in] char_type Characteristic type
* @param[in] enabled Indicate if sending of notifications is enabled
****************************************************************************************
*/
typedef void (*arc_aicc_cb_cfg)(uint8_t con_lid, uint8_t input_lid, uint8_t char_type, uint8_t enabled);
/**
****************************************************************************************
* @brief Callback function called when a service changed indication has been received from Server device
*
* @param[in] con_lid Connection local index
****************************************************************************************
*/
typedef void (*arc_aicc_cb_svc_changed)(uint8_t con_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Audio Input Control Client
typedef struct arc_aicc_cb
{
/// Callback function called when a command has been completed
arc_aicc_cb_cmp_evt cb_cmp_evt;
/// Callback function called when value for Input State characteristic has been received from a peer server device
arc_aicc_cb_gain cb_gain;
/// Callback function called when value for Gain Setting Properties have been received from a peer server device
arc_aicc_cb_gain_prop cb_gain_prop;
/// Callback function called when value for Audio Input Description characteristic has been received from a peer
/// server device
arc_aicc_cb_description cb_description;
/// Callback function called when value for Input Type or Input Status characteristic has been received from a peer
/// server device
arc_aicc_cb_value cb_value;
/// Callback function called when a client characteristic configuration value has been received from a peer server
/// device
arc_aicc_cb_cfg cb_cfg;
/// Callback function called when Audio Input Control Service instance has been discovered in a peer server
/// database
arc_aicc_cb_bond_data cb_bond_data;
/// Callback function called when a service changed indication has been received from Server device
arc_aicc_cb_svc_changed cb_svc_changed;
} arc_aicc_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure Audio Input Control Client module
*
* @param[in] p_cb Pointer to set of callback functions for communication with upper layers
* @param[in] pref_mtu Preferred MTU
* Values from 0 to 63 are equivalent to 64
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aicc_configure(const arc_aicc_cb_t* p_cb, uint16_t pref_mtu);
/**
****************************************************************************************
* @brief Discover Audio Input Control Service Services in peer server device database
*
* @param[in] con_lid Connection local index
* @param[in] nb_inputs Number of inputs
* @param[in] p_svc_hdl Pointer to service handles
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aicc_discover(uint8_t con_lid, uint8_t nb_inputs, prf_svc_t* p_svc_hdl);
/**
****************************************************************************************
* @brief Set bonding information related to Audio Input Control after connection with a peer device
*
* @param[in] con_lid Connection local index
* @param[in] nb_inputs Number of inputs
* @param[in] p_aics_info Pointer to Audio Input Control Service description structures
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aicc_restore_bond_data(uint8_t con_lid, uint8_t nb_inputs, arc_aicc_aics_t* p_aics_info);
/**
****************************************************************************************
* @brief Control peer server device's Gain value for one of its inputs
*
* @param[in] con_lid Connection local index
* @param[in] input_lid Input local index
* @param[in] opcode Operation code
* @param[in] gain Gain Setting value
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aicc_control(uint8_t con_lid, uint8_t input_lid, uint8_t opcode, int8_t gain);
/**
****************************************************************************************
* @brief Set value for Audio Input Description characteristic of a peer server device input
*
* @param[in] con_lid Connection local index
* @param[in] input_lid Input local index
* @param[in] desc_len Audio input description length
* @param[in] p_desc Pointer to audio input description value
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aicc_set_description(uint8_t con_lid, uint8_t input_lid, uint16_t desc_len, uint8_t* p_desc);
/**
****************************************************************************************
* @brief Get value for either Input State or Gain Setting Properties or Input Type or Input Status or Audio Input
* Description characteristic of a peer server device output
*
* @param[in] con_lid Connection local index
* @param[in] input_lid Input local index
* @param[in] char_type Characteristic type
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aicc_get(uint8_t con_lid, uint8_t input_lid, uint8_t char_type);
/**
****************************************************************************************
* @brief Get Client Characteristic Configuration value for either Input State or Input Status or Audio Input
* Description characteristic of a peer server device input
*
* @param[in] con_lid Connection local index
* @param[in] input_lid Input local index
* @param[in] char_type Characteristic type
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aicc_get_cfg(uint8_t con_lid, uint8_t input_lid, uint8_t char_type);
/**
****************************************************************************************
* @brief Set Client Characteristic Configuration value for either Input State or Input Status or Audio Input
* Description characteristic of a peer server device input
*
* @param[in] con_lid Connection local index
* @param[in] input_lid Input local index
* @param[in] char_type Characteristic type
* @param[in] enable Indicate if sending of notifications must be enabled or disabled
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aicc_set_cfg(uint8_t con_lid, uint8_t input_lid, uint8_t char_type, uint8_t enable);
#endif //(GAF_ARC_AICC)
/// @}
#endif // ARC_AICC_H_
@@ -0,0 +1,295 @@
/**
****************************************************************************************
*
* @file arc_aicc_msg.h
*
* @brief Audio Rendering Control - Definition of Kernel Messages (Audio Input Control Client)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_AICC_MSG_H_
#define ARC_AICC_MSG_H_
/**
****************************************************************************************
* @addtogroup ARC_AICC_MSG Audio Rendering Control - Definition of Kernel Messages (Audio Input Control Client)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "arc_msg.h" // Audio Rendering Control Kernel Messages Definitions
#include "arc_aicc.h" // Audio Rendering Control - Audio Input Control Client Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ARC_AICC_DISCOVER command message
typedef struct arc_aicc_discover_cmd
{
/// Command code (@see enum arc_aicc_cmd_code)
/// - ARC_AICC_DISCOVER
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Number of inputs
uint8_t nb_inputs;
/// Service handles
prf_svc_t svc_hdl[__ARRAY_EMPTY];
} arc_aicc_discover_cmd_t;
/// Structure for ARC_AICC_CONTROL command message
typedef struct arc_aicc_control_cmd
{
/// Command code (@see enum arc_aicc_cmd_code)
/// - ARC_AICC_CONTROL
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Input local index
uint8_t input_lid;
/// Operation code
uint8_t opcode;
/// Gain
int8_t gain;
} arc_aicc_control_cmd_t;
/// Structure for ARC_AICC_GET command message
typedef struct arc_aicc_get_cmd
{
/// Command code (@see enum arc_aicc_cmd_code)
/// - ARC_AICC_GET
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Input local index
uint8_t input_lid;
/// Characteristic type
uint8_t char_type;
} arc_aicc_get_cmd_t;
/// Structure for ARC_AICC_SET_DESCRIPTION command message
typedef struct arc_aicc_set_description_cmd
{
/// Command code (@see enum arc_aicc_cmd_code)
/// - ARC_AICC_SET_DESCRIPTION
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Input local index
uint8_t input_lid;
/// Audio input description length
uint16_t desc_len;
/// Audio input description
uint8_t desc[__ARRAY_EMPTY];
} arc_aicc_set_description_cmd_t;
/// Structure for ARC_AICC_GET_CFG command message
typedef struct arc_aicc_get_cfg_cmd
{
/// Command code (@see enum arc_aicc_cmd_code)
/// - ARC_AICC_GET_CFG
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Input local index
uint8_t input_lid;
/// Characteristic type
uint8_t char_type;
} arc_aicc_get_cfg_cmd_t;
/// Structure for ARC_AICC_SET_CFG command message
typedef struct arc_aicc_set_cfg_cmd
{
/// Command code (@see enum arc_aicc_cmd_code)
/// - ARC_AICC_SET_CFG
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Input local index
uint8_t input_lid;
/// Characteristic type
uint8_t char_type;
/// Enable or disable
uint8_t enable;
} arc_aicc_set_cfg_cmd_t;
/// Structure for command complete event message
typedef struct arc_aicc_cmp_evt
{
/// Command code (@see enum arc_aicc_cmd_code)
uint16_t cmd_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
/// Input local index
uint8_t input_lid;
/// Union
union
{
/// Value
uint8_t value;
/// Operation code
uint8_t opcode;
/// Characteristic type
uint8_t char_type;
} u;
} arc_aicc_cmp_evt_t;
/// Structure for ARC_AICC_CONFIGURE request message
typedef struct arc_aicc_configure_req
{
/// Request code (@see enum arc_aicc_req_code)
/// - ARC_AICC_CONFIGURE
uint16_t req_code;
/// Preferred MTU
/// Values from 0 to 63 are equivalent to 64
uint16_t pref_mtu;
} arc_aicc_configure_req_t;
/// Structure for ARC_AICC_RESTORE_BOND_DATA request message
typedef struct arc_aicc_restore_bond_data_req
{
/// Request code (@see enum arc_aicc_req_code)
/// - ARC_AICC_RESTORE_BOND_DATA
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Number of inputs
uint8_t nb_inputs;
/// Description of found Audio Input Control Service instances
arc_aicc_aics_t aics_info[__ARRAY_EMPTY];
} arc_aicc_restore_bond_data_req_t;
/// Structure for response message
typedef struct arc_aicc_rsp
{
/// Request code (@see enum arc_aicc_req_code)
uint16_t req_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
} arc_aicc_rsp_t;
/// Structure for ARC_AICC_BOND_DATA indication message
typedef struct arc_aicc_bond_data_ind
{
/// Indication code (@see enum arc_aicc_ind_code)
/// - ARC_AICC_BOND_DATA
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Input local index
uint8_t input_lid;
/// Description of found Audio Input Control Service instance
arc_aicc_aics_t aics_info;
} arc_aicc_bond_data_ind_t;
/// Structure for ARC_AICC_GAIN indication message
typedef struct arc_aicc_gain_ind
{
/// Indication code (@see enum arc_aicc_ind_code)
/// - ARC_AICC_GAIN
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Input local index
uint8_t input_lid;
/// Gain
int8_t gain;
/// Mute
uint8_t mute;
/// Gain mode
uint8_t gain_mode;
} arc_aicc_gain_ind_t;
/// Structure for ARC_AICC_GAIN_PROP indication message
typedef struct arc_aicc_gain_prop_ind
{
/// Indication code (@see enum arc_aicc_ind_code)
/// - ARC_AICC_GAIN_PROP
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Input local index
uint8_t input_lid;
/// Gain Setting Units
uint8_t units;
/// Gain Setting Minimum
int8_t min;
/// Gain Setting Maximum
int8_t max;
} arc_aicc_gain_prop_ind_t;
/// Structure for ARC_AICC_DESCRIPTION indication message
typedef struct arc_aicc_description_ind
{
/// Indication code (@see enum arc_aicc_ind_code)
/// - ARC_AICC_DESCRIPTION
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Input local index
uint8_t input_lid;
/// Audio input description length
uint16_t desc_len;
/// Audio input description
uint8_t desc[__ARRAY_EMPTY];
} arc_aicc_description_ind_t;
/// Structure for ARC_AICC_VALUE indication message
typedef struct arc_aicc_value_ind
{
/// Indication code (@see enum arc_aicc_ind_code)
/// - ARC_AICC_VALUE
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Input local index
uint8_t input_lid;
/// Characteristic type
uint8_t char_type;
/// Value
uint8_t val;
} arc_aicc_value_ind_t;
/// Structure for ARC_AICC_CFG indication message
typedef struct arc_aicc_cfg_ind
{
/// Indication code (@see enum arc_aicc_ind_code)
/// - ARC_AICC_CFG
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Input local index
uint8_t input_lid;
/// Characteristic type
uint8_t char_type;
/// Enabled or disabled
uint8_t enabled;
} arc_aicc_cfg_ind_t;
/// Structure for ARC_AICC_SVC_CHANGED indication message
typedef struct arc_aicc_svc_changed_ind
{
/// Indication code (@see enum arc_aicc_ind_code)
/// - ARC_AICC_GAIN
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
} arc_aicc_svc_changed_ind_t;
/// @}
#endif // ARC_AICC_MSG_H_
@@ -0,0 +1,246 @@
/**
****************************************************************************************
*
* @file arc_aics.h
*
* @brief Audio Rendering Control - Audio Input Control Server - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_AICS_H_
#define ARC_AICS_H_
/**
****************************************************************************************
* @addtogroup ARC_AICS Audio Rendering Control - Audio Input Control Server
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "arc_aic.h" // Audio Rendering Control - Audio Input Control Definition
#if (GAF_ARC_AICS)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_REQ request codes for Audio Input Control Server
enum arc_aics_req_code
{
ARC_AICS_CONFIGURE = GAF_CODE(ARC, AICS, 0),
ARC_AICS_ADD = GAF_CODE(ARC, AICS, 1),
ARC_AICS_ENABLE = GAF_CODE(ARC, AICS, 2),
ARC_AICS_RESTORE_BOND_DATA = GAF_CODE(ARC, AICS, 3),
ARC_AICS_SET = GAF_CODE(ARC, AICS, 4),
ARC_AICS_SET_DESCRIPTION = GAF_CODE(ARC, AICS, 5),
};
/// List of GAF_IND indication codes for Audio Input Control Server
enum arc_aics_ind_code
{
ARC_AICS_STATE = GAF_CODE(ARC, AICS, 0),
ARC_AICS_BOND_DATA = GAF_CODE(ARC, AICS, 1),
};
/// List of GAF_REQ_IND indication codes for Audio Input Control Server
enum arc_aics_req_ind_code
{
ARC_AICS_SET_DESCRIPTION_RI = GAF_CODE(ARC, AICS, 0),
};
/// Input configuration bit field
enum arc_aics_cfg_bf
{
/// Set to 1 if Audio Input Description characteristic is writable
ARC_AICS_CFG_DESC_WR_POS = 0,
ARC_AICS_CFG_DESC_WR_BIT = CO_BIT(ARC_AICS_CFG_DESC_WR_POS),
/// Set to 1 if Audio Input Description characteristic supports sending of notifications
ARC_AICS_CFG_DESC_NTF_POS = 1,
ARC_AICS_CFG_DESC_NTF_BIT = CO_BIT(ARC_AICS_CFG_DESC_NTF_POS),
};
/// Set type values
enum arc_aics_set_type
{
/// Set Input Status
ARC_AICS_SET_TYPE_INPUT_STATUS = 0,
/// Set Gain Setting
ARC_AICS_SET_TYPE_GAIN,
/// Set Mute
ARC_AICS_SET_TYPE_MUTE,
/// Set Gain Mode
ARC_AICS_SET_TYPE_GAIN_MODE,
ARC_AICS_SET_TYPE_MAX,
};
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called when Client Characteristic Configuration of a notification-capable
* characteristic has been updated by a peer client
*
* @param[in] input_lid Input local index
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field (@see enum arc_aics_cli_cfg_bf)
****************************************************************************************
*/
typedef void (*arc_aics_cb_bond_data)(uint8_t input_lid, uint8_t con_lid, uint8_t cli_cfg_bf);
/**
****************************************************************************************
* @brief Callback function called when Input State characteristic value has been updated
*
* @param[in] input_lid Input local index
* @param[in] p_state Pointer to Input State value
****************************************************************************************
*/
typedef void (*arc_aics_cb_state)(uint8_t input_lid, arc_aic_state_t* p_state);
/**
****************************************************************************************
* @brief Callback function called when Audio Input Description characteristic value has been updated
*
* @param[in] input_lid Input local index
* @param[in] con_lid Connection local index
* @param[in] desc_len Value length
* @param[in] p_desc Pointer to value
****************************************************************************************
*/
typedef void (*arc_aics_cb_description)(uint8_t input_lid, uint8_t con_lid, uint8_t desc_len, uint8_t* p_desc);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Audio Input Control Server
typedef struct arc_aics_cb
{
/// Callback function called when Client Characteristic Configuration of a notification-capable characteristic has
/// been updated by a peer client
arc_aics_cb_bond_data cb_bond_data;
/// Callback function called when Input State characteristic value has been updated
arc_aics_cb_state cb_state;
/// Callback function called when Audio Input Description characteristic value has been updated
arc_aics_cb_description cb_description;
} arc_aics_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure Audio Input Control Server module
*
* @param[in] p_cb Pointer to set of callback functions
* @param[in] nb_inputs Number of inputs
* @param[in] pref_mtu Preferred MTU
* Values from 0 to 63 are equivalent to 64
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aics_configure(const arc_aics_cb_t* p_cb, uint8_t nb_inputs, uint16_t pref_mtu);
/**
****************************************************************************************
* @brief Add an input
*
* @param[in] p_gain_prop Pointer to Gain Setting Properties initial value
* @param[in] input_type Input Type
* @param[in] input_status Input Status
* @param[in] desc_max_len Maximum length of Audio Input Description
* @param[in] cfg_bf Configuration bit field (@see enum arc_aics_cfg_bf)
* @param[in] nb_att_rsvd Number of attributes reserved for the service
* @param[out] p_input_lid Pointer at which allocated input local index is returned
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aics_add(arc_aic_gain_prop_t* p_gain_prop, uint8_t input_type,uint8_t desc_max_len, uint8_t cfg_bf,
uint16_t nb_att_rsvd, uint8_t* p_input_lid);
/**
****************************************************************************************
* @brief Enable Audio Input Control Server module
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aics_enable(void);
/**
****************************************************************************************
* @brief Set bonding information related to an input after establishment of a connection
*
* @param[in] input_lid Input local index
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field
* @param[in] evt_cfg_bf Event configuration bit field
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aics_restore_bond_data(uint8_t input_lid, uint8_t con_lid, uint8_t cli_cfg_bf, uint8_t evt_cfg_bf);
/**
****************************************************************************************
* @brief Set value of Input Status characteristic
*
* @param[in] input_lid Input local index
* @param[in] set_type Set type
* @param[in] value Value
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aics_set(uint8_t input_lid, uint8_t set_type, uint32_t val);
/**
****************************************************************************************
* @brief Set value of Audio Input Description characteristic value
*
* @param[in] input_lid Input local index
* @param[in] desc_len Value length
* @param[in] p_desc Pointer to value
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_aics_set_description(uint8_t input_lid, uint8_t desc_len, uint8_t *p_desc);
/**
****************************************************************************************
* @brief Confirm or not value written for Audio Input Description characteristic
*
* @param[in] cfm_status Confirmation status
* @param[in] input_lid Input local index
* @param[in] desc_len Audio input description length
* @param[in] p_desc Pointer to Audio input description value
****************************************************************************************
*/
void arc_aics_cfm_set_description(uint16_t cfm_status, uint8_t input_lid, uint8_t desc_len, uint8_t *p_desc);
#endif //(GAF_ARC_AICS)
/// @}
#endif // ARC_AICS_H_
@@ -0,0 +1,202 @@
/**
****************************************************************************************
*
* @file arc_aics_msg.h
*
* @brief Audio Rendering Control - Definition of Kernel Messages (Audio Input Control Server)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_AICS_MSG_H_
#define ARC_AICS_MSG_H_
/**
****************************************************************************************
* @addtogroup ARC_AICS_MSG Audio Rendering Control - Definition of Kernel Messages (Audio Input Control Server)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "arc_msg.h" // Audio Rendering Control Kernel Messages Definitions
#include "arc_aics.h" // Audio Rendering Control - Audio Input Control Server Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ARC_AICS_ADD request message
typedef struct arc_aics_add_req
{
/// Request code (@see enum arc_aics_req_code)
/// - ARC_AICS_ADD
uint16_t req_code;
/// Maximum length of Audio Input Description
uint8_t desc_max_len;
/// Gain Units
uint8_t gain_units;
/// Gain Minimum
int8_t gain_min;
/// Gain Maximum
int8_t gain_max;
/// Input Type
uint8_t input_type;
/// Service configuration bit field
uint8_t cfg_bf;
/// Number of attributes reserved for all Volume Offset Control Service instances inserted
/// in the database
uint16_t nb_att_rsvd;
} arc_aics_add_req_t;
/// Structure for ARC_AICS_RESTORE_BOND_DATA request message
typedef struct arc_aics_restore_bond_data_req
{
/// Request code (@see enum arc_aics_req_code)
/// - ARC_AICS_RESTORE_BOND_DATA
uint16_t req_code;
/// Input local index
uint8_t input_lid;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
uint8_t cli_cfg_bf;
/// Event configuration bit field
uint8_t evt_cfg_bf;
} arc_aics_restore_bond_data_req_t;
/// Structure for ARC_AICS_CONFIGURE request message
typedef struct arc_aics_configure_req
{
/// Request code (@see enum arc_aics_req_code)
/// - ARC_AICS_CONFIGURE
uint16_t req_code;
/// Number of inputs
uint8_t nb_inputs;
/// Preferred MTU
/// Values from 0 to 63 are equivalent to 64
uint16_t pref_mtu;
} arc_aics_configure_req_t;
/// Structure for ARC_AICS_SET request message
typedef struct arc_aics_set_req
{
/// Request code (@see enum arc_aics_req_code)
/// - ARC_AICS_SET
uint16_t req_code;
/// Input local index
uint8_t input_lid;
/// Set type
uint8_t set_type;
/// Value
uint32_t val;
} arc_aics_set_req_t;
/// Structure for ARC_AICS_SET_DESCRIPTION request message
typedef struct arc_aics_set_description_req
{
/// Request code (@see enum arc_aics_req_code)
/// - ARC_AICS_SET_DESCRIPTION
uint16_t req_code;
/// Input local index
uint8_t input_lid;
/// Value length
uint8_t desc_len;
/// Value
uint8_t desc[__ARRAY_EMPTY];
} arc_aics_set_description_req_t;
/// Structure for request message
typedef struct arc_aics_rsp
{
/// Request code (@see enum arc_aics_req_code)
uint16_t req_code;
/// Status
uint16_t status;
/// Input local index
uint8_t input_lid;
/// Union
union
{
/// Value
uint8_t value;
/// Connection local index
uint8_t con_lid;
/// Set type
uint8_t set_type;
} u;
} arc_aics_rsp_t;
/// Structure for ARC_AICS_STATE indication message
typedef struct arc_aics_state_ind
{
/// Indication code (@see enum arc_aics_ind_code)
/// - ARC_AICS_STATE
uint16_t ind_code;
/// Input local index
uint8_t input_lid;
/// Gain
int8_t gain;
/// Gain Mode
uint8_t gain_mode;
/// Mute
uint8_t mute;
} arc_aics_state_ind_t;
/// Structure for ARC_AICS_BOND_DATA indication message
typedef struct arc_aics_cfg_ind
{
/// Indication code (@see enum arc_aics_ind_code)
/// - ARC_AICS_BOND_DATA
uint16_t ind_code;
/// Input local index
uint8_t input_lid;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
uint8_t cli_cfg_bf;
} arc_aics_cfg_ind_t;
/// Structure for ARC_AICS_SET_DESCRIPTION request indication message
typedef struct arc_aics_set_description_req_ind
{
/// Request Indication code (@see enum arc_aics_req_ind_code)
/// - ARC_AICS_SET_DESCRIPTION_RI
uint16_t req_ind_code;
/// Input local index
uint8_t input_lid;
/// Connection local index
uint8_t con_lid;
/// Value length
uint8_t desc_len;
/// Value
uint8_t desc[__ARRAY_EMPTY];
} arc_aics_set_description_req_ind_t;
/// Structure for ARC_AICS_SET_DESCRIPTION confirmation message
typedef struct arc_aics_set_description_cfm
{
/// Request Indication code (@see enum arc_aics_req_ind_code)
/// - ARC_AICS_SET_DESCRIPTION_RI
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Input local index
uint8_t input_lid;
/// Value length
uint8_t desc_len;
/// Value
uint8_t desc[__ARRAY_EMPTY];
} arc_aics_set_description_cfm_t;
/// @}
#endif // ARC_AICS_MSG_H_
+68
View File
@@ -0,0 +1,68 @@
/**
****************************************************************************************
*
* @file arc.h
*
* @brief Audio Rendering Control - Header file
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_H_
#define ARC_H_
/**
****************************************************************************************
* @addtogroup ARC Audio Rendering Control
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf_cfg.h" // GAF Configuration
#include "gaf.h" // GAF defaut defines
/*
* MACROS
****************************************************************************************
*/
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Module type values
enum arc_module_type
{
/// Common
ARC_MODULE_COMMON = 0,
/// Volume Control Server
ARC_MODULE_VCS = 1,
/// Volume Control Client
ARC_MODULE_VCC = 2,
/// Audio Input Control Server
ARC_MODULE_AICS = 3,
/// Audio Input Control Client
ARC_MODULE_AICC = 4,
/// Volume Offset Control Server
ARC_MODULE_VOCS = 5,
/// Volume Offset Control Client
ARC_MODULE_VOCC = 6,
/// Microphone Control Server
ARC_MODULE_MICS = 7,
/// Microphone Control Client
ARC_MODULE_MICC = 8,
ARC_MODULE_MAX,
};
/// @}
#endif // ARC_H_
+111
View File
@@ -0,0 +1,111 @@
/**
****************************************************************************************
*
* @file arc_msg.h
*
* @brief Audio Rendering Control - Definition of Kernel Messages
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_MSG_H_
#define ARC_MSG_H_
/**
****************************************************************************************
* @addtogroup ARC Audio Rendering Control - Definition of Kernel Messages
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "arc.h" // ARC Definitions
#if (GAF_ARC)
#include "gaf_msg.h" // Generic Audio Framework API Message Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_REQ request codes
enum arc_msg_req_codes
{
ARC_GET_FEATURES = GAF_CODE(ARC, COMMON, 0),
};
/// Features bit field meaning
enum arc_msg_feat_bf
{
/// Volume Control Service Server supported
ARC_FEAT_VCS_SUPP_POS = 0,
ARC_FEAT_VCS_SUPP_BIT = CO_BIT(ARC_FEAT_VCS_SUPP_POS),
/// Volume Control Service Client supported
ARC_FEAT_VCC_SUPP_POS = 1,
ARC_FEAT_VCC_SUPP_BIT = CO_BIT(ARC_FEAT_VCC_SUPP_POS),
/// Audio Input Control Service Server supported
ARC_FEAT_AICS_SUPP_POS = 2,
ARC_FEAT_AICS_SUPP_BIT = CO_BIT(ARC_FEAT_AICS_SUPP_POS),
/// Audio Input Control Service Client supported
ARC_FEAT_AICC_SUPP_POS = 3,
ARC_FEAT_AICC_SUPP_BIT = CO_BIT(ARC_FEAT_AICC_SUPP_POS),
/// Volume Offset Control Service Server supported
ARC_FEAT_VOCS_SUPP_POS = 4,
ARC_FEAT_VOCS_SUPP_BIT = CO_BIT(ARC_FEAT_VOCS_SUPP_POS),
/// Volume Offset Control Service Client supported
ARC_FEAT_VOCC_SUPP_POS = 5,
ARC_FEAT_VOCC_SUPP_BIT = CO_BIT(ARC_FEAT_VOCC_SUPP_POS),
/// Microphone Control Service Server supported
ARC_FEAT_MICS_SUPP_POS = 6,
ARC_FEAT_MICS_SUPP_BIT = CO_BIT(ARC_FEAT_MICS_SUPP_POS),
/// Microphone Control Service Client supported
ARC_FEAT_MICC_SUPP_POS = 7,
ARC_FEAT_MICC_SUPP_BIT = CO_BIT(ARC_FEAT_MICC_SUPP_POS),
};
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ARC_GET_FEATURES request message
typedef struct arc_get_features_req
{
/// Request code (@see enum arc_msg_req_codes)
/// - ARC_GET_FEATURES
uint16_t req_code;
} arc_get_features_req_t;
/// Structure for ARC_GET_FEATURES response message
typedef struct arc_get_features_rsp
{
/// Request code (@see enum arc_msg_req_codes)
/// - ARC_GET_FEATURES
uint16_t req_code;
/// Status
uint16_t status;
/// Features bit field
uint32_t feat_bf;
} arc_get_features_rsp_t;
#endif //(GAF_ARC)
/// @}
#endif // ARC_MSG_H_
@@ -0,0 +1,89 @@
/**
****************************************************************************************
*
* @file arc_mic.h
*
* @brief Audio Rendering Control - Microphone Control - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_MIC_H_
#define ARC_MIC_H_
/**
****************************************************************************************
* @addtogroup ARC_MIC Audio Rendering Control - Microphone Control
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "arc.h" // Audio Rendering Control Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Position of fields in Mute characteristic value
enum arc_mic_mute_pos
{
/// Mute field
ARC_MIC_MUTE_POS_MUTE = 0,
/// Length of Mute characteristic value
ARC_MIC_MUTE_LEN
};
/// List of Microphone Control Service characteristics
enum arc_mic_char_type
{
/// Mute characteristic
ARC_MIC_CHAR_TYPE_MUTE = 0,
/// Number of characteristics
ARC_MIC_CHAR_TYPE_MAX,
};
/// List of Microphone Control Service descriptors
enum arc_mic_desc_type
{
/// Mute characteristic
ARC_MIC_DESC_TYPE_CCC_MUTE = 0,
/// Number of descriptors
ARC_MIC_DESC_TYPE_MAX,
};
/// List of Mute value for Microphone Control Service
enum arc_mic_mute
{
/// Not muted
ARC_MIC_MUTE_NOT_MUTED = 0,
/// Muted
ARC_MIC_MUTE_MUTED,
/// Disabled
ARC_MIC_MUTE_DISABLED,
ARC_MIC_MUTE_MAX,
};
/// Error codes for Microphone Control Service
enum arc_mic_err
{
/// Mute disabled
ARC_MIC_ERR_MUTE_DISABLED = 0x80,
/// Value out of range
ARC_MIC_ERR_OUT_OF_RANGE = 0x81,
};
/// @}
#endif // ARC_MIC_H_
@@ -0,0 +1,261 @@
/**
****************************************************************************************
*
* @file arc_micc.h
*
* @brief Audio Rendering Control - Microphone Control Client - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_MICC_H_
#define ARC_MICC_H_
/**
****************************************************************************************
* @addtogroup ARC_MICC Audio Rendering Control - Microphone Control Client
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "arc_mic.h" // Audio Rendering Control - Microphone Control Definitions
#if (GAF_ARC_MICC)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for Microphone Control Client
enum arc_micc_cmd_code
{
ARC_MICC_DISCOVER = GAF_CODE(ARC, MICC, 0),
ARC_MICC_GET_MUTE = GAF_CODE(ARC, MICC, 1),
ARC_MICC_SET_MUTE = GAF_CODE(ARC, MICC, 2),
ARC_MICC_GET_CFG = GAF_CODE(ARC, MICC, 3),
ARC_MICC_SET_CFG = GAF_CODE(ARC, MICC, 4),
};
/// List of GAF_REQ request codes for Microphone Control Client
enum arc_micc_req_code
{
ARC_MICC_CONFIGURE = GAF_CODE(ARC, MICC, 0),
ARC_MICC_RESTORE_BOND_DATA = GAF_CODE(ARC, MICC, 1),
};
/// List of GAF_IND indication codes for Microphone Control Client
enum arc_micc_ind_code
{
ARC_MICC_BOND_DATA = GAF_CODE(ARC, MICC, 0),
ARC_MICC_INCLUDED_SVC = GAF_CODE(ARC, MICC, 1),
ARC_MICC_MUTE = GAF_CODE(ARC, MICC, 2),
ARC_MICC_CFG = GAF_CODE(ARC, MICC, 3),
ARC_MICC_SVC_CHANGED = GAF_CODE(ARC, MICC, 4),
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Microphone Control Service content description structure
typedef struct arc_micc_mics
{
/// Service description
prf_svc_t svc_info;
/// Characteristics description
prf_char_t char_info[ARC_MIC_CHAR_TYPE_MAX];
/// Descriptors description
prf_desc_t desc_info[ARC_MIC_DESC_TYPE_MAX];
} arc_micc_mics_t;
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called each time a command has been completed
*
* @param[in] cmd_code Command code (@see enum arc_cmd_codes)
* @param[in] status Status
* @param[in] con_lid Connection local index
****************************************************************************************
*/
typedef void (*arc_micc_cb_cmp_evt)(uint16_t cmd_code, uint16_t status, uint8_t con_lid);
/**
****************************************************************************************
* @brief Callback function called when Microphone Control Service instance has been discovered in a peer server
* database
*
* @param[in] con_lid Connection local index
* @param[in] p_mics_info Pointer to service content description
****************************************************************************************
*/
typedef void (*arc_micc_cb_bond_data)(uint8_t con_lid, arc_micc_mics_t* p_mics_info);
/**
****************************************************************************************
* @brief Callback function called when Mute characteristic value has been received from a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] mute Mute value
****************************************************************************************
*/
typedef void (*arc_micc_cb_mute)(uint8_t con_lid, uint8_t mute);
/**
****************************************************************************************
* @brief Callback function called when an Audio Input Control Service instance has been discovered in a peer server
*
* @param[in] con_lid Connection local index
* @param[in] shdl Start handle
* @param[in] ehdl End handle
****************************************************************************************
*/
typedef void (*arc_micc_cb_included_svc)(uint8_t con_lid, uint16_t shdl, uint16_t ehdl);
/**
****************************************************************************************
* @brief Callback function called when a Client Characteristic Configuration descriptor value for Mute
* characteristic has been received from a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] enable Indicate if sending of notifications is enabled for Mute characteristic
****************************************************************************************
*/
typedef void (*arc_micc_cb_cfg)(uint8_t con_lid, uint8_t enable);
/**
****************************************************************************************
* @brief Callback function called when a service changed indication is received from a Server device
*
* @param[in] con_lid Connection local index
****************************************************************************************
*/
typedef void (*arc_micc_cb_svc_changed)(uint8_t con_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for microphone management (client)
typedef struct arc_micc_cb
{
/// Callback function called when a command has been completed
arc_micc_cb_cmp_evt cb_cmp_evt;
/// Callback function called when Mute characteristic value has been received from a peer server device
arc_micc_cb_mute cb_mute;
/// Callback function called when a Client Characteristic Configuration descriptor value for Mute
/// characteristic has been received from a peer server device
arc_micc_cb_cfg cb_cfg;
/// Callback function called when Microphone Control Service instance has been discovered in a peer server database
arc_micc_cb_bond_data cb_bond_data;
/// Callback function called when an Audio Input Control Service instance has been discovered in a peer server
arc_micc_cb_included_svc cb_included_svc;
/// Callback function called when a service changed indication is received from a Server device
arc_micc_cb_svc_changed cb_svc_changed;
} arc_micc_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Create and configure Microphone Control Client module
*
* @param[in] p_cb Pointer to set of callback functions for communications with upper layers
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_micc_configure(const arc_micc_cb_t* p_cb);
/**
****************************************************************************************
* @brief Initiate discovery of Microphone Control Service in peer server device database
*
* @param[in] con_lid Connection local index
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_micc_discover(uint8_t con_lid);
/**
****************************************************************************************
* @brief Set bonding information related to Microphone Management after connection with a peer device
*
* @param[in] con_lid Connection local index
* @param[in] p_mics_info Pointer to Microphone Control Service description structures
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_micc_restore_bond_data(uint8_t con_lid, arc_micc_mics_t* p_mics_info);
/**
****************************************************************************************
* @brief Set value for Mute State characteristic of a peer server device output
*
* @param[in] con_lid Connection local index
* @param[in] mute Mute value
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_micc_set_mute(uint8_t con_lid, uint8_t mute);
/**
****************************************************************************************
* @brief Get value for Mute State characteristic of a peer server device output
*
* @param[in] con_lid Connection local index
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_micc_get_mute(uint8_t con_lid);
/**
****************************************************************************************
* @brief Get Client Characteristic Configuration value for Mute characteristic of a peer server device
*
* @param[in] con_lid Connection local index
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_micc_get_cfg(uint8_t con_lid);
/**
****************************************************************************************
* @brief Set Client Characteristic Configuration value for Mute characteristic.
*
* @param[in] con_lid Connection local index
* @param[in] enable Indicate if sending of notifications must be enabled or disabled
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_micc_set_cfg(uint8_t con_lid, uint8_t enable);
#endif //(GAF_ARC_MICC)
/// @}
#endif // ARC_MICC_H_
@@ -0,0 +1,195 @@
/**
****************************************************************************************
*
* @file arc_micc_msg.h
*
* @brief Audio Rendering Control - Definition of Kernel Messages (Microphone Control Client)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_MICC_MSG_H_
#define ARC_MICC_MSG_H_
/**
****************************************************************************************
* @addtogroup ARC_MICC_MSG Audio Rendering Control - Definition of Kernel Messages (Microphone Control Client)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "arc_msg.h" // Audio Rendering Control Kernel Messages Definitions
#include "arc_micc.h" // Audio Rendering Control - Microphone Control Client Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ARC_MICC_DISCOVER request message
typedef struct arc_micc_discover_cmd
{
/// Command code (@see enum arc_micc_cmd_code)
/// - ARC_MICC_DISCOVER
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
} arc_micc_discover_cmd_t;
/// Structure for ARC_MICC_SET_MUTE command message
typedef struct arc_micc_set_mute_cmd
{
/// Command code (@see enum arc_micc_cmd_code)
/// - ARC_MICC_SET_MUTE
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Mute
uint8_t mute;
} arc_micc_set_mute_cmd_t;
/// Structure for ARC_MICC_GET_MUTE command message
typedef struct arc_micc_get_mute_cmd
{
/// Command code (@see enum arc_micc_cmd_code)
/// - ARR_MICC_GET_MUTE
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
} arc_micc_get_mute_cmd_t;
/// Structure for ARC_MICC_GET_CFG command message
typedef struct arc_micc_get_cfg_cmd
{
/// Command code (@see enum arc_micc_cmd_code)
/// - ARC_MICC_GET_CFG
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
} arc_micc_get_cfg_cmd_t;
/// Structure for ARC_MICC_SET_CFG command message
typedef struct arc_micc_set_cfg_cmd
{
/// Command code (@see enum arc_micc_cmd_code)
/// - ARC_MICC_SET_CFG
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Indicate if sending of notifications must be enabled or not
uint8_t enable;
} arc_micc_set_cfg_cmd_t;
/// Structure for command complete event message for ARC_MICC_DISCOVER, ARC_MICC_SET_MUTE, ARC_MICC_GET_MUTE,
/// ARC_MICC_GET_CFG, ARC_MICC_SET_CFG commands
typedef struct arc_micc_cmp_evt
{
/// Command code (@see enum arc_micc_cmd_code)
uint16_t cmd_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
} arc_micc_cmp_evt_t;
/// Structure for ARC_MICC_CONFIGURE request message
typedef struct arc_micc_configure_req
{
/// Request code (@see enum arc_micc_req_code)
/// - ARC_MICC_CONFIGURE
uint16_t req_code;
} arc_micc_configure_req_t;
/// Structure for ARC_MICC_RESTORE_BOND_DATA request message
typedef struct arc_micc_restore_bond_data_req
{
/// Request code (@see enum arc_micc_req_code)
/// - ARC_MICC_RESTORE_BOND_DATA
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Microphone Control Service description
arc_micc_mics_t mics_info;
} arc_micc_restore_bond_data_req_t;
/// Structure for response message
typedef struct arc_micc_rsp
{
/// Request code (@see enum arc_micc_req_code)
uint16_t req_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
} arc_micc_rsp_t;
/// Structure for ARC_MICC_BOND_DATA indication message
typedef struct arc_micc_bond_data_ind
{
/// Indication code (@see enum arc_micc_ind_code)
/// - ARC_MICC_BOND_DATA
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Description of found Microphone Control Service instance
arc_micc_mics_t mics_info;
} arc_micc_bond_data_ind_t;
/// Structure for ARC_MICC_INCLUDED_SVC indication message
typedef struct arc_micc_included_svc_ind
{
/// Indication code (@see enum arc_micc_ind_code)
/// - ARC_MICC_INCLUDED_SVC
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Start handle
uint16_t shdl;
/// End handle
uint16_t ehdl;
} arc_micc_included_svc_ind_t;
/// Structure for ARC_MICC_MUTE indication message
typedef struct arc_micc_mute_ind
{
/// Indication code (@see enum arc_micc_ind_code)
/// - ARC_MICC_MUTE
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Mute
uint8_t mute;
} arc_micc_mute_ind_t;
/// Structure for ARC_MICC_CFG indication message
typedef struct arc_micc_cfg_ind
{
/// Indication code (@see enum arc_micc_ind_code)
/// - ARC_MICC_CFG
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Enabled or disabled
uint8_t enabled;
} arc_micc_cfg_ind_t;
/// Structure for ARC_MICC_SVC_CHANGED indication message
typedef struct arc_micc_svc_changed_ind
{
/// Indication code (@see enum arc_micc_ind_code)
/// - ARC_MICC_SVC_CHANGED
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
} arc_micc_svc_changed_ind_t;
/// @}
#endif // ARC_MICC_MSG_H_
@@ -0,0 +1,146 @@
/**
****************************************************************************************
*
* @file arc_mics.h
*
* @brief Audio Rendering Control - Microphone Control Server - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_MICS_H_
#define ARC_MICS_H_
/**
****************************************************************************************
* @addtogroup ARC_MICS Audio Rendering Control - Microphone Control Server
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "arc_mic.h" // Microphone Control Definitions
#if (GAF_ARC_MICS)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_REQ request codes for Microphone Control Server
enum arc_mics_req_code
{
ARC_MICS_CONFIGURE = GAF_CODE(ARC, MICS, 0),
ARC_MICS_ENABLE = GAF_CODE(ARC, MICS, 1),
ARC_MICS_RESTORE_BOND_DATA = GAF_CODE(ARC, MICS, 2),
ARC_MICS_SET_MUTE = GAF_CODE(ARC, MICS, 3),
};
/// List of GAF_IND indication codes for Microphone Control Server
enum arc_mics_ind_code
{
ARC_MICS_BOND_DATA = GAF_CODE(ARC, MICS, 0),
ARC_MICS_MUTE = GAF_CODE(ARC, MICS, 1),
};
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called when Client Characteristic Configuration value has been updated by a peer client for
* Mute characteristic
*
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field
****************************************************************************************
*/
typedef void (*arc_mics_cb_bond_data)(uint8_t con_lid, uint8_t cli_cfg_bf);
/**
****************************************************************************************
* @brief Callback function called when Mute characteristic value has been updated
*
* @param[in] mute Mute value
****************************************************************************************
*/
typedef void (*arc_mics_cb_mute)(uint8_t mute);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Microphone Control Server
typedef struct arc_mics_cb
{
/// Callback function called when Client Characteristic Configuration value has been updated by a peer client for
/// Mute characteristic
arc_mics_cb_bond_data cb_bond_data;
/// Callback function called when Mute characteristic value has been updated
arc_mics_cb_mute cb_mute;
} arc_mics_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure Microphone Control Server module
*
* @param[in] p_cb Pointer to set of callback functions for communication with upper layers
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_mics_configure(const arc_mics_cb_t* p_cb);
/**
****************************************************************************************
* @brief Enable Microphone Control Server module
*
* @param[in] nb_att_rsvd Number of attributes reserved for the service
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_mics_enable(uint16_t nb_att_rsvd);
/**
****************************************************************************************
* @brief Set bonding information related to Microphone Control after connection with a peer device
*
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field
* @param[in] evt_cfg_bf Event configuration bit field
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_mics_restore_bond_data(uint8_t con_lid, uint8_t cli_cfg_bf, uint8_t evt_cfg_bf);
/**
****************************************************************************************
* @brief Set value of Mute characteristic
*
* @param[in] mute Mute value
****************************************************************************************
*/
uint16_t arc_mics_set_mute(uint8_t mute);
#endif //(GAF_ARC_MICS)
/// @}
#endif // ARC_MICS_H_
@@ -0,0 +1,106 @@
/**
****************************************************************************************
*
* @file arc_mics_msg.h
*
* @brief Audio Rendering Control - Microphone Control Server - Message API Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_MICS_MSG_H_
#define ARC_MICS_MSG_H_
/**
****************************************************************************************
* @addtogroup ARC_MICS_MSG Audio Rendering Control - Microphone Control Server - Message API Definitions
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "arc_msg.h" // Message API Definitions
#include "arc_mics.h" // Microphone Control Server Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ARC_MICS_ENABLE request message
typedef struct arc_mics_enable_req
{
/// Request code (@see enum arc_mics_req_code)
/// - ARC_MICS_ENABLE
uint16_t req_code;
/// Number of attributes reserved for the service
uint8_t nb_att_rsvd;
} arc_mics_enable_req_t;
/// Structure for ARC_MICS_RESTORE_BOND_DATA request message
typedef struct arc_mics_restore_bond_data_req
{
/// Request code (@see enum arc_mics_req_code)
/// - ARC_MICS_RESTORE_BOND_DATA
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
uint8_t cli_cfg_bf;
/// Event configuration bit field
uint8_t evt_cfg_bf;
} arc_mics_restore_bond_data_req_t;
/// Structure for ARC_MICS_SET_MUTE command message
typedef struct arc_mics_set_mute_req
{
/// Request code (@see enum arc_mics_req_code)
/// - ARC_MICS_SET_MUTE
uint16_t req_code;
/// Mute value
uint8_t mute;
} arc_mics_set_mute_req_t;
/// Structure for request message
typedef struct arc_mics_rsp
{
/// Request code (@see enum arc_mics_req_code)
uint16_t req_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
} arc_mics_rsp_t;
/// Structure for ARC_MICS_BOND_DATA indication message
typedef struct arc_mics_cfg_ind
{
/// Indication code (@see enum arc_mics_ind_code)
/// - ARC_MICS_BOND_DATA
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
uint8_t cli_cfg_bf;
} arc_mics_cfg_ind_t;
/// Structure for ARC_MICS_MUTE indication message
typedef struct arc_mics_mute_ind
{
/// Indication code (@see enum arc_mics_ind_code)
/// - ARC_MICS_MUTE
uint16_t ind_code;
/// Mute value
uint8_t mute;
} arc_mics_mute_ind_t;
/// @}
#endif // ARC_MICS_MSG_H_
@@ -0,0 +1,160 @@
/**
****************************************************************************************
*
* @file arc_vc.h
*
* @brief Audio Rendering Control - Volume Control - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_VC_H_
#define ARC_VC_H_
/**
****************************************************************************************
* @addtogroup ARC_VC Audio Rendering Control - Volume Control
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "arc.h" // Audio Rendering Control Definitions
/*
* DEFINES
****************************************************************************************
*/
/// Minimum volume value
#define ARC_VC_VOLUME_MIN (0)
/// Maximum volume value
#define ARC_VC_VOLUME_MAX (255)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Position of fields in Volume State characteristic value
enum arc_vc_state_pos
{
/// Volume Setting field
ARC_VC_STATE_POS_SETTING = 0,
/// Mute field
ARC_VC_STATE_POS_MUTE,
/// Change Counter field
ARC_VC_STATE_POS_CHANGE_CNT,
/// Length of Volume State characteristic value
ARC_VC_STATE_LEN
};
/// Position of fields in value written in Volume Control Point characteristic
enum arc_vc_cp_pos
{
/// Operation Code field
ARC_VC_CP_POS_OPCODE = 0,
/// Change Counter field
ARC_VC_CP_POS_CHANGE_CNT,
/// Volume Setting field
ARC_VC_CP_POS_SETTING,
/// Minimal length of Volume Control Point characteristic value
ARC_VC_CP_LEN_MIN = ARC_VC_CP_POS_CHANGE_CNT + 1,
ARC_VC_CP_LEN_MAX = ARC_VC_CP_POS_SETTING + 1,
};
/// Position of fields in Volume Flags characteristic value
enum arc_vc_flags_pos
{
/// Volume Flags field
ARC_VC_FLAGS_POS_FLAGS = 0,
/// Length of Volume Flags characteristic value
ARC_VC_FLAGS_LEN
};
/// Volume Operation Code values
enum arc_vc_opcode
{
/// Relative Volume Down
ARC_VC_OPCODE_VOL_DOWN = 0,
/// Relative Volume Up
ARC_VC_OPCODE_VOL_UP,
/// Unmute/Relative Volume Down
ARC_VC_OPCODE_VOL_DOWN_UNMUTE,
/// Unmute/Relative Volume Up
ARC_VC_OPCODE_VOL_UP_UNMUTE,
/// Set Absolute Volume
ARC_VC_OPCODE_VOL_SET_ABS,
/// Unmute
ARC_VC_OPCODE_VOL_UNMUTE,
/// Mute
ARC_VC_OPCODE_VOL_MUTE,
ARC_VC_OPCODE_MAX
};
/// Application error codes
enum arc_vc_err
{
/// Invalid change counter
ARC_VC_ERR_INVALID_CHANGE_CNT = 0x80,
/// Opcode not supported
ARC_VC_ERR_OPCODE_NOT_SUPP,
};
/// Volume Flags characteristic value bit field meaning
enum arc_vc_flags_bf
{
/// Volume Setting Persisted bit
ARC_VC_FLAGS_SETTING_PERSISTED_POS = 0,
ARC_VC_FLAGS_SETTING_PERSISTED_BIT = CO_BIT(ARC_VC_FLAGS_SETTING_PERSISTED_POS),
};
/// List of Volume Control Service characteristics
enum arc_vc_char_type
{
/// Volume State characteristic
ARC_VC_CHAR_TYPE_STATE = 0,
/// Volume Flags characteristic
ARC_VC_CHAR_TYPE_FLAGS,
ARC_VC_NTF_CHAR_TYPE_MAX,
/// Volume Control Point characteristic
ARC_VC_CHAR_TYPE_CP = ARC_VC_NTF_CHAR_TYPE_MAX,
ARC_VC_CHAR_TYPE_MAX,
};
/// List of Volume Control Service descriptors
enum arc_vc_desc_type
{
/// Volume State characteristic
ARC_VC_DESC_TYPE_CCC_STATE = 0,
/// Volume Flags characteristic
ARC_VC_DESC_TYPE_CCC_FLAGS,
ARC_VC_DESC_TYPE_MAX,
};
/// List of Mute value for Volume Control Service
enum arc_vc_mute
{
/// Not muted
ARC_VC_NOT_MUTED = 0,
/// Muted
ARC_VC_MUTED
};
/// @}
#endif // ARC_VC_H_
@@ -0,0 +1,286 @@
/**
****************************************************************************************
*
* @file arc_vcc.h
*
* @brief Audio Rendering Control - Volume Control Client - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_VCC_H_
#define ARC_VCC_H_
/**
****************************************************************************************
* @addtogroup ARC_VCC Audio Rendering Control - Volume Control Client
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "arc_vc.h" // Audio Rendering Control - Volume Control Definitions
#if (GAF_ARC_VCC)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for Volume Control Client
enum arc_vcc_cmd_code
{
ARC_VCC_DISCOVER = GAF_CODE(ARC, VCC, 0),
ARC_VCC_CONTROL = GAF_CODE(ARC, VCC, 1),
ARC_VCC_GET = GAF_CODE(ARC, VCC, 2),
ARC_VCC_GET_CFG = GAF_CODE(ARC, VCC, 3),
ARC_VCC_SET_CFG = GAF_CODE(ARC, VCC, 4),
};
/// List of GAF_REQ request codes for Volume Control Client
enum arc_vcc_req_code
{
ARC_VCC_CONFIGURE = GAF_CODE(ARC, VCC, 0),
ARC_VCC_RESTORE_BOND_DATA = GAF_CODE(ARC, VCC, 1),
};
/// List of GAF_IND indication codes for Volume Control Client
enum arc_vcc_ind_code
{
ARC_VCC_BOND_DATA = GAF_CODE(ARC, VCC, 0),
ARC_VCC_INCLUDED_SVC = GAF_CODE(ARC, VCC, 1),
ARC_VCC_VOLUME = GAF_CODE(ARC, VCC, 2),
ARC_VCC_FLAGS = GAF_CODE(ARC, VCC, 3),
ARC_VCC_CFG = GAF_CODE(ARC, VCC, 4),
ARC_VCC_SVC_CHANGED = GAF_CODE(ARC, VCC, 5),
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Volume Control Service content description structure
typedef struct arc_vcc_vcs
{
/// Service description
prf_svc_t svc_info;
/// Characteristics description
prf_char_t char_info[ARC_VC_CHAR_TYPE_MAX];
/// Descriptors description
prf_desc_t desc_info[ARC_VC_DESC_TYPE_MAX];
} arc_vcc_vcs_t;
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called each time a command has been completed
*
* @param[in] cmd_code Command code (@see enum arc_cmd_codes)
* @param[in] status Status
* @param[in] con_lid Connection local index
* @param[in] param Additional parameter
****************************************************************************************
*/
typedef void (*arc_vcc_cb_cmp_evt)(uint16_t cmd_code, uint16_t status, uint8_t con_lid, uint8_t param);
/**
****************************************************************************************
* @brief Callback function called when Volume Control Service instance has been discovered in a peer server database
*
* @param[in] con_lid Connection local index
* @param[in] p_svc_info Pointer to service content description
****************************************************************************************
*/
typedef void (*arc_vcc_cb_bond_data)(uint8_t con_lid, arc_vcc_vcs_t* p_svc_info);
/**
****************************************************************************************
* @brief Callback function called when Volume State has been received from a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] volume Volume Setting value
* @param[in] mute Mute value
****************************************************************************************
*/
typedef void (*arc_vcc_cb_volume)(uint8_t con_lid, uint8_t volume, uint8_t mute);
/**
****************************************************************************************
* @brief Callback function called when Volume Flags has been received from a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] flags Volume Flags characteristic value
****************************************************************************************
*/
typedef void (*arc_vcc_cb_flags)(uint8_t con_lid, uint8_t flags);
/**
****************************************************************************************
* @brief Callback function called when a Volume Offset Control Service or an Audio Input Control Service instance has
* been discovered in a peer server
*
* @param[in] con_lid Connection local index
* @param[in] uuid UUID
* @param[in] shdl Start handle
* @param[in] ehdl End handle
****************************************************************************************
*/
typedef void (*arc_vcc_cb_included_svc)(uint8_t con_lid, uint16_t uuid, uint16_t shdl, uint16_t ehdl);
/**
****************************************************************************************
* @brief Callback function called each time a client characteristic configuration value has been received from a peer
* server device
*
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] enabled Indicate if sending of notifications is enabled or not
****************************************************************************************
*/
typedef void (*arc_vcc_cb_cfg)(uint8_t con_lid, uint8_t char_type, uint8_t enabled);
/**
****************************************************************************************
* @brief Callback function called when a service changed indication is received from a Service device
*
* @param[in] con_lid Connection local index
****************************************************************************************
*/
typedef void (*arc_vcc_cb_svc_changed)(uint8_t con_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for volume management (client)
typedef struct arc_vcc_cb
{
/// Callback function called when a command has been completed
arc_vcc_cb_cmp_evt cb_cmp_evt;
/// Callback function called when Volume State has been received from a peer server device
arc_vcc_cb_volume cb_volume;
/// Callback function called when Volume Flags have been received from a peer server device
arc_vcc_cb_flags cb_flags;
/// Callback function called when a client characteristic configuration value has been received from a peer server
/// device
arc_vcc_cb_cfg cb_cfg;
/// Callback function called when Volume Control Service instance has been discovered in a peer server database
arc_vcc_cb_bond_data cb_bond_data;
/// Callback function called when a Volume Offset Control Service or an Audio Input Control Service instance has
/// been discovered in a peer server
arc_vcc_cb_included_svc cb_included_svc;
/// Callback function called when a service changed indication is received from a Service device
arc_vcc_cb_svc_changed cb_svc_changed;
} arc_vcc_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Create and configure Volume Control Client module
*
* @param[in] p_cb Pointer to set of callback functions for communications with upper layers
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vcc_configure(const arc_vcc_cb_t* p_cb);
/**
****************************************************************************************
* @brief Initiate discovery of Volume Control Service in peer server device database
*
* @param[in] con_lid Connection local index
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vcc_discover(uint8_t con_lid);
/**
****************************************************************************************
* @brief Set bonding information related to Volume Control after connection with a peer device
*
* @param[in] con_lid Connection local index
* @param[in] p_vcs_info Pointer to Volume Control Service description structures
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vcc_restore_bond_data(uint8_t con_lid, arc_vcc_vcs_t* p_vcs_info);
/**
****************************************************************************************
* @brief Control peer server device's Volume State values
*
* @param[in] con_lid Connection local index
* @param[in] opcode Operation code
* @param[in] volume Volume
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vcc_control(uint8_t con_lid, uint8_t opcode, uint8_t volume);
/**
****************************************************************************************
* @brief Get value for either Volume State or Volume Flags characteristic of a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vcc_get(uint8_t con_lid, uint8_t char_type);
/**
****************************************************************************************
* @brief Get Client Characteristic Configuration value for either Volume State or Volume Flags characteristic of a
* peer server device
*
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vcc_get_cfg(uint8_t con_lid, uint8_t char_type);
/**
****************************************************************************************
* @brief Set Client Characteristic Configuration value for either Volume State or Volume Flags characteristic of a
* peer server device
*
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] enable Indicate if sending of notifications must be enabled or disabled
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vcc_set_cfg(uint8_t con_lid, uint8_t char_type, uint8_t enable);
#endif //(GAF_ARC_VCC)
/// @}
#endif // ARC_VCC_H_
@@ -0,0 +1,230 @@
/**
****************************************************************************************
*
* @file arc_vcc_msg.h
*
* @brief Audio Rendering Control - Definition of Kernel Messages (Volume Control Client)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_VCC_MSG_H_
#define ARC_VCC_MSG_H_
/**
****************************************************************************************
* @addtogroup ARC_VCC_MSG Audio Rendering Control - Definition of Kernel Messages (Volume Control Client)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "arc_msg.h" // Audio Rendering Control Kernel Messages Definitions
#include "arc_vcc.h" // Audio Rendering Control - Volume Control Client Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ARC_VCC_DISCOVER command message
typedef struct arc_vcc_discover_cmd
{
/// Command code (@see enum arc_vcc_cmd_code)
/// - ARC_VCC_DISCOVER
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
} arc_vcc_discover_cmd_t;
/// Structure for ARC_VCC_CONTROL command message
typedef struct arc_vcc_control_cmd
{
/// Command code (@see enum arc_vcc_cmd_code)
/// - ARC_VCC_CONTROL
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Operation code
uint8_t opcode;
/// Volume
uint8_t volume;
} arc_vcc_control_cmd_t;
/// Structure for ARC_VCC_GET command message
typedef struct arc_vcc_get_cmd
{
/// Command code (@see enum arc_vcc_cmd_code)
/// - ARC_VCC_GET
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
} arc_vcc_get_cmd_t;
/// Structure for ARC_VCC_GET_CFG command message
typedef struct arc_vcc_get_cfg_cmd
{
/// Command code (@see enum arc_vcc_cmd_code)
/// - ARC_VCC_GET_CFG
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
} arc_vcc_get_cfg_cmd_t;
/// Structure for ARC_VCC_SET_CFG command message
typedef struct arc_vcc_set_cfg_cmd
{
/// Command code (@see enum arc_vcc_cmd_code)
/// - ARC_VCC_SET_CFG
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
/// Enable
uint8_t enable;
} arc_vcc_set_cfg_cmd_t;
/// Structure for command complete event message
typedef struct arc_vcc_cmp_evt
{
/// Command code (@see enum arc_vcc_cmd_code)
uint16_t cmd_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
/// Union
union
{
/// Value
uint8_t value;
/// Operation code
uint8_t opcode;
/// Characteristic type
uint8_t char_type;
} u;
} arc_vcc_cmp_evt_t;
/// Structure for ARC_VCC_CONFIGURE request message
typedef struct arc_vcc_configure_req
{
/// Request code (@see enum arc_vcc_req_code)
/// - ARC_VCC_CONFIGURE
uint16_t req_code;
} arc_vcc_configure_req_t;
/// Structure for ARC_VCC_RESTORE_BOND_DATA request message
typedef struct arc_vcc_restore_bond_data_req
{
/// Request code (@see enum arc_vcc_req_code)
/// - ARC_VCC_RESTORE_BOND_DATA
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Volume Control Service description
arc_vcc_vcs_t vcs_info;
} arc_vcc_restore_bond_data_req_t;
/// Structure for response message
typedef struct arc_vcc_rsp
{
/// Request code (@see enum arc_vcc_req_code)
uint16_t req_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
} arc_vcc_rsp_t;
/// Structure for ARC_VCC_BOND_DATA indication message
typedef struct arc_vcc_bond_data_ind
{
/// Indication code (@see enum arc_vcc_ind_code)
/// - ARC_VCC_BOND_DATA
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Volume Control Service description
arc_vcc_vcs_t vcs_info;
} arc_vcc_bond_data_ind_t;
/// Structure for ARC_VCC_INCLUDED_SVC indication message
typedef struct arc_vcc_included_svc_ind
{
/// Indication code (@see enum arc_vcc_ind_code)
/// - ARC_VCC_INCLUDED_SVC
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// UUID
uint16_t uuid;
/// Start handle
uint16_t shdl;
/// End handle
uint16_t ehdl;
} arc_vcc_included_svc_ind_t;
/// Structure for ARC_VCC_VOLUME indication message
typedef struct arc_vcc_volume_ind
{
/// Indication code (@see enum arc_vcc_ind_code)
/// - ARC_VCC_VOLUME
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Volume
uint8_t volume;
/// Mute
uint8_t mute;
} arc_vcc_volume_ind_t;
/// Structure for ARC_VCC_FLAGS indication message
typedef struct arc_vcc_flags_ind
{
/// Indication code (@see enum arc_vcc_ind_code)
/// - ARC_VCC_FLAGS
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Volume Flags
uint8_t flags;
} arc_vcc_flags_ind_t;
/// Structure for ARC_VCC_CFG indication message
typedef struct arc_vcc_cfg_ind
{
/// Indication code (@see enum arc_vcc_ind_code)
/// - ARC_VCC_CFG
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
/// Indicate if sending of notifications is enabled for the indicated characteristic
uint8_t enabled;
} arc_vcc_cfg_ind_t;
/// Structure for ARC_VCC_SVC_CHANGED indication message
typedef struct arc_vcc_svc_changed_ind
{
/// Indication code (@see enum arc_vcc_ind_code)
/// - ARC_VCC_SVC_CHANGED
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
} arc_vcc_svc_changed_ind_t;
/// @}
#endif // ARC_VCC_MSG_H_
@@ -0,0 +1,162 @@
/**
****************************************************************************************
*
* @file arc_vcs.h
*
* @brief Audio Rendering Control - Volume Control Server - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_VCS_H_
#define ARC_VCS_H_
/**
****************************************************************************************
* @addtogroup ARC_VCS Audio Rendering Control - Volume Control Server
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "arc_vc.h" // Volume Control Definitions
#if (GAF_ARC_VCS)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_REQ request codes for Volume Control Server
enum arc_vcs_req_code
{
ARC_VCS_CONFIGURE = GAF_CODE(ARC, VCS, 0),
ARC_VCS_ENABLE = GAF_CODE(ARC, VCS, 1),
ARC_VCS_RESTORE_BOND_DATA = GAF_CODE(ARC, VCS, 2),
ARC_VCS_CONTROL = GAF_CODE(ARC, VCS, 3),
};
/// List of GAF_IND indication codes for Volume Control Server
enum arc_vcs_ind_code
{
ARC_VCS_VOLUME = GAF_CODE(ARC, VCS, 0),
ARC_VCS_BOND_DATA = GAF_CODE(ARC, VCS, 1),
ARC_VCS_FLAGS = GAF_CODE(ARC, VCS, 2),
};
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called when Client Characteristic Configuration of a notification-capable
* characteristic has been updated by a peer client
*
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field
****************************************************************************************
*/
typedef void (*arc_vcs_cb_bond_data)(uint8_t con_lid, uint8_t cli_cfg_bf);
/**
****************************************************************************************
* @brief Callback function called when Volume State characteristic value has been updated
*
* @param[in] volume Volume Setting value
* @param[in] mute Mute value
****************************************************************************************
*/
typedef void (*arc_vcs_cb_volume)(uint8_t volume, uint8_t mute);
/**
****************************************************************************************
* @brief Callback function called when Volume Flags characteristic value has been updated
*
* @param[in] flags Volume Flags value
****************************************************************************************
*/
typedef void (*arc_vcs_cb_flags)(uint8_t flags);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for volume management (server)
typedef struct arc_vcs_cb
{
/// Callback function called when Client Characteristic Configuration of a notification-capable characteristic has
/// been updated by a peer client
arc_vcs_cb_bond_data cb_bond_data;
/// Callback function called when Volume State characteristic value has been updated
arc_vcs_cb_volume cb_volume;
/// Callback function called when Volume Flags characteristic value has been updated
arc_vcs_cb_flags cb_flags;
} arc_vcs_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure Volume Control Server module
*
* @param[in] p_cb Pointer to set of callback functions
* @param[in] step_size Step Size value
* @param[in] flags Volume Flags value
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vcs_configure(const arc_vcs_cb_t* p_cb, uint8_t step_size, uint8_t flags);
/**
****************************************************************************************
* @brief Enable Volume Control Server module
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vcs_enable(void);
/**
****************************************************************************************
* @brief Set bonding information related to Volume Control after connection with a peer device
*
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field
* @param[in] evt_cfg_bf Event configuration bit field
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vcs_restore_bond_data(uint8_t con_lid, uint8_t cli_cfg_bf, uint8_t evt_cfg_bf);
/**
****************************************************************************************
* @brief Control Volume State characteristic value
*
* @param[in] opcode Operation code
* @param[in] volume Volume
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vcs_control(uint8_t opcode, uint8_t volume);
#endif //(GAF_ARC_VCS)
/// @}
#endif // ARC_VCS_H_
@@ -0,0 +1,137 @@
/**
****************************************************************************************
*
* @file arc_vcs_msg.h
*
* @brief Audio Rendering Control - Volume Control Server - Message API Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_VCS_MSG_H_
#define ARC_VCS_MSG_H_
/**
****************************************************************************************
* @addtogroup ARC_VCS_MSG Audio Rendering Control - Volume Control Server - Message API Definitions
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "arc_msg.h" // Message API Definitions
#include "arc_vcs.h" // Volume Control Server Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ARC_VCS_CONFIGURE request message
typedef struct arc_vcs_configure_req
{
/// Request code (@see enum arc_vcs_req_code)
/// - ARC_VCS_CONFIGURE
uint16_t req_code;
/// Step size
uint8_t step_size;
/// Volume Flags characteristic value
uint8_t flags;
} arc_vcs_configure_req_t;
/// Structure for ARC_VCS_ENABLE request message
typedef struct arc_vcs_enable_req
{
/// Request code (@see enum arc_vcs_req_code)
/// - ARC_VCS_ENABLE
uint16_t req_code;
} arc_vcs_enable_req_t;
/// Structure for ARC_VCS_RESTORE_BOND_DATA request message
typedef struct arc_vcs_restore_bond_data_req
{
/// Request code (@see enum arc_vcs_req_code)
/// - ARC_VCS_RESTORE_BOND_DATA
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
uint8_t cli_cfg_bf;
/// Event configuration bit field
uint8_t evt_cfg_bf;
} arc_vcs_restore_bond_data_req_t;
/// Structure for ARC_VCS_CONTROL request message
typedef struct arc_vcs_control_req
{
/// Request code (@see enum arc_vcs_req_code)
/// - ARC_VCS_CONTROL
uint16_t req_code;
/// Operation code
uint8_t opcode;
/// Volume
uint8_t volume;
} arc_vcs_control_req_t;
/// Structure for request message
typedef struct arc_vcs_rsp
{
/// Request code (@see enum arc_vcs_req_code)
uint16_t req_code;
/// Status
uint16_t status;
union
{
/// Value
uint8_t value;
/// Connection local index
uint8_t con_lid;
/// Operation code
uint8_t opcode;
} u;
} arc_vcs_rsp_t;
/// Structure for ARC_VCS_BOND_DATA indication message
typedef struct arc_vcs_cfg_ind
{
/// Indication code (@see enum arc_vcs_ind_code)
/// - ARC_VCS_BOND_DATA
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
uint8_t cli_cfg_bf;
} arc_vcs_cfg_ind_t;
/// Structure for ARC_VCS_VOLUME indication message
typedef struct arc_vcs_volume_ind
{
/// Indication code (@see enum arc_vcs_ind_code)
/// - ARC_VCS_VOLUME
uint16_t ind_code;
/// Volume
uint8_t volume;
/// Mute
uint8_t mute;
} arc_vcs_volume_ind_t;
/// Structure for ARC_VCS_FLAGS indication message
typedef struct arc_vcs_flags_ind
{
/// Indication code (@see enum arc_vcs_ind_code)
/// - ARC_VCS_FLAGS
uint16_t ind_code;
/// Volume Flags
uint8_t flags;
} arc_vcs_flags_ind_t;
/// @}
#endif // ARC_VCS_MSG_H_
@@ -0,0 +1,146 @@
/**
****************************************************************************************
*
* @file arc_voc.h
*
* @brief Audio Rendering Control - Volume Offset Control - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_VOC_H_
#define ARC_VOC_H_
/**
****************************************************************************************
* @addtogroup ARC_VOC Audio Rendering Control - Volume Offset Control
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "arc.h" // Audio Rendering Control Definitions
/*
* DEFINES
****************************************************************************************
*/
/// Minimum offset value
#define ARC_VOC_OFFSET_MIN (-255)
/// Maximum offset value
#define ARC_VOC_OFFSET_MAX (255)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Position of fields in Offset State characteristic value
enum arc_voc_offset_pos
{
/// Volume Offset field
ARC_VOC_OFFSET_POS_OFFSET = 0,
/// Change Counter field
ARC_VOC_OFFSET_POS_CHANGE_CNT = 2,
/// Length of Offset State characteristic value
ARC_VOC_OFFSET_LEN
};
/// Position of fields in Audio Location characteristic value
enum arc_voc_location_pos
{
/// Audio Location field
ARC_VOC_LOCATION_POS_LOC = 0,
/// Length of Audio Location characteristic value
ARC_VOC_LOCATION_LEN = 1
};
/// Position of fields in value written in Volume Offset Control Point characteristic
enum arc_voc_cp_pos
{
/// Operation Code field
ARC_VOC_CP_POS_OPCODE = 0,
/// Change Counter field
ARC_VOC_CP_POS_CHANGE_CNT,
/// Volume Offset field
ARC_VOC_CP_POS_OFFSET,
/// Length of Volume Offset Control Point characteristic value
ARC_VOC_CP_LEN = ARC_VOC_CP_POS_OFFSET + 2,
};
/// Volume Offset Operation Code values
enum arc_voc_opcode
{
/// Set Volume Offset
ARC_VOC_OPCODE_SET_OFFSET = 1,
ARC_VOC_OPCODE_MAX,
ARC_VOC_OPCODE_MIN = ARC_VOC_OPCODE_SET_OFFSET,
};
/// Application error codes
enum arc_voc_err
{
/// Invalid change counter
ARC_VOC_ERR_INVALID_CHANGE_CNT = 0x80,
/// Opcode not supported
ARC_VOC_ERR_OPCODE_NOT_SUPP,
/// Value out of range
ARC_VOC_ERR_VALUE_OUT_OF_RANGE,
};
/// Set type values
enum arc_voc_set_type
{
/// Volume offset
ARC_VOC_SET_TYPE_OFFSET = 0,
/// Audio location
ARC_VOC_SET_TYPE_LOCATION,
ARC_VOC_SET_TYPE_MAX,
};
/// List of Volume Offset Control Service characteristics
enum arc_voc_char_type
{
/// Offset characteristic
ARC_VOC_CHAR_TYPE_OFFSET = 0,
/// Audio Location characteristic
ARC_VOC_CHAR_TYPE_LOC,
/// Audio Output Description characteristic
ARC_VOC_CHAR_TYPE_DESC,
ARC_VOC_NTF_CHAR_TYPE_MAX,
/// Volume Offset Control Point characteristic
ARC_VOC_CHAR_TYPE_CP = ARC_VOC_NTF_CHAR_TYPE_MAX,
ARC_VOC_CHAR_TYPE_MAX,
};
/// List of Volume Control Service descriptors
enum arc_voc_desc_type
{
/// Offset State characteristic
ARC_VOC_DESC_TYPE_CCC_OFFSET = 0,
/// Audio Location characteristic
ARC_VOC_DESC_TYPE_CCC_LOC,
/// Audio Output Description characteristic
ARC_VOC_DESC_TYPE_CCC_DESC,
ARC_VOC_DESC_TYPE_MAX,
};
/// @}
#endif // ARC_VOC_H_
@@ -0,0 +1,306 @@
/**
****************************************************************************************
*
* @file arc_vocc.h
*
* @brief Audio Rendering Control - Volume Offset Control Client - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_VOCC_H_
#define ARC_VOCC_H_
/**
****************************************************************************************
* @addtogroup ARC_VOCC Audio Rendering Control - Volume Offset Control Client
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "arc_voc.h" // Audio Rendering Control - Volume Offset Control Definitions
#if (GAF_ARC_VOCC)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for Volume Offset Control Client
enum arc_vocc_cmd_codes
{
ARC_VOCC_DISCOVER = GAF_CODE(ARC, VOCC, 0),
ARC_VOCC_GET = GAF_CODE(ARC, VOCC, 1),
ARC_VOCC_SET_DESCRIPTION = GAF_CODE(ARC, VOCC, 2),
ARC_VOCC_SET = GAF_CODE(ARC, VOCC, 3),
ARC_VOCC_GET_CFG = GAF_CODE(ARC, VOCC, 4),
ARC_VOCC_SET_CFG = GAF_CODE(ARC, VOCC, 5),
};
/// List of GAF_REQ request codes for Volume Offset Control Client
enum arc_vocc_req_codes
{
ARC_VOCC_CONFIGURE = GAF_CODE(ARC, VOCC, 0),
ARC_VOCC_RESTORE_BOND_DATA = GAF_CODE(ARC, VOCC, 1),
};
/// List of GAF_IND indication codes for Volume Offset Control Client
enum arc_vocc_ind_codes
{
ARC_VOCC_BOND_DATA = GAF_CODE(ARC, VOCC, 0),
ARC_VOCC_VALUE = GAF_CODE(ARC, VOCC, 1),
ARC_VOCC_DESCRIPTION = GAF_CODE(ARC, VOCC, 2),
ARC_VOCC_CFG = GAF_CODE(ARC, VOCC, 3),
ARC_VOCC_SVC_CHANGED = GAF_CODE(ARC, VOCC, 4),
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Volume Offset Control Service content description structure
typedef struct arc_vocc_vocs
{
/// Service description
prf_svc_t svc_info;
/// Characteristics description
prf_char_t char_info[ARC_VOC_CHAR_TYPE_MAX];
/// Descriptors description
prf_desc_t desc_info[ARC_VOC_DESC_TYPE_MAX];
} arc_vocc_vocs_t;
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called each time a command has been completed
*
* @param[in] cmd_code Command code (@see enum arc_cmd_codes)
* @param[in] status Status
* @param[in] con_lid Connection local index
* @param[in] output_lid Output local index
* @param[in] param Additional parameter
****************************************************************************************
*/
typedef void (*arc_vocc_cb_cmp_evt)(uint16_t cmd_code, uint16_t status, uint8_t con_lid, uint8_t output_lid,
uint8_t param);
/**
****************************************************************************************
* @brief Callback function called when a Volume Offset Control Service instance has been discovered in a peer server
* database
*
* @param[in] con_lid Connection local index
* @param[in] output_lid Output local index
* @param[in] p_svc_info Pointer to service content description
****************************************************************************************
*/
typedef void (*arc_vocc_cb_bond_data)(uint8_t con_lid, uint8_t output_lid, arc_vocc_vocs_t* p_svc_info);
/**
****************************************************************************************
* @brief Callback function called when Audio Location or Offset Staet characteristic value has been received from a
* peer server device
*
* @param[in] con_lid Connection local index
* @param[in] output_lid Output local index
* @param[in] char_type Characteristic type
* @param[in] val Value
****************************************************************************************
*/
typedef void (*arc_vocc_cb_value)(uint8_t con_lid, uint8_t output_lid, uint8_t char_type, uint16_t val);
/**
****************************************************************************************
* @brief Callback function called when Audio Output Description characteristic value has been received from a peer
* server device
*
* @param[in] con_lid Connection local index
* @param[in] output_lid Output local index
* @param[in] desc_len Audio output description length
* @param[in] p_desc Pointer to audio output description value
****************************************************************************************
*/
typedef void (*arc_vocc_cb_description)(uint8_t con_lid, uint8_t output_lid, uint16_t desc_len, uint8_t* p_desc);
/**
****************************************************************************************
* @brief Callback function called when Client Characteristic Configuration value has been received for a
* characteristic
*
* @param[in] con_lid Connection local index
* @param[in] output_lid Output local index
* @param[in] char_type Characteristic type
* @param[in] enabled Indicate if sending of notifications is enabled
****************************************************************************************
*/
typedef void (*arc_vocc_cb_cfg)(uint8_t con_lid, uint8_t output_lid, uint8_t char_type, uint8_t enabled);
/**
****************************************************************************************
* @brief Callback function called when a service changed indication is received from a Server device
*
* @param[in] con_lid Connection local index
****************************************************************************************
*/
typedef void (*arc_vocc_cb_svc_changed)(uint8_t con_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Volume Offset Control Client
typedef struct arc_vocc_cb
{
/// Callback function called when a command has been completed
arc_vocc_cb_cmp_evt cb_cmp_evt;
/// Callback function called when Audio Location or Offset State characteristic value has been received from a
/// peer server device
arc_vocc_cb_value cb_value;
/// Callback function called when Audio Output Description characteristic value has been received from a peer
/// server device
arc_vocc_cb_description cb_description;
/// Callback function called when a client characteristic configuration value has been received from a peer server
/// device
arc_vocc_cb_cfg cb_cfg;
/// Callback function called when a Volume Offset Control Service instance has been discovered in a peer server
/// database
arc_vocc_cb_bond_data cb_bond_data;
/// Callback function called when a service changed indication is received from a Server device
arc_vocc_cb_svc_changed cb_svc_changed;
} arc_vocc_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure use of Volume Offset Control Client module
*
* @param[in] p_cb Pointer to set of callback functions
* @param[in] pref_mtu Preferred MTU
* Values from 0 to 63 are equivalent to 64
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocc_configure(const arc_vocc_cb_t* p_cb, uint16_t pref_mtu);
/**
****************************************************************************************
* @brief Discover Volume Offset Control Service Services in peer server device database
*
* @param[in] con_lid Connection local index
* @param[in] nb_outputs Number of outputs
* @param[in] p_svc_hdl Pointer to service handles
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocc_discover(uint8_t con_lid, uint8_t nb_outputs, prf_svc_t* p_svc_hdl);
/**
****************************************************************************************
* @brief Set bonding information related to Volume Offset Control after connection with a peer device
*
* @param[in] con_lid Connection local index
* @param[in] nb_outputs Number of outputs
* @param[in] p_vocs_info Pointer to Volume Offset Control Service description structures
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocc_restore_bond_data(uint8_t con_lid, uint8_t nb_outputs, arc_vocc_vocs_t* p_vocs_info);
/**
****************************************************************************************
* @brief Set value for Audio Location characteristic of a peer server device output
*
* @param[in] con_lid Connection local index
* @param[in] output_lid Output local index
* @param[in] set_type Set type
* @param[in] val Value
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocc_set(uint8_t con_lid, uint8_t output_lid, uint8_t set_type, uint32_t val);
/**
****************************************************************************************
* @brief Set value for Audio Output Description characteristic of a peer server device output
*
* @param[in] con_lid Connection local index
* @param[in] output_lid Output local index
* @param[in] desc_len Audio output description length
* @param[in] p_desc Pointer to audio output description value
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocc_set_description(uint8_t con_lid, uint8_t output_lid, uint16_t desc_len, uint8_t* p_desc);
/**
****************************************************************************************
* @brief Get value for either Offset State or Audio Location or Audio Output Description characteristic of a peer
* server device output
*
* @param[in] con_lid Connection local index
* @param[in] output_lid Output local index
* @param[in] char_type Characteristic type
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocc_get(uint8_t con_lid, uint8_t output_lid, uint8_t char_type);
/**
****************************************************************************************
* @brief Get Client Characteristic Configuration value for either Offset State or Audio Location or Audio Output
* Description characteristic of a peer server device output
*
* @param[in] con_lid Connection local index
* @param[in] output_lid Output local index
* @param[in] char_type Characteristic type
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocc_get_cfg(uint8_t con_lid, uint8_t output_lid, uint8_t char_type);
/**
****************************************************************************************
* @brief Set Client Characteristic Configuration value for either Offset State or Audio Location or Audio Output
* Description characteristic of a peer server device output
*
* @param[in] con_lid Connection local index
* @param[in] output_lid Output local index
* @param[in] char_type Characteristic type
* @param[in] enable Indicate if sending of notifications must be enabled or disabled
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocc_set_cfg(uint8_t con_lid, uint8_t output_lid, uint8_t char_type, uint8_t enable);
#endif //(GAF_ARC_VOCC)
/// @}
#endif // ARC_VOCC_H_
@@ -0,0 +1,273 @@
/**
****************************************************************************************
*
* @file arc_vocc_msg.h
*
* @brief Audio Rendering Control - Definition of Kernel Messages (Volume Offset Control Client)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_VOCC_MSG_H_
#define ARC_VOCC_MSG_H_
/**
****************************************************************************************
* @addtogroup ARC_VOCC_MSG Audio Rendering Control - Definition of Kernel Messages (Volume Offset Control Client)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "arc_msg.h" // Audio Rendering Control Kernel Messages Definitions
#include "arc_vocc.h" // Audio Rendering Control - Volume Offset Control Client Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ARC_VOCC_DISCOVER command message
typedef struct arc_vocc_discover_cmd
{
/// Command code (@see enum arc_vocc_cmd_code)
/// - ARC_VOCC_DISCOVER
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Number of outputs
uint8_t nb_outputs;
/// Service handles
prf_svc_t svc_hdl[__ARRAY_EMPTY];
} arc_vocc_discover_cmd_t;
/// Structure for ARC_VOCC_GET command message
typedef struct arc_vocc_get_cmd
{
/// Command code (@see enum arc_vocc_cmd_code)
/// - ARC_VOCC_GET
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Output local index
uint8_t output_lid;
/// Characteristic type
uint8_t char_type;
} arc_vocc_get_cmd_t;
/// Structure for ARC_VOCC_SET_DESCRIPTION command message
typedef struct arc_vocc_set_description_cmd
{
/// Command code (@see enum arc_vocc_cmd_code)
/// - ARC_VOCC_SET_DESCRIPTION
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Output local index
uint8_t output_lid;
/// Audio output description length
uint16_t desc_len;
/// Audio output description
uint8_t desc[__ARRAY_EMPTY];
} arc_vocc_set_description_cmd_t;
/// Structure for ARC_VOCC_SET command message
typedef struct arc_vocc_set_cmd
{
/// Command code (@see enum arc_vocc_cmd_code)
/// - ARC_VOCC_SET
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Output local index
uint8_t output_lid;
/// Set type
uint8_t set_type;
union
{
/// Value
uint16_t val;
/// Volume offset
int16_t offset;
/// Audio location
uint8_t location;
} u;
} arc_vocc_set_cmd_t;
/// Structure for ARC_VOCC_GET_CFG command message
typedef struct arc_vocc_get_cfg_cmd
{
/// Command code (@see enum arc_vocc_cmd_code)
/// - ARC_VOCC_GET_CFG
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Output local index
uint8_t output_lid;
/// Characteristic type
uint8_t char_type;
} arc_vocc_get_cfg_cmd_t;
/// Structure for ARC_VOCC_SET_CFG command message
typedef struct arc_vocc_set_cfg_cmd
{
/// Command code (@see enum arc_vocc_cmd_code)
/// - ARC_VOCC_SET_CFG
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Output local index
uint8_t output_lid;
/// Characteristic type
uint8_t char_type;
/// Enable or disable
uint8_t enable;
} arc_vocc_set_cfg_cmd_t;
/// Structure for command complete event message
typedef struct arc_vocc_cmp_evt
{
/// Command code (@see enum arc_vocc_cmd_code)
uint16_t cmd_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
/// Output local index
uint8_t output_lid;
/// Union
union
{
/// Value
uint8_t value;
/// Set type
uint8_t set_type;
/// Characteristic type
uint8_t char_type;
} u;
} arc_vocc_cmp_evt_t;
/// Structure for ARC_VOCC_CONFIGURE request message
typedef struct arc_vocc_configure_req
{
/// Request code (@see enum arc_vocc_req_code)
/// - ARC_VOCC_CONFIGURE
uint16_t req_code;
/// Preferred MTU
/// Values from 0 to 63 are equivalent to 64
uint16_t pref_mtu;
} arc_vocc_configure_req_t;
/// Structure for ARC_VOCC_RESTORE_BOND_DATA request message
typedef struct arc_vocc_restore_bond_data_req
{
/// Request code (@see enum arc_vocc_req_code)
/// - ARC_VOCC_RESTORE_BOND_DATA
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Number of outputs
uint8_t nb_outputs;
/// Description of found Volume Offset Control Service instances
arc_vocc_vocs_t vocs_info[__ARRAY_EMPTY];
} arc_vocc_restore_bond_data_req_t;
/// Structure for response message
typedef struct arc_vocc_rsp
{
/// Request code (@see enum arc_vocc_req_code)
uint16_t req_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
} arc_vocc_rsp_t;
/// Structure for ARC_VOCC_BOND_DATA indication message
typedef struct arc_vocc_bond_data_ind
{
/// Indication code (@see enum arc_vocc_ind_code)
/// - ARC_VOCC_BOND_DATA
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Output local index
uint8_t output_lid;
/// Description of found Volume Offset Control Service instance
arc_vocc_vocs_t vocs_info;
} arc_vocc_bond_data_ind_t;
/// Structure for ARC_VOCC_VALUE indication message
typedef struct arc_vocc_value_ind
{
/// Indication code (@see enum arc_vocc_ind_code)
/// - ARC_VOCC_VALUE
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Output local index
uint8_t output_lid;
/// Characteristic type
uint8_t char_type;
union
{
/// Value
uint16_t val;
/// Volume offset
int16_t offset;
/// Audio location
uint8_t location;
} u;;
} arc_vocc_value_ind_t;
/// Structure for ARC_VOCC_DESCRIPTION indication message
typedef struct arc_vocc_description_ind
{
/// Indication code (@see enum arc_vocc_ind_code)
/// - ARC_VOCC_DESCRIPTION
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Output local index
uint8_t output_lid;
/// Audio output description length
uint16_t desc_len;
/// Audio output description
uint8_t desc[__ARRAY_EMPTY];
} arc_vocc_description_ind_t;
/// Structure for ARC_VOCC_CFG indication message
typedef struct arc_vocc_cfg_ind
{
/// Indication code (@see enum arc_vocc_ind_code)
/// - ARC_VOCC_CFG
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Output local index
uint8_t output_lid;
/// Characteristic type
uint8_t char_type;
/// Enabled or disabled
uint8_t enabled;
} arc_vocc_cfg_ind_t;
/// Structure for ARC_VOCC_SVC_CHANGED indication message
typedef struct arc_vocc_svc_changed_ind
{
/// Indication code (@see enum arc_vocc_ind_code)
/// - ARC_VOCC_SVC_CHANGED
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
} arc_vocc_svc_changed_ind_t;
/// @}
#endif // ARC_VOCC_MSG_H_
@@ -0,0 +1,264 @@
/**
****************************************************************************************
*
* @file arc_vocs.h
*
* @brief Audio Rendering Control - Volume Offset Control Server - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_VOCS_H_
#define ARC_VOCS_H_
/**
****************************************************************************************
* @addtogroup ARC_VOCS Audio Rendering Control - Volume Offset Control Server
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "arc_voc.h" // Audio Rendering Control - Volume Offset Control Definitions
#if (GAF_ARC_VOCS)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_REQ request codes for Volume Offset Control Server
enum arc_vocs_req_code
{
ARC_VOCS_CONFIGURE = GAF_CODE(ARC, VOCS, 0),
ARC_VOCS_ADD = GAF_CODE(ARC, VOCS, 1),
ARC_VOCS_ENABLE = GAF_CODE(ARC, VOCS, 2),
ARC_VOCS_RESTORE_BOND_DATA = GAF_CODE(ARC, VOCS, 3),
ARC_VOCS_SET = GAF_CODE(ARC, VOCS, 4),
ARC_VOCS_SET_DESCRIPTION = GAF_CODE(ARC, VOCS, 5),
};
/// List of GAF_IND indication codes for Volume Offset Control Server
enum arc_vocs_ind_code
{
ARC_VOCS_OFFSET = GAF_CODE(ARC, VOCS, 0),
ARC_VOCS_BOND_DATA = GAF_CODE(ARC, VOCS, 1),
};
/// List of GAF_REQ_IND indication codes for Volume Offset Control Server
enum arc_vocs_req_ind_code
{
ARC_VOCS_SET_DESCRIPTION_RI = GAF_CODE(ARC, VOCS, 0),
ARC_VOCS_SET_LOCATION = GAF_CODE(ARC, VOCS, 1),
};
/// Output configuration bit field
enum arc_vocs_cfg_bf
{
/// Set to 1 if Audio Location characteristic is notification-capable
ARC_VOCS_CFG_LOC_NTF_POS = 0,
ARC_VOCS_CFG_LOC_NTF_BIT = CO_BIT(ARC_VOCS_CFG_LOC_NTF_POS),
/// Set to 1 if Audio Location characteristic is writable
ARC_VOCS_CFG_LOC_WR_POS = 1,
ARC_VOCS_CFG_LOC_WR_BIT = CO_BIT(ARC_VOCS_CFG_LOC_WR_POS),
/// Set to 1 if Audio Output Description characteristic is notification-capable
ARC_VOCS_CFG_DESC_NTF_POS = 2,
ARC_VOCS_CFG_DESC_NTF_BIT = CO_BIT(ARC_VOCS_CFG_DESC_NTF_POS),
/// Set to 1 if Audio Output Description characteristic is writable
ARC_VOCS_CFG_DESC_WR_POS = 3,
ARC_VOCS_CFG_DESC_WR_BIT = CO_BIT(ARC_VOCS_CFG_DESC_WR_POS),
};
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called when Offset State characteristic value has been updated
*
* @param[in] output_lid Output local index
* @param[in] offset Offset value
****************************************************************************************
*/
typedef void (*arc_vocs_cb_offset)(uint8_t output_lid, int16_t offset);
/**
****************************************************************************************
* @brief Callback function called when Client Characteristic Configuration of a notification-capable
* characteristic has been updated by a peer client
*
* @param[in] output_lid Output local index
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field
****************************************************************************************
*/
typedef void (*arc_vocs_cb_bond_data)(uint8_t output_lid, uint8_t con_lid, uint8_t cli_cfg_bf);
/**
****************************************************************************************
* @brief Callback function called when value of Audio Output Description characteristic has been written so that it
* can be confirmed by upper layers
*
* @param[in] output_lid Output local index
* @param[in] con_lid Connection local index
* @param[in] desc_len Audio output description length
* @param[in] p_desc Pointer to audio output description value
****************************************************************************************
*/
typedef void (*arc_vocs_cb_description)(uint8_t output_lid, uint8_t con_lid, uint8_t desc_len, uint8_t* p_desc);
/**
****************************************************************************************
* @brief Callback function called when value of Audio Location characteristic has been written so that it can be
* confirmed by upper layers
*
* @param[in] output_lid Output local index
* @param[in] con_lid Connection local index
* @param[in] location Audio location
****************************************************************************************
*/
typedef void (*arc_vocs_cb_location)(uint8_t output_lid, uint8_t con_lid, uint8_t location);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for volume management (server)
typedef struct arc_vocs_cb
{
/// Callback function called when Client Characteristic Configuration of a notification-capable
/// characteristic has been updated by a peer client
arc_vocs_cb_bond_data cb_bond_data;
/// Callback function called when Offset State characteristic value has been updated
arc_vocs_cb_offset cb_offset;
/// Callback function called when value of Audio Output Description characteristic has been written so that it can
/// be confirmed by upper layers
arc_vocs_cb_description cb_description;
/// Callback function called when value of Audio Location characteristic has been written so that it can be
/// confirmed by upper layers
arc_vocs_cb_location cb_location;
} arc_vocs_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure Volume Offset Control Server module
*
* @param[in] p_cb Pointer to set of callback functions for communication with upper layers
* @param[in] nb_outputs Number of outputs
* @param[in] pref_mtu Preferred MTU
* Values from 0 to 63 are equivalent to 64
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocs_configure(const arc_vocs_cb_t* p_cb, uint8_t nb_outputs, uint16_t pref_mtu);
/**
****************************************************************************************
* @brief Add an output
*
* @param[in] desc_max_len Audio Output Description maximum length
* @param[in] cfg_bf Configuration bit field
* @param[in] nb_att_rsvd Number of attributes reserved for the service
* @param[out] p_output_lid Pointer at which allocated output local index is returned
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocs_add(uint8_t desc_max_len, uint8_t cfg_bf, uint16_t nb_att_rsvd, uint8_t* p_output_lid);
/**
****************************************************************************************
* @brief Enable Volume Offset Control Server module
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocs_enable(void);
/**
****************************************************************************************
* @brief Set bonding information related to an input after establishment of a connection
*
* @param[in] output_lid Output local index
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field
* @param[in] evt_bf Event bit field
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocs_restore_bond_data(uint8_t output_lid, uint8_t con_lid, uint8_t cli_cfg_bf, uint8_t evt_bf);
/**
****************************************************************************************
* @brief Set value of Audio Location or Offset State characteristic
*
* @param[in] output_lid Output local index
* @param[in] set_type Set type
* @param[in] value Value
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocs_set(uint8_t output_lid, uint8_t set_type, uint32_t val);
/**
****************************************************************************************
* @brief Set value of Audio Output Description characteristic value
*
* @param[in] output_lid Output local index
* @param[in] desc_len Audio output description length
* @param[in] p_desc Pointer to Audio output description value
*
* @return An error status
****************************************************************************************
*/
uint16_t arc_vocs_set_description(uint8_t output_lid, uint8_t desc_len, uint8_t *p_desc);
/**
****************************************************************************************
* @brief Confirm or not value written for Audio Output Description characteristic
*
* @param[in] cfm_status Confirmation status
* @param[in] output_lid Output local index
* @param[in] desc_len Audio output description length
* @param[in] p_desc Pointer to Audio output description value
****************************************************************************************
*/
void arc_vocs_cfm_set_description(uint16_t cfm_status, uint8_t output_lid, uint8_t desc_len, uint8_t *p_desc);
/**
****************************************************************************************
* @brief Confirm or not value written for Audio Location characteristic
*
* @param[in] cfm_status Confirmation status
* @param[in] output_lid Output local index
* @param[in] location Audio location
****************************************************************************************
*/
void arc_vocs_cfm_set_location(uint16_t cfm_status, uint8_t output_lid, uint8_t location);
#endif //(GAF_ARC_VOCS)
/// @}
#endif // ARC_VOCS_H_
@@ -0,0 +1,236 @@
/**
****************************************************************************************
*
* @file arc_vocs_msg.h
*
* @brief Audio Rendering Control - Definition of Kernel Messages (Volume Offset Control Server)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_VOCS_MSG_H_
#define ARC_VOCS_MSG_H_
/**
****************************************************************************************
* @addtogroup ARC_VOCS_MSG Audio Rendering Control - Definition of Kernel Messages (Volume Offset Control Server)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "arc_msg.h" // Audio Rendering Control Kernel Messages Definitions
#include "arc_vocs.h" // Audio Rendering Control - Volume Offset Control Server Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ARC_VOCS_ADD request message
typedef struct arc_vocs_add_req
{
/// Request code (@see enum arc_vocs_req_code)
/// - ARC_VOCS_ADD
uint16_t req_code;
/// Maximum length of Audio Output Description
uint8_t desc_max_len;
/// Service configuration bit field
uint8_t cfg_bf;
/// Number of attributes reserved for all Volume Offset Control Service instances inserted
/// in the database
uint16_t nb_att_rsvd;
} arc_vocs_add_req_t;
/// Structure for ARC_VOCS_ADD response message
typedef struct arc_vocs_add_rsp
{
/// Request code (@see enum arc_vocs_req_code)
uint16_t req_code;
/// Status
uint16_t status;
/// Allocated output local index
uint8_t output_lid;
} arc_vocs_add_rsp_t;
/// Structure for ARC_VOCS_RESTORE_BOND_DATA request message
typedef struct arc_vocs_restore_bond_data_req
{
/// Request code (@see enum arc_vocs_req_code)
/// - ARC_VOCS_RESTORE_BOND_DATA
uint16_t req_code;
/// Output local index
uint8_t output_lid;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
uint8_t cli_cfg_bf;
/// Event bit field
uint8_t evt_cfg_bf;
} arc_vocs_restore_bond_data_req_t;
/// Structure for ARC_VOCS_CONFIGURE request message
typedef struct arc_vocs_configure_req
{
/// Request code (@see enum arc_vocs_req_code)
/// - ARC_VOCS_CONFIGURE
uint16_t req_code;
/// Number of outputs
uint8_t nb_outputs;
/// Preferred MTU
/// Values from 0 to 63 are equivalent to 64
uint16_t pref_mtu;
} arc_vocs_configure_req_t;
/// Structure for ARC_VOCS_SET request message
typedef struct arc_vocs_set_req
{
/// Request code (@see enum arc_vocs_req_code)
/// - ARC_VOCS_SET
uint16_t req_code;
/// Output local index
uint8_t output_lid;
/// Set type
uint8_t set_type;
union
{
/// Value
uint32_t val;
/// Volume offset
int16_t offset;
/// Audio location
uint8_t location;
} u;
} arc_vocs_set_req_t;
/// Structure for ARC_VOCS_SET_DESCRIPTION request message
typedef struct arc_vocs_set_description_req
{
/// Request code (@see enum arc_vocs_req_code)
/// - ARC_VOCS_SET_DESCRPITION
uint16_t req_code;
/// Output local index
uint8_t output_lid;
/// Audio output description length
uint8_t desc_len;
/// Audio output description
uint8_t desc[__ARRAY_EMPTY];
} arc_vocs_set_description_req_t;
/// Structure for request message
typedef struct arc_vocs_rsp
{
/// Request code (@see enum arc_vocs_req_code)
uint16_t req_code;
/// Status
uint16_t status;
/// Output local index
uint8_t output_lid;
/// Union
union
{
/// Value
uint8_t value;
/// Connection local index
uint8_t con_lid;
/// Set type
uint8_t set_type;
} u;
} arc_vocs_rsp_t;
/// Structure for ARC_VOCS_OFFSET indication message
typedef struct arc_vocs_offset_ind
{
/// Indication code (@see enum arc_vocs_ind_code)
/// - ARC_VOCS_OFFSET
uint16_t ind_code;
/// Output local index
uint8_t output_lid;
/// Offset
int16_t offset;
} arc_vocs_offset_ind_t;
/// Structure for ARC_VOCS_BOND_DATA indication message
typedef struct arc_vocs_cfg_ind
{
/// Indication code (@see enum arc_vocs_ind_code)
/// - ARC_VOCS_BOND_DATA
uint16_t ind_code;
/// Output local index
uint8_t output_lid;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
uint8_t cli_cfg_bf;
} arc_vocs_cfg_ind_t;
/// Structure for ARC_VOCS_SET_DESCRIPTION request indication message
typedef struct arc_vocs_set_description_req_ind
{
/// Request Indication code (@see enum arc_vocs_req_ind_code)
/// - ARC_VOCS_SET_DESCRPITION
uint16_t req_ind_code;
/// Output local index
uint8_t output_lid;
/// Connection local index
uint8_t con_lid;
/// Audio output description length
uint8_t desc_len;
/// Audio output description
uint8_t desc[__ARRAY_EMPTY];
} arc_vocs_set_description_req_ind_t;
/// Structure for ARC_VOCS_SET_DESCRIPTION confirmation message
typedef struct arc_vocs_set_description_cfm
{
/// Request Indication code (@see enum arc_vocs_req_ind_code)
/// - ARC_VOCS_SET_DESCRPITION
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Output local index
uint8_t output_lid;
/// Audio output description length
uint8_t desc_len;
/// Audio output description
uint8_t desc[__ARRAY_EMPTY];
} arc_vocs_set_description_cfm_t;
/// Structure for ARC_VOCS_SET_LOCATION request indication message
typedef struct arc_vocs_set_location_req_ind
{
/// Request Indication code (@see enum arc_vocs_req_ind_code)
/// - ARC_VOCS_SET_LOCATION
uint16_t req_ind_code;
/// Output local index
uint8_t output_lid;
/// Connection local index
uint8_t con_lid;
/// Audio location
uint8_t location;
} arc_vocs_set_location_req_ind_t;
/// Structure for ARC_VOCS_SET_LOCATION confirmation message
typedef struct arc_vocs_set_location_cfm
{
/// Request Indication code (@see enum arc_vocs_req_ind_code)
/// - ARC_VOCS_SET_LOCATION
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Output local index
uint8_t output_lid;
/// Audio location
uint8_t location;
} arc_vocs_set_location_cfm_t;
/// @}
#endif // ARC_VOCS_MSG_H_
+60
View File
@@ -0,0 +1,60 @@
/**
****************************************************************************************
*
* @file atc.h
*
* @brief Audio Topology Control - Header file
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ATC_H_
#define ATC_H_
/**
****************************************************************************************
* @addtogroup ATC Audio Topology Control
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf_cfg.h" // GAF Configuration
/*
* MACROS
****************************************************************************************
*/
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Module type values
enum atc_module_type
{
/// Common
ATC_MODULE_COMMON = 0,
/// Routing Active Audio Server
ATC_MODULE_RAAS = 1,
/// Routing Active Audio Client
ATC_MODULE_RAAC = 2,
/// Coordinated Set Identification Set Member
ATC_MODULE_CSISM = 3,
/// Coordinated Set Identification Set Coordinator
ATC_MODULE_CSISC = 4,
ATC_MODULE_MAX,
};
/// @}
#endif // ATC_H_
@@ -0,0 +1,94 @@
/**
****************************************************************************************
*
* @file atc_msg.h
*
* @brief Audio Topology Control - Definition of Kernel Messages
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ATC_MSG_H_
#define ATC_MSG_H_
/**
****************************************************************************************
* @addtogroup ATC Audio Topology Control - Definition of Kernel Messages
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "atc.h" // ATC Definitions
#if (GAF_ATC)
#include "gaf_msg.h" // Generic Audio Framework API Message Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_REQ request codes
enum atc_msg_req_codes
{
ATC_GET_FEATURES = GAF_CODE(ATC, COMMON, 0),
};
/// Features bit field meaning
enum atc_feat_bf
{
/// Routing Active Audio Service Server supported
ATC_FEAT_RAAS_SUPP_POS = 0,
ATC_FEAT_RAAS_SUPP_BIT = CO_BIT(ATC_FEAT_RAAS_SUPP_POS),
/// Routing Active Audio Service Server supported
ATC_FEAT_RAAC_SUPP_POS = 1,
ATC_FEAT_RAAC_SUPP_BIT = CO_BIT(ATC_FEAT_RAAC_SUPP_POS),
/// Coordinated Set Identification Set Member supported
ATC_FEAT_CSISM_SUPP_POS = 2,
ATC_FEAT_CSISM_SUPP_BIT = CO_BIT(ATC_FEAT_CSISM_SUPP_POS),
/// Coordinated Set Identification Set Coordinator supported
ATC_FEAT_CSISC_SUPP_POS = 3,
ATC_FEAT_CSISC_SUPP_BIT = CO_BIT(ATC_FEAT_CSISC_SUPP_POS),
};
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ATC_GET_FEATURES request message
typedef struct atc_get_features_req
{
/// Request code (@see enum atc_msg_req_codes)
uint16_t req_code;
} atc_get_features_req_t;
/// Structure for ATC_GET_FEATURES response message
typedef struct atc_get_features_rsp
{
/// Request code (@see enum atc_msg_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
/// Features bit field
uint32_t feat_bf;
} atc_get_features_rsp_t;
#endif //(GAF_ATC)
/// @}
#endif // ATC_MSG_H_
@@ -0,0 +1,36 @@
/**
****************************************************************************************
*
* @file atc_csi.h
*
* @brief Audio Topology Control - Coordinated Set Identification - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ATC_CSI_H_
#define ATC_CSI_H_
/**
****************************************************************************************
* @addtogroup ATC_CSI Audio Topology Control - Coordinated Set Identification
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "atc.h" // Audio Topology Control Definitions
#if (GAF_ATC_CSISM || GAF_ATC_CSISC)
#include "csis.h" // Coordinated Set Identification Service Definitions
#endif //(GAF_ATC_CSISM || GAF_ATC_CSISC)
/// @}
#endif // ATC_CSI_H_
@@ -0,0 +1,115 @@
/**
****************************************************************************************
*
* @file atc_csisc.h
*
* @brief Audio Topology Control - Coordinated Set Identification Set Coordinator - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ATC_CSISC_H_
#define ATC_CSISC_H_
/**
****************************************************************************************
* @addtogroup ATC_CSISC Audio Topology Control - Coordinated Set Identification Set Coordinator
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "atc_csi.h" // Audio Topology Control - Coordinated Set Identification Definitions
#if (GAF_ATC_CSISC)
#include "csisc.h" // Coordinated Set Identification Set Coordinator Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for Coordinated Set Identification Set Coordinator
enum atc_csisc_cmd_codes
{
ATC_CSISC_RESOLVE = GAF_CODE(ATC, CSISC, 0),
ATC_CSISC_DISCOVER = GAF_CODE(ATC, CSISC, 1),
ATC_CSISC_LOCK = GAF_CODE(ATC, CSISC, 2),
ATC_CSISC_GET = GAF_CODE(ATC, CSISC, 3),
ATC_CSISC_GET_CFG = GAF_CODE(ATC, CSISC, 4),
ATC_CSISC_SET_CFG = GAF_CODE(ATC, CSISC, 5),
};
/// List of GAF_REQ request codes for Coordinated Set Identification Set Coordinator
enum atc_csisc_msg_req_codes
{
ATC_CSISC_CONFIGURE = GAF_CODE(ATC, CSISC, 0),
ATC_CSISC_RESTORE_BOND_DATA = GAF_CODE(ATC, CSISC, 1),
ATC_CSISC_ADD_SIRK = GAF_CODE(ATC, CSISC, 2),
ATC_CSISC_REMOVE_SIRK = GAF_CODE(ATC, CSISC, 3),
};
/// List of GAF_IND indication codes for Coordinated Set Identification Set Coordinator
enum atc_csisc_msg_ind_codes
{
ATC_CSISC_BOND_DATA = GAF_CODE(ATC, CSISC, 0),
ATC_CSISC_SIRK = GAF_CODE(ATC, CSISC, 1),
ATC_CSISC_INFO = GAF_CODE(ATC, CSISC, 2),
ATC_CSISC_CFG = GAF_CODE(ATC, CSISC, 3),
ATC_CSISC_SVC_CHANGED = GAF_CODE(ATC, CSISC, 4),
};
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Coordinated Set Identification Set Coordinator
typedef csisc_cb_t atc_csisc_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Create and configure Coordinated Set Identification Set Coordinator module
*
* @param[in] nb_sirk Number of SIRK value that can be stored
* @param[in] p_cb Pointer to set of callback functions for communications with
* upper layers
*
* @return An error status
****************************************************************************************
*/
uint16_t atc_csisc_configure(uint8_t nb_sirk, const atc_csisc_cb_t* p_cb);
/// Wrapper for functions defined in csisc.h
#define atc_csisc_resolve(p_psri) (csisc_resolve(p_psri))
#define atc_csisc_discover(con_lid, nb_sets_max, shdl, ehdl) \
(csisc_discover(con_lid, nb_sets_max, shdl, ehdl))
#define atc_csisc_restore_bond_data(con_lid, nb_sets, p_csis_info) \
(csisc_restore_bond_data(con_lid, nb_sets, p_csis_info))
#define atc_csisc_lock(con_lid, set_lid, lock) (csisc_lock(con_lid, set_lid, lock))
#define atc_csisc_get(con_lid, set_lid, char_type) (csisc_get(con_lid, set_lid, char_type))
#define atc_csisc_get_cfg(con_lid, set_lid, char_type) \
(csisc_get_cfg(con_lid, set_lid, char_type))
#define atc_csisc_set_cfg(con_lid, set_lid, char_type, enable) \
(csisc_set_cfg(con_lid, set_lid, char_type, enable))
#define atc_csisc_add_sirk(p_sirk, p_key_lid) (csisc_add_sirk(p_sirk, p_key_lid))
#define atc_csisc_remove_sirk(key_lid) (csisc_remove_sirk(key_lid))
#endif //(GAF_ATC_CSISC)
/// @}
#endif // ATC_CSISC_H_
@@ -0,0 +1,102 @@
/**
****************************************************************************************
*
* @file atc_csisc_msg.h
*
* @brief Audio Topology Control - Definition of Kernel Messages (Coordinated Set
* Identification Set Coordinator)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ATC_CSISC_MSG_H_
#define ATC_CSISC_MSG_H_
/**
****************************************************************************************
* @addtogroup ATC_CSISC_MSG Audio Topology Control - Definition of Kernel Messages
* (Coordinated Set Identification Set Coordinator)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "atc_msg.h" // Audio Topology Control Kernel Messages Definitions
#include "csisc_msg.h" // Coordinated Set Identification Set Coordinator - Message API Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ATC_CSISC_RESOLVE command message
typedef csisc_resolve_cmd_t atc_csisc_resolve_cmd_t;
/// Structure for ATC_CSISC_DISCOVER command message
typedef csisc_discover_cmd_t atc_csisc_discover_cmd_t;
/// Structure for ATC_CSISC_LOCK command message
typedef csisc_lock_cmd_t atc_csisc_lock_cmd_t;
/// Structure for ATC_CSISC_GET command message
typedef csisc_get_cmd_t atc_csisc_get_cmd_t;
/// Structure for ATC_CSISC_GET_CFG command message
typedef csisc_get_cfg_cmd_t atc_csisc_get_cfg_cmd_t;
/// Structure for ATC_CSISC_SET_CFG command message
typedef csisc_set_cfg_cmd_t atc_csisc_set_cfg_cmd_t;
/// Structure command complete event
typedef csisc_cmp_evt_t atc_csisc_cmp_evt_t;
/// Structure for ATC_CSISC_CONFIGURE request message
typedef struct atc_csisc_configure_req
{
/// Request code
uint16_t req_code;
/// Number of SIRK values that can be stored
uint8_t nb_sirk;
} atc_csisc_configure_req_t;
/// Structure for ATC_CSISC_RESTORE_BOND_DATA request message
typedef csisc_restore_bond_data_req_t atc_csisc_restore_bond_data_req_t;
/// Structure for CSISC_ADD_SIRK request message
typedef csisc_add_sirk_req_t atc_csisc_add_sirk_req_t;
/// Structure for CSISC_REMOVE_SIRK request message
typedef csisc_remove_sirk_req_t atc_csisc_remove_sirk_req_t;
/// Structure for response message
typedef csisc_rsp_t atc_csisc_rsp_t;
/// Structure for ATC_CSISC_BOND_DATA indication message
typedef csisc_bond_data_ind_t atc_csisc_bond_data_ind_t;
/// Structure for ATC_CSISC_SIRK indication message
typedef csisc_sirk_ind_t atc_csisc_sirk_ind_t;
/// Structure for ATC_CSISC_INFO indication message
typedef csisc_info_ind_t atc_csisc_info_ind_t;
/// Structure for ATC_CSISC_CFG indication message
typedef csisc_cfg_ind_t atc_csisc_cfg_ind_t;
/// Structure for ATC_CSISC_SVC_CHANGED indication message
typedef csisc_svc_changed_ind_t atc_csisc_svc_changed_ind_t;
/// @}
#endif // ATC_CSISC_MSG_H_
@@ -0,0 +1,110 @@
/**
****************************************************************************************
*
* @file atc_csism.h
*
* @brief Audio Topology Control - Coordinated Set Identification Set Member - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ATC_CSISM_H_
#define ATC_CSISM_H_
/**
****************************************************************************************
* @addtogroup ATC_CSISM Audio Topology Control - Coordinated Set Identification Set Member
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "atc_csi.h" // Audio Topology Control - Coordinated Set Identification Definitions
#if (GAF_ATC_CSISM)
#include "csism.h" // Coordinated Set Identification Set Member Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for Coordinated Set Identification Set Member
enum atc_csism_cmd_codes
{
ATC_CSISM_ADD = GAF_CODE(ATC, CSISM, 0),
ATC_CSISM_SET_SIRK = GAF_CODE(ATC, CSISM, 1),
ATC_CSISM_UPDATE_PSRI = GAF_CODE(ATC, CSISM, 2),
};
/// List of GAF_REQ request codes for Coordinated Set Identification Set Member
enum atc_csism_msg_req_codes
{
ATC_CSISM_CONFIGURE = GAF_CODE(ATC, CSISM, 0),
ATC_CSISM_RESTORE_BOND_DATA = GAF_CODE(ATC, CSISM, 1),
ATC_CSISM_SET_SIZE = GAF_CODE(ATC, CSISM, 2),
};
/// List of GAF_IND indication codes for Coordinated Set Identification Set Member
enum atc_csism_msg_ind_codes
{
ATC_CSISM_LOCK = GAF_CODE(ATC, CSISM, 0),
ATC_CSISM_BOND_DATA = GAF_CODE(ATC, CSISM, 1),
};
/// List of GAF_REQ_IND request indication codes for Coordinated Set Identification Set Member
enum atc_csism_msg_req_ind_codes
{
ATC_CSISM_AUTHORIZATION = GAF_CODE(ATC, CSISM, 0),
};
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Coordinated Set Identification Set Member
typedef csism_cb_t atc_csism_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Create and configure Coordinated Set Identification Set Member module
*
* @param[in] nb_sets Number of Coordinated Set the device may belongs to
* @param[in] p_cb Pointer to set of callback functions for communications with
* upper layers
*
* @return An error status
****************************************************************************************
*/
uint16_t atc_csism_configure(uint8_t nb_sets, const atc_csism_cb_t* p_cb);
/// Wrapper for functions defined in csism.h
#define atc_csism_add(cfg_bf, size, rank, lock_timeout_s, nb_att_rsvd, p_sirk) \
(csism_add(cfg_bf, size, rank, lock_timeout_s, nb_att_rsvd, p_sirk))
#define atc_csism_restore_bond_data(con_lid, set_lid, cli_cfg_bf, evt_cfg_bf) \
(csism_restore_bond_data(con_lid, set_lid, cli_cfg_bf, evt_cfg_bf))
#define atc_csism_set_sirk(set_lid, p_sirk) (csism_set_sirk(set_lid, p_sirk))
#define atc_csism_update_psri(set_lid) (csism_update_psri(set_lid))
#define atc_csism_set_size(set_lid, size) (csism_set_size(set_lid, size))
#define atc_csism_authorization_cfm(status, set_lid, con_lid, dont_ask) \
(csism_authorization_cfm(status, set_lid, con_lid, dont_ask))
#endif //(GAF_ATC_CSISM)
/// @}
#endif // ATC_CSISM_H_
@@ -0,0 +1,88 @@
/**
****************************************************************************************
*
* @file atc_csism_msg.h
*
* @brief Audio Topology Control - Definition of Kernel Messages (Coordinated Set
* Identification Set Member)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ATC_CSISM_MSG_H_
#define ATC_CSISM_MSG_H_
/**
****************************************************************************************
* @addtogroup ATC_CSISM_MSG Audio Topology Control - Definition of Kernel Messages
* (Coordinated Set Identification Set Member)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "atc_msg.h" // Audio Topology Control Kernel Messages Definitions
#include "csism_msg.h" // Coordinated Set Identification Set Member - Message API Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for ATC_CSISM_ADD command message
typedef csism_add_cmd_t atc_csism_add_cmd_t;
/// Structure for ATC_CSISM_SET_SIRK command message
typedef csism_set_sirk_cmd_t atc_csism_set_sirk_cmd_t;
/// Structure for ATC_CSISM_UPDATE_PSRI command message
typedef csism_update_psri_cmd_t atc_csism_update_psri_cmd_t;
/// Structure command complete event
typedef csism_cmp_evt_t atc_csism_cmp_evt_t;
/// Structure for ATC_CSISM_CONFIGURE request message
typedef struct atc_csism_configure_req
{
/// Request code
uint16_t req_code;
/// Number of Coordinated Sets
uint8_t nb_sets;
} atc_csism_configure_req_t;
/// Structure for ATC_CSISM_RESTORE_BOND_DATA request message
typedef csism_restore_bond_data_req_t atc_csism_restore_bond_data_req_t;
/// Structure for ATC_CSISM_SET_SIZE request message
typedef csism_set_size_req_t atc_csism_set_size_req_t;
/// Structure for response message
typedef csism_rsp_t atc_csism_rsp_t;
/// Structure for ATC_CSISM_LOCK indication message
typedef csism_lock_ind_t atc_csism_lock_ind_t;
/// Structure for ATC_CSISM_BOND_DATA indication message
typedef csism_bond_data_ind_t atc_csism_bond_data_ind_t;
/// Structure for ATC_CSISM_AUTHORIZATION request indication message
typedef csism_authorization_req_ind_t atc_csism_authorization_req_ind_t;
/// Structure for ATC_CSISM_AUTHORIZATION confirmation message
typedef csism_authorization_cfm_t atc_csism_authorization_cfm_t;
/// @}
#endif // ATC_CSISM_MSG_H_
+593
View File
@@ -0,0 +1,593 @@
/**
****************************************************************************************
*
* @file bap.h
*
* @brief Basic Audio Profile - Header file
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_H_
#define BAP_H_
/**
****************************************************************************************
* @addtogroup BAP Basic Audio Profile
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf_cfg.h" // GAF Configuration
#include "gaf.h" // Code definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Module type values
enum bap_module_type
{
/// Common
BAP_MODULE_COMMON = 0,
/// Basic Audio Profile Capabilities Server
BAP_MODULE_CAPA_SRV = 1,
/// Basic Audio Profile Capabilities Client
BAP_MODULE_CAPA_CLI = 2,
/// Basic Audio Profile Unicast Server
BAP_MODULE_UC_SRV = 3,
/// Basic Audio Profile Unicast Client
BAP_MODULE_UC_CLI = 4,
/// Basic Audio Profile Broadcast Source
BAP_MODULE_BC_SRC = 5,
/// Basic Audio Profile Broadcast Sink
BAP_MODULE_BC_SINK = 6,
/// Basic Audio Profile Broadcast Scan
BAP_MODULE_BC_SCAN = 7,
/// Basic Audio Profile Broadcast Assistant
BAP_MODULE_BC_ASSIST = 8,
/// Basic Audio Profile Broadcast Delegator
BAP_MODULE_BC_DELEG = 9,
BAP_MODULE_MAX,
};
/// List of GAF_REQ request codes
enum bap_msg_req_codes
{
/// Configure Basic Audio Profile
BAP_CONFIGURE = GAF_CODE(BAP, COMMON, 0),
/// Get supported roles
BAP_GET_ROLES = GAF_CODE(BAP, COMMON, 1),
};
/// Position of fields in LTV structure
enum bap_ltv_pos
{
/// Length
BAP_LTV_LENGTH_POS = 0,
/// Type
BAP_LTV_TYPE_POS,
/// Value
BAP_LTV_VALUE_POS,
/// Minimal length of LTV structure
BAP_LTV_LENGTH_MIN = 1,
};
/// Type values for Metadata LTV structure
enum bap_ltv_type_metadata
{
/// Preferred Audio Contexts
BAP_LTV_TYPE_METADATA_PREF_CONTEXTS = 0,
/// Streaming Audio Contexts
BAP_LTV_TYPE_METADATA_STREAM_CONTEXTS,
};
/// (Minimal) value of length field for Metadata LTV structure
enum bap_ltv_length_metadata
{
/// Preferred Audio Contexts
BAP_LTV_LENGTH_METADATA_PREF_CONTEXTS = 3,
/// Streaming Audio Contexts
BAP_LTV_LENGTH_METADATA_STREAM_CONTEXTS = 3,
};
/// Type values for LC3 Specific Capabilities LTV structure
enum bap_ltv_type_lc3_capa
{
/// Supported Sampling Frequencies
BAP_LTV_TYPE_LC3_CAPA_SUPP_SAMP_FREQ = 0,
/// Supported Frame Durations
BAP_LTV_TYPE_LC3_CAPA_SUPP_FRAME_DUR,
/// Audio Channel Counts
BAP_LTV_TYPE_LC3_CAPA_CHNL_CNT,
/// Supported Octets per Codec Frame
BAP_LTV_TYPE_LC3_CAPA_SUPP_OCTETS_FRAME,
/// Maximum Supported LC3 Frames per SDU
BAP_LTV_TYPE_LC3_CAPA_SUPP_FRAMES_SDU,
};
/// (Minimal) value of length field for LC3 Specific Capabilities LTV structure
enum bap_ltv_length_lc3_capa
{
/// Supported Sampling Frequencies
BAP_LTV_LENGTH_LC3_CAPA_SUPP_SAMP_FREQ = 3,
/// Supported Frame Durations
BAP_LTV_LENGTH_LC3_CAPA_SUPP_FRAME_DUR = 2,
/// Audio Channel Counts
BAP_LTV_LENGTH_LC3_CAPA_CHNL_CNT = 2,
/// Supported Octets per Codec Frame
BAP_LTV_LENGTH_LC3_CAPA_SUPP_OCTETS_FRAME = 5,
/// Maximum Supported LC3 Frames per SDU
BAP_LTV_LENGTH_LC3_CAPA_SUPP_FRAMES_SDU = 2,
};
/// Supported Roles bit field meaning
enum bap_role_bf
{
/// Capabilities Server supported
BAP_ROLE_SUPP_CAPA_SRV_BIT = 0x0001,
BAP_ROLE_SUPP_CAPA_SRV_POS = 0,
/// Capabilities Client supported
BAP_ROLE_SUPP_CAPA_CLI_BIT = 0x0002,
BAP_ROLE_SUPP_CAPA_CLI_POS = 1,
/// Unicast Server supported
BAP_ROLE_SUPP_UC_SRV_BIT = 0x0004,
BAP_ROLE_SUPP_UC_SRV_POS = 2,
/// Unicast Client supported
BAP_ROLE_SUPP_UC_CLI_BIT = 0x0008,
BAP_ROLE_SUPP_UC_CLI_POS = 3,
/// Broadcast Source supported
BAP_ROLE_SUPP_BC_SRC_BIT = 0x0010,
BAP_ROLE_SUPP_BC_SRC_POS = 4,
/// Broadcast Sink supported
BAP_ROLE_SUPP_BC_SINK_BIT = 0x0020,
BAP_ROLE_SUPP_BC_SINK_POS = 5,
/// Broadcast Scan supported
BAP_ROLE_SUPP_BC_SCAN_BIT = 0x0040,
BAP_ROLE_SUPP_BC_SCAN_POS = 6,
/// Broadcast Scan Assistant supported
BAP_ROLE_SUPP_BC_ASSIST_BIT = 0x0080,
BAP_ROLE_SUPP_BC_ASSIST_POS = 7,
/// Broadcast Scan Delegator supported
BAP_ROLE_SUPP_BC_DELEG_BIT = 0x0100,
BAP_ROLE_SUPP_BC_DELEG_POS = 8,
};
/*
* TYPE DEFINITION
****************************************************************************************
*/
typedef struct bap_capa_srv_cfg
{
/// Number of PAC Groups for Sink direction
uint8_t nb_pacs_sink;
/// Number of PAC Groups for Source direction
uint8_t nb_pacs_src;
/// Configuration bit field (@see TODO [LT])
uint8_t cfg_bf;
/// Preferred MTU
/// Values from 0 to 63 are equivalent to 64
uint16_t pref_mtu;
/// Required start handle
/// If set to GATT_INVALID_HDL, the start handle will be automatically chosen
uint16_t shdl;
/// Supported Audio Locations bit field for Sink direction
/// Meaningful only if nb_pac_sink is different than 0
uint32_t location_bf_sink;
/// Supported Audio Locations bit field for Source direction
/// Meaningful only if nb_pac_src is different than 0
uint32_t location_bf_src;
/// Supported Audio Contexts bit field for Sink direction
/// Meaningful only if nb_pac_sink is different than 0
uint16_t supp_context_bf_sink;
/// Supported Audio Contexts bit field for Source direction
/// Meaningful only if nb_pac_src is different than 0
uint16_t supp_context_bf_src;
} bap_capa_srv_cfg_t;
typedef struct bap_capa_cli_cfg
{
/// Preferred MTU
/// Values from 0 to 63 are equivalent to 64
uint16_t pref_mtu;
} bap_capa_cli_cfg_t;
/// Configuration structure for BAP Unicast Server module
typedef struct bap_uc_srv_cfg
{
/// Number of instances of the ASE characteristic
/// Shall be in the range ]0, 15]
uint8_t nb_ase_chars;
/// Number of ASE configurations that can be maintained
/// Shall be at least equal to nb_ase_chars
/// Should be a multiple of nb_ase_chars
/// Shall not be larger than nb_ase_chars * BLE_CONNECTION_MAX
uint8_t nb_ases_cfg;
/// Preferred MTU
/// Values from 0 to 63 are equivalent to 64
uint16_t pref_mtu;
/// Required start handle
/// If set to GATT_INVALID_HDL, the start handle will automatically chosen
uint16_t shdl;
} bap_uc_srv_cfg_t;
/// Configuration structure for BAP Unicast Client module
typedef struct bap_uc_cli_cfg
{
/// Configuration bit field
uint8_t cfg_bf;
/// Number of ASE configurations that can be maintained
/// Shall be at least equal to nb_ase_chars
/// Should be a multiple of nb_ase_chars
/// Shall not be larger than nb_ase_chars * BLE_CONNECTION_MAX
uint8_t nb_ases_cfg;
/// Preferred MTU
/// Values from 0 to 63 are equivalent to 64
uint16_t pref_mtu;
} bap_uc_cli_cfg_t;
/// Broadcast Scanner configuration structure
typedef struct bap_bc_scan_cfg
{
/// Number of Broadcast Source information that may be stored in the cache
uint8_t cache_size;
/// Number of Periodic Synchronizations that may be established in parallel
uint8_t nb_sync;
} bap_bc_scan_cfg_t;
/// Broadcast Assistant configuration structure
typedef struct bap_bc_assist_cfg
{
/// Preferred MTU - Values from 0 to 63 are equivalent to 64
uint16_t pref_mtu;
} bap_bc_assist_cfg_t;
/// Broadcast Delegator configuration structure
typedef struct bap_bc_deleg_cfg
{
/// Number of supported Broadcast Sources Up to 15
uint8_t nb_srcs;
/// Required start handle - If set to GATT_INVALID_HDL, the start handle will be automatically chosen
uint16_t shdl;
/// Preferred MTU - Values from 0 to 63 are equivalent to 64
uint16_t pref_mtu;
} bap_bc_deleg_cfg_t;
/// Broadcast Group Parameters structure
typedef struct bap_bc_grp_param
{
/// SDU interval in microseconds
uint32_t sdu_intv_us;
/// Maximum size of an SDU
uint16_t max_sdu;
/// Maximum time (in milliseconds) between the first transmission of an SDU to the end of the last transmission
/// of the same SDU
uint16_t max_tlatency;
/// Sequential or Interleaved scheduling
uint8_t packing;
/// Unframed or framed mode
uint8_t framing;
/// Bitfield indicating PHYs that can be used by the controller for transmission of SDUs
uint8_t phy_bf;
/// Number of times every PDU should be transmitted
uint8_t rtn;
}bap_bc_grp_param_t;
/// Advertising Parameters structure
typedef struct bap_bc_adv_param
{
/// Minimum advertising interval in multiple of 0.625ms. Must be higher than 20ms.
uint32_t adv_intv_min_slot;
/// Maximum advertising interval in multiple of 0.625ms. Must be higher than 20ms.
uint32_t adv_intv_max_slot;
/// Channel Map
uint8_t chnl_map;
/// PHY for primary advertising. Only LE 1M and LE Codec PHYs are allowed
uint8_t phy_prim;
/// PHY for secondary advertising
uint8_t phy_second;
/// Advertising SID
uint8_t adv_sid;
}bap_bc_adv_param_t;
/// Periodic Advertising Parameters structure
typedef struct bap_bc_per_adv_param
{
/// Minimum periodic advertising interval in multiple of 1.25ms. Must be higher than 7.5ms
uint32_t adv_intv_min_frame;
/// Maximum periodic advertising interval in multiple of 1.25ms. Must be higher than 7.5ms
uint32_t adv_intv_max_frame;
} bap_bc_per_adv_param_t;
/// LC3 Capabilities structure (with pointer)
typedef struct bap_lc3_capa_ptr
{
/// Supported sampling frequencies bit field (@see TODO [LT])
uint16_t sampling_freq_bf;
/// Minimum number of octets supported per codec frame
uint16_t frame_octet_min;
/// Maximum number of octets supported per codec frame
uint16_t frame_octet_max;
/// Preferred Audio Context bit field
uint16_t context_bf;
/// Supported frame durations bit field (@see TODO [LT])
uint8_t frame_dur_bf;
/// Channel count supported (@see TODO [LT])
uint8_t chan_cnt;
/// Length of full Codec Capabilities value
uint8_t capa_len;
/// Length of full Metadata value
uint8_t metadata_len;
/// Maximum supported LC3 frames per SDU
/// Shall be either equal to 0 or >= to chan_cnt
/// Part of Codec Specific Capabilities only if different than 0
uint8_t max_lc3_frame_sdu;
/// Pointer to full Codec Capabilities value (in LTV format)
const uint8_t* p_capa;
/// Pointer to full Metadata value (in LTV format)
const uint8_t* p_metadata;
} bap_lc3_capa_ptr_t;
/// Codec Capabilities structure (with pointer)
typedef struct bap_vendor_codec_capa_ptr
{
/// Preferred Audio Context bit field
uint16_t context_bf;
/// Length of full Codec Capabilities value
uint8_t capa_len;
/// Length of full Metadata value
uint8_t metadata_len;
/// Pointer to full Codec Capabilities value (in LTV format)
const uint8_t* p_capa;
/// Pointer to full Metadata value (in LTV format)
const uint8_t* p_metadata;
} bap_vendor_codec_capa_ptr_t;
/// LC3 Capabilities structure
typedef struct bap_lc3_capa
{
/// Supported sampling frequencies bit field
uint16_t sampling_freq_bf;
/// Minimum number of octets supported per codec frame
uint16_t frame_octet_min;
/// Maximum number of octets supported per codec frame
uint16_t frame_octet_max;
/// Preferred Audio Context bit field
uint16_t context_bf;
/// Supported frame durations bit field
uint8_t frame_dur_bf;
/// Channel count supported
uint8_t chan_cnt;
/// Maximum supported LC3 frames per SDU
/// Shall be either equal to 0 or >= to chan_cnt
/// Part of Codec Specific Capabilities only if different than 0
uint8_t max_lc3_frame_sdu;
/// Length of additional Codec Capabilities value
uint8_t add_capa_len;
/// Length of additional Metadata value
uint8_t add_metadata_len;
/// Additional Codec Capabilities value (in LTV format) followed by additional Metadata value
/// (in LTV format)
uint8_t val[__ARRAY_EMPTY];
} bap_lc3_capa_t;
/// Codec Capabilities structure
typedef struct bap_vendor_codec_capa
{
/// Preferred Audio Context bit field
/// Part of Metadata only if different than 0
uint16_t context_bf;
/// Length of additional Codec Capabilities value
uint8_t add_capa_len;
/// Length of additional Metadata value
uint8_t add_metadata_len;
/// Additional Codec Capabilities value (in LTV format) followed by additional Metadata value (in LTV format)
uint8_t val[__ARRAY_EMPTY];
} bap_vendor_codec_capa_t;
/// LC3 Parameters structure
typedef struct bap_lc3_param
{
/// Audio Locations of audio channels being configured for the codec
uint32_t location_bf;
/// Number of octets for a codec frame
uint16_t frame_octet;
/// Sampling frequency
uint8_t sampling_freq;
/// Frame duration
uint8_t frame_dur;
/// Number of blocks of LC3 codec frames per SDU
uint8_t nb_lc3_frames;
} bap_lc3_param_t;
/// LC3 Configuration structure
typedef struct bap_lc3_cfg
{
/// LC3 parameters
bap_lc3_param_t params;
/// Length of Codec Configuration value
uint8_t cfg_len;
/// Codec Configuration value (in LTV format)
uint8_t cfg[__ARRAY_EMPTY];
} bap_lc3_cfg_t;
/// LC3 Configuration structure (Codec Parameters and Codec Configuration provided as pointer)
typedef struct bap_lc3_cfg_ptr
{
/// Length of Codec Configuration value
uint8_t cfg_len;
/// LC3 parameters
bap_lc3_param_t* p_params;
/// Pointer to Codec Configuration value (in LTV format)
uint8_t* p_cfg;
} bap_lc3_cfg_ptr_t;
/// Vendor Codec Configuration structure
typedef struct bap_vendor_codec_cfg
{
/// Length of Codec Configuration value
uint8_t cfg_len;
/// Codec Configuration value (in LTV format)
uint8_t cfg[__ARRAY_EMPTY];
} bap_vendor_codec_cfg_t;
/// Vendor Codec Configuration structure (Codec Configuration provided as pointer)
typedef struct bap_vendor_codec_cfg_ptr
{
/// Length of Codec Configuration value
uint8_t cfg_len;
/// Pointer to Codec Configuration value (in LTV format)
uint8_t* p_cfg;
} bap_vendor_codec_cfg_ptr_t;
/// Metadata for Codec Configuration structure
typedef struct bap_metadata_cfg
{
/// Streaming audio context bit field
uint16_t context_bf;
/// Length of Metadata value
uint8_t metadata_len;
/// Metadata value
uint8_t metadata[__ARRAY_EMPTY];
} bap_metadata_cfg_t;
/// Metadata for Codec Configuration structure (Metadata provided as pointer)
typedef struct bap_metadata_cfg_ptr
{
/// Streaming audio context bit field
uint16_t context_bf;
/// Length of Metadata value
uint8_t metadata_len;
/// Pointer to Metadata value
uint8_t* p_metadata;
} bap_metadata_cfg_ptr_t;
/// QoS Requirement structure
typedef struct bap_qos_req
{
/// Preferred SDU interval minimum in microseconds
/// From 255us (0xFF) to 16777215us (0xFFFFFF)
uint32_t sdu_intv_min_us;
/// Preferred SDU interval maximum in microseconds
/// From 255us (0xFF) to 16777215us (0xFFFFFF)
uint32_t sdu_intv_max_us;
/// Presentation delay minimum microseconds
uint32_t pres_delay_min_us;
/// Presentation delay maximum in microseconds
uint32_t pres_delay_max_us;
/// Preferred Transport latency maximum in milliseconds
/// From 5ms (0x5) to 4000ms (0xFA0)
uint16_t trans_latency_max_ms;
/// Preferred maximum SDU size
/// From 0 to 4095 bytes (0xFFF)
uint16_t max_sdu_size;
/// Preferred PDU framing arrangement
uint8_t framing;
/// Preferred PHY bit field
uint8_t phy_bf;
/// Preferred maximum number of retransmissions for each CIS Data PDU
/// From 0 to 15
uint8_t retx_nb;
} bap_qos_req_t;
/// QoS Configuration structure
typedef struct bap_qos_cfg
{
/// PDU framing arrangement
uint8_t framing;
/// PHY
uint8_t phy;
/// Maximum number of retransmissions for each CIS Data PDU
/// From 0 to 15
uint8_t retx_nb;
/// Maximum SDU size
/// From 0 to 4095 bytes (0xFFF)
uint16_t max_sdu_size;
/// Transport latency in milliseconds
/// From 5ms (0x5) to 4000ms (0xFA0)
uint16_t trans_latency_ms;
/// Presentation delay in microseconds
uint32_t pres_delay_us;
/// SDU interval in microseconds
/// From 255us (0xFF) to 16777215us (0xFFFFFF)
uint32_t sdu_intv_us;
} bap_qos_cfg_t;
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
typedef struct bap_capa_srv_cb bap_capa_srv_cb_t;
typedef struct bap_capa_cli_cb bap_capa_cli_cb_t;
typedef struct bap_uc_srv_cb bap_uc_srv_cb_t;
typedef struct bap_uc_cli_cb bap_uc_cli_cb_t;
typedef struct bap_bc_src_cb bap_bc_src_cb_t;
typedef struct bap_bc_sink_cb bap_bc_sink_cb_t;
typedef struct bap_bc_scan_cb bap_bc_scan_cb_t;
typedef struct bap_bc_assist_cb bap_bc_assist_cb_t;
typedef struct bap_bc_deleg_cb bap_bc_deleg_cb_t;
/// Basic Audio Profile callback set for each roles
typedef struct bap_cb
{
/// Capabilities Server callback functions
const bap_capa_srv_cb_t* p_capa_srv_cb;
/// Capabilities Client callback functions
const bap_capa_cli_cb_t* p_capa_cli_cb;
/// Unicast Server callback functions
const bap_uc_srv_cb_t* p_uc_srv_cb;
/// Unicast Client callbacks
const bap_uc_cli_cb_t* p_uc_cli_cb;
/// Broadcast Source callback functions
const bap_bc_src_cb_t* p_bc_src_cb;
/// Broadcast Sink callback functions
const bap_bc_sink_cb_t* p_bc_sink_cb;
/// Broadcast Scan callback functions
const bap_bc_scan_cb_t* p_bc_scan_cb;
/// Broadcast Scan Assistant callbacks
const bap_bc_assist_cb_t* p_bc_assist_cb;
/// Broadcast Scan Delegator callbacks
const bap_bc_deleg_cb_t* p_bc_deleg_cb;
} bap_cb_t;
/*
* API FUNCTION DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure Basic Audio profile
*
* @param[in] role_bf Supported role bit field (@see enum gaf_role_bf)
* @param[in] p_capa_srv_cfg Pointer to Capabilities Server configuration
* @param[in] p_capa_cli_cfg Pointer to Capabilities Client configuration
* @param[in] p_uc_srv_cfg Pointer to Unicast Server configuration
* @param[in] p_uc_cli_cfg Pointer to Unicast Client configuration
* @param[in] p_bc_scan_cfg Pointer to Broadcast Scan configuration
* @param[in] p_bc_deleg_cfg Pointer to Broadcast Delegator configuration
* @param[in] p_cb Pointer to callback structure
*
* @return status of function execution (@see gaf_err)
****************************************************************************************
*/
uint16_t bap_configure(uint32_t role_bf, bap_capa_srv_cfg_t* p_capa_srv_cfg, bap_capa_cli_cfg_t* p_capa_cli_cfg,
bap_uc_srv_cfg_t* p_uc_srv_cfg, bap_uc_cli_cfg_t* p_uc_cli_cfg,
bap_bc_scan_cfg_t* p_bc_scan_cfg, bap_bc_deleg_cfg_t* p_bc_deleg_cfg,
bap_bc_assist_cfg_t* p_bc_assist_cfg, const bap_cb_t* p_cb);
/// @}
#endif // BAP_H_
@@ -0,0 +1,87 @@
/**
****************************************************************************************
*
* @file bap_msg.h
*
* @brief Basic Audio Profile - Definition of Kernel Messages
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_MSG_H_
#define BAP_MSG_H_
/**
****************************************************************************************
* @addtogroup BAP Basic Audio Profile - Definition of Kernel Messages
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap.h" // BAP Definitions
#if (GAF_BAP)
#include "gaf_msg.h" // Generic Audio Framework API Message Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for BAP_CONFIGURE request message
typedef struct bap_configure_req
{
/// Request code (@see enum bap_msg_req_code)
/// - BAP_CONFIGURE
uint16_t req_code;
/// Supported role bit field (@see enum bap_role_bf)
uint32_t role_bf;
/// Capabilities Server configuration
bap_capa_srv_cfg_t capa_srv_cfg;
/// Capabilities Client configuration
bap_capa_cli_cfg_t capa_cli_cfg;
/// Unicast Server configuration
bap_uc_srv_cfg_t uc_srv_cfg;
/// Unicast Client configuration
bap_uc_cli_cfg_t uc_cli_cfg;
/// Broadcast Scan configuration
bap_bc_scan_cfg_t bc_scan_cfg;
/// Broadcast Delegator configuration
bap_bc_deleg_cfg_t bc_deleg_cfg;
/// Broadcast Assistant configuration
bap_bc_assist_cfg_t bc_assist_cfg;
} bap_configure_req_t;
/// Structure for BAP_GET_ROLES request message
typedef struct bap_get_roles_req
{
/// Request code (@see enum bap_msg_req_code)
/// - BAP_GET_ROLES
uint16_t req_code;
} bap_get_roles_req_t;
/// Structure for BAP_GET_ROLES response message
typedef struct bap_get_roles_rsp
{
/// Request code (@see enum bap_msg_req_code)
/// - BAP_GET_ROLES
uint16_t req_code;
/// Status
uint16_t status;
/// Role bit field (@see enum bap_role_bf)
uint32_t role_bf;
} bap_get_roles_rsp_t;
#endif //(GAF_BAP)
/// @}
#endif // BAP_MSG_H_
@@ -0,0 +1,451 @@
/**
****************************************************************************************
*
* @file bap_bc_assist.h
*
* @brief Basic Audio Profile - Broadcast Assistant - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_BC_ASSIST_H_
#define BAP_BC_ASSIST_H_
/**
****************************************************************************************
* @addtogroup BAP_BC_ASSIST Basic Audio Profile - Broadcast Assistant
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "bap.h" // Basic Audio Profile Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Command type values
enum bap_bc_assist_cmd_type
{
BAP_BC_ASSIST_CMD_TYPE_START_SCAN = 0,
BAP_BC_ASSIST_CMD_TYPE_STOP_SCAN,
BAP_BC_ASSIST_CMD_TYPE_DISCOVER,
BAP_BC_ASSIST_CMD_TYPE_GET_STATE,
BAP_BC_ASSIST_CMD_TYPE_GET_CFG,
BAP_BC_ASSIST_CMD_TYPE_SET_CFG,
BAP_BC_ASSIST_CMD_TYPE_UPDATE_SCAN,
BAP_BC_ASSIST_CMD_TYPE_SOURCE_ADD,
BAP_BC_ASSIST_CMD_TYPE_SOURCE_ADD_LOCAL,
BAP_BC_ASSIST_CMD_TYPE_SOURCE_REMOVE,
BAP_BC_ASSIST_CMD_TYPE_SOURCE_UPDATE,
BAP_BC_ASSIST_CMD_TYPE_MAX
};
/// List of GAF_CMD command codes for BAP Broadcast Assistant
enum bap_bc_assist_cmd_code
{
BAP_BC_ASSIST_START_SCAN = GAF_CODE(BAP, BC_ASSIST, BAP_BC_ASSIST_CMD_TYPE_START_SCAN),
BAP_BC_ASSIST_STOP_SCAN = GAF_CODE(BAP, BC_ASSIST, BAP_BC_ASSIST_CMD_TYPE_STOP_SCAN),
BAP_BC_ASSIST_DISCOVER = GAF_CODE(BAP, BC_ASSIST, BAP_BC_ASSIST_CMD_TYPE_DISCOVER),
BAP_BC_ASSIST_GET_STATE = GAF_CODE(BAP, BC_ASSIST, BAP_BC_ASSIST_CMD_TYPE_GET_STATE),
BAP_BC_ASSIST_GET_CFG = GAF_CODE(BAP, BC_ASSIST, BAP_BC_ASSIST_CMD_TYPE_GET_CFG),
BAP_BC_ASSIST_SET_CFG = GAF_CODE(BAP, BC_ASSIST, BAP_BC_ASSIST_CMD_TYPE_SET_CFG),
BAP_BC_ASSIST_UPDATE_SCAN = GAF_CODE(BAP, BC_ASSIST, BAP_BC_ASSIST_CMD_TYPE_UPDATE_SCAN),
BAP_BC_ASSIST_SOURCE_ADD = GAF_CODE(BAP, BC_ASSIST, BAP_BC_ASSIST_CMD_TYPE_SOURCE_ADD),
BAP_BC_ASSIST_SOURCE_ADD_LOCAL = GAF_CODE(BAP, BC_ASSIST, BAP_BC_ASSIST_CMD_TYPE_SOURCE_ADD_LOCAL),
BAP_BC_ASSIST_SOURCE_REMOVE = GAF_CODE(BAP, BC_ASSIST, BAP_BC_ASSIST_CMD_TYPE_SOURCE_REMOVE),
BAP_BC_ASSIST_SOURCE_UPDATE = GAF_CODE(BAP, BC_ASSIST, BAP_BC_ASSIST_CMD_TYPE_SOURCE_UPDATE),
};
/// List of GAF_REQ request codes for BAP Broadcast Assistant
enum bap_bc_assist_req_code
{
BAP_BC_ASSIST_RESTORE_BOND_DATA = GAF_CODE(BAP, BC_ASSIST, 2),
};
/// List of GAF_IND indication codes for BAP Broadcast Assistant
enum bap_bc_assist_ind_code
{
BAP_BC_ASSIST_SCAN_TIMEOUT = GAF_CODE(BAP, BC_ASSIST, 0),
BAP_BC_ASSIST_SOLICITATION = GAF_CODE(BAP, BC_ASSIST, 1),
BAP_BC_ASSIST_BOND_DATA = GAF_CODE(BAP, BC_ASSIST, 2),
BAP_BC_ASSIST_CFG = GAF_CODE(BAP, BC_ASSIST, 3),
BAP_BC_ASSIST_SOURCE_STATE = GAF_CODE(BAP, BC_ASSIST, 4),
BAP_BC_ASSIST_SVC_CHANGED = GAF_CODE(BAP, BC_ASSIST, 5),
};
/// List of GAF_REQ_IND request indication codes for BAP Broadcast Assistant
enum bap_bc_assist_req_ind_code
{
BAP_BC_ASSIST_BCAST_CODE = GAF_CODE(BAP, BC_ASSIST, 0),
};
/// List of Broadcast Audio Scan Service characteristics
enum bap_bc_char_type
{
/// Broadcast Audio Scan Control Point characteristic
BAP_BC_CHAR_TYPE_CP = 0,
/// Number of mono-instantiated characteristics
BAP_BC_CHAR_TYPE_MAX_MONO,
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Broadcast Receive State characteristic description structure
typedef struct bap_bc_assist_rx_state_char
{
/// Characteristic value handle
uint16_t val_hdl;
/// Client characteristic configuration descriptor handle
uint16_t desc_hdl;
/// Source ID
uint8_t src_id;
} bap_bc_assist_rx_state_char_t;
/// Broadcast Audio Scan Service content description structure
typedef struct bap_bc_assist_bass
{
/// Service description
prf_svc_t svc_info;
/// Characteristic value handle for Broadcast Audio Scan Control Point characteristic
uint16_t cp_val_hdl;
/// Number of discovered Broadcast Receive State characteristics
uint8_t nb_rx_state;
/// Pointer to information structures for Broadcast Receive State characteristic
bap_bc_assist_rx_state_char_t rx_state_char_info[__ARRAY_EMPTY];
} bap_bc_assist_bass_t;
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called each time a command has been completed
*
* @param[in] cmd_code Command code (@see enum asc_cmd_codes)
* @param[in] status Status
* @param[in] con_lid Connection local index
* @param[in] src_lid Source local index
****************************************************************************************
*/
typedef void (*bap_bc_assist_cb_cmp_evt)(uint16_t cmd_code, uint16_t status, uint8_t con_lid, uint8_t src_lid);
/**
****************************************************************************************
* @brief Callback function called when Broadcast Scan Audio Service has been discovered in a peer service device
* database
*
* @param[in] con_lid Connection local index
* @param[in] p_bass_info Pointer to Broadcast Audio Scan Service description structure
****************************************************************************************
*/
typedef void (*bap_bc_assist_cb_bond_data)(uint8_t con_lid, const bap_bc_assist_bass_t* p_bass_info);
/**
****************************************************************************************
* @brief Callback function called when a receive state for a Broadcast Source has been received
*
* @param[in] con_lid Connection local index
* @param[in] src_lid Source local index
* @param[in] src_id Source ID
* @param[in] src_adv_sid Source Advertiser SID
* @param[in] src_addr_type Source Address Type
* @param[in] p_src_addr Pointer to Source Address
* @param[in] pa_sync Synchronization state for PA
* @param[in] big_enc Encryption state for BIG
* @param[in] big_sync_bf Synchronization bit field for BIG
* @param[in] p_metadata Pointer to Metadata
****************************************************************************************
*/
typedef void (*bap_bc_assist_cb_source_state)(uint8_t con_lid, uint8_t src_lid, uint8_t src_id, uint8_t src_adv_sid,
uint8_t src_addr_type, const uint8_t* p_src_addr, uint8_t pa_sync,
uint8_t big_enc, uint32_t big_sync_bf, const gaf_ltv_t* p_metadata);
/**
****************************************************************************************
* @brief Callback function called when a client characteristic configuration value has been received from a peer
* server device
*
* @param[in] con_lid Connection local index
* @param[in] sec_lid Source local index
* @param[in] enabled Indicate if sending of event is enabled (!= 0) or not
****************************************************************************************
*/
typedef void (*bap_bc_assist_cb_cfg)(uint8_t con_lid, uint8_t src_lid, uint8_t enabled);
/**
****************************************************************************************
* @brief Callback function called when a Delegator requires Broadcast Code for a given Source
*
* @param[in] con_lid Connection local index
* @param[in] src_lid Source local index
****************************************************************************************
*/
typedef void (*bap_bc_assist_cb_bcast_code_req)(uint8_t con_lid, uint8_t src_lid);
/**
****************************************************************************************
* @brief Callback function called when a Solicitation Request has been received
*
* @param[in] addr_type Address type
* @param[in] p_addr Pointer to address
* @param[in] context_bf Available audio contexts bit field
* @param[in] length Length of advertising data
* @param[in] p_adv_data Pointer to advertising data
****************************************************************************************
*/
typedef void (*bap_bc_assist_cb_solicitation)(uint8_t addr_type, const uint8_t* p_addr, uint32_t context_bf,
uint16_t length, const uint8_t* p_adv_data);
/**
****************************************************************************************
* @brief Callback function called when scan allowing to find Solicitation Requests has been stopped due to a timeout
****************************************************************************************
*/
typedef void (*bap_bc_assist_cb_timeout)(void);
/**
****************************************************************************************
* @brief Callback function called when a service changed indication has been received from a Delegator device
*
* @param[in] con_lid Connection local index
****************************************************************************************
*/
typedef void (*bap_bc_assist_cb_svc_changed)(uint8_t con_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for volume management (client)
typedef struct bap_bc_assist_cb
{
/// Callback function called when a command has been completed
bap_bc_assist_cb_cmp_evt cb_cmp_evt;
/// Callback function called when a receive state for a Broadcast Source has been received
bap_bc_assist_cb_source_state cb_source_state;
#if (GAF_DBG)
/// Callback function called when a client characteristic configuration value has been received from a peer server
/// device
bap_bc_assist_cb_cfg cb_cfg;
#endif //(GAF_DBG)
/// Callback function called when a Delegator requires Broadcast Code for a given Source
bap_bc_assist_cb_bcast_code_req cb_bcast_code_req;
/// Callback function called when Broadcast Scan Audio Service has been discovered in a peer service device
/// database
bap_bc_assist_cb_bond_data cb_bond_data;
/// Callback function called when a Solicitation Request has been received
bap_bc_assist_cb_solicitation cb_solicitation;
/// Callback function called when scan allowing to find Solicitation Requests has been stopped due to a timeout
bap_bc_assist_cb_timeout cb_timeout;
/// Callback function called when a service changed indication has been received from a Delegator device
bap_bc_assist_cb_svc_changed cb_svc_changed;
} bap_bc_assist_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
#if (GAF_BAP_BC_ASSIST)
/**
****************************************************************************************
* @brief Enable use of Broadcast Scan Audio Service as Client and start discovery of the service in peer server
* device database
*
* @param[in] con_lid Connection local index
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_bc_assist_discover(uint8_t con_lid);
/**
****************************************************************************************
* @brief Enable use of Broadcast Scan Audio Service as Client and set bonding information after reconnection with
* peer server device
*
* @param[in] con_lid Connection local index
* @param[in] p_bass_info Pointer to Broadcast Audio Scan Service description structure
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_bc_assist_restore_bond_data(uint8_t con_lid, const bap_bc_assist_bass_t* p_bass_info);
/**
****************************************************************************************
* @brief Start scanning for Solicitation Requests sent by Broadcast Delegator devices
*
* @param[in] timeout_s Timeout in seconds
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_bc_assist_start_scan(uint16_t timeout_s);
/**
****************************************************************************************
* @brief Stop scanning for Solicitation Requests
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_bc_assist_stop_scan(void);
#if (GAF_DBG)
/**
****************************************************************************************
* @brief Get value for a Broadcast Receive Source instance of a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] src_lid Source local index
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_bc_assist_get_state(uint8_t con_lid, uint8_t src_lid);
/**
****************************************************************************************
* @brief Get Client Characteristic Configuration Descriptor value for for a Broadcast Receive Source instance of a
* peer server device
*
* @param[in] con_lid Connection local index
* @param[in] src_lid Source local index
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_bc_assist_get_cfg(uint8_t con_lid, uint8_t src_lid);
/**
****************************************************************************************
* @brief Set Client Characteristic Configuration Descriptor value for for a Broadcast Receive Source instance of a
* peer server device
*
* @param[in] con_lid Connection local index
* @param[in] src_lid Source local index
* @param[in] enable Indicate if sending of events must be enabled (!= 0) or disabled
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_bc_assist_set_cfg(uint8_t con_lid, uint8_t src_lid, uint8_t enable);
#endif //(GAF_DBG
/**
****************************************************************************************
* @brief Inform server that scanning on its behalf has been either started or stopped
*
* @param[in] con_lid Connection local index
* @param[in] started Indicate if scan has been started (!= 0) or stopped
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_bc_assist_update_scan(uint8_t con_lid, uint8_t started);
/**
****************************************************************************************
* @brief Inform the server about discovery of a Broadcast Source
*
* @param[in] con_lid Connection local index
* @param[in] src_adv_sid Source Advertiser SID
* @param[in] src_addr_type Source Address Type
* @param[in] p_src_addr Pointer to Source Address
* @param[in] pa_sync Required PA synchronization state
* @param[in] big_sync_bf Required BIG synchronization bit field
* @param[in] p_metadata Pointer to Metadata
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_bc_assist_source_add(uint8_t con_lid, uint8_t src_adv_sid, uint8_t src_addr_type,
const uint8_t* p_src_addr, uint8_t pa_sync, uint32_t big_sync_bf,
const gaf_ltv_t* p_metadata);
#if (GAF_BAP_BC_SRC)
/**
****************************************************************************************
* @brief Inform the server about a local Broadcast Source
*
* @param[in] con_lid Connection local index
* @param[in] grp_lid Group local index
* @param[in] pa_sync Required PA synchronization state
* @param[in] big_sync_bf Required BIG synchronization bit field
* @param[in] p_metadata Pointer to Metadata
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_bc_assist_source_add_local(uint8_t con_lid, uint8_t grp_lid, uint8_t pa_sync, uint32_t big_sync_bf,
const gaf_ltv_t* p_metadata);
#endif //(GAF_BAP_BC_SRC)
/**
****************************************************************************************
* @brief Request the server to remove information about a Broadcast Source
*
* @param[in] con_lid Connection local index
* @param[in] src_lid Source local index
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_bc_assist_source_remove(uint8_t con_lid, uint8_t src_lid);
/**
****************************************************************************************
* @brief Request the server to synchronize to, or to stop synchronization to, a PA and/or a BIS
*
* @param[in] con_lid Connection local index
* @param[in] src_lid Source local index
* @param[in] pa_sync Required PA synchronization state
* @param[in] big_sync_bf Required BIG synchronization bit field
* @param[in] p_metadata Pointer to Metadata
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_bc_assist_source_update(uint8_t con_lid, uint8_t src_lid, uint8_t pa_sync, uint32_t big_sync_bf,
const gaf_ltv_t* p_metadata);
/**
****************************************************************************************
* @brief Confirmation for BAP_BC_ASSIST_BCAST_CODE request indication
*
* @param[in] status Status
* @param[in] con_lid Connection local index
* @param[in] src_lid Source local index
* @param[in] p_bcast_code Pointer to Broadcast Code value
*
* @return An error status
****************************************************************************************
*/
void bap_bc_assist_bcast_code_cfm(uint16_t status, uint8_t con_lid, uint8_t src_lid, const uint8_t* p_bcast_code);
#endif //(GAF_BAP_BC_ASSIST)
/// @}
#endif // BAP_BC_ASSIST_H_
@@ -0,0 +1,329 @@
/**
****************************************************************************************
*
* @file bap_bc_assist_msg.h
*
* @brief Basic Audio Profile - Definition of Kernel Messages (Broadcast Assistant)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_BC_ASSIST_MSG_H_
#define BAP_BC_ASSIST_MSG_H_
/**
****************************************************************************************
* @addtogroup BAP_BC_ASSIST_MSG Basic Audio Profile - Definition of Kernel Messages (Broadcast Assistant)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap_msg.h" // Basic Audio Profile API Messages Definitions
#include "bap_bc_assist.h" // Basic Audio Profile - Broadcast Assistant Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for BAP_BC_ASSIST_START_SCAN command message
typedef struct bap_bc_assist_start_scan_cmd
{
/// Request code (@see enum bap_bc_assist_cmd_code)
/// - BAP_BC_ASSIST_START_SCAN
uint16_t cmd_code;
/// Timeout in seconds
uint16_t timeout_s;
} bap_bc_assist_start_scan_cmd_t;
/// Structure for BAP_BC_ASSIST_STOP_SCAN command message
typedef struct bap_bc_assist_stop_scan_cmd
{
/// Request code (@see enum bap_bc_assist_cmd_code)
/// - BAP_BC_ASSIST_STOP_SCAN
uint16_t cmd_code;
} bap_bc_assist_stop_scan_cmd_t;
/// Structure for BAP_BC_ASSIST_DISCOVER command message
typedef struct bap_bc_assist_discover_cmd
{
/// Command code (@see enum bap_bc_assist_cmd_code)
/// - BAP_BC_ASSIST_DISCOVER
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
} bap_bc_assist_discover_cmd_t;
/// Structure for BAP_BC_ASSIST_GET_STATE command message
typedef struct bap_bc_assist_get_state_cmd
{
/// Command code (@see enum bap_bc_assist_cmd_code)
/// - BAP_BC_ASSIST_GET
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Source local index
uint8_t src_lid;
} bap_bc_assist_get_state_cmd_t;
/// Structure for BAP_BC_ASSIST_GET_CFG command message
typedef struct bap_bc_assist_get_cfg_cmd
{
/// Command code (@see enum bap_bc_assist_cmd_code)
/// - BAP_BC_ASSIST_GET_CFG
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Source local index
uint8_t src_lid;
} bap_bc_assist_get_cfg_cmd_t;
/// Structure for BAP_BC_ASSIST_SET_CFG command message
typedef struct bap_bc_assist_set_cfg_cmd
{
/// Command code (@see enum bap_bc_assist_cmd_code)
/// - BAP_BC_ASSIST_SET_CFG
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Source local index
uint8_t src_lid;
/// Enable
uint8_t enable;
} bap_bc_assist_set_cfg_cmd_t;
/// Structure for BAP_BC_ASSIST_UPDATE_SCAN command message
typedef struct bap_bc_assist_update_scan_cmd
{
/// Command code (@see enum bap_bc_assist_cmd_code)
/// - BAP_BC_ASSIST_UPDATE_SCAN
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;;
/// Started
uint8_t started;
} bap_bc_assist_update_scan_cmd_t;
/// Structure for BAP_BC_ASSIST_SOURCE_UPDATE command message
typedef struct bap_bc_assist_source_update_cmd
{
/// Command code (@see enum bap_bc_assist_cmd_code)
/// - BAP_BC_ASSIST_SOURCE_UPDATE
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;;
/// Source local index
uint8_t src_lid;
/// Required PA synchronization state
uint8_t pa_sync;
/// Required BIG synchronization bit field
uint32_t big_sync_bf;
/// Metadata
gaf_ltv_t metadata;
} bap_bc_assist_source_update_cmd_t;
/// Structure for BAP_BC_ASSIST_SOURCE_ADD command message
typedef struct bap_bc_assist_source_add_cmd
{
/// Command code (@see enum bap_bc_assist_cmd_code)
/// - BAP_BC_ASSIST_SOURCE_ADD
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;;
/// Source Advertiser SID
uint8_t src_adv_sid;
/// Source Address Type
uint8_t src_addr_type;
/// Source Address
uint8_t src_addr[GAP_BD_ADDR_LEN];
/// Required PA synchronization state
uint8_t pa_sync;
/// Required BIG synchronization bit field
uint32_t big_sync_bf;
/// Metadata
gaf_ltv_t metadata;
} bap_bc_assist_source_add_cmd_t;
/// Structure for BAP_BC_ASSIST_SOURCE_ADD_LOCAL command message
typedef struct bap_bc_assist_source_add_local_cmd
{
/// Command code (@see enum bap_bc_assist_cmd_code)
/// - BAP_BC_ASSIST_SOURCE_ADD_LOCAL
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;;
/// Group local index
uint8_t grp_lid;
/// Required PA synchronization state
uint8_t pa_sync;
/// Required BIG synchronization bit field
uint32_t big_sync_bf;
/// Metadata
gaf_ltv_t metadata;
} bap_bc_assist_source_add_local_cmd_t;
/// Structure for BAP_BC_ASSIST_SOURCE_REMOVE command message
typedef struct bap_bc_assist_source_remove_cmd
{
/// Command code (@see enum bap_bc_assist_cmd_code)
/// - BAP_BC_ASSIST_SOURCE_REMOVE
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;;
/// Source local index
uint8_t src_lid;
} bap_bc_assist_source_remove_cmd_t;
/// Structure for command complete event message
typedef struct bap_bc_assist_cmp_evt
{
/// Command code (@see enum bap_bc_assist_cmd_code)
uint16_t cmd_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
/// Source local index
uint8_t src_lid;
} bap_bc_assist_cmp_evt_t;
/// Structure for BAP_BC_ASSIST_RESTORE_BOND_DATA request message
typedef struct bap_bc_assist_restore_bond_data_req
{
/// Request code (@see enum bap_bc_assist_req_code)
/// - BAP_BC_ASSIST_RESTORE_BOND_DATA
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Service description
bap_bc_assist_bass_t bass_info;
} bap_bc_assist_restore_bond_data_req_t;
/// Structure for BAP_BC_ASSIST_BOND_DATA indication message
typedef struct bap_bc_assist_bond_data_ind
{
/// Indication code (@see enum bap_bc_assist_ind_code)
/// - BAP_BC_ASSIST_BOND_DATA
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Service description
bap_bc_assist_bass_t bass_info;
} bap_bc_assist_bond_data_ind_t;
/// Structure for BAP_BC_ASSIST_SOURCE_STATE indication message
typedef struct bap_bc_assist_source_state_ind
{
/// Indication code (@see enum bap_bc_assist_ind_code)
/// - BAP_BC_ASSIST_SOURCE_STATE
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Source local index
uint8_t src_lid;
/// Source index
uint8_t src_id;
/// Source Advertiser SID
uint8_t src_adv_sid;
/// Source Address Type
uint8_t src_addr_type;
/// Source Address
uint8_t src_addr[GAP_BD_ADDR_LEN];
/// Synchronization state for PA
uint8_t pa_sync;
/// Encryption state for BIG
uint8_t big_enc;
/// Synchronization bit field for BIG
uint32_t big_sync_bf;
/// Metadata
gaf_ltv_t metadata;
} bap_bc_assist_source_state_ind_t;
/// Structure for BAP_BC_ASSIST_CFG indication message
typedef struct bap_bc_assist_cfg_ind
{
/// Indication code (@see enum bap_bc_assist_ind_code)
/// - BAP_BC_ASSIST_CFG
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Source local index
uint8_t src_lid;
/// Indicate if sending of events is enabled (!= 0) for the indicated characteristic
uint8_t enabled;
} bap_bc_assist_cfg_ind_t;
/// Structure for BAP_BC_ASSIST_SCAN_TIMEOUT indication message
typedef struct bap_bc_assist_scan_timeout_ind
{
/// Indication code (@see enum bap_bc_assist_ind_code)
/// - BAP_BC_ASSIST_SCAN_TIMEOUT
uint16_t ind_code;
} bap_bc_assist_scan_timeout_ind_t;
/// Structure for BAP_BC_ASSIST_SOLICITATION indication message
typedef struct bap_bc_assist_solicitation_ind
{
/// Indication code (@see enum bap_bc_assist_ind_code)
/// - BAP_BC_ASSIST_SOLICITATION
uint16_t ind_code;
/// Address type
uint8_t addr_type;
/// Address
uint8_t addr[GAP_BD_ADDR_LEN];
/// Available Audio Contexts bit field
uint8_t context_bf;
/// Length of advertising data
uint16_t length;
/// Advertising data
uint8_t adv_data[__ARRAY_EMPTY];
} bap_bc_assist_solicitation_ind_t;
/// Structure for BAP_BC_ASSIST_SVC_CHANGED indication message
typedef struct bap_bc_assist_svc_changed_ind
{
/// Indication code (@see enum bap_bc_assist_ind_code)
/// - BAP_BC_ASSIST_SVC_CHANGED
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
} bap_bc_assist_svc_changed_ind_t;
/// Structure for BAP_BC_ASSIST_BCAST_CODE request indication message
typedef struct bap_bc_assist_bcast_code_req_ind
{
/// Command code (@see enum bap_bc_assist_req_ind_code)
/// - BAP_BC_ASSIST_BCAST_CODE
uint16_t req_ind_code;
/// Connection local index
uint8_t con_lid;;
/// Source local index
uint8_t src_lid;
} bap_bc_assist_bcast_code_req_ind_t;
/// Structure for BAP_BC_ASSIST_BCAST_CODE confirmation message
typedef struct bap_bc_assist_bcast_code_cfm
{
/// Command code (@see enum bap_bc_assist_req_ind_code)
/// - BAP_BC_ASSIST_BCAST_CODE
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
/// Source local index
uint8_t src_lid;
/// Broadcast code
uint8_t bcast_code[GAP_KEY_LEN];
} bap_bc_assist_bcast_code_cfm_t;
/// @}
#endif // BAP_BC_ASSIST_MSG_H_
@@ -0,0 +1,387 @@
/**
****************************************************************************************
*
* @file bap_bc_deleg.h
*
* @brief Basic Audio Profile - Broadcast Delegator - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_BC_DELEG_H_
#define BAP_BC_DELEG_H_
/**
****************************************************************************************
* @addtogroup BAP_BC_DELEG Basic Audio Profile - Broadcast Delegator
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "bap.h" // BAP Defines
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for BAP Broadcast Delegator
enum bap_bc_deleg_cmd_code
{
/// Start sending of Solicitation Requests so that a Broadcast Assistant may start scanning for
/// Broadcast Sources on delegator behalf.
BAP_BC_DELEG_START_SOLICITE = GAF_CODE(BAP, BC_DELEG, 0),
/// Stop sending of solicitation requests.
BAP_BC_DELEG_STOP_SOLICITE = GAF_CODE(BAP, BC_DELEG, 1),
/// Ask for Periodic advertising sync establishment
BAP_BC_DELEG_PA_SYNCHRONIZE = GAF_CODE(BAP, BC_DELEG, 2),
/// Ask for Broadcast synchronization establishment
BAP_BC_DELEG_BIG_SYNCHRONIZE = GAF_CODE(BAP, BC_DELEG, 4),
};
/// List of GAF_REQ request codes for BAP Broadcast Delegator
enum bap_bc_deleg_req_code
{
/// Set bonding information related to Broadcast Audio Scan Service after connection with a peer device
BAP_BC_DELEG_RESTORE_BOND_DATA = GAF_CODE(BAP, BC_DELEG, 0),
/// Add a broadcast source from upper layer
BAP_BC_DELEG_SOURCE_ADD = GAF_CODE(BAP, BC_DELEG, 1),
/// Update metadata of broadcast source from upper layer
BAP_BC_DELEG_SOURCE_UPDATE = GAF_CODE(BAP, BC_DELEG, 2),
/// Remove broadcast source from upper layer
BAP_BC_DELEG_SOURCE_REMOVE = GAF_CODE(BAP, BC_DELEG, 3),
};
/// List of GAF_IND indication codes for BAP Broadcast Delegator
enum bap_bc_deleg_ind_code
{
/// Inform upper layer that sending of solicitation requests has been stopped.
BAP_BC_DELEG_SOLICITE_STOPPED = GAF_CODE(BAP, BC_DELEG, 0),
/// Inform upper layer about an updated client configuration for Broadcast Audio Scan Service.
BAP_BC_DELEG_BOND_DATA = GAF_CODE(BAP, BC_DELEG, 1),
/// Inform upper layer about broadcast assistant scanning state update
BAP_BC_DELEG_BOND_REMOTE_SCAN = GAF_CODE(BAP, BC_DELEG, 2),
};
/// List of GAF_REQ_IND request indication codes for BAP Broadcast Delegator
enum bap_bc_deleg_req_ind_codes
{
/// Inform upper layer that a Broadcast Scan Assistant device asking to add new Broadcast Source.
BAP_BC_DELEG_SOURCE_ADD_RI = GAF_CODE(BAP, BC_DELEG, 0),
/// Inform upper layer that a Broadcast Scan Assistant device asking to update metadata of a Broadcast Source.
BAP_BC_DELEG_SOURCE_UPDATE_RI = GAF_CODE(BAP, BC_DELEG, 1),
/// Inform upper layer that a Broadcast Scan Assistant device asking to remove a Broadcast Source.
BAP_BC_DELEG_SOURCE_REMOVE_RI = GAF_CODE(BAP, BC_DELEG, 2),
};
/// Solicitation stop reason
enum bap_bc_deleg_reason
{
/// Connection established with a broadcast assistant
BAP_BC_DELEG_ESTABLISHED = 0x00,
/// Broadcast assistant solicitation stops due to timeout
BAP_BC_DELEG_UPPER_TERMINATE = 0x01,
/// Broadcast assistant solicitation request timeout.
BAP_BC_DELEG_TIMEOUT = 0x02,
};
/// Broadcast assistant device scan state
enum bap_bc_deleg_scan_state
{
/// Broadcast assistant device has started to scan on behalf of device
BAP_BC_DELEG_SCAN_STARTED = 0x00,
/// Broadcast assistant device has stopped to scan on behalf of device
BAP_BC_DELEG_SCAN_STOPPED = 0x01,
};
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called when a command execution completes
*
* @param[in] cmd_code Command code (@see enum bap_bc_deleg_cmd_code)
* @param[in] status Status of command execution (@see enum gaf_err)
* @param[in] src_lid Source local index
* (valid only for BAP_BC_DELEG_PA_SYNCHRONIZE and BAP_BC_DELEG_BIG_SYNCHRONIZE)
****************************************************************************************
*/
typedef void (*bap_bc_deleg_cb_cmp_evt)(uint16_t cmd_code, uint16_t status, uint8_t src_lid);
/**
****************************************************************************************
* @brief Callback function called when broadcast assitant solicitation requests has been stopped.
*
* @param[in] reason Reason why sending of solicitation request has been stopped (@see enum bap_bc_deleg_reason)
****************************************************************************************
*/
typedef void (*bap_bc_deleg_cb_solicite_stopped)(uint16_t reason);
/**
****************************************************************************************
* @brief Callback function called when client configuration for Broadcast Audio Scan Service has been updated
*
* @param[in] con_lid Connection local index
* @param[in] cfg_bf Client configuration bit field
****************************************************************************************
*/
typedef void (*bap_bc_deleg_cb_bond_data)(uint8_t con_lid, uint16_t cli_cfg_bf);
/**
****************************************************************************************
* @brief Callback function called when Broadcast Assistant device updates its scanning status
*
* @param[in] con_lid Connection local index
* @param[in] state Broadcast Assistant device scan state (@see enum bap_bc_deleg_scan_state)
****************************************************************************************
*/
typedef void (*bap_bc_deleg_cb_remote_scan)(uint8_t con_lid, uint8_t state);
/**
****************************************************************************************
* @brief Callback function called when a broadcast source is asking to be added by a broadcast assistant
*
* @param[in] src_lid Source local index
* @param[in] con_lid Connection local index
* @param[in] p_addr Pointer to periodic advertising address
* @param[in] p_metadata Pointer to metadata in LTV format
****************************************************************************************
*/
typedef void (*bap_bc_deleg_cb_source_add_req)(uint8_t src_lid, uint8_t con_lid, const gap_per_adv_bdaddr_t* p_addr,
const gaf_ltv_t* p_metadata);
/**
****************************************************************************************
* @brief Callback function called when a broadcast assistant asking for broadcast source metadata update
*
* @param[in] src_lid Source local index
* @param[in] con_lid Connection local index
* @param[in] p_metadata Pointer to metadata in LTV format
****************************************************************************************
*/
typedef void (*bap_bc_deleg_cb_source_update_req)(uint8_t src_lid, uint8_t con_lid, const gaf_ltv_t* p_metadata);
/**
****************************************************************************************
* @brief Callback function called when a broadcast assistant asking for broadcast source removal
*
* @param[in] src_lid Source local index
* @param[in] con_lid Connection local index
****************************************************************************************
*/
typedef void (*bap_bc_deleg_cb_source_remove_req)(uint8_t src_lid, uint8_t con_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Broadcast Audio Scan Service Server
typedef struct bap_bc_deleg_cb
{
/// Callback function called when a command execution completes
bap_bc_deleg_cb_cmp_evt cb_cmp_evt;
/// Callback function called when broadcast assitant solicitation requests has been stopped.
bap_bc_deleg_cb_solicite_stopped cb_solicite_stopped;
/// Callback function called when client configuration for Broadcast Audio Scan Service has been updated
bap_bc_deleg_cb_bond_data cb_bond_data;
/// Callback function called when Broadcast Assistant device updates its scanning status
bap_bc_deleg_cb_remote_scan cb_remote_scan;
/// Callback function called when a broadcast source is asking to be added by a broadcast assistant
bap_bc_deleg_cb_source_add_req cb_source_add_req;
/// Callback function called when a broadcast assistant asking for broadcast source metadata update
bap_bc_deleg_cb_source_update_req cb_source_update_req;
/// Callback function called when a broadcast assistant asking for broadcast source removal
bap_bc_deleg_cb_source_remove_req cb_source_remove_req;
} bap_bc_deleg_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
#if (GAF_BAP_BC_DELEG)
/**
****************************************************************************************
* @brief Set bonding information related to Broadcast Audio Scan Service after connection with a peer device
*
* @param[in] con_lid Connection local index
* @param[in] cfg_bf Configuration bit field (1 bit per broadcast source)
* @param[in] evt_bf Event bit field (1 bit per broadcast source) to notify
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_deleg_restore_bond_data(uint8_t con_lid, uint8_t cfg_bf, uint8_t evt_bf);
/**
****************************************************************************************
* @brief Add a Broadcast Source
*
* @param[in] p_addr Pointer to periodic advertising address
* @param[in] p_metadata Pointer to metadata in LTV format
* @param[out] p_src_lid Pointer at which allocated Source local index will be returned
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_deleg_source_add(const gap_per_adv_bdaddr_t* p_addr, const gaf_ltv_t* p_metadata, uint8_t* p_src_lid);
/**
****************************************************************************************
* @brief Update Broadcast Source metadata
*
* @param[in] src_lid Source local index
* @param[in] p_metadata Pointer to metadata in LTV format
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_deleg_source_update(uint8_t src_lid, const gaf_ltv_t* p_metadata);
/**
****************************************************************************************
* @brief Remove a Broadcast Source
*
* @param[in] src_lid Source local index
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_deleg_source_remove(uint8_t src_lid);
/**
****************************************************************************************
* @brief Start sending of Solicitation Requests so that a Broadcast Assistant may start scanning for
* Broadcast Sources on delegator behalf.
*
* When a connection is established or requests timeout, @see cb_solicite_stopped is called
*
* @param[in] timeout_s Timeout duration in seconds
* 0 means that sending of Solicitation Requests will last until stopped by the upper layer
* @param[in] context_bf Available audio contexts bit field
* @param[in] p_adv_param Pointer to Advertising parameters
* @param[in] p_adv_data Pointer to additional advertising data
*
* @return Function execution status code. (@see enum gaf_err)
if function returns GAF_ERR_NO_ERROR, wait for @see cb_cmp_evt execution
****************************************************************************************
*/
uint16_t bap_bc_deleg_start_solicite(uint16_t timeout_s, uint32_t context_bf, const bap_bc_adv_param_t* p_adv_param,
const gaf_ltv_t* p_adv_data);
/**
****************************************************************************************
* @brief Stop sending of Solicitation Requests
*
* When solicitations stops, @see cb_solicite_stopped is called
*
*
* @return Function execution status code. (@see enum gaf_err)
if function returns GAF_ERR_NO_ERROR, wait for @see cb_cmp_evt execution
****************************************************************************************
*/
uint16_t bap_bc_deleg_stop_solicite(void);
/**
****************************************************************************************
* @brief Ask for a periodic advertising sync establishment
*
* Establishment status of periodic advertising sync is provided by bap_bc_scan module.
*
* @param[in] src_lid Source local index
* @param[in] skip Number of periodic advertising that can be skipped after a successful receive.
* Maximum authorized value is 499
* @param[in] report_filter_bf Bit field of filtered report types - The reception of BIGInfo is forced to enable
* (@see enum bap_bc_scan_report_filter_bf)
* @param[in] sync_to Synchronization timeout for the periodic advertising
* (in unit of 10ms between 100ms and 163.84s)
* @param[in] timeout_s Sync establishment timeout in seconds
*
* @return Function execution status code. (@see enum gaf_err)
if function returns GAF_ERR_NO_ERROR, wait for @see cb_cmp_evt execution
****************************************************************************************
*/
uint16_t bap_bc_deleg_pa_synchronize(uint8_t src_lid, uint16_t skip, uint8_t report_filter_bf, uint16_t sync_to,
uint16_t timeout_s);
/**
****************************************************************************************
* @brief Ask for broadcast sink establishment
*
* Establishment status of broadcast sink is provided by bap_bc_sink module.
* @note If BIG is encrypted and broadcast code not provided (unknown at application level),
* it must have been provided by a broadcast assistant
*
* @param[in] src_lid Source local index
* @param[in] stream_pos_bf Stream position bit field indicating streams to synchronize with.
* @param[in] p_bcast_code Pointer to broadcast code, NULL if not encrypted
* @param[in] mse Maximum number of subevents the controller should use to received data
* payloads in each interval
* @param[in] timeout Timeout duration (10ms unit) before considering synchronization lost
* (Range 100 ms to 163.84 s).
*
* @return Function execution status code. (@see enum gaf_err)
if function returns GAF_ERR_NO_ERROR, wait for @see cb_cmp_evt execution
****************************************************************************************
*/
uint16_t bap_bc_deleg_big_synchronize(uint8_t src_lid, uint32_t stream_pos_bf, const gaf_bcast_code_t* p_bcast_code,
uint8_t mse, uint16_t timeout);
/**
****************************************************************************************
* @brief Confirm addition of a new Broadcast Source
*
* @param[in] src_lid Source local index
* @param[in] con_lid Connection local index
* @param[in] accept True to accept new broadcast source, False to reject
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_deleg_source_add_cfm(uint8_t src_lid, uint8_t con_lid, bool accept);
/**
****************************************************************************************
* @brief Confirm update of Broadcast Source metadata
*
* @param[in] src_lid Source local index
* @param[in] con_lid Connection local index
* @param[in] accept True to accept metadata update, False to reject
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_deleg_source_update_cfm(uint8_t src_lid, uint8_t con_lid, bool accept);
/**
****************************************************************************************
* @brief Confirm removal of a Broadcast Source
*
* @param[in] src_lid Source local index
* @param[in] con_lid Connection local index
* @param[in] accept True to accept broadcast source removal, False to reject
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_deleg_source_remove_cfm(uint8_t src_lid, uint8_t con_lid, bool accept);
#endif //(GAF_BAP_BC_DELEG)
/// @}
#endif // BAP_BC_DELEG_H_
@@ -0,0 +1,293 @@
/**
****************************************************************************************
*
* @file bap_bc_deleg_msg.h
*
* @brief Basic Audio Profile - Definition of Kernel Messages (Broadcast Delegator)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_BC_DELEG_MSG_H_
#define BAP_BC_DELEG_MSG_H_
/**
****************************************************************************************
* @addtogroup BAP_BC_DELEG_MSG Basic Audio Profile - Definition of Kernel Messages (Broadcast Delegator)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap_msg.h" // Basic Audio Profile API Messages Definitions
#include "bap_bc_deleg.h" // Basic Audio Profile - Broadcast Delegator Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for BAP_BC_DELEG_START_SOLICITE command message
typedef struct bap_bc_deleg_start_solicite_cmd
{
/// Command code (@see enum bap_bc_deleg_cmd_code)
/// - BAP_BC_DELEG_START_SOLICITE
uint16_t cmd_code;
/// Timeout duration in seconds
/// 0 means that sending of Solicitation Requests will last until stopped by the upper layer
uint16_t timeout_s;
/// Available audio contexts bit field
uint32_t context_bf;
/// Advertising parameters
bap_bc_adv_param_t adv_param;
/// Additional advertising data (in LTV format)
gaf_ltv_t adv_data;
} bap_bc_deleg_start_solicite_cmd_t;
/// Structure for BAP_BC_DELEG_STOP_SOLICITE command message
typedef struct bap_bc_deleg_stop_solicite_cmd
{
/// Command code (@see enum bap_bc_deleg_cmd_code)
/// - BAP_BC_DELEG_STOP_SOLICITE
uint16_t cmd_code;
} bap_bc_deleg_stop_solicite_cmd_t;
/// Structure for BAP_BC_DELEG_PA_SYNCHRONIZE command message
typedef struct bap_bc_deleg_pa_synchronize_cmd
{
/// Command code (@see enum bap_bc_deleg_cmd_code)
/// - BAP_BC_DELEG_PA_SYNCHRONIZE
uint16_t cmd_code;
/// Source local index
uint8_t src_lid;
/// Bit field of filtered report types - The reception of BIGInfo is forced to enable
/// (@see enum bap_bc_scan_report_filter_bf)
uint8_t report_filter_bf;
/// Number of periodic advertising that can be skipped after a successful receive.
/// Maximum authorized value is 499
uint16_t skip;
/// Synchronization timeout for the periodic advertising
/// (in unit of 10ms between 100ms and 163.84s)
uint16_t sync_to;
/// Sync establishment timeout in seconds
uint16_t timeout_s;
} bap_bc_deleg_pa_synchronize_cmd_t;
/// Structure for BAP_BC_DELEG_BIG_SYNCHRONIZE command message
typedef struct bap_bc_deleg_big_synchronize_cmd
{
/// Command code (@see enum bap_bc_deleg_cmd_code)
/// - BAP_BC_DELEG_BIG_SYNCHRONIZE
uint16_t cmd_code;
/// Source local index
uint8_t src_lid;
/// True if Broadcast code is meaningful, False otherwise
/// if False it means that broadcast code has already been received by delegator or Broadcast group isn't encrypted
bool bcast_code_present;
/// Broadcast code
gaf_bcast_code_t bcast_code;
/// Stream position bit field indicating streams to synchronize with.
uint32_t stream_pos_bf;
/// Timeout duration (10ms unit) before considering synchronization lost - (Range 100 ms to 163.84 s).
uint16_t timeout;
/// Maximum number of subevents the controller should use to received data payloads in each interval
uint8_t mse;
} bap_bc_deleg_big_synchronize_cmd_t;
/// Structure for command complete message
typedef struct bap_bc_deleg_cmp_evt
{
/// Command code (@see enum bap_bc_deleg_cmd_code)
uint16_t cmd_code;
/// Status of command execution (@see enum gaf_err)
uint16_t status;
/// Source local index (valid only for BAP_BC_DELEG_PA_SYNCHRONIZE and BAP_BC_DELEG_BIG_SYNCHRONIZE)
uint8_t src_lid;
} bap_bc_deleg_cmp_evt_t;
/// Structure for BAP_BC_DELEG_RESTORE_BOND_DATA request message
typedef struct bap_bc_deleg_restore_bond_data_req
{
/// Request code (@see enum bap_bc_deleg_req_code)
/// - BAP_BC_DELEG_RESTORE_BOND_DATA
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Configuration bit field (1 bit per broadcast source)
uint8_t cfg_bf;
/// Event bit field (1 bit per broadcast source) to notify
uint8_t evt_bf;
} bap_bc_deleg_restore_bond_data_req_t;
/// Structure for BAP_BC_DELEG_SOURCE_ADD request message
typedef struct bap_bc_deleg_source_add_req
{
/// Request code (@see enum bap_bc_deleg_req_code)
/// - BAP_BC_DELEG_SOURCE_ADD
uint16_t req_code;
/// Periodic advertising address
gap_per_adv_bdaddr_t addr;
/// Metadata in LTV format
gaf_ltv_t metadata;
} bap_bc_deleg_source_add_req_t;
/// Structure for BAP_BC_DELEG_SOURCE_UPDATE request message
typedef struct bap_bc_deleg_source_update_req
{
/// Request code (@see enum bap_bc_deleg_req_code)
/// - BAP_BC_DELEG_SOURCE_UPDATE
uint16_t req_code;
/// Source local index
uint8_t src_lid;
/// Metadata in LTV format
gaf_ltv_t metadata;
} bap_bc_deleg_source_update_req_t;
/// Structure for BAP_BC_DELEG_SOURCE_REMOVE request message
typedef struct bap_bc_deleg_source_remove_req
{
/// Request code (@see enum bap_bc_deleg_req_code)
/// - BAP_BC_DELEG_SOURCE_REMOVE
uint16_t req_code;
/// Source local index
uint8_t src_lid;
} bap_bc_deleg_source_remove_req_t;
/// Structure for Delegator response message
typedef struct bap_bc_deleg_rsp
{
/// Request code (@see enum bap_bc_deleg_req_code)
uint16_t req_code;
/// Request execution status (@see enum gaf_err)
uint16_t status;
/// Connection local index for BAP_BC_DELEG_RESTORE_BOND_DATA, Source local index otherwise
uint8_t lid;
} bap_bc_deleg_rsp_t;
/// Structure for BAP_BC_DELEG_SOLICITE_STOPPED indication message
typedef struct bap_bc_deleg_solicite_stopped_ind
{
/// Indication code (@see enum bap_bc_deleg_ind_code)
/// - BAP_BC_DELEG_SOLICITE_STOPPED
uint16_t ind_code;
/// Reason why sending of solicitation request has been stopped (@see enum bap_bc_deleg_reason)
uint16_t reason;
} bap_bc_deleg_solicite_stopped_ind_t;
/// Structure for BAP_BC_DELEG_BOND_DATA indication message
typedef struct bap_bc_deleg_bond_data_ind
{
/// Indication code (@see enum bap_bc_deleg_ind_code)
/// - BAP_BC_DELEG_BOND_DATA
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
uint8_t cli_cfg_bf;
} bap_bc_deleg_bond_data_ind_t;
/// Structure for BAP_BC_DELEG_BOND_REMOTE_SCAN indication message
typedef struct bap_bc_deleg_bond_remote_scan_ind
{
/// Indication code (@see enum bap_bc_deleg_ind_code)
/// - BAP_BC_DELEG_BOND_REMOTE_SCAN
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Broadcast Assistant device scan state (@see enum bap_bc_deleg_scan_state)
uint8_t state;
} bap_bc_deleg_bond_remote_scan_ind_t;
/// Structure for BAP_BC_DELEG_SOURCE_ADD_RI request indication message
typedef struct bap_bc_deleg_source_add_req_ind
{
/// Request Indication code (@see enum bap_bc_deleg_req_ind_code)
/// - BAP_BC_DELEG_SOURCE_ADD_RI
uint16_t req_ind_code;
/// Allocated Source local index
uint8_t src_lid;
/// Connection local index for device that has added the source
uint8_t con_lid;
/// Periodic advertising address
gap_per_adv_bdaddr_t addr;
/// Metadata in LTV format
gaf_ltv_t metadata;
} bap_bc_deleg_source_add_req_ind_t;
/// Structure for BAP_BC_DELEG_SOURCE_UPDATE_RI request indication message
typedef struct bap_bc_deleg_source_update_req_ind
{
/// Request Indication code (@see enum bap_bc_deleg_req_ind_code)
/// - BAP_BC_DELEG_SOURCE_UPDATE_RI
uint16_t req_ind_code;
/// Source local index
uint8_t src_lid;
/// Connection local index
uint8_t con_lid;
/// Metadata in LTV format
gaf_ltv_t metadata;
} bap_bc_deleg_source_update_req_ind_t;
/// Structure for BAP_BC_DELEG_SOURCE_REMOVE_RI request indication message
typedef struct bap_bc_deleg_source_remove_req_ind
{
/// Request Indication code (@see enum bap_bc_deleg_req_ind_code)
/// - BAP_BC_DELEG_SOURCE_REMOVE_RI
uint16_t req_ind_code;
/// Source local index
uint8_t src_lid;
/// Connection local index
uint8_t con_lid;
} bap_bc_deleg_source_remove_req_ind_t;
/// Structure for BAP_BC_DELEG_SOURCE_ADD_RI confirmation message
typedef struct bap_bc_deleg_source_add_cfm
{
/// Request Indication code (@see enum bap_bc_deleg_req_ind_code)
/// - BAP_BC_DELEG_SOURCE_ADD_RI
uint16_t req_ind_code;
/// Source local index
uint8_t src_lid;
/// Connection local index
uint8_t con_lid;
/// True to accept new broadcast source, False to reject
bool accept;
} bap_bc_deleg_source_add_cfm_t;
/// Structure for BAP_BC_DELEG_SOURCE_UPDATE_RI confirmation message
typedef struct bap_bc_deleg_source_update_cfm
{
/// Request Indication code (@see enum bap_bc_deleg_req_ind_code)
/// - BAP_BC_DELEG_SOURCE_UPDATE_RI
uint16_t req_ind_code;
/// Source local index
uint8_t src_lid;
/// Connection local index
uint8_t con_lid;
/// True to accept metadata update, False to reject
bool accept;
} bap_bc_deleg_source_update_cfm_t;
/// Structure for BAP_BC_DELEG_SOURCE_REMOVE_RI confirmation message
typedef struct bap_bc_deleg_source_remove_cfm
{
/// Request Indication code (@see enum bap_bc_deleg_req_ind_code)
/// - BAP_BC_DELEG_SOURCE_REMOVE_RI
uint16_t req_ind_code;
/// Source local index
uint8_t src_lid;
/// Connection local index
uint8_t con_lid;
/// True to accept broadcast source removal, False to reject
bool accept;
} bap_bc_deleg_source_remove_cfm_t;
/// @}
#endif // BAP_BC_DELEG_MSG_H_
@@ -0,0 +1,528 @@
/**
****************************************************************************************
*
* @file bap_bc_scan.h
*
* @brief Basic Audio Profile - Broadcast Scan - Native API
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_BC_SCAN_H_
#define BAP_BC_SCAN_H_
/**
****************************************************************************************
* @addtogroup BAP_BC_SCAN Basic Audio Profile - Broadcast Scan - Native API
* @ingroup BAP
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "bap.h" // Basic Audio Profile Definitions
#include "gap.h" // GAP Definitions
#include "iap.h" // IAP Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for Basic Audio Profile - Broadcast Scan
enum bap_bc_scan_cmd_codes
{
/// Start seeking for Broadcast Audio Announcements sent by Broadcast Source devices.
BAP_BC_SCAN_START = GAF_CODE(BAP, BC_SCAN, 0),
/// Stop all Scan procedures currently in progress.
BAP_BC_SCAN_STOP = GAF_CODE(BAP, BC_SCAN, 1),
/// Establish a periodic sync using Scanning
BAP_BC_SCAN_PA_SYNCHRONIZE = GAF_CODE(BAP, BC_SCAN, 2),
/// Establish a periodic sync using connection
BAP_BC_SCAN_PA_SYNCHRONIZE_CON = GAF_CODE(BAP, BC_SCAN, 3),
/// Transfer information about synchronization with a Periodic Advertising
BAP_BC_SCAN_PA_TRANSFER = GAF_CODE(BAP, BC_SCAN, 4),
};
/// List of GAF_REQ request codes for Basic Audio Profile - Broadcast Scan
enum bap_bc_scan_req_codes
{
/// Set scan parameters to be used for all scan procedures
BAP_BC_SCAN_SET_PARAMS = GAF_CODE(BAP, BC_SCAN, 0),
/// Terminate or cancel establishment of a periodic advertising sync activity
BAP_BC_SCAN_PA_TERMINATE = GAF_CODE(BAP, BC_SCAN, 1),
/// Control reception or not of periodic advertising reports
BAP_BC_SCAN_PA_REPORT_CTRL = GAF_CODE(BAP, BC_SCAN, 2),
};
/// List of GAF_IND indication codes for Basic Audio Profile - Broadcast Scan
enum bap_bc_scan_ind_codes
{
/// Inform upper layer that discovery of Broadcast Source devices has been stopped due to a timeout.
BAP_BC_SCAN_TIMEOUT = GAF_CODE(BAP, BC_SCAN, 0),
/// Inform upper layer that a Broadcast Source device has been discovered.
BAP_BC_SCAN_REPORT = GAF_CODE(BAP, BC_SCAN, 1),
/// Inform upper layer that a periodic advertising sync has been established
BAP_BC_SCAN_PA_ESTABLISHED = GAF_CODE(BAP, BC_SCAN, 2),
/// Inform upper layer that a periodic advertising sync has been terminated, lost or establishment has been aborted
BAP_BC_SCAN_PA_TERMINATED = GAF_CODE(BAP, BC_SCAN, 3),
/// Inform upper layer that a periodic advertising report has been received
BAP_BC_SCAN_PA_REPORT = GAF_CODE(BAP, BC_SCAN, 4),
/// Inform upper layer that a BIG Info advertising report has been received
BAP_BC_SCAN_BIG_INFO_REPORT = GAF_CODE(BAP, BC_SCAN, 5),
/// Inform upper layer about Broadcast group info in basic audio announcement advertising data
BAP_BC_SCAN_GROUP_REPORT = GAF_CODE(BAP, BC_SCAN, 6),
/// Inform upper layer about Broadcast sub-group info in basic audio announcement advertising data
BAP_BC_SCAN_SUBGROUP_REPORT = GAF_CODE(BAP, BC_SCAN, 7),
/// Inform upper layer about Broadcast stream info in basic audio announcement advertising data
BAP_BC_SCAN_STREAM_REPORT = GAF_CODE(BAP, BC_SCAN, 8),
};
/// List of GAF_REQ_IND request indication codes for Basic Audio Profile - Broadcast Scan
enum bap_bc_scan_req_ind_codes
{
/// Scan delegator receives request to establish a periodic advertising sync
BAP_BC_SCAN_PA_SYNCHRONIZE_RI = GAF_CODE(BAP, BC_SCAN, 0),
/// Scan delegator receives request to terminate a periodic advertising sync
BAP_BC_SCAN_PA_TERMINATE_RI = GAF_CODE(BAP, BC_SCAN, 1),
};
/// Bit Field of periodic advertising information that is supposed to be report by scan module
/// Filtering level to report information about basic audio announcement present in periodic advertising report
enum bap_bc_scan_report_filter_bf
{
/// Report Periodic advertising data (in raw format)
BAP_BC_SCAN_REPORT_PER_ADV_DATA_BIT = 0x01,
BAP_BC_SCAN_REPORT_PER_ADV_DATA_POS = 0,
/// Report BIG Info present in ACAD data of a periodic advertising report
BAP_BC_SCAN_REPORT_BIG_INFO_BIT = 0x02,
BAP_BC_SCAN_REPORT_BIG_INFO_POS = 1,
/// Report Broadcast Group information of basic audio announcement present in periodic advertising report
BAP_BC_SCAN_REPORT_ANNOUNCE_LVL_1_BIT = 0x04,
BAP_BC_SCAN_REPORT_ANNOUNCE_LVL_1_POS = 2,
/// Report Broadcast SubGroups information of basic audio announcement present in periodic advertising report
BAP_BC_SCAN_REPORT_ANNOUNCE_LVL_2_BIT = 0x08,
BAP_BC_SCAN_REPORT_ANNOUNCE_LVL_2_POS = 3,
/// Report Broadcast Stream information of basic audio announcement present in periodic advertising report
BAP_BC_SCAN_REPORT_ANNOUNCE_LVL_3_BIT = 0x10,
BAP_BC_SCAN_REPORT_ANNOUNCE_LVL_3_POS = 4,
};
/*
* TYPES DEFINITION
****************************************************************************************
*/
/// Scan Parameters structure
typedef struct bap_bc_scan_param
{
/// Scan configuration bit field (see TODO)
uint8_t cfg_bf;
/// Scan interval for LE 1M PHY in multiple of 0.625ms - Must be higher than 2.5ms
uint16_t intv_1m_slot;
/// Scan interval for LE Codec PHY in multiple of 0.625ms - Must be higher than 2.5ms
uint16_t intv_coded_slot;
/// Scan window for LE 1M PHY in multiple of 0.625ms - Must be higher than 2.5ms
uint16_t wd_1m_slot;
/// Scan window for LE Codec PHY in multiple of 0.625ms - Must be higher than 2.5ms
uint16_t wd_coded_slot;
} bap_bc_scan_param_t;
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called each time a Broadcast scan command has been completed
*
* @param[in] cmd_code Command code (@see enum bap_bc_scan_cmd_codes)
* @param[in] status Status of command execution (@see enum gaf_err)
* @param[in] pa_lid Periodic Advertising local index
* meaningful only for periodic advertising sync command,
* equals to GAF_INVALID_LID otherwise
****************************************************************************************
*/
typedef void (*bap_bc_scan_cb_cmp_evt)(uint16_t cmd_code, uint16_t status, uint8_t pa_lid);
/**
****************************************************************************************
* @brief Callback function called when scan has timeout
****************************************************************************************
*/
typedef void (*bap_bc_scan_cb_timeout)(void);
/**
****************************************************************************************
* @brief Callback function called when a Broadcast Source device has been discovered.
*
* @param[in] p_addr Pointer to address that report event
* @param[in] adv_sid Advertising SID
* @param[in] length Length of complete advertising data
* @param[in] p_data Pointer to complete advertising data containing the complete Broadcast Audio Announcement
*
****************************************************************************************
*/
typedef void (*bap_bc_scan_cb_found)(const gap_bdaddr_t* p_addr, uint8_t adv_sid,
uint8_t length, const uint8_t* p_data);
/**
****************************************************************************************
* @brief Callback function called when periodic sync has been established
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] p_adv_addr Pointer to periodic advertising address information
* @param[in] serv_data Only valid for a Periodic Advertising Sync Transfer, else ignore
****************************************************************************************
*/
typedef void (*bap_bc_scan_cb_pa_established)(uint8_t pa_lid, const gap_per_adv_bdaddr_t* p_adv_addr, uint16_t serv_data);
/**
****************************************************************************************
* @brief Callback function called as result of @see bap_bc_scan_pa_terminate function or if
* the periodic sync establishment is canceled or periodic sync is lost
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] reason Stop reason (@see enum gaf_err)
****************************************************************************************
*/
typedef void (*bap_bc_scan_cb_pa_terminated)(uint8_t pa_lid, uint16_t reason);
/**
****************************************************************************************
* @brief Callback function called when a periodic advertising report is received *
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] length Length of advertising data
* @param[in] p_data Pointer to complete periodic advertising report
****************************************************************************************
*/
typedef void (*bap_bc_scan_cb_pa_report)(uint8_t pa_lid, uint8_t length, const uint8_t* p_data);
/**
****************************************************************************************
* @brief Callback function called when a BIG Info report is received
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] p_report Pointer to structure that contains Big Info data
****************************************************************************************
*/
typedef void (*bap_bc_scan_cb_big_info_report)(uint8_t pa_lid, const gap_big_info_t* p_report);
/**
****************************************************************************************
* @brief Callback function called when an advertising report is received with audio announcement
* It provides information about Broadcast Group
*
* @note Triggered when audio announcement filtering level 1 is set (@ see enum bap_bc_scan_report_filter_bf)
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] nb_subgroups Number of subgroups in the Broadcast Group
* @param[in] nb_streams Total number of streams in the Broadcast Group
* @param[in] pres_delay_us Presentation delay in microseconds
* @param[in] p_codec_id Pointer to codec identifier
* @param[in] p_cfg Pointer to group codec configuration in LTV format, NULL if no codec configuration
* @param[in] p_metadata Pointer to group metadata in LTV format, NULL if no metadata
*
****************************************************************************************
*/
typedef void (*bap_bc_scan_cb_group_report)(uint8_t pa_lid, uint8_t nb_subgroups, uint8_t nb_streams,
uint32_t pres_delay_us, const gaf_codec_id_t* p_codec_id,
const gaf_ltv_t* p_cfg, const gaf_ltv_t* p_metadata);
/**
****************************************************************************************
* @brief Callback function called when an advertising report is received with audio announcement
* It provides information about Broadcast Sub-Group
*
* @note Triggered when audio announcement filtering level 2 is set (@ see enum bap_bc_scan_report_filter_bf)
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] sgrp_id Subgroup identifier
* @param[in] stream_pos_bf Stream position index bit field indicating for which streams are part of the subgroup
* @param[in] p_codec_id Pointer to codec identifier if codec group surcharged, NULL otherwise
* @param[in] p_cfg Pointer to subgroup codec configuration in LTV format, NULL if no codec configuration
* @param[in] p_metadata Pointer to subgroup metadata, NULL if no metadata
****************************************************************************************
*/
typedef void (*bap_bc_scan_cb_subgroup_report)(uint8_t pa_lid, uint8_t sgrp_id, uint32_t stream_pos_bf,
const gaf_codec_id_t* p_codec_id, const gaf_ltv_t* p_cfg,
const gaf_ltv_t* p_metadata);
/**
****************************************************************************************
* @brief Callback function called when an advertising report is received with audio announcement
* It provides information about Broadcast Streams
*
* @note Triggered when audio announcement filtering level 3 is set (@ see enum bap_bc_scan_report_filter_bf)
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] stream_pos Stream position in group
* @param[in] p_cfg Pointer to stream codec configuration in LTV format, NULL if no codec configuration
*
****************************************************************************************
*/
typedef void (*bap_bc_scan_cb_stream_report)(uint8_t pa_lid, uint8_t stream_pos, const gaf_ltv_t* p_cfg);
/**
****************************************************************************************
* @brief Callback executed when scan delegator receives request to establish a periodic advertising sync
* @see bap_bc_scan_pa_synchronize_cfm must be called to accept or reject request
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] src_lid Source local index
* @param[in] con_lid Connection Local Identifier of requester
* @param[in] p_adv_addr Pointer to targeted periodic advertiser
*
****************************************************************************************
*/
typedef void (*bap_bc_scan_cb_pa_sync_req)(uint8_t pa_lid, uint8_t src_lid, uint8_t con_lid,
const gap_per_adv_bdaddr_t* p_adv_addr);
/**
****************************************************************************************
* @brief Callback executed when scan delegator receives request to terminate a periodic advertising sync
* @see bap_bc_scan_pa_terminate_cfm must be called to accept or reject request
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] src_lid Source local index
* @param[in] con_lid Connection Local Identifier of requester
*
****************************************************************************************
*/
typedef void (*bap_bc_scan_cb_pa_terminate_req)(uint8_t pa_lid, uint8_t src_lid, uint8_t con_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Basic Audio Profile - Broadcast scan role
typedef struct bap_bc_scan_cb
{
/// Callback function called when a command has been completed
bap_bc_scan_cb_cmp_evt cb_cmp_evt;
/// Callback function called when a scan has timeout
bap_bc_scan_cb_timeout cb_timeout;
/// Callback function called when a Broadcast Source device has been discovered.
bap_bc_scan_cb_found cb_found;
/// Callback function called when a Periodic Advertising Sync is established
bap_bc_scan_cb_pa_established cb_pa_established;
/// Callback function called when a Periodic Advertising Sync is lost, canceled or terminated
bap_bc_scan_cb_pa_terminated cb_pa_terminated;
/// Callback function called when a Periodic Advertising Sync report is received
bap_bc_scan_cb_pa_report cb_pa_report;
/// Callback function called when a BIG Info report is received
bap_bc_scan_cb_big_info_report cb_big_info_report;
/// Callback function called when an advertising report is received with audio announcement (level 1)
bap_bc_scan_cb_group_report cb_group_report;
/// Callback function called when an advertising report is received with audio announcement (level 2)
bap_bc_scan_cb_subgroup_report cb_subgroup_report;
/// Callback function called when an advertising report is received with audio announcement (level 3)
bap_bc_scan_cb_stream_report cb_stream_report;
/// Callback function called when peer scan assistant requests to perform a periodic advertising synchronization
/// - Mandatory only if Delegator role supported
bap_bc_scan_cb_pa_sync_req cb_pa_sync_req;
/// Callback function called when peer scan assistant requests to terminate periodic advertising sync
/// - Mandatory only if Delegator role supported
bap_bc_scan_cb_pa_terminate_req cb_pa_terminate_req;
} bap_bc_scan_cb_t;
#if (GAF_BAP_BC_SCAN)
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Set scan parameters to be used for all scan procedures.
* By default, following scan parameters are used:
* - LE 1M PHY only
* - Scan Windows = 5ms
* - Scan Interval = 10ms
*
* @param[in] p_scan_param Pointer to new scan parameters
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_scan_set_params(const bap_bc_scan_param_t* p_scan_param);
/**
****************************************************************************************
* @brief Start seeking for Broadcast Audio Announcements sent by Broadcast Source devices.
*
* When Broadcast Assistant role is supported and configured, all connected Broadcast
* Delegators are informed that scan on their behalf has been started.
*
* @param[in] timeout_s Timeout duration in seconds
* 0 means that sending of solicitation requests will last for ever
*
* @return Function execution status code. (@see enum gaf_err).
* If no error, no new function should be executed until @see bap_bc_scan_cb_cmp_evt
* with BAP_BC_SCAN_START command code is called.
****************************************************************************************
*/
uint16_t bap_bc_scan_start(uint16_t timeout_s);
/**
****************************************************************************************
* @brief Stop all Scan procedures currently in progress.
*
* When Broadcast Assistant role is supported and configured, all connected
* Broadcast Delegators are informed that scan on their behalf has been stopped.
*
* @return Function execution status code. (@see enum gaf_err).
* If no error, no new function should be executed until @see bap_bc_scan_cb_cmp_evt
* with BAP_BC_SCAN_STOP command code is called.
****************************************************************************************
*/
uint16_t bap_bc_scan_stop(void);
/**
****************************************************************************************
* @brief Establish a periodic sync using Scanning
*
* Once the periodic sync is established, @see cb_pa_established callback is executed.
*
* @param[in] p_adv_addr Pointer to periodic advertising address information
* @param[in] skip Number of periodic advertising that can be skipped after a successful receive.
* Maximum authorized value is 499
* @param[in] report_filter_bf Bit field of filtered report types
* (@see enum bap_bc_scan_report_filter_bf)
* @param[in] sync_to Synchronization timeout for the periodic advertising
* (in unit of 10ms between 100ms and 163.84s)
* @param[in] timeout_s Scan Timeout in seconds
* @param[out] p_pa_lid Pointert at which allocated Periodic Advertising local index will be returned
*
*
* @return Status of function execution(@see enum gaf_err)
* If no error, no new function should be executed until @see bap_bc_scan_cb_cmp_evt
* with BAP_BC_SCAN_PA_SYNCHRONIZE command code is called.
****************************************************************************************
*/
uint16_t bap_bc_scan_pa_synchronize(const gap_per_adv_bdaddr_t* p_adv_addr, uint16_t skip, uint8_t report_filter_bf,
uint16_t sync_to, uint16_t timeout_s, uint8_t* p_pa_lid);
/**
****************************************************************************************
* @brief Establish a periodic sync using connection
*
* Once the periodic sync is established, @see cb_pa_established callback is executed.
*
* @param[in] act_lid Activity local identifier
* @param[in] con_lid Connection local identifier
* @param[in] skip Number of periodic advertising that can be skipped after a successful receive.
* Maximum authorized value is 499
* @param[in] report_filter_bf Bit field of filtered report types
* (@see enum bap_bc_scan_report_filter_bf)
* @param[in] sync_to Synchronization timeout for the periodic advertising
* (in unit of 10ms between 100ms and 163.84s)
* @param[out] p_pa_lid Pointert at which allocated Periodic Advertising local index will be returned
*
* @return Status of function execution(@see enum gaf_err)
* If no error, no new function should be executed until @see bap_bc_scan_cb_cmp_evt
* with BAP_BC_SCAN_PA_SYNCHRONIZE_CON command code is called.
****************************************************************************************
*/
uint16_t bap_bc_scan_pa_synchronize_con(uint8_t con_lid, uint16_t skip, uint8_t report_filter_bf, uint16_t sync_to,
uint8_t* p_pa_lid);
/**
****************************************************************************************
* @brief Transfer information about a Periodic Synchronization with a Periodic Advertising
*
* Once the transfer has been performed, @see cb_cmp_evt callback is executed.
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] con_lid Connection local index
*
* @return Status of function execution (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_scan_pa_transfer(uint8_t pa_lid, uint8_t con_lid);
/**
****************************************************************************************
* @brief Terminate periodic sync activity, according to state of the activity it cancels
* periodic sync establishment or terminate it
*
* Once the periodic sync is terminated, @see cb_pa_terminated callback is executed.
*
* @param[in] pa_lid Periodic Advertising local index
*
* @return Status of function execution (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_scan_pa_terminate(uint8_t pa_lid);
/**
****************************************************************************************
* @brief Enable or disable reception of periodic advertising reports
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] report_filter_bf Bit field of filtered report types
* (@see enum bap_bc_scan_report_filter_bf)
*
* @return Status of function execution (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_scan_pa_report_ctrl(uint8_t pa_lid, uint8_t report_filter_bf);
/**
****************************************************************************************
* @brief Confirm or not establishment of a periodic sync
*
* Once the periodic sync is established, @see cb_pa_established callback is executed.
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] accept True to accept request, False to reject it
* @param[in] skip Number of periodic advertising that can be skipped after a successful receive.
* Maximum authorized value is 499
* @param[in] report_filter_bf Bit field of filtered report types (@see enum bap_bc_scan_report_filter_bf)
* @param[in] sync_to Synchronization timeout for the periodic advertising
* (in unit of 10ms between 100ms and 163.84s)
* @param[in] timeout_s Sync establishment timeout in seconds
*
* @return Status of function execution (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_scan_pa_synchronize_cfm(uint8_t pa_lid, bool accept, uint16_t skip, uint8_t report_filter_bf,
uint16_t sync_to, uint16_t timeout_s);
/**
****************************************************************************************
* @brief Confirm or not termination of periodic sync activity,
* according to state of the activity it cancels
* periodic sync establishment or terminate it
*
* Once the periodic sync is terminated, @see cb_pa_terminated callback is executed.
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] accept True to accept request, False to reject it
*
* @return Status of function execution (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_scan_pa_terminate_cfm(uint8_t pa_lid, bool accept);
#endif //(GAF_BAP_BC_SCAN)
/// @}
#endif // BAP_BC_SCAN_H_
@@ -0,0 +1,343 @@
/**
****************************************************************************************
*
* @file bap_bc_scan_msg.h
*
* @brief Basic Audio Profile - Broadcast Scan - Message API Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_BC_SCAN_MSG_H_
#define BAP_BC_SCAN_MSG_H_
/**
****************************************************************************************
* @addtogroup BAP_BC_SCAN Basic Audio Profile - Broadcast Scan - Message API Definitions
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap_bc_scan.h" // Basic Audio Profile - Broadcast scan Definitions
#include "bap_msg.h" // Message API Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for BAP_BC_SCAN_SET_PARAMS request message
typedef struct bap_bc_scan_set_params_req
{
/// Request code (@see enum bap_bc_scan_req_codes)
/// - BAP_BC_SCAN_SET_PARAMS
uint16_t req_code;
/// Scan parameters
bap_bc_scan_param_t scan_param;
} bap_bc_scan_set_params_req_t;
/// Structure for BAP_BC_SCAN_START command message
typedef struct bap_bc_scan_start_cmd
{
/// Request code (@see enum bap_bc_scan_cmd_codes)
/// - BAP_BC_SCAN_START
uint16_t cmd_code;
/// Timeout duration in seconds
uint16_t timeout_s;
} bap_bc_scan_start_cmd_t;
/// Structure for BAP_BC_SCAN_STOP command message
typedef struct bap_bc_scan_stop_cmd
{
/// Request code (@see enum bap_bc_scan_cmd_codes)
/// - BAP_BC_SCAN_STOP
uint16_t cmd_code;
} bap_bc_scan_stop_cmd_t;
/// Structure for BAP_BC_SCAN_TIMEOUT indication message
typedef struct bap_bc_scan_timeout_ind
{
/// Indication code (@see enum bap_bc_scan_ind_codes)
/// - BAP_BC_SCAN_TIMEOUT
uint16_t ind_code;
} bap_bc_scan_timeout_ind_t;
/// Structure for BAP_BC_SCAN_REPORT indication message
typedef struct bap_bc_scan_report_ind
{
/// Indication code (@see enum bap_bc_scan_ind_codes)
/// - BAP_BC_SCAN_REPORT
uint16_t ind_code;
/// Device Address
gap_bdaddr_t addr;
/// Advertising SID
uint8_t adv_sid;
/// Length of complete advertising data
uint8_t length;
/// Complete advertising data containing the complete Broadcast Audio Announcement
uint8_t data[__ARRAY_EMPTY];
} bap_bc_scan_report_ind_t;
/// Structure for BAP_BC_SCAN_PA_SYNCHRONIZE and BAP_BC_SCAN_PA_SYNCHRONIZE_CON command complete event message
typedef struct bap_bc_scan_pa_synchronize_cmp_evt
{
/// Command code (@see enum bap_bc_scan_cmd_codes)
/// - BAP_BC_SCAN_PA_SYNCHRONIZE
/// - BAP_BC_SCAN_PA_SYNCHRONIZE_CON
uint16_t cmd_code;
/// Command execution status code (@see enum gaf_err)
uint16_t status;
/// Periodic Advertising local index assigned (meaningful is command succeed)
uint8_t pa_lid;
} bap_bc_scan_pa_synchronize_cmp_evt_t;
/// Structure for BAP_BC_SCAN_PA_SYNCHRONIZE command message
typedef struct bap_bc_scan_pa_synchronize_cmd
{
/// Command code (@see enum bap_bc_scan_cmd_codes)
/// - BAP_BC_SCAN_PA_SYNCHRONIZE
uint16_t cmd_code;
/// Periodic advertising address information
gap_per_adv_bdaddr_t adv_addr;
/// Number of periodic advertising that can be skipped after a successful receive.
/// Maximum authorized value is 499
uint16_t skip;
/// Bit field of filtered report types (@see enum bap_bc_scan_report_filter_bf)
uint8_t report_filter_bf;
/// Synchronization timeout for the periodic advertising (in unit of 10ms between 100ms and 163.84s)
uint16_t sync_to;
/// Scan Timeout in seconds
uint16_t timeout_s;
} bap_bc_scan_pa_synchronize_cmd_t;
/// Structure for BAP_BC_SCAN_PA_SYNCHRONIZE_CON command message
typedef struct bap_bc_scan_pa_synchronize_con_cmd
{
/// Command code (@see enum bap_bc_scan_cmd_codes)
/// - BAP_BC_SCAN_PA_SYNCHRONIZE_CON
uint16_t cmd_code;
/// Connection local identifier
uint8_t con_lid;
/// Number of periodic advertising that can be skipped after a successful receive.
/// Maximum authorized value is 499
uint16_t skip;
/// Bit field of filtered report types (@see enum bap_bc_scan_report_filter_bf)
uint8_t report_filter_bf;
/// Synchronization timeout for the periodic advertising (in unit of 10ms between 100ms and 163.84s)
uint16_t sync_to;
} bap_bc_scan_pa_synchronize_con_cmd_t;
/// Structure for BAP_BC_SCAN_PA_TERMINATE request message
typedef struct bap_bc_scan_pa_terminate_req
{
/// Request code (@see enum bap_bc_scan_req_codes)
/// - BAP_BC_SCAN_PA_TERMINATE
uint16_t req_code;
/// Periodic Advertising local index
uint8_t pa_lid;
} bap_bc_scan_pa_terminate_req_t;
/// Structure for BAP_BC_SCAN_PA_REPORT_CTRL request message
typedef struct bap_bc_scan_pa_report_ctrl_req
{
/// Request code (@see enum bap_bc_scan_req_codes)
/// - BAP_BC_SCAN_PA_REPORT_CTRL
uint16_t req_code;
/// Periodic Advertising local index
uint8_t pa_lid;
/// Bit field of filtered report types (@see enum bap_bc_scan_report_filter_bf)
uint8_t report_filter_bf;
} bap_bc_scan_pa_report_ctrl_req_t;
/// Structure for BAP_BC_SCAN_PA_ESTABLISHED indication message
typedef struct bap_bc_scan_pa_established_ind
{
/// Indication code (@see enum bap_bc_scan_ind_codes)
/// - BAP_BC_SCAN_PA_ESTABLISHED
uint16_t ind_code;
/// Periodic Advertising local index
uint8_t pa_lid;
/// Periodic advertising address information
gap_per_adv_bdaddr_t adv_addr;
/// Only valid for a Periodic Advertising Sync Transfer, else ignore
uint16_t serv_data;
} bap_bc_scan_pa_established_ind_t;
/// Structure for BAP_BC_SCAN_PA_TERMINATED indication message
typedef struct bap_bc_scan_pa_terminated_ind
{
/// Indication code (@see enum bap_bc_scan_ind_codes)
/// - BAP_BC_SCAN_PA_TERMINATED
uint16_t ind_code;
/// Periodic Advertising local index
uint8_t pa_lid;
/// Stop reason (@see enum gaf_err)
uint16_t reason;
} bap_bc_scan_pa_terminated_ind_t;
/// Structure for BAP_BC_SCAN_PA_REPORT indication message
typedef struct bap_bc_scan_pa_report_ind
{
/// Indication code (@see enum bap_bc_scan_ind_codes)
/// - BAP_BC_SCAN_PA_REPORT
uint16_t ind_code;
/// Periodic Advertising local index
uint8_t pa_lid;
/// Length of advertising data
uint8_t length;
/// Complete periodic advertising report
uint8_t data[__ARRAY_EMPTY];
} bap_bc_scan_pa_report_ind_t;
/// Structure for BAP_BC_SCAN_BIG_INFO_REPORT indication message
typedef struct bap_bc_scan_big_info_report_ind
{
/// Indication code (@see enum bap_bc_scan_ind_codes)
/// - BAP_BC_SCAN_BIG_INFO_REPORT
uint16_t ind_code;
/// Periodic Advertising local index
uint8_t pa_lid;
/// BIG Info Report
gap_big_info_t report;
} bap_bc_scan_big_info_report_ind_t;
/// Structure for BAP_BC_SCAN_GROUP_REPORT indication message
typedef struct bap_bc_scan_group_report_ind
{
/// Indication code (@see enum bap_bc_scan_ind_codes)
/// - BAP_BC_SCAN_GROUP_REPORT
uint16_t ind_code;
/// Periodic Advertising local index
uint8_t pa_lid;
/// Number of subgroups in the Broadcast Group
uint8_t nb_subgroups;
/// Total number of streams in the Broadcast Group
uint8_t nb_streams;
/// Codec ID value
gaf_codec_id_t codec_id;
/// Audio output presentation delay in microseconds
uint32_t pres_delay_us;
/// Length of Codec Configuration value
uint8_t cfg_len;
/// Length of Metadata value
uint8_t metadata_len;
/// Codec Configuration value followed by Metadata value
/// Both values are in LTV format
uint8_t val[__ARRAY_EMPTY];
} bap_bc_scan_group_report_ind_t;
/// Structure for BAP_BC_SCAN_SUBGROUP_REPORT indication message
typedef struct bap_bc_scan_subgroup_report_ind
{
/// Indication code (@see enum bap_bc_scan_ind_codes)
/// - BAP_BC_SCAN_SUBGROUP_REPORT
uint16_t ind_code;
/// Periodic Advertising local index
uint8_t pa_lid;
/// Subgroup identifier
uint8_t sgrp_id;
/// Codec ID value
/// (Octet = 0xFE if equals to group codec, surcharged otherwise)
gaf_codec_id_t codec_id;
/// Stream position index bit field indicating for which streams are part of the subgroup
uint32_t stream_pos_bf;
/// Length of Codec Configuration value
uint8_t cfg_len;
/// Length of Metadata value
uint8_t metadata_len;
/// Codec Configuration value followed by Metadata value
/// Both values are in LTV format
uint8_t val[__ARRAY_EMPTY];
} bap_bc_scan_subgroup_report_ind_t;
/// Structure for BAP_BC_SCAN_STREAM_REPORT indication message
typedef struct bap_bc_scan_stream_report_ind
{
/// Indication code (@see enum bap_bc_scan_ind_codes)
/// - BAP_BC_SCAN_STREAM_REPORT
uint16_t ind_code;
/// Periodic Advertising local index
uint8_t pa_lid;
/// Stream position in group
uint8_t stream_pos;
/// Codec configuration length
uint8_t cfg_len;
/// Codec configuration data in LTV format
uint8_t cfg[__ARRAY_EMPTY];
} bap_bc_scan_stream_report_ind_t;
/// Structure for BAP_BC_SCAN_PA_SYNCHRONIZE_RI request indication message
typedef struct bap_bc_scan_pa_synchronize_req_ind
{
/// Indication code (@see enum bap_bc_scan_req_ind_codes)
/// - BAP_BC_SCAN_PA_SYNCHRONIZE_RI
uint16_t req_ind_code;
/// Periodic Advertising local index
uint8_t pa_lid;
/// Source local index
uint8_t src_lid;
/// Connection Local Identifier of requester
uint8_t con_lid;
/// Targeted periodic advertiser
gap_per_adv_bdaddr_t addr;
} bap_bc_scan_pa_synchronize_req_ind_t;
/// Structure for BAP_BC_SCAN_PA_TERMINATE_RI request indication message
typedef struct bap_bc_scan_pa_terminate_req_ind
{
/// Indication code (@see enum bap_bc_scan_req_ind_codes)
/// - BAP_BC_SCAN_PA_TERMINATE_RI
uint16_t req_ind_code;
/// Periodic Advertising local index
uint8_t pa_lid;
/// Source local index
uint8_t src_lid;
/// Connection Local Identifier of requester
uint8_t con_lid;
} bap_bc_scan_pa_terminate_req_ind_t;
/// Structure for BAP_BC_SCAN_PA_SYNCHRONIZE_RI confirmation message
typedef struct bap_bc_scan_pa_synchronize_cfm
{
/// Indication code (@see enum bap_bc_scan_req_ind_codes)
/// - BAP_BC_SCAN_PA_SYNCHRONIZE_RI
uint16_t req_ind_code;
/// Periodic Advertising local index
uint8_t pa_lid;
/// True to accept request, False to reject it
bool accept;
/// Bit field of filtered report types (@see enum bap_bc_scan_report_filter_bf)
uint8_t report_filter_bf;
/// Number of periodic advertising that can be skipped after a successful receive.
/// Maximum authorized value is 499
uint16_t skip;
/// Synchronization timeout for the periodic advertising (in unit of 10ms between 100ms and 163.84s)
uint16_t sync_to;
/// Sync establishment timeout in seconds
uint16_t timeout_s;
} bap_bc_scan_pa_synchronize_cfm_t;
/// Structure for BAP_BC_SCAN_PA_TERMINATE_RI confirmation message
typedef struct bap_bc_scan_pa_terminate_cfm
{
/// Indication code (@see enum bap_bc_scan_req_ind_codes)
/// - BAP_BC_SCAN_PA_TERMINATE_RI
uint16_t req_ind_code;
/// Periodic Advertising local index
uint8_t pa_lid;
/// True to accept request, False to reject it
bool accept;
} bap_bc_scan_pa_terminate_cfm_t;
/// @}
#endif // BAP_BC_SCAN_MSG_H_
@@ -0,0 +1,277 @@
/**
****************************************************************************************
*
* @file bap_bc_sink.h
*
* @brief Basic Audio Profile - Broadcast Sink - Native API
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_BC_SINK_H_
#define BAP_BC_SINK_H_
/**
****************************************************************************************
* @addtogroup BAP_BC_SINK Basic Audio Profile - Broadcast Sink - Native API
* @ingroup BAP
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "bap.h" // Basic Audio Profile Definitions
#include "gap.h" // GAP Definitions
#include "iap.h" // IAP Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for Basic Audio Profile - Broadcast Sink
enum bap_bc_sink_cmd_codes
{
/// Enable a Broadcast Group Sink - it creates a corresponding Broadcast group.
BAP_BC_SINK_ENABLE = GAF_CODE(BAP, BC_SINK, 0),
/// Disable a Broadcast Group Sink - it removes Broadcast group and included streams.
BAP_BC_SINK_DISABLE = GAF_CODE(BAP, BC_SINK, 1),
/// Start reception of audio data onto a Broadcast stream.
BAP_BC_SINK_START_STREAMING = GAF_CODE(BAP, BC_SINK, 2),
/// Stop reception of audio data onto a Broadcast stream.
BAP_BC_SINK_STOP_STREAMING = GAF_CODE(BAP, BC_SINK, 3),
};
/// List of GAF_REQ_IND request indication codes for Basic Audio Profile - Broadcast Sink
enum bap_bc_sink_req_ind_codes
{
/// Request to enable a Broadcast Group Sink - it creates a corresponding Broadcast group.
BAP_BC_SINK_ENABLE_RI = GAF_CODE(BAP, BC_SINK, 0),
/// Request to disable a Broadcast Group Sink - it removes Broadcast group and included streams.
BAP_BC_SINK_DISABLE_RI = GAF_CODE(BAP, BC_SINK, 1),
};
/// List of GAF_IND request indication codes for Basic Audio Profile - Broadcast Sink
enum bap_bc_sink_ind_codes
{
/// Inform upper layer about status of synchronization with a Broadcast Group
BAP_BC_SINK_STATUS = GAF_CODE(BAP, BC_SINK, 0),
};
/// Broadcast group sink state
enum bap_bc_sink_state
{
/// Broadcast Sink establishment succeed
BAP_BC_SINK_ESTABLISHED = 0x00,
/// Broadcast Sink establishment failed due to LL error
BAP_BC_SINK_FAILED = 0x01,
/// Broadcast Sink establishment canceled
BAP_BC_SINK_CANCELLED = 0x02,
/// Broadcast Sink connection lost
BAP_BC_SINK_LOST = 0x03,
/// Broadcast Sink connection stop due to peer termination
BAP_BC_SINK_PEER_TERMINATE = 0x04,
/// Broadcast Sink connection stop due to upper layer termination
BAP_BC_SINK_UPPER_TERMINATE = 0x05,
/// Broadcast Sink connection stop due to an encryption error
BAP_BC_SINK_MIC_FAILURE = 0x06,
};
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called each time a Broadcast sink command has been completed
*
*
* @param[in] cmd_code Command code (@see enum bap_bc_sink_cmd_codes)
* @param[in] status Status of command execution (@see enum gaf_err)
* @param[in] grp_lid Broadcast group local index
* @param[in] stream_pos Stream positing in group BAP_BC_SINK_START_STREAMING and BAP_BC_SINK_STOP_STREAMING commands
****************************************************************************************
*/
typedef void (*bap_bc_sink_cb_cmp_evt)(uint16_t cmd_code, uint16_t status, uint8_t grp_lid, uint8_t stream_pos);
/**
****************************************************************************************
* @brief Inform upper layer about status of synchronization with a Broadcast Group
*
* Group local index is removed in case of sync termination (if state != BAP_BC_SINK_ESTABLISHED).
*
* @param[in] grp_lid Broadcast group local index
* @param[in] state Broadcast Sink state (@see enum bap_bc_sink_state)
* @param[in] stream_pos_bf Stream position bit field in broadcast group to receive
* @param[in] p_bg_cfg When sync established, provides information about broadcast group
****************************************************************************************
*/
typedef void (*bap_bc_sink_cb_status)(uint8_t grp_lid, uint8_t state, uint32_t stream_pos_bf,
const iap_bg_config_t* p_bg_cfg);
/**
****************************************************************************************
* @brief Callback executed when scan delegator receives request to establish a broadcast sink
* @see bap_bc_sink_enable_cfm must be called to accept or reject Broadcast sink establishment
*
* @param[in] grp_lid Broadcast group local index
* @param[in] src_lid Delegator Source local index
* @param[in] con_lid Connection Local Identifier of requester
* @param[in] stream_pos_bf Stream position bit field indicating streams to synchronize with.
*
****************************************************************************************
*/
typedef void (*bap_bc_sink_cb_enable_req)(uint8_t grp_lid, uint8_t src_lid, uint8_t con_lid, uint32_t stream_pos_bf);
/**
****************************************************************************************
* @brief Callback executed when scan delegator receives request to terminate a broadcast sink
* @see bap_bc_sink_disable_cfm must be called to accept or reject Broadcast sink termination
*
* @param[in] grp_lid Broadcast group local index
* @param[in] src_lid Delegator Source local index
* @param[in] con_lid Connection Local Identifier of requester
*
****************************************************************************************
*/
typedef void (*bap_bc_sink_cb_disable_req)(uint8_t grp_lid, uint8_t src_lid, uint8_t con_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Basic Audio Profile - Broadcast Sink role
typedef struct bap_bc_sink_cb
{
/// Callback function called when a command has been completed
bap_bc_sink_cb_cmp_evt cb_cmp_evt;
/// Callback function called when status of synchronization with a Broadcast Group changed
bap_bc_sink_cb_status cb_status;
/// Callback function called when peer scan assistant requests to establish a broadcast sink
bap_bc_sink_cb_enable_req cb_enable_req;
/// Callback function called when peer scan assistant requests to terminate broadcast sink
bap_bc_sink_cb_disable_req cb_disable_req;
} bap_bc_sink_cb_t;
#if (GAF_BAP_BC_SINK)
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Create a broadcast sync group and synchronize with.
* Synchronization with the Periodic Advertising must have been established using @see bap_bc_scan_pa_sync
*
* Broadcast Sync status is provided with @see cb_status callback
*
* TODO: when IAP updated, used cb_cmp_evt to inform when HCI status event received
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] stream_pos_bf Stream position bit field indicating streams to synchronize with.
* @param[in] p_bcast_code Pointer to broadcast code, NULL if not encrypted
* @param[in] mse Maximum number of subevents the controller should use to received data
* payloads in each interval
* @param[in] timeout Timeout duration (10ms unit) before considering synchronization lost
* (Range 100 ms to 163.84 s).
* @param[out] p_grp_lid Pointer at which allocated Group local index is returned
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_sink_enable(uint8_t pa_lid, uint32_t stream_pos_bf, const gaf_bcast_code_t* p_bcast_code,
uint8_t mse, uint16_t timeout, uint8_t* p_grp_lid);
/**
****************************************************************************************
* @brief Stop synchronization with a Broadcast Group or cancel establishment.
*
* TODO: when IAP updated, used cb_cmp_evt to inform that procedure is over (is it needed)
*
* @param[in] grp_lid Broadcast group local index
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_sink_disable(uint8_t grp_lid);
/**
****************************************************************************************
* @brief Stop synchronization with a Broadcast Group or cancel establishment.
*
* Wait for @see cb_cmp_evt before stopping same stream
*
* @param[in] grp_lid Broadcast group local index
* @param[in] stream_pos Position of the stream in the group (range 1 to 32)
* @param[in] p_codec_id Pointer to Codec ID value
* @param[in] dp_id Datapath identifier
* @param[in] ctl_delay_us Controller delay in microseconds
* @param[in] p_cfg Pointer to Codec Configuration - to be casted as bap_lc3_cfg_t for LC3 codec.
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_sink_start_streaming(uint8_t grp_lid, uint8_t stream_pos, const gaf_codec_id_t* p_codec_id, uint8_t dp_id,
uint32_t ctl_delay_us, const void* p_cfg);
/**
****************************************************************************************
* @brief Stop synchronization with a Broadcast Group or cancel establishment.
*
* Wait for @see cb_cmp_evt before starting same stream
*
* @param[in] grp_lid Broadcast group local index
* @param[in] stream_pos Position of the stream in the group (range 1 to 32)
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_sink_stop_streaming(uint8_t grp_lid, uint8_t stream_pos);
#if (GAF_BAP_BC_DELEG)
/**
****************************************************************************************
* @brief This function must be called in response of @see cb_enable_req callback execution to accept or reject
* Broadcast sink establishment
*
* Broadcast Sync status is then provided with @see cb_status callback
*
* @param[in] grp_lid Broadcast group local index
* @param[in] accept True to accept broadcast sink establishment, False otherwise
* @param[in] timeout_s Timeout duration in seconds for synchronization establishment with the Broadcast Group
* @param[in] mse Maximum number of subevents the controller should use to received data
* payloads in each interval
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_sink_enable_cfm(uint8_t grp_lid, bool accept, uint16_t timeout_s, uint8_t mse);
/**
****************************************************************************************
* @brief This function must be called in response of @see cb_disable_req callback execution to accept or reject
* Broadcast sink termination
*
* @param[in] grp_lid Broadcast group local index
* @param[in] accept True to accept broadcast sink termination, False otherwise
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_sink_disable_cfm(uint8_t grp_lid, bool accept);
#endif // (GAF_BAP_BC_DELEG)
#endif //(GAF_BAP_BC_SINK)
/// @}
#endif // BAP_BC_SINK_H_
@@ -0,0 +1,192 @@
/**
****************************************************************************************
*
* @file bap_bc_sink_msg.h
*
* @brief Basic Audio Profile - Broadcast Sink - Message API Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_BC_SINK_MSG_H_
#define BAP_BC_SINK_MSG_H_
/**
****************************************************************************************
* @addtogroup BAP_BC_SINK Basic Audio Profile - Broadcast Sink - Message API Definitions
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap_bc_sink.h" // Basic Audio Profile - Broadcast Sink Definitions
#include "bap_msg.h" // Message API Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for command complete message
typedef struct bap_bc_sink_cmp_evt
{
/// Command code (@see enum bap_bc_sink_cmd_codes)
uint16_t cmd_code;
/// Status of command execution (@see enum gaf_err)
uint16_t status;
/// Group local index
uint8_t grp_lid;
/// Stream position. Meaningful only for
/// BAP_BC_SINK_START_STREAMING and BAP_BC_SINK_STOP_STREAMING commands
uint8_t stream_pos;
} bap_bc_sink_cmp_evt_t;
/// Structure for BAP_BC_SINK_ENABLE command message
typedef struct bap_bc_sink_enable_cmd
{
/// Request code (@see enum bap_bc_sink_cmd_codes)
/// - BAP_BC_SINK_ENABLE
uint16_t cmd_code;
/// Periodic Advertising local index
uint8_t pa_lid;
/// Maximum number of subevents the controller should use to receive data payloads in each interval
uint8_t mse;
/// Stream position bit field indicating streams to synchronize with.
uint32_t stream_pos_bf;
/// Timeout duration (10ms unit) before considering synchronization lost (Range 100 ms to 163.84 s).
uint16_t timeout_s;
/// Indicate if streams are encrypted (!= 0) or not
uint8_t encrypted;
/// Broadcast code. Meaningful only if encrypted parameter indicates that streams are encrypted
gaf_bcast_code_t bcast_code;
} bap_bc_sink_enable_cmd_t;
/// Structure for BAP_BC_SINK_DISABLE command message
typedef struct bap_bc_sink_disable_cmd
{
/// Request code (@see enum bap_bc_sink_cmd_codes)
/// - BAP_BC_SINK_DISABLE
uint16_t cmd_code;
/// Group local index
uint8_t grp_lid;
} bap_bc_sink_disable_cmd_t;
/// Structure for BAP_BC_SINK_START_STREAMING command message
typedef struct bap_bc_sink_start_streaming_cmd
{
/// Request code (@see enum bap_bc_sink_cmd_codes)
/// - BAP_BC_SINK_START_STREAMING
uint16_t cmd_code;
/// Group local index
uint8_t grp_lid;
/// Position of the stream in the group (range 1 to 32)
uint8_t stream_pos;
/// Controller delay in microseconds
uint32_t ctl_delay_us;
/// Codec ID value
gaf_codec_id_t codec_id;
/// Datapath identifier
uint8_t dp_id;
/// Length of Codec Configuration value - in bytes
uint8_t cfg_len;
/// Codec Configuration - to be casted as bap_lc3_cfg_t for LC3 codec.
/// Array of bytes - 32-bit aligned to be casted as a SW structure
uint32_t cfg[__ARRAY_EMPTY];
} bap_bc_sink_start_streaming_cmd_t;
/// Structure for BAP_BC_SINK_STOP_STREAMING command message
typedef struct bap_bc_sink_stop_streaming_cmd
{
/// Request code (@see enum bap_bc_sink_cmd_codes)
/// - BAP_BC_SINK_STOP_STREAMING
uint16_t cmd_code;
/// Group local index
uint8_t grp_lid;
/// Position of the stream in the group (range 1 to 32)
uint8_t stream_pos;
} bap_bc_sink_stop_streaming_cmd_t;
/// Structure for BAP_BC_SINK_STATUS indication message
typedef struct bap_bc_sink_status_ind
{
/// Indication code (@see enum bap_bc_sink_ind_codes)
/// - BAP_BC_SINK_STATUS
uint16_t ind_code;
/// Group local index
uint8_t grp_lid;
/// Broadcast Sink state (@see enum bap_bc_sink_state)
uint8_t state;
/// Stream position bit field in broadcast group to receive
uint32_t stream_pos_bf;
/// When sync established, provides information about broadcast group else meaningless
iap_bg_config_t bg_cfg;
} bap_bc_sink_status_ind_t;
/// Structure for BAP_BC_SINK_ENABLE_RI request indication message
typedef struct bap_bc_sink_enable_req_ind
{
/// Request Indication code (@see enum bap_bc_sink_req_ind_codes)
/// - BAP_BC_SINK_ENABLE_RI
uint16_t req_ind_code;
/// Group local index
uint8_t grp_lid;
/// Source local index
uint8_t src_lid;
/// Connection Local Identifier of requester
uint8_t con_lid;
/// Stream position bit field indicating streams to synchronize with.
uint32_t stream_pos_bf;
} bap_bc_sink_enable_req_ind_t;
/// Structure for BAP_BC_SINK_ENABLE_RI confirm message
typedef struct bap_bc_sink_enable_cfm
{
/// Request Indication code (@see enum bap_bc_sink_req_ind_codes)
/// - BAP_BC_SINK_ENABLE_RI
uint16_t req_ind_code;
/// Group local index
uint8_t grp_lid;
/// True to accept broadcast sink establishment, False otherwise
bool accept;
/// Timeout duration (10ms unit) before considering synchronization lost (Range 100 ms to 163.84 s).
uint16_t timeout_s;
/// Maximum number of subevents the controller should use to received data payloads in each interval
uint8_t mse;
} bap_bc_sink_enable_cfm_t;
/// Structure for BAP_BC_SINK_DISABLE_RI request indication message
typedef struct bap_bc_sink_disable_req_ind
{
/// Request Indication code (@see enum bap_bc_sink_req_ind_codes)
/// - BAP_BC_SINK_DISABLE_RI
uint16_t req_ind_code;
/// Group local index
uint8_t grp_lid;
/// Source local index
uint8_t src_lid;
/// Connection Local Identifier of requester
uint8_t con_lid;
} bap_bc_sink_disable_req_ind_t;
/// Structure for BAP_BC_SINK_DISABLE_RI confirm message
typedef struct bap_bc_sink_disable_cfm
{
/// Request Indication code (@see enum bap_bc_sink_req_ind_codes)
/// - BAP_BC_SINK_DISABLE_RI
uint16_t req_ind_code;
/// Group local index
uint8_t grp_lid;
/// True to accept broadcast sink termination, False otherwise
bool accept;
} bap_bc_sink_disable_cfm_t;
/// @}
#endif // BAP_BC_SINK_MSG_H_
@@ -0,0 +1,312 @@
/**
****************************************************************************************
*
* @file bap_bc_src.h
*
* @brief Basic Audio Profile - Broadcast Source - Native API
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_BC_SRC_H_
#define BAP_BC_SRC_H_
/**
****************************************************************************************
* @addtogroup BAP_BC_SRC Basic Audio Profile - Broadcast Source - Native API
* @ingroup BAP
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "bap.h" // Basic Audio Profile Definitions
#include "gap.h" // GAP Definitions
#include "iap.h" // IAP Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for Basic Audio Profile - Broadcast Source
enum bap_bc_src_cmd_codes
{
/// Enable Periodic Advertising for a Broadcast Group.
BAP_BC_SRC_ENABLE_PA = GAF_CODE(BAP, BC_SRC, 0),
/// Enable a Broadcast Group.
BAP_BC_SRC_ENABLE = GAF_CODE(BAP, BC_SRC, 1),
/// Start transmission of audio data on either all streams or on a subset of streams within a Broadcast Group.
BAP_BC_SRC_START_STREAMING = GAF_CODE(BAP, BC_SRC, 2),
/// Stop transmission of audio data for either all streams or for a subset of streams within a Broadcast Group.
BAP_BC_SRC_STOP_STREAMING = GAF_CODE(BAP, BC_SRC, 3),
/// Disable Periodic Advertising for a Broadcast Group.
BAP_BC_SRC_DISABLE_PA = GAF_CODE(BAP, BC_SRC, 4),
/// Disable a Broadcast Group.
BAP_BC_SRC_DISABLE = GAF_CODE(BAP, BC_SRC, 5),
};
/// List of GAF_REQ request codes for Basic Audio Profile - Broadcast Source
enum bap_bc_src_req_codes
{
/// Add a Broadcast Group.
BAP_BC_SRC_ADD_GROUP = GAF_CODE(BAP, BC_SRC, 0),
/// Configure or reconfigure a Broadcast Group.
BAP_BC_SRC_SET_GROUP = GAF_CODE(BAP, BC_SRC, 1),
/// Configure or reconfigure a Broadcast Subgroup.
BAP_BC_SRC_SET_SUBGROUP = GAF_CODE(BAP, BC_SRC, 2),
/// Configure or reconfigure a Broadcast Stream and set the Broadcast Subgroup it belongs to.
BAP_BC_SRC_SET_STREAM = GAF_CODE(BAP, BC_SRC, 3),
/// Remove a Broadcast Group.
BAP_BC_SRC_REMOVE_GROUP = GAF_CODE(BAP, BC_SRC, 4),
};
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called each time a Broadcast source command has been completed
*
* @param[in] cmd_code Command code (@see enum bap_bc_src_cmd_codes)
* @param[in] status Status of command execution (@see enum gaf_err)
* @param[in] grp_lid Broadcast group local index
* @param[in] stream_lid_bf Stream local index bit field. Meaningful only for
* BAP_BC_SRC_START_STREAMING and BAP_BC_SRC_STOP_STREAMING commands
****************************************************************************************
*/
typedef void (*bap_bc_src_cb_cmp_evt)(uint16_t cmd_code, uint16_t status, uint8_t grp_lid, uint32_t stream_lid_bf);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Basic Audio Profile - Broadcast source role
typedef struct bap_bc_src_cb
{
/// Callback function called when a command has been completed
bap_bc_src_cb_cmp_evt cb_cmp_evt;
} bap_bc_src_cb_t;
#if (GAF_BAP_BC_SRC)
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Add a Broadcast Group.
*
* A Broadcast Group may contain one or several Broadcast Subgroup(s). A Broadcast Subgroup
* may contain one or several Broadcast Stream(s).
*
* A local index is allocated for the added Broadcast Group and is returned.
* Local index for a Broadcast Subgroup belonging to the group (named sgrp_lid in other
* messages) is in the range [0, nb_streams[.
*
* Local index for a Broadcast Stream belonging to the group (named stream_lid in other
* messages) is in the range [0, nb_streams[.
*
* By default, all Broadcast Streams are part of the first Subgroup (sgrp_lid = 0).
*
* Broadcast Group shall be configured at least once using @see bap_bc_src_set_group function.
*
* A Broadcast Subgroup can be configured using @see bap_bc_src_set_subgroup function.
*
* A Broadcast Streams can be configured using @see bap_bc_src_set_stream function.
*
*
* @param[in] nb_streams Number of streams in the group.
* At least one stream must be present in the group.
* @param[in] nb_subgroups Number of Subgroups in the Broadcast Group. Cannot be 0.
* @param[in] p_grp_param Pointer to Broadcast Group parameters.
* @param[in] p_adv_param Pointer to Advertising parameters
* @param[in] p_per_adv_param Pointer to Periodic advertising parameters
* @param[out] p_grp_lid Pointer at which allocated Group local index is returned
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_src_add_group(uint8_t nb_streams, uint8_t nb_subgroups, const bap_bc_grp_param_t* p_grp_param,
const bap_bc_adv_param_t* p_adv_param, const bap_bc_per_adv_param_t* p_per_adv_param,
uint8_t* p_grp_lid);
/**
****************************************************************************************
* @brief Remove a Broadcast Group.
*
* The Broadcast Group must have been stopped.
*
* @param[in] grp_lid Group local index
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_src_remove_group(uint8_t grp_lid);
/**
****************************************************************************************
* @brief Configure or reconfigure a Broadcast Group.
*
* The Broadcast Group (including the Periodic Advertising) must not be enabled
* in case of a reconfiguration.
*
* @param[in] grp_lid Group local index
* @param[in] pres_delay_us Audio output presentation delay in microseconds
* @param[in] p_codec_id Pointer to Codec ID value
* @param[in] p_cfg Pointer to additional Codec Configuration value
* To be casted as @see bap_lc3_cfg_t for LC3.
* @param[in] p_metadata Pointer to additional Metadata value (in LTV format)
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_src_set_group(uint8_t grp_lid, uint32_t pres_delay_us, const gaf_codec_id_t* p_codec_id,
const void* p_cfg, const gaf_ltv_t* p_metadata);
/**
****************************************************************************************
* @brief Configure or reconfigure a Broadcast Subgroup.
*
* The Broadcast Group (including the Periodic Advertising) must not be enabled in case of a reconfiguration.
* *
* @param[in] grp_lid Group local index
* @param[in] sgrp_lid Subgroup local index
* @param[in] p_metadata Pointer to metadata value for the subgroup (in LTV format)
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_src_set_subgroup(uint8_t grp_lid, uint8_t sgrp_lid, const gaf_ltv_t* p_metadata);
/**
****************************************************************************************
* @brief Configure or reconfigure a Broadcast Stream and set the Broadcast Subgroup
* it belongs to.
*
* The Broadcast Group (including the Periodic Advertising) must not be enabled in case of
* a reconfiguration.
*
* @param[in] grp_lid Group local index
* @param[in] stream_lid Stream local index
* @param[in] sgrp_lid Subgroup local index
* @param[in] dp_id Datapath ID
* @param[in] ctl_delay_us Controller delay in microseconds
* @param[in] p_cfg Pointer to additional Codec Configuration value (in LTV format)
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_src_set_stream(uint8_t grp_lid, uint8_t stream_lid, uint8_t sgrp_lid, uint8_t dp_id,
uint32_t ctl_delay_us, const gaf_ltv_t* p_cfg);
/**
****************************************************************************************
* @brief Enable Periodic Advertising for a Broadcast Group.
*
* @param[in] grp_lid Group local index.
* @param[in] adv_data_len Length of additional advertising data.
* @param[in] per_adv_data_len Length of additional periodic advertising data.
* @param[in] p_adv_data Pointer to additional advertising data.
* @param[in] p_per_adv_data Pointer to additional periodic advertising data.
*
* @return Function execution status code. (@see enum gaf_err).
* If no error, no new function should be executed until @see bap_bc_src_cb_cmp_evt
* with BAP_BC_SRC_ENABLE_PA command code is called.
****************************************************************************************
*/
uint16_t bap_bc_src_enable_pa(uint8_t grp_lid, uint8_t adv_data_len, uint8_t per_adv_data_len,
const uint8_t* p_adv_data, const uint8_t* p_per_adv_data);
/**
****************************************************************************************
* @brief Disable Periodic Advertising for a Broadcast Group.
*
* @param[in] grp_lid Group local index
*
* @return Function execution status code. (@see enum gaf_err).
* If no error, no new function should be executed until @see bap_bc_src_cb_cmp_evt
* with BAP_BC_SRC_DISABLE_PA command code is called.
****************************************************************************************
*/
uint16_t bap_bc_src_disable_pa(uint8_t grp_lid);
/**
****************************************************************************************
* @brief Enable a Broadcast Group.
*
* @param[in] grp_lid Group local index
* @param[in] p_bcast_code Pointer to Broadcast Code, NULL if streams are not encrypted
*
* @return Function execution status code. (@see enum gaf_err).
* If no error, no new function should be executed until @see bap_bc_src_cb_cmp_evt
* with BAP_BC_SRC_ENABLE command code is called.
****************************************************************************************
*/
uint16_t bap_bc_src_enable(uint8_t grp_lid, const gaf_bcast_code_t* p_bcast_code);
/**
****************************************************************************************
* @brief Disable a Broadcast Group.
*
* Periodic Advertising is also disabled if still enabled when this command is received.
*
* @param[in] grp_lid Group local index
*
* @return Function execution status code. (@see enum gaf_err).
* If no error, no new function should be executed until @see bap_bc_src_cb_cmp_evt
* with BAP_BC_SRC_DISABLE command code is called.
****************************************************************************************
*/
uint16_t bap_bc_src_disable(uint8_t grp_lid);
/**
****************************************************************************************
* @brief Start transmission of audio data on either all streams or on a subset of streams
* within a Broadcast Group.
*
* @param[in] grp_lid Group local index
* @param[in] stream_lid_bf Stream local index bit field indicating for which stream
* streaming must be started. 0xFFFFFFFF means that
* streaming must be started for all BISes
*
* @return Function execution status code. (@see enum gaf_err).
* If no error, no new function should be executed until @see bap_bc_src_cb_cmp_evt
* with BAP_BC_SRC_START_STREAMING command code is called.
****************************************************************************************
*/
uint16_t bap_bc_src_start_streaming(uint8_t grp_lid, uint32_t stream_lid_bf);
/**
****************************************************************************************
* @brief Stop transmission of audio data for either all streams or for a subset of
* streams within a Broadcast Group.
*
* @param[in] grp_lid Group local index
* @param[in] stream_lid_bf Stream local index bit field indicating for which stream
* streaming must be stopped. 0xFFFFFFFF means that
* streaming must be stopped for all BISes
*
* @return Function execution status code. (@see enum gaf_err).
* If no error, no new function should be executed until @see bap_bc_src_cb_cmp_evt
* with BAP_BC_SRC_STOP_STREAMING command code is called.
****************************************************************************************
*/
uint16_t bap_bc_src_stop_streaming(uint8_t grp_lid, uint32_t stream_lid_bf);
#endif //(GAF_BAP_BC_SRC)
/// @}
#endif // BAP_BC_SRC_H_
@@ -0,0 +1,265 @@
/**
****************************************************************************************
*
* @file bap_bc_src_msg.h
*
* @brief Basic Audio Profile - Broadcast Source - Message API Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_BC_SRC_MSG_H_
#define BAP_BC_SRC_MSG_H_
/**
****************************************************************************************
* @addtogroup BAP_BC_SRC Basic Audio Profile - Broadcast Source - Message API Definitions
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap_bc_src.h" // Basic Audio Profile - Broadcast Source Definitions
#include "bap_msg.h" // Message API Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for BAP_BC_SRC_ADD_GROUP, BAP_BC_SRC_SET_GROUP and BAP_BC_SRC_REMOVE_GROUP response message
typedef struct bap_bc_src_rsp
{
/// Request code (@see enum bap_bc_src_req_codes)
/// - BAP_BC_SRC_ADD_GROUP
/// - BAP_BC_SRC_SET_GROUP
/// - BAP_BC_SRC_REMOVE_GROUP
uint16_t req_code;
/// Status of request execution (@see enum gaf_err)
uint16_t status;
/// Group local index
uint8_t grp_lid;
} bap_bc_src_rsp_t;
/// Structure for BAP_BC_SRC_ADD_GROUP request message
typedef struct bap_bc_src_add_group_req
{
/// Request code (@see enum bap_bc_src_req_codes)
/// - BAP_BC_SRC_ADD_GROUP
uint16_t req_code;
/// Number of Streams in the Broadcast Group. Cannot be 0
uint8_t nb_streams;
/// Number of Subgroups in the Broadcast Group. Cannot be 0
uint8_t nb_subgroups;
/// Broadcast Group parameters
bap_bc_grp_param_t grp_param;
/// Advertising parameters
bap_bc_adv_param_t adv_param;
/// Periodic Advertising parameters
bap_bc_per_adv_param_t per_adv_param;
} bap_bc_src_add_group_req_t;
/// Structure for BAP_BC_SRC_SET_GROUP request message
typedef struct bap_bc_src_set_group_req
{
/// Request code (@see enum bap_bc_src_req_codes)
/// - BAP_BC_SRC_SET_GROUP
uint16_t req_code;
/// Group local index
uint8_t grp_lid;
/// Audio output presentation delay in microseconds
uint32_t pres_delay_us;
/// Codec ID value
gaf_codec_id_t codec_id;
/// Length of Codec Configuration value
uint8_t cfg_len;
/// Length of Metadata value
uint8_t metadata_len;
/// Codec Configuration value followed by Metadata value
/// Codec Configuration part to be casted as bap_lc3_cfg_t for LC3 codec.
uint32_t val[__ARRAY_EMPTY];
} bap_bc_src_set_group_req_t;
/// Structure for BAP_BC_SRC_SET_SUBGROUP request message
typedef struct bap_bc_src_set_subgroup_req
{
/// Request code (@see enum bap_bc_src_req_codes)
/// - BAP_BC_SRC_SET_SUBGROUP
uint16_t req_code;
/// Group local index
uint8_t grp_lid;
/// Subgroup local index
uint8_t sgrp_lid;
/// Length of Metadata value for the subgroup
uint8_t metadata_len;
/// Metadata value for the subgroup (in LTV format)
uint8_t metadata[__ARRAY_EMPTY];
} bap_bc_src_set_subgroup_req_t;
/// Structure for BAP_BC_SRC_SET_SUBGROUP response message
typedef struct bap_bc_src_set_subgroup_rsp
{
/// Request code (@see enum bap_bc_src_req_codes)
/// - BAP_BC_SRC_SET_SUBGROUP
uint16_t req_code;
/// Status of request execution (@see enum gaf_err)
uint16_t status;
/// Group local index
uint8_t grp_lid;
/// Subgroup local index
uint8_t sgrp_lid;
} bap_bc_src_set_subgroup_rsp_t;
/// Structure for BAP_BC_SRC_SET_STREAM request message
typedef struct bap_bc_src_set_stream_req
{
/// Request code (@see enum bap_bc_src_req_codes)
/// - BAP_BC_SRC_SET_STREAM
uint16_t req_code;
/// Group local index
uint8_t grp_lid;
/// Subgroup local index the Stream belongs to
uint8_t sgrp_lid;
/// Stream local index
uint8_t stream_lid;
/// Controller delay in microseconds
uint32_t ctl_delay_us;
/// Datapath ID
uint8_t dp_id;
/// Length of Codec Configuration value for the Stream
uint8_t cfg_len;
/// Codec Configuration value for the Stream (in LTV format)
uint8_t cfg[__ARRAY_EMPTY];
} bap_bc_src_set_stream_req_t;
/// Structure for BAP_BC_SRC_SET_SUBGROUP response message
typedef struct bap_bc_src_set_stream_rsp
{
/// Request code (@see enum bap_bc_src_req_codes)
/// - BAP_BC_SRC_SET_SUBGROUP
uint16_t req_code;
/// Status of request execution (@see enum gaf_err)
uint16_t status;
/// Group local index
uint8_t grp_lid;
/// Subgroup local index
uint8_t sgrp_lid;
/// Stream local index
uint8_t stream_lid;
} bap_bc_src_set_stream_rsp_t;
/// Structure for BAP_BC_SRC_REMOVE_GROUP request message
typedef struct bap_bc_src_remove_group_req
{
/// Request code (@see enum bap_bc_src_cmd_codes)
/// - BAP_BC_SRC_REMOVE_GROUP
uint16_t req_code;
/// Group local index
uint8_t grp_lid;
} bap_bc_src_remove_group_req_t;
/// Structure for command complete message
typedef struct bap_bc_src_cmp_evt
{
/// Command code (@see enum bap_bc_src_cmd_codes)
/// - BAP_BC_SRC_ENABLE_PA
/// - BAP_BC_SRC_ENABLE
/// - BAP_BC_SRC_START_STREAMING
/// - BAP_BC_SRC_STOP_STREAMING
/// - BAP_BC_SRC_DISABLE_PA
/// - BAP_BC_SRC_DISABLE
uint16_t cmd_code;
/// Status of command execution (@see enum gaf_err)
uint16_t status;
/// Group local index
uint8_t grp_lid;
/// Stream local index bit field. Meaningful only for
/// BAP_BC_SRC_START_STREAMING and BAP_BC_SRC_STOP_STREAMING commands
uint32_t stream_lid_bf;
} bap_bc_src_cmp_evt_t;
/// Structure for BAP_BC_SRC_ENABLE_PA command message
typedef struct bap_bc_src_enable_pa_cmd
{
/// Request code (@see enum bap_bc_src_cmd_codes)
/// - BAP_BC_SRC_ENABLE_PA
uint16_t cmd_code;
/// Group local index
uint8_t grp_lid;
/// Length of additional advertising data
uint8_t adv_data_len;
/// Length of additional periodic advertising data
uint8_t per_adv_data_len;
/// Additional advertising data followed by additional periodic advertising data
uint8_t data[__ARRAY_EMPTY];
} bap_bc_src_enable_pa_cmd_t;
/// Structure for BAP_BC_SRC_ENABLE command message
typedef struct bap_bc_src_enable_cmd
{
/// Request code (@see enum bap_bc_src_cmd_codes)
/// - BAP_BC_SRC_ENABLE
uint16_t cmd_code;
/// Group local index
uint8_t grp_lid;
/// Indicate if streams are encrypted (!= 0) or not
uint8_t encrypted;
/// Broadcast code. Meaningful only if encrypted parameter indicates that streams are encrypted
gaf_bcast_code_t bcast_code;
} bap_bc_src_enable_cmd_t;
/// Structure for BAP_BC_SRC_START_STREAMING command message
typedef struct bap_bc_src_start_streaming_cmd
{
/// Request code (@see enum bap_bc_src_cmd_codes)
/// - BAP_BC_SRC_START_STREAMING
uint16_t cmd_code;
/// Group local index
uint8_t grp_lid;
/// Stream local index bit field indicating for which stream streaming must be started
/// 0xFFFFFFFF means that streaming must be started for all BISes
uint32_t stream_lid_bf;
} bap_bc_src_start_streaming_cmd_t;
/// Structure for BAP_BC_SRC_STOP_STREAMING command message
typedef struct bap_bc_src_stop_streaming_cmd
{
/// Request code (@see enum bap_bc_src_cmd_codes)
/// - BAP_BC_SRC_STOP_STREAMING
uint16_t cmd_code;
/// Group local index
uint8_t grp_lid;
/// Stream local index bit field indicating for which stream streaming must be stopped
/// 0xFFFFFFFF means that streaming must be stopped for all BISes
uint32_t stream_lid_bf;
} bap_bc_src_stop_streaming_cmd_t;
/// Structure for BAP_BC_SRC_DISABLE_PA command message
typedef struct bap_bc_src_disable_pa_cmd
{
/// Request code (@see enum bap_bc_src_cmd_codes)
/// - BAP_BC_SRC_DISABLE_PA
uint16_t cmd_code;
/// Group local index
uint8_t grp_lid;
} bap_bc_src_disable_pa_cmd_t;
/// Structure for BAP_BC_SRC_DISABLE command message
typedef struct bap_bc_src_disable_cmd
{
/// Request code (@see enum bap_bc_src_cmd_codes)
/// - BAP_BC_SRC_DISABLE
uint16_t cmd_code;
/// Group local index
uint8_t grp_lid;
} bap_bc_src_disable_cmd_t;
/// @}
#endif // BAP_BC_SRC_MSG_H_
@@ -0,0 +1,144 @@
/**
****************************************************************************************
*
* @file bap_capa.h
*
* @brief Basic Audio Profile - Capabilities - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_CAPA_H_
#define BAP_CAPA_H_
/**
****************************************************************************************
* @addtogroup BAP_CAPA Basic Audio Profile - Capabilities
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap.h" // Basic Audio Profile Definitions
#include "gaf_inc.h" // Generic Audio Framework Included Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Characteristic type values for Published Audio Capabilities Service
enum bap_capa_char_type
{
/// Available Audio Contexts characteristic
BAP_CAPA_CHAR_TYPE_CONTEXT_AVA = 0,
/// Supported Audio Contexts characteristic
BAP_CAPA_CHAR_TYPE_CONTEXT_SUPP,
/// Sink Audio Locations characteristic
BAP_CAPA_CHAR_TYPE_LOC_SINK,
/// Source Audio Locations characteristic
BAP_CAPA_CHAR_TYPE_LOC_SRC,
/// PAC characteristic
BAP_CAPA_CHAR_TYPE_PAC,
BAP_CAPA_CHAR_TYPE_MAX,
};
/// Audio Locations bit field positions
enum bap_capa_audio_loc_bf_pos
{
/// Front Left
BAP_CAPA_LOC_FRONT_LEFT_POS = 0,
/// Front Right
BAP_CAPA_LOC_FRONT_RIGHT_POS,
/// Front Center
BAP_CAPA_LOC_FRONT_CENTER_POS,
/// Low Frequency Effect 1
BAP_CAPA_LOC_LFE1_POS,
/// Back Left
BAP_CAPA_LOC_BACK_LEFT_POS,
/// Back Right
BAP_CAPA_LOC_BACK_RIGHT_POS,
/// Front Left Center
BAP_CAPA_LOC_FRONT_LEFT_CENTER_POS,
/// Front Right Center
BAP_CAPA_LOC_FRONT_RIGHT_CENTER_POS,
/// Back Center
BAP_CAPA_LOC_BACK_CENTER_POS,
/// Low Frequency Effect 2
BAP_CAPA_LOC_LFE2_POS,
/// Side Left
BAP_CAPA_LOC_SIDE_LEFT_POS,
/// Side Right
BAP_CAPA_LOC_SIDE_RIGHT_POS,
/// Top Front Left
BAP_CAPA_LOC_TOP_FRONT_LEFT_POS,
/// Top Front Right
BAP_CAPA_LOC_TOP_FRONT_RIGHT_POS,
/// Top Front Center
BAP_CAPA_LOC_TOP_FRONT_CENTER_POS,
/// Top Center
BAP_CAPA_LOC_TOP_CENTER_POS,
/// Top Back Left
BAP_CAPA_LOC_TOP_BACK_LEFT_POS,
/// Top Back Right
BAP_CAPA_LOC_TOP_BACK_RIGHT_POS,
/// Top Side Left
BAP_CAPA_LOC_TOP_SIDE_LEFT_POS,
/// Top Side Right
BAP_CAPA_LOC_TOP_SIDE_RIGHT_POS,
/// Top Back Center
BAP_CAPA_LOC_TOP_BACK_CENTER_POS,
/// Bottom Front Center
BAP_CAPA_LOC_BOTTOM_FRONT_CENTER_POS,
/// Bottom Front Left
BAP_CAPA_LOC_BOTTOM_FRONT_LEFT_POS,
/// Bottom Front Right
BAP_CAPA_LOC_BOTTOM_FRONT_RIGHT_POS,
/// Front Left Wide
BAP_CAPA_LOC_FRONT_LEFT_WIDE_POS,
/// Front Right Wide
BAP_CAPA_LOC_FRONT_RIGHT_WIDE_POS,
/// Front Left Surround
BAP_CAPA_LOC_FRONT_LEFT_SURROUND_POS,
/// Front Right Surround
BAP_CAPA_LOC_FRONT_RIGHT_SURROUND_POS,
};
/// Sampling Frequency bit field positions
enum bap_capa_samp_freq_pos
{
/// 8 kHz
BAP_CAPA_SAMP_FREQ_8_POS = 0,
/// 16 kHz
BAP_CAPA_SAMP_FREQ_16_POS,
/// 24 kHz
BAP_CAPA_SAMP_FREQ_24_POS,
/// 32 kHz
BAP_CAPA_SAMP_FREQ_32_POS,
/// 44.1 kHz
BAP_CAPA_SAMP_FREQ_44_1_POS,
/// 48 kHz
BAP_CAPA_SAMP_FREQ_48_POS,
};
/// Context type values
enum bap_capa_context_type
{
/// Supported Audio Contexts
BAP_CAPA_CONTEXT_TYPE_SUPP = 0,
/// Available Audio Contexts
BAP_CAPA_CONTEXT_TYPE_AVA,
BAP_CAPA_CONTEXT_TYPE_MAX
};
/// @}
#endif // BAP_CAPA_H_
@@ -0,0 +1,335 @@
/**
****************************************************************************************
*
* @file bap_capa_cli.h
*
* @brief Basic Audio Profile - Capabilities Client - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_CAPA_CLI_H_
#define BAP_CAPA_CLI_H_
/**
****************************************************************************************
* @addtogroup BAP_CAPA_CLI Basic Audio Profile - Capabilities Client
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "bap_capa.h" // Basic Audio Profile - Capabilities Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of command types for BAP Capabilities Client
enum bap_capa_cli_cmd_type
{
BAP_CAPA_CLI_CMD_TYPE_DISCOVER = 0,
BAP_CAPA_CLI_CMD_TYPE_GET,
BAP_CAPA_CLI_CMD_TYPE_GET_CFG,
BAP_CAPA_CLI_CMD_TYPE_SET_CFG,
BAP_CAPA_CLI_CMD_TYPE_SET_LOCATION,
};
/// List of GAF_CMD command codes for BAP Capabilities Client
enum bap_capa_cli_cmd_code
{
BAP_CAPA_CLI_DISCOVER = GAF_CODE(BAP, CAPA_CLI, BAP_CAPA_CLI_CMD_TYPE_DISCOVER),
BAP_CAPA_CLI_GET = GAF_CODE(BAP, CAPA_CLI, BAP_CAPA_CLI_CMD_TYPE_GET),
BAP_CAPA_CLI_GET_CFG = GAF_CODE(BAP, CAPA_CLI,BAP_CAPA_CLI_CMD_TYPE_GET_CFG),
BAP_CAPA_CLI_SET_CFG = GAF_CODE(BAP, CAPA_CLI, BAP_CAPA_CLI_CMD_TYPE_SET_CFG),
BAP_CAPA_CLI_SET_LOCATION = GAF_CODE(BAP, CAPA_CLI, BAP_CAPA_CLI_CMD_TYPE_SET_LOCATION),
};
/// List of GAF_REQ request codes for BAP Capabilities Client
enum bap_capa_cli_req_code
{
BAP_CAPA_CLI_RESTORE_BOND_DATA = GAF_CODE(BAP, CAPA_CLI, 0),
};
/// List of GAF_IND indication codes for BAP Capabilities Client
enum bap_capa_cli_ind_code
{
BAP_CAPA_CLI_BOND_DATA = GAF_CODE(BAP, CAPA_CLI, 0),
BAP_CAPA_CLI_RECORD = GAF_CODE(BAP, CAPA_CLI, 1),
BAP_CAPA_CLI_LOCATION = GAF_CODE(BAP, CAPA_CLI, 2),
BAP_CAPA_CLI_CONTEXT = GAF_CODE(BAP, CAPA_CLI, 3),
BAP_CAPA_CLI_CFG = GAF_CODE(BAP, CAPA_CLI, 4),
BAP_CAPA_CLI_SVC_CHANGED = GAF_CODE(BAP, CAPA_CLI, 5),
};
/// Optional features bit field meaning
enum bap_capa_cli_feat_bf
{
/// Indicate if Sink Audio Locations characteristic is writable or not
BAP_CAPA_CLI_FEAT_SINK_LOC_WR_POS = 0,
BAP_CAPA_CLI_FEAT_SINK_LOC_WR_BIT = CO_BIT(BAP_CAPA_CLI_FEAT_SINK_LOC_WR_POS),
/// Indicate if Sink Audio Locations characteristic is writable or not
BAP_CAPA_CLI_FEAT_SRC_LOC_WR_POS = 1,
BAP_CAPA_CLI_FEAT_SRC_LOC_WR_BIT = CO_BIT(BAP_CAPA_CLI_FEAT_SRC_LOC_WR_POS),
};
/*
* TYPES DEFINITION
****************************************************************************************
*/
/// Published Audio Capabilities Service characteristic description structure
typedef struct bap_capa_cli_pacs_char
{
/// Characteristic value handle
uint16_t val_hdl;
/// Client Characteristic Configuration descriptor handle
uint16_t desc_hdl;
} bap_capa_cli_pacs_char_t;
/// Published Audio Capabilities Service content description structure
typedef struct bap_capa_cli_pacs
{
/// Service description
prf_svc_t svc_info;
/// Number of PAC Groups for Sink direction
uint8_t nb_pacs_sink;
/// Number of PAC Group for Source direction
uint8_t nb_pacs_src;
/// Optional features bit field (@see enum bap_capa_cli_feat_bf)
uint8_t opt_feat_bf;
/// Characteristic information structures
bap_capa_cli_pacs_char_t char_info[__ARRAY_EMPTY];
} bap_capa_cli_pacs_t;
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called each time a command has been completed
*
* @param[in] cmd_code Command code (@see enum bap_capa_cli_cmd_code)
* @param[in] status Status
* @param[in] con_lid Connection local index
* @param[in] param_1 Characteristic type or Direction
* - Direction: Meaningful only for BAP_CAPA_CLI_SET_LOCATION command (@see enum gaf_direction)
* - Characteristic type: Meaningless for BAP_CAPA_CLI_SET_LOCATION and BAP_CAPA_CLI_DISCOVER
* commands (@see enum bap_capa_char_type)
* @param[in] pac_lid PAC local index
****************************************************************************************
*/
typedef void (*bap_capa_cli_cb_cmp_evt)(uint16_t cmd_code, uint16_t status, uint8_t con_lid,
uint8_t param_1, uint8_t pac_lid);
/**
****************************************************************************************
* @brief Callback function called when Published Audio Capabilities Service has been discovered in a peer service
* device database
*
* @param[in] con_lid Connection local index
* @param[in] p_pacs_info Pointer to Published Audio Capabilities Service content description structure
****************************************************************************************
*/
typedef void (*bap_capa_cli_cb_bond_data)(uint8_t con_lid, bap_capa_cli_pacs_t* p_pacs_info);
/**
****************************************************************************************
* @brief Callback function called when a PAC record has been received from a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] pac_lid PAC local index
* @param[in] record_lid Record local index
* @param[in] nb_records Number of records
* @param[in] p_codec_id Pointer to Codec ID
* @param[in] p_codec_capa Pointer to Codec Specific Capabilities value
****************************************************************************************
*/
typedef void (*bap_capa_cli_cb_record)(uint8_t con_lid, uint8_t pac_lid, uint8_t record_lid, uint8_t nb_records,
gaf_codec_id_t* p_codec_id, void* p_codec_capa);
/**
****************************************************************************************
* @brief Callback function called when value for Sink/Source Audio Locations characteristic has been received from
* a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] direction Direction (@see enum gaf_direction)
* @param[in] location_bf Location bit field
****************************************************************************************
*/
typedef void (*bap_capa_cli_cb_location)(uint8_t con_lid, uint8_t direction, uint32_t location_bf);
/**
****************************************************************************************
* @brief Callback function called when value for Sink/Source Audio Locations or Audio Content Availability or
* Supported Audio Content characteristic has been received from a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] context_type Context type (@see enum bap_capa_context_type)
* @param[in] context_bf_sink Context bit field for Sink direction
* @param[in] context_bf_src Context bit field for Source direction
****************************************************************************************
*/
typedef void (*bap_capa_cli_cb_context)(uint8_t con_lid, uint8_t context_type,
uint16_t context_bf_sink, uint16_t context_bf_src);
/**
****************************************************************************************
* @brief Callback function called when a client characteristic configuration value has been received from a peer
* server device
*
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type (@see enum bap_capa_char_type)
* @param[in] pac_lid PAC local index for Sink/Source PAC characteristic
* @param[in] enabled Indicate if sending of event is enabled (!= 0) or not
****************************************************************************************
*/
typedef void (*bap_capa_cli_cb_cfg)(uint8_t con_lid, uint8_t char_type, uint8_t pac_lid, uint8_t enabled);
/**
****************************************************************************************
* @brief Callback function called when service changed indication for the Published Audio Capabilities Service has
* been received
*
* @param[in] con_lid Connection local index
****************************************************************************************
*/
typedef void (*bap_capa_cli_cb_svc_changed)(uint8_t con_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for BAP Capabilities Client module
typedef struct bap_capa_cli_cb
{
/// Callback function called when a command has been completed
bap_capa_cli_cb_cmp_evt cb_cmp_evt;
/// Callback function called when Published Audio Capabilities Service instance has been discovered in a peer
/// server database
bap_capa_cli_cb_bond_data cb_bond_data;
/// Callback function called when a PAC record has been received from a peer server device
bap_capa_cli_cb_record cb_record;
/// Callback function called when value for Sink/Source Audio Locations characteristic has been received from a
/// peer server device
bap_capa_cli_cb_location cb_location;
/// Callback function called when value for Available Audio Contexts or Supported Audio Contexts characteristic
/// has been received from a peer server device
bap_capa_cli_cb_context cb_context;
/// Callback function called when a client characteristic configuration value has been received from a peer server
/// device
bap_capa_cli_cb_cfg cb_cfg;
/// Callback function called when service changed indication for the Published Audio Capabilities Service has been
/// received
bap_capa_cli_cb_svc_changed cb_svc_changed;
} bap_capa_cli_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
#if (GAF_BAP_CAPA_CLI)
/**
****************************************************************************************
* @brief Discover Audio Capabilities exposed by a Server device.
*
* @param[in] con_lid Connection local index
*
* @return An error status. cb_cmp_evt callback function called once procedure is finished.
****************************************************************************************
*/
uint16_t bap_capa_cli_discover(uint8_t con_lid);
/**
****************************************************************************************
* @brief Restore Published Capabilities Audio Service information after connection with a server device with which
* discovery has already been performed and with which a trusted relationship has been established.
*
* @param[in] con_lid Connection local index
* @param[in] p_pacs_info Pointer to Service information structure
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_capa_cli_restore_bond_data(uint8_t con_lid, bap_capa_cli_pacs_t* p_pacs_info);
/**
****************************************************************************************
* @brief Set value for either Source Audio Locations or Sink Audio Locations characteristic of a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] direction Direction
* @param[in] location_bf Location bit field
*
* @return An error status. cb_cmp_evt callback function called once procedure is finished.
****************************************************************************************
*/
uint16_t bap_capa_cli_set_location(uint8_t con_lid, uint8_t direction, uint32_t location_bf);
#if (GAF_DBG)
/**
****************************************************************************************
* @brief Get value for either Source Audio Locations or Sink Audio Locations or Sink PAC or Source PAC or Available
* Audio Contexts or Supported Audio Contexts characteristic of a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] pac_lid PAC local index for Sink/Source PAC characteristic
*
* @return An error status. cb_cmp_evt callback function called once procedure is finished.
****************************************************************************************
*/
uint16_t bap_capa_cli_get(uint8_t con_lid, uint8_t char_type, uint8_t pac_lid);
/**
****************************************************************************************
* @brief Get Client Characteristic Configuration Descriptor value for either Source Audio Locations or Sink Audio
* Locations or Sink PAC or Source PAC or Available Audio Contexts or Supported Audio Contexts characteristic of a peer
* server device
*
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] pac_lid PAC local index for Sink/Source PAC characteristic
*
* @return An error status. cb_cmp_evt callback function called once procedure is finished.
****************************************************************************************
*/
uint16_t bap_capa_cli_get_cfg(uint8_t con_lid, uint8_t char_type, uint8_t pac_lid);
/**
****************************************************************************************
* @brief Set Client Characteristic Configuration Descriptor value for either Source Audio Locations or Sink Audio
* Locations or Sink PAC or Source PAC or Available Audio Contexts or Supported Audio Contexts characteristic of a peer
* server device
*
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] pac_lid PAC local index for Sink/Source PAC characteristic
* @param[in] enable Indicate if sending of events must be enabled (!= 0) or disabled
*
* @return An error status. cb_cmp_evt callback function called once procedure is finished.
****************************************************************************************
*/
uint16_t bap_capa_cli_set_cfg(uint8_t con_lid, uint8_t char_type, uint8_t pac_lid, uint8_t enable);
#endif //(GAF_DBG)
#endif //(GAF_BAP_CAPA_CLI)
/// @}
#endif // BAP_CAPA_CLI_H_
@@ -0,0 +1,243 @@
/**
****************************************************************************************
*
* @file bap_capa_cli_msg.h
*
* @brief Basic Audio Profile - Definition of Kernel Messages (Capabilities Client)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_CAPA_CLI_MSG_H_
#define BAP_CAPA_CLI_MSG_H_
/**
****************************************************************************************
* @addtogroup BAP_CAPA_CLI_MSG Basic Audio Profile - Definition of Kernel Messages (Capabilities Client)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap_msg.h" // Basic Audio Profile Kernel Messages Definitions
#include "bap_capa_cli.h" // Basic Audio Profile - Capabilities Client Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for BAP_CAPA_CLI_DISCOVER command message
typedef struct bap_capa_cli_discover_cmd
{
/// Command code (@see enum bap_capa_cli_cmd_code)
/// - BAP_CAPA_CLI_DISCOVER
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
} bap_capa_cli_discover_cmd_t;
/// Structure for BAP_CAPA_CLI_GET command message
typedef struct bap_capa_cli_get_cmd
{
/// Command code (@see enum bap_capa_cli_cmd_code)
/// - BAP_CAPA_CLI_GET
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Characteristic type (@enum bap_capa_char_type)
uint8_t char_type;
/// PAC local index
uint8_t pac_lid;
} bap_capa_cli_get_cmd_t;
/// Structure for BAP_CAPA_CLI_GET_CFG command message
typedef struct bap_capa_cli_get_cfg_cmd
{
/// Command code (@see enum bap_capa_cli_cmd_code)
/// - BAP_CAPA_CLI_GET_CFG
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Characteristic type (@enum bap_capa_char_type)
uint8_t char_type;
/// PAC local index
uint8_t pac_lid;
} bap_capa_cli_get_cfg_cmd_t;
/// Structure for BAP_CAPA_CLI_SET_CFG command message
typedef struct bap_capa_cli_set_cfg_cmd
{
/// Command code (@see enum bap_capa_cli_cmd_code)
/// - BAP_CAPA_CLI_SET_CFG
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Characteristic type (@enum bap_capa_char_type)
uint8_t char_type;
/// PAC local index
uint8_t pac_lid;
/// Enable
uint8_t enable;
} bap_capa_cli_set_cfg_cmd_t;
/// Structure for BAP_CAPA_CLI_SET_LOCATION command message
typedef struct bap_capa_cli_set_location_cmd
{
/// Command code (@see enum bap_capa_cli_cmd_code)
/// - BAP_CAPA_CLI_SET_LOCATION
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Direction (@see enum gaf_direction)
uint8_t direction;
/// Location bit field
uint32_t location_bf;
} bap_capa_cli_set_location_cmd_t;
/// Structure for command complete event message
typedef struct bap_capa_cli_cmp_evt
{
/// Command code (@see enum bap_capa_cli_cmd_code)
uint16_t cmd_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
union
{
uint8_t param;
/// Direction (@see enum gaf_direction)
/// Meaningful only for BAP_CAPA_CLI_SET_LOCATION command
uint8_t direction;
/// Characteristic type (@enum bap_capa_char_type)
/// Meaningless for BAP_CAPA_CLI_SET_LOCATION and BAP_CAPA_CLI_DISCOVER commands
uint8_t char_type;
} u;
/// PAC local index
/// Meaningless for BAP_CAPA_CLI_SET_LOCATION and BAP_CAPA_CLI_DISCOVER commands
uint8_t pac_lid;
} bap_capa_cli_cmp_evt_t;
/// Structure for BAP_CAPA_CLI_RESTORE_BOND_DATA request message
typedef struct bap_capa_cli_restore_bond_data_req
{
/// Request code (@see enum bap_capa_cli_req_code)
/// - BAP_CAPA_CLI_RESTORE_BOND_DATA
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Published Audio Capabilities Service content description
bap_capa_cli_pacs_t pacs_info;
} bap_capa_cli_restore_bond_data_req_t;
/// Structure for response message
typedef struct bap_capa_cli_rsp
{
/// Request code (@see enum bap_capa_cli_req_code)
uint16_t req_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
} bap_capa_cli_rsp_t;
/// Structure for BAP_CAPA_CLI_BOND_DATA indication message
typedef struct bap_capa_cli_bond_data_ind
{
/// Indication code (@see enum bap_capa_cli_ind_code)
/// - BAP_CAPA_CLI_BOND_DATA
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Published Audio Capabilities Service content description
bap_capa_cli_pacs_t pacs_info;
} bap_capa_cli_bond_data_ind_t;
/// Structure for BAP_CAPA_CLI_RECORD indication message
typedef struct bap_capa_cli_record_ind
{
/// Indication code (@see enum bap_capa_cli_ind_code)
/// - BAP_CAPA_CLI_RECORD
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// PAC local index
uint8_t pac_lid;
/// Record local index
uint8_t record_lid;
/// Number of records
uint8_t nb_records;
/// Codec ID
gaf_codec_id_t codec_id;
/// Length of Codec Capabilities value
uint16_t capa_len;
/// Codec Capabilities value
uint8_t capa[__ARRAY_EMPTY];
} bap_capa_cli_record_ind_t;
/// Structure for BAP_CAPA_CLI_CONTEXT indication message
typedef struct bap_capa_cli_context_ind
{
/// Indication code (@see enum bap_capa_cli_ind_code)
/// - BAP_CAPA_CLI_CONTEXT
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Context type (@see enum bap_capa_context_type)
uint8_t context_type;
/// Context type bit field for Sink direction
uint16_t context_bf_sink;
/// Context type bit field for Source direction
uint16_t context_bf_src;
} bap_capa_cli_context_ind_t;
/// Structure for BAP_CAPA_CLI_LOCATION indication message
typedef struct bap_capa_cli_location_ind
{
/// Indication code (@see enum bap_capa_cli_ind_code)
/// - BAP_CAPA_CLI_LOCATION
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Direction (@see enum gaf_direction)
uint8_t direction;
/// Location bit field
uint32_t location_bf;
} bap_capa_cli_location_ind_t;
/// Structure for BAP_CAPA_CLI_CFG indication message
typedef struct bap_capa_cli_cfg_ind
{
/// Indication code (@see enum bap_capa_cli_ind_code)
/// - BAP_CAPA_CLI_CFG
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Characteristic type (@see enum bap_capa_char_type)
uint8_t char_type;
/// PAC local index for Sink/Source PAC characteristic
uint8_t pac_lid;
/// Indicate if sending of notifications is enabled (!= 0) for the indicated characteristic
uint8_t enabled;
} bap_capa_cli_cfg_ind_t;
/// Structure for BAP_CAPA_CLI_SVC_CHANGED indication message
typedef struct bap_capa_cli_svc_changed_ind
{
/// Indication code (@see enum bap_capa_cli_ind_code)
/// - BAP_CAPA_CLI_SVC_CHANGED
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
} bap_capa_cli_svc_changed_ind_t;
/// @}
#endif // BAP_CAPA_CLI_MSG_H_
@@ -0,0 +1,219 @@
/**
****************************************************************************************
*
* @file bap_capa_srv.h
*
* @brief Basic Audio Profile - Capabilities Server - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_CAPA_SRV_H_
#define BAP_CAPA_SRV_H_
/**
****************************************************************************************
* @addtogroup BAP_CAPA_SRV Basic Audio Profile - Capabilities Server
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "bap_capa.h" // Basic Audio Profile - Capabilities Definitions
/*
* DEFINES
****************************************************************************************
*/
/// Maximum number of PACs
#define BAP_CAPA_SRV_PAC_NB_MAX (15)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for BAP Capabilities Server
enum bap_capa_srv_req_code
{
BAP_CAPA_SRV_SET_RECORD = GAF_CODE(BAP, CAPA_SRV, 0),
BAP_CAPA_SRV_REMOVE_RECORD = GAF_CODE(BAP, CAPA_SRV, 1),
BAP_CAPA_SRV_RESTORE_BOND_DATA = GAF_CODE(BAP, CAPA_SRV, 2),
BAP_CAPA_SRV_SET_LOCATION = GAF_CODE(BAP, CAPA_SRV, 3),
BAP_CAPA_SRV_SET_CONTEXT = GAF_CODE(BAP, CAPA_SRV, 4),
};
/// List of GAF_IND indication codes for BAP Capabilities Server
enum bap_capa_srv_ind_code
{
BAP_CAPA_SRV_BOND_DATA = GAF_CODE(BAP, CAPA_SRV, 0),
BAP_CAPA_SRV_LOCATION = GAF_CODE(BAP, CAPA_SRV, 1),
};
/// Service configuration bit field meaning
enum bap_capa_srv_cfg_bf
{
/// Indicate if sending of notifications is supported for Sink/Source PACs characteristics
BAP_CAPA_SRV_CFG_PAC_NTF_POS = 0,
BAP_CAPA_SRV_CFG_PAC_NTF_BIT = CO_BIT(BAP_CAPA_SRV_CFG_PAC_NTF_POS),
/// Indicate if sending of notifications is supported for Sink/Source Audio Locations characteristic
BAP_CAPA_SRV_CFG_LOC_NTF_POS = 1,
BAP_CAPA_SRV_CFG_LOC_NTF_BIT = CO_BIT(BAP_CAPA_SRV_CFG_LOC_NTF_POS),
/// Indicate if sending of notifications is supported for Supported Audio Contexts characteristic
BAP_CAPA_SRV_CFG_SUPP_CONTEXT_NTF_POS = 2,
BAP_CAPA_SRV_CFG_SUPP_CONTEXT_NTF_BIT = CO_BIT(BAP_CAPA_SRV_CFG_SUPP_CONTEXT_NTF_POS),
/// Indicate if Sink/Source Audio Locations characteristics are writable
/// If these characteristic are writable, sending of notifications will also be supported
BAP_CAPA_SRV_CFG_LOC_WR_POS = 3,
BAP_CAPA_SRV_CFG_LOC_WR_BIT = CO_BIT(BAP_CAPA_SRV_CFG_LOC_WR_POS),
};
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called when client configuration for Published Audio Capabilities Service has been
* updated
*
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field (no direction)
* @param[in] pac_cli_cfg_bf Client configuration bit field for sink direction
****************************************************************************************
*/
typedef void (*bap_capa_srv_cb_bond_data)(uint8_t con_lid, uint8_t cli_cfg_bf, uint16_t pac_cli_cfg_bf);
/**
****************************************************************************************
* @brief Callback function called when either Sink Audio Locations or Source Audio Locations characteristic has been
* written by a client device
*
* @param[in] con_lid Connection local index
* @param[in] direction Direction (@see enum gaf_direction)
* @param[in] location_bf Location bit field
****************************************************************************************
*/
typedef void (*bap_capa_srv_cb_location)(uint8_t con_lid, uint8_t direction, uint32_t location_bf);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for BAP Capabilities Server module
typedef struct bap_capa_srv_cb
{
/// Callback function called when client configuration for Published Audio Capabilities Service has been updated
bap_capa_srv_cb_bond_data cb_bond_data;
/// Callback function called when either Sink Audio Locations or Source Audio Locations characteristic has been
/// written by a client device
bap_capa_srv_cb_location cb_location;
} bap_capa_srv_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
#if (GAF_BAP_CAPA_SRV)
/**
****************************************************************************************
* @brief Add or update a PAC Record.
* PAC Record is identified using a Record ID provided by the upper layer. The provided Record ID shall be unique
* (meaning not used for any other PAC Record whatever the PAC Group it belongs to).
*
* @param[in] pac_lid PAC local index
* @param[in] record_id Record identifier
* @param[in] p_codec_id Pointer to Codec ID value
* @param[in] p_codec_capa Pointer to Codec Capabilities structure
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_capa_srv_set_record(uint8_t pac_lid, uint8_t record_id, gaf_codec_id_t* p_codec_id, void* p_codec_capa);
/**
****************************************************************************************
* @brief Remove a PAC record
*
* @param[in] record_id Record identifier
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_capa_srv_remove_record(uint8_t record_id);
/**
****************************************************************************************
* @brief Set bonding information related to Published Audio Capabilities Service after
* connection with a peer device
*
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field
* Each bit corresponds to a characteristic in the range [0, BAP_CAPA_CHAR_TYPE_PAC[
* @param[in] pac_cli_cfg_bf Client configuration bit field for Sink/Source PAC characteristic
* Each bit corresponds to an instance of the Sink/Source PAC characteristic
* (Sink placed first)
* @param[in] evt_bf Event bit field
* Each bit corresponds to a characteristic in the range [0, BAP_CAPA_CHAR_TYPE_PAC[
* @param[in] pac_evt_bf Event configuration bit field for Sink/Source PAC characteristics
* Each bit corresponds to an instance of the Sink/Source PAC characteristic
* (Sink placed first)
* @param[in] context_bf_sink Available Audio Contexts for Sink direction
* @param[in] context_bf_src Available Audio Contexts for Source direction
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_capa_srv_restore_bond_data(uint8_t con_lid, uint8_t cli_cfg_bf, uint16_t pac_cli_cfg_bf, uint8_t evt_bf,
uint16_t pac_evt_bf, uint16_t context_bf_sink, uint16_t context_bf_src);
/**
****************************************************************************************
* @brief Update value of either Available Audio Contexts or Supported Audio Contexts characteristic
*
* @param[in] context_type Context type (@see enum bap_capa_context_type)
* @param[in] con_lid Connection local index
* Meaningful only for Available Audio Contexts value
* Must be set to GAP_INVALID_CONIDX if indicated audio contexts are available for all
* connections
* @param[in] context_bf_sink Context bit field for Sink direction
* @param[in] context_bf_src Context bit field for Source direction
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_capa_srv_set_context(uint8_t context_type, uint8_t con_lid, uint16_t context_bf_sink,
uint16_t context_bf_src);
/**
****************************************************************************************
* @brief Update value of either Sink Audio Locations or Source Audio Locations characteristic
*
* @param[in] direction Direction (@see enum gaf_direction)
* @param[in] location_bf Location bit field
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_capa_srv_set_location(uint8_t direction, uint32_t location_bf);
#endif //(GAF_BAP_CAPA_SRV)
/// @}
#endif // BAP_CAPA_SRV_H_
@@ -0,0 +1,182 @@
/**
****************************************************************************************
*
* @file bap_capa_srv_msg.h
*
* @brief Basic Audio Profile - Definition of Kernel Messages (Capabilities Server)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_CAPA_SRV_MSG_H_
#define BAP_CAPA_SRV_MSG_H_
/**
****************************************************************************************
* @addtogroup BAP_CAPA_SRV_MSG Basic Audio Profile - Definition of Kernel Messages
* (Capabilities Server)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap_msg.h" // Basic Audio Profile Kernel Messages Definitions
#include "bap_capa_srv.h" // Basic Audio Profile - Capabilities Server Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for BAP_CAPA_SRV_RESTORE_BOND_DATA request message
typedef struct bap_capa_srv_restore_bond_data_req
{
/// Request code (@see enum bap_capa_srv_req_code)
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
/// Each bit corresponds to a characteristic in the range [0, BAP_CAPA_CHAR_TYPE_PAC[
uint8_t cli_cfg_bf;
/// Client configuration bit field for Sink/Source PAC characteristic
/// Each bit corresponds to an instance of the Sink/Source PAC characteristic (Sink placed first)
uint16_t pac_cli_cfg_bf;
/// Event bit field
/// Each bit corresponds to a characteristic in the range [0, BAP_CAPA_CHAR_TYPE_PAC[
uint8_t evt_bf;
/// Event configuration bit field for Sink/Source PAC characteristics
/// Each bit corresponds to an instance of the Sink/Source PAC characteristic (Sink placed first)
uint16_t pac_evt_bf;
/// Available Audio Contexts for Sink direction
uint16_t context_bf_sink;
/// Available Audio Contexts for Source direction
uint16_t context_bf_src;
} bap_capa_srv_restore_bond_data_req_t;
/// Structure for BAP_CAPA_SRV_SET_RECORD request message
typedef struct bap_capa_srv_set_record_req
{
/// Request code (@see enum bap_capa_srv_req_code)
uint16_t req_code;
/// PAC local index
uint8_t pac_lid;
/// Record identifier
uint8_t record_id;
/// Codec ID
gaf_codec_id_t codec_id;
/// Length of Codec Capabilities structure value
uint16_t capa_len;
/// Codec Capabilities structure value
/// To be casted as bap_lc3_capa_t for LC3.
/// To be casted as bap_vendor_codec_capa_t for Vendor Codec
uint8_t capa[__ARRAY_EMPTY];
} bap_capa_srv_set_record_req_t;
/// Structure for BAP_CAPA_SRV_REMOVE_RECORD request message
typedef struct bap_capa_srv_remove_record_req
{
/// Request code (@see enum bap_capa_srv_req_code)
uint16_t req_code;
/// Record identifier
uint8_t record_id;
} bap_capa_srv_remove_record_req_t;
/// Structure for BAP_CAPA_SRV_SET_LOCATION request message
typedef struct bap_capa_srv_set_location_req
{
/// Request code (@see enum bap_capa_srv_req_code)
uint16_t req_code;
/// Direction (@see enum gaf_direction)
uint8_t direction;
/// Location bit field
uint32_t location_bf;
} bap_capa_srv_set_location_req_t;
/// Structure for BAP_CAPA_SRV_SET_CONTEXT request message
typedef struct bap_capa_srv_set_context_req
{
/// Request code (@see enum bap_capa_srv_req_code)
uint16_t req_code;
/// Context type (@see enum bap_capa_context_type)
uint8_t context_type;
/// Connection local index
/// Meaningful only for Available Audio Contexts value
/// Must be set to GAP_INVALID_CONIDX if indicated audio contexts are available for all connections
uint8_t con_lid;
/// Context bit field value for Sink direction
uint16_t context_bf_sink;
/// Context bit field value for Source direction
uint16_t context_bf_src;
} bap_capa_srv_set_context_req_t;
/// Structure for BAP_CAPA_SRV_SET_CONTEXT response message
typedef struct bap_capa_srv_rsp
{
/// Request code (@see enum bap_capa_srv_req_code)
uint16_t req_code;
/// Status
uint16_t status;
/// First parameter
union
{
uint8_t param;
/// Connection local index
/// Meaningful only for BAP_CAPA_SRV_RESTORE_BOND_DATA and BAP_CAPA_SRV_SET_CONTEXT requests
uint8_t con_lid;
/// Record ID
/// Meaningful only for BAP_CAPA_SRV_SET_RECORD and BAP_CAPA_SRV_REMOVE_RECORD requests
uint8_t record_id;
/// Direction (@see enum gaf_direction)
/// Meaningful only for BAP_CAPA_SRV_SET_LOCATION request
uint8_t direction;
} u1;
/// Second parameter
union
{
uint8_t param;
/// Context type (@see enum bap_capa_context_type)
/// Meaningful only for BAP_CAPA_SRV_SET_CONTEXT request
uint8_t context_type;
/// PAC local index
/// Meaningful only for BAP_CAPA_SRV_SET_RECORD request
uint8_t pac_lid;
} u2;
} bap_capa_srv_rsp_t;
/// Structure for BAP_CAPA_SRV_BOND_DATA indication message
typedef struct bap_capa_srv_bond_data_ind
{
/// Indication code (@see enum bap_capa_srv_ind_code)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field
/// Each bit corresponds to a characteristic in the range [0, BAP_CAPA_CHAR_TYPE_PAC[
uint8_t cli_cfg_bf;
/// Client configuration bit field for Sink/Source PAC characteristic
/// Each bit corresponds to an instance of the Sink/Source PAC characteristic (Sink placed first)
uint16_t pac_cli_cfg_bf;
} bap_capa_srv_bond_data_ind_t;
/// Structure for BAP_CAPA_SRV_LOCATION indication message
typedef struct bap_capa_srv_location_ind
{
/// Indication code (@see enum bap_capa_srv_ind_code)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Direction (@see enum gaf_direction)
uint8_t direction;
/// Location bit field
uint32_t location_bf;
} bap_capa_srv_location_ind_t;
/// @}
#endif // BAP_CAPA_SRV_MSG_H_
@@ -0,0 +1,191 @@
/**
****************************************************************************************
*
* @file bap_uc.h
*
* @brief Basic Audio Profile - Unicast - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_UC_H_
#define BAP_UC_H_
/**
****************************************************************************************
* @addtogroup BAP_UC Basic Audio Profile - Unicast
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap.h" // Basic Audio Profile Definitions
#include "gaf_inc.h" // Generic Audio Framework Included Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of Audio Stream Control Service characteristics
enum bap_uc_char_type
{
/// ASE Control Point characteristic
BAP_UC_CHAR_TYPE_CP = 0,
/// ASE characteristic
BAP_UC_CHAR_TYPE_ASE,
BAP_UC_CHAR_TYPE_MAX,
};
/// Operation code values for ASE Control Point characteristic
enum bap_uc_opcode
{
/// Configure Codec
BAP_UC_OPCODE_CFG_CODEC = 1,
BAP_UC_OPCODE_MIN = BAP_UC_OPCODE_CFG_CODEC,
/// Configure QoS
BAP_UC_OPCODE_CFG_QOS,
/// Enable
BAP_UC_OPCODE_ENABLE,
/// Receiver Start Ready
BAP_UC_OPCODE_RX_START_READY,
/// Disable
BAP_UC_OPCODE_DISABLE,
/// Receiver Stop Ready
BAP_UC_OPCODE_RX_STOP_READY,
/// Update Metadata
BAP_UC_OPCODE_UPDATE_METADATA,
/// Release
BAP_UC_OPCODE_RELEASE,
BAP_UC_OPCODE_MAX,
};
/// ASE State values
enum bap_uc_ase_state
{
/// Idle
BAP_UC_ASE_STATE_IDLE = 0,
/// Codec configured
BAP_UC_ASE_STATE_CODEC_CONFIGURED,
/// QoS configured
BAP_UC_ASE_STATE_QOS_CONFIGURED,
/// Enabling
BAP_UC_ASE_STATE_ENABLING,
/// Streaming
BAP_UC_ASE_STATE_STREAMING,
/// Disabling
BAP_UC_ASE_STATE_DISABLING,
/// Releasing
BAP_UC_ASE_STATE_RELEASING,
BAP_UC_ASE_STATE_MAX,
};
/// Response Code values for ASE Control Point characteristic
enum bap_uc_cp_rsp_code
{
/// Success
BAP_UC_CP_RSP_CODE_SUCCESS = 0,
/// Unsupported Opcode
BAP_UC_CP_RSP_CODE_UNSUPPORTED_OPCODE,
/// Truncated Operation
BAP_UC_CP_RSP_CODE_TRUNACTED_OPERATION,
/// Invalid ASE ID
BAP_UC_CP_RSP_CODE_INVALID_ASE_ID,
/// Invalid ASE State Machine Transition
BAP_UC_CP_RSP_CODE_INVALID_TRANSITION,
/// Unsupported Audio Capabilities
BAP_UC_CP_RSP_CODE_UNSUPPORTED_AUDIO_CAPA,
/// Unsupported Configuration Parameter value
BAP_UC_CP_RSP_CODE_UNSUPPORTED_CFG_PARAM,
/// Rejected Configuration Parameter value
BAP_UC_CP_RSP_CODE_REJECTED_CFG_PARAM,
/// Invalid Configuration Parameter value
BAP_UC_CP_RSP_CODE_INVALID_CFG_PARAM,
/// Unsupported Metadata
BAP_UC_CP_RSP_CODE_UNSUPPORTED_METADATA,
/// Rejected Metadata
BAP_UC_CP_RSP_CODE_REJECTED_METADATA,
/// Invalid Metadata
BAP_UC_CP_RSP_CODE_INVALID_METADATA,
/// Insufficient Resources
BAP_UC_CP_RSP_CODE_INSUFFICIENT_RESOURCES,
/// Unspecified Error
BAP_UC_CP_RSP_CODE_UNSPECIFIED_ERROR,
BAP_UC_CP_RSP_CODE_MAX,
};
/// Reason values for ASE Control Point characteristic
enum bap_uc_cp_reason
{
BAP_UC_CP_REASON_MIN = 1,
/// Direction
BAP_UC_CP_REASON_DIRECTION = BAP_UC_CP_REASON_MIN,
/// Codec ID
BAP_UC_CP_REASON_CODEC_ID,
/// Codec Specific Configuration Length
BAP_UC_CP_REASON_CODEC_CFG_LEN,
/// Codec Specific Configuration
BAP_UC_CP_REASON_CODEC_CFG,
/// SDU Interval
BAP_UC_CP_REASON_SDU_INTERVAL,
/// Framing
BAP_UC_CP_REASON_FRAMING,
/// PHY
BAP_UC_CP_REASON_PHY,
/// Maximum SDU Size
BAP_UC_CP_REASON_MAX_SDU_SIZE,
/// Retransmission Number
BAP_UC_CP_REASON_RETX_NB,
/// Transport Latency
BAP_UC_CP_REASON_TRANS_LATENCY,
/// Presentation Delay
BAP_UC_CP_REASON_PRES_DELAY,
/// Metadata length
BAP_UC_CP_REASON_METADATA_LEN,
BAP_UC_CP_REASON_MAX,
};
/// Target Latency values
enum bap_uc_tgt_latency
{
BAP_UC_TGT_LATENCY_MIN = 1,
/// Target lower latency
BAP_UC_TGT_LATENCY_LOWER = BAP_UC_TGT_LATENCY_MIN,
/// Target balanced latency and reliability
BAP_UC_TGT_LATENCY_BALENCED,
/// Target higher reliability
BAP_UC_TGT_LATENCY_RELIABLE,
BAP_UC_TGT_LATENCY_MAX,
};
/// Target PHY values
enum bap_uc_tgt_phy
{
BAP_UC_TGT_PHY_MIN = 1,
/// 1M PHY
BAP_UC_TGT_PHY_1M = BAP_UC_TGT_PHY_MIN,
/// 2M PHY
BAP_UC_TGT_PHY_2M,
/// Coded PHY
BAP_UC_TGT_PHY_CODED,
BAP_UC_TGT_PHY_MAX,
};
/// @}
#endif // BAP_UC_H_
@@ -0,0 +1,570 @@
/**
****************************************************************************************
*
* @file bap_uc_cli.h
*
* @brief Basic Audio Profile - Unicast Client - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_UC_CLI_H_
#define BAP_UC_CLI_H_
/**
****************************************************************************************
* @addtogroup BAP_UC_CLI Basic Audio Profile - Unicast Client
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Defines
#include "bap_uc.h" // Basic Audio Profile - Unicast Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of command types for BAP Unicast Client
enum bap_uc_cli_cmd_type
{
BAP_UC_CLI_CMD_TYPE_DISCOVER = 0,
BAP_UC_CLI_CMD_TYPE_CONFIGURE_CODEC,
BAP_UC_CLI_CMD_TYPE_CONFIGURE_QOS,
BAP_UC_CLI_CMD_TYPE_ENABLE,
BAP_UC_CLI_CMD_TYPE_UPDATE_METADATA,
BAP_UC_CLI_CMD_TYPE_DISABLE,
BAP_UC_CLI_CMD_TYPE_RELEASE,
BAP_UC_CLI_CMD_TYPE_GET_QUALITY,
BAP_UC_CLI_CMD_TYPE_VS_SET_TRIGGER,
BAP_UC_CLI_CMD_TYPE_GET_CFG,
BAP_UC_CLI_CMD_TYPE_SET_CFG,
BAP_UC_CLI_CMD_TYPE_GET_STATE,
};
/// List of GAF_CMD command codes for BAP Unicast Client
enum bap_uc_cli_cmd_code
{
BAP_UC_CLI_DISCOVER = GAF_CODE(BAP, UC_CLI, BAP_UC_CLI_CMD_TYPE_DISCOVER),
BAP_UC_CLI_CONFIGURE_CODEC = GAF_CODE(BAP, UC_CLI, BAP_UC_CLI_CMD_TYPE_CONFIGURE_CODEC),
BAP_UC_CLI_CONFIGURE_QOS = GAF_CODE(BAP, UC_CLI, BAP_UC_CLI_CMD_TYPE_CONFIGURE_QOS),
BAP_UC_CLI_ENABLE = GAF_CODE(BAP, UC_CLI, BAP_UC_CLI_CMD_TYPE_ENABLE),
BAP_UC_CLI_UPDATE_METADATA = GAF_CODE(BAP, UC_CLI, BAP_UC_CLI_CMD_TYPE_UPDATE_METADATA),
BAP_UC_CLI_DISABLE = GAF_CODE(BAP, UC_CLI, BAP_UC_CLI_CMD_TYPE_DISABLE),
BAP_UC_CLI_RELEASE = GAF_CODE(BAP, UC_CLI, BAP_UC_CLI_CMD_TYPE_RELEASE),
BAP_UC_CLI_GET_QUALITY = GAF_CODE(BAP, UC_CLI, BAP_UC_CLI_CMD_TYPE_GET_QUALITY),
BAP_UC_CLI_VS_SET_TRIGGER = GAF_CODE(BAP, UC_CLI, BAP_UC_CLI_CMD_TYPE_VS_SET_TRIGGER),
BAP_UC_CLI_GET_CFG = GAF_CODE(BAP, UC_CLI, BAP_UC_CLI_CMD_TYPE_GET_CFG),
BAP_UC_CLI_SET_CFG = GAF_CODE(BAP, UC_CLI, BAP_UC_CLI_CMD_TYPE_SET_CFG),
BAP_UC_CLI_GET_STATE = GAF_CODE(BAP, UC_CLI, BAP_UC_CLI_CMD_TYPE_GET_STATE),
};
/// List of GAF_REQ request codes for BAP Unicast Client
enum bap_uc_cli_req_code
{
BAP_UC_CLI_RESTORE_BOND_DATA = GAF_CODE(BAP, UC_CLI, 0),
BAP_UC_CLI_RESTORE_BOND_DATA_CODEC = GAF_CODE(BAP, UC_CLI, 1),
BAP_UC_CLI_CREATE_GROUP = GAF_CODE(BAP, UC_CLI, 2),
BAP_UC_CLI_REMOVE_GROUP = GAF_CODE(BAP, UC_CLI, 3),
};
/// List of GAF_IND indication codes for BAP Unicast Client
enum bap_uc_cli_ind_code
{
BAP_UC_CLI_BOND_DATA = GAF_CODE(BAP, UC_CLI, 0),
BAP_UC_CLI_CFG = GAF_CODE(BAP, UC_CLI, 1),
BAP_UC_CLI_CIS_STATE = GAF_CODE(BAP, UC_CLI, 2),
BAP_UC_CLI_STATE_EMPTY = GAF_CODE(BAP, UC_CLI, 3),
BAP_UC_CLI_STATE_CODEC = GAF_CODE(BAP, UC_CLI, 4),
BAP_UC_CLI_STATE_QOS = GAF_CODE(BAP, UC_CLI, 5),
BAP_UC_CLI_STATE_METADATA = GAF_CODE(BAP, UC_CLI, 6),
BAP_UC_CLI_ERROR = GAF_CODE(BAP, UC_CLI, 7),
BAP_UC_CLI_SVC_CHANGED = GAF_CODE(BAP, UC_CLI, 8),
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Audio Stream Control Service characteristic description structure
typedef struct bap_uc_cli_ascs_char
{
/// Characteristic value handle
uint16_t val_hdl;
/// Client Characteristic Configuration descriptor handle
uint16_t desc_hdl;
/// ASE ID
uint8_t ase_id;
} bap_uc_cli_ascs_char_t;
/// Audio Stream Control Service content description structure
typedef struct bap_uc_cli_ascs
{
/// Service description
prf_svc_t svc_info;
/// Number of discovered ASE characteristics
uint8_t nb_ases;
/// Characteristic information structures
bap_uc_cli_ascs_char_t char_info[__ARRAY_EMPTY];
} bap_uc_cli_ascs_t;
typedef struct bap_uc_cli_grp_param
{
/// SDU interval from Master to Slave in microseconds
/// From 0xFF (255us) to 0xFFFF (1.048575s)
uint32_t sdu_intv_m2s_us;
/// SDU interval from Slave to Master in microseconds
/// From 0xFF (255us) to 0xFFFF (1.048575s)
uint32_t sdu_intv_s2m_us;
/// Maximum time (in milliseconds) for an SDU to be transported from master controller to slave
/// controller. From 0x5 (5ms) to 0xFA0 (4s)
uint16_t tlatency_m2s_ms;
/// Maximum time (in milliseconds) for an SDU to be transported from slave controller to master
/// controller. From 0x5 (5ms) to 0xFA0 (4s)
uint16_t tlatency_s2m_ms;
/// Sequential or interleaved scheduling
uint8_t packing;
/// Unframed or framed mode
uint8_t framing;
/// Worst slow clock accuracy of slaves
uint8_t sca;
} bap_uc_cli_grp_param_t;
/// QoS Configuration structure (short)
typedef struct bap_uc_cli_qos_cfg
{
/// PHY
uint8_t phy;
/// Maximum number of retransmissions for each CIS Data PDU
/// From 0 to 15
uint8_t retx_nb;
/// Maximum SDU size
/// From 0 to 4095 bytes (0xFFF)
uint16_t max_sdu_size;
/// Presentation delay in microseconds
uint32_t pres_delay_us;
} bap_uc_cli_qos_cfg_t;
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called each time a command has been completed
*
* @param[in] cmd_code Command code (@see enum bap_uc_cli_cmd_code)
* @param[in] status Status
* @param[in] con_lid Connection local index
* @param[in] ase_info ASE information (ASE local index or ASE instance index)
* @param[in] char_type Characteristic type (@see enum bap_uc_char_type)
****************************************************************************************
*/
typedef void (*bap_uc_cli_cb_cmp_evt)(uint16_t cmd_code, uint16_t status, uint8_t con_lid, uint8_t ase_info,
uint8_t char_type);
/**
****************************************************************************************
* @brief Callback function called each time BAP_UC_CLI_GET_QUALITY command has been completed
*
* @param[in] status Status
* @param[in] ase_lid ASE local index
* @param[in] tx_unacked_packets Number of packets transmitted and unacked
* @param[in] tx_flushed_packets Number of flushed transmitted packets
* @param[in] tx_last_subevent_packets Number of packets transmitted during last subevent
* @param[in] retx_packets Number of retransmitted packets
* @param[in] crc_error_packets Number of packets received with a CRC error
* @param[in] rx_unrx_packets Number of unreceived packets
* @param[in] duplicate_packets Number of duplicate packet received
****************************************************************************************
*/
typedef void (*bap_uc_cli_cb_quality_cmp_evt)(uint16_t status, uint8_t ase_lid, uint32_t tx_unacked_packets,
uint32_t tx_flushed_packets, uint32_t tx_last_subevent_packets,
uint32_t retransmitted_packets, uint32_t crc_error_packets,
uint32_t rx_unreceived_packets, uint32_t duplicate_packets);
/**
****************************************************************************************
* @brief Callback function called when Audio Stream Control Service has been discovered in a peer server device
* database
*
* @param[in] con_lid Connection local index
* @param[in] p_ascs_info Pointer to Audio Stream Control Service content description
* structure
****************************************************************************************
*/
typedef void (*bap_uc_cli_cb_bond_data)(uint8_t con_lid, bap_uc_cli_ascs_t* p_ascs_info);
/**
****************************************************************************************
* @brief Callback function called when an error has been received for an ASE
*
* @param[in] ase_lid ASE local index
* @param[in] opcode Operation code (@see enum bap_uc_opcode)
* @param[in] rsp_code Response code (@see enum bap_uc_cp_rsp_code)
* @param[in] reason Reason (@see enum bap_uc_cp_reason)
****************************************************************************************
*/
typedef void (*bap_uc_cli_cb_error)(uint8_t ase_lid, uint8_t opcode, uint8_t rsp_code, uint8_t reason);
/**
****************************************************************************************
* @brief Callback function called when a client characteristic configuration value has been received
* from a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] ase_instance_idx ASE instance index
* @param[in] enabled Indicate if sending of event is enabled (!= 0) or not
****************************************************************************************
*/
typedef void (*bap_uc_cli_cb_cfg)(uint8_t con_lid, uint8_t char_type, uint8_t ase_instance_idx, uint8_t enabled);
/**
****************************************************************************************
* @brief Callback function called when state of a CIS has been updated
*
* @param[in] ase_lid_sink ASE local index for Sink direction
* @param[in] ase_lid_src ASE local index for Source direction
* @param[in] grp_lid Group local index
* @param[in] cis_id CIS ID
* @param[in] conhdl Connection handle
****************************************************************************************
*/
typedef void (*bap_uc_cli_cb_cis_state)(uint8_t ase_lid_sink, uint8_t ase_lid_src, uint8_t grp_lid, uint8_t cis_id,
uint16_t conhdl);
/**
****************************************************************************************
* @brief Callback function called when state of an ASE has been update and state is Idle or Releasing
*
* @param[in] con_lid Connection local index
* @param[in] ase_instance_idx ASE instance index
* @param[in] ase_lid ASE local index
* @param[in] state State (@see enum bap_uc_ase_state)
****************************************************************************************
*/
typedef void (*bap_uc_cli_cb_state_empty)(uint8_t con_lid, uint8_t ase_instance_idx, uint8_t ase_lid, uint8_t state);
/**
****************************************************************************************
* @brief Callback function called when state of an ASE has been update and state is Codec Configured
*
* @param[in] con_lid Connection local index
* @param[in] ase_instance_idx ASE instance index
* @param[in] ase_lid ASE local index
* @param[in] direction Direction (@see enum gaf_direction)
* @param[in] p_codec_id Pointer to Codec ID
* @param[in] p_qos_req Pointer to QoS requirements structure
* @param[in] p_codec_cfg Pointer to Codec Configuration structure
****************************************************************************************
*/
typedef void (*bap_uc_cli_cb_state_codec)(uint8_t con_lid, uint8_t ase_instance_idx, uint8_t ase_lid,
uint8_t direction, gaf_codec_id_t* p_codec_id, bap_qos_req_t* p_qos_req,
void* p_codec_cfg);
/**
****************************************************************************************
* @brief Callback function called when state of an ASE has been update and state is QoS Configured
*
* @param[in] ase_lid ASE local index
* @param[in] p_qos_cfg Pointer to QoS configuration structure
****************************************************************************************
*/
typedef void (*bap_uc_cli_cb_state_qos)(uint8_t ase_lid, bap_qos_cfg_t* p_qos_cfg);
/**
****************************************************************************************
* @brief Callback function called when state of an ASE has been update and state is Enable or Streaming or Disabling
*
* @param[in] ase_lid ASE local index
* @param[in] state ASE state
* @param[in] p_metadata Pointer to Metadata structure
****************************************************************************************
*/
typedef void (*bap_uc_cli_cb_state_metadata)(uint8_t ase_lid, uint8_t state, bap_metadata_cfg_ptr_t* p_metadata);
/**
****************************************************************************************
* @brief Callback function called when service changed indication has been received for Audio Stream Control Service
* from a peer server device
*
* @param[in] con_lid Connection local index
****************************************************************************************
*/
typedef void (*bap_uc_cli_cb_svc_changed)(uint8_t con_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Audio Stream Control Service Client
typedef struct bap_uc_cli_cb
{
/// Callback function called when a command has been completed
bap_uc_cli_cb_cmp_evt cb_cmp_evt;
/// Callback function called when BAP_UC_CLI_GET_QUALITY command has been completed
bap_uc_cli_cb_quality_cmp_evt cb_quality_cmp_evt;
/// Callback function called when Audio Stream Control Service has been discovered in a peer server device
/// database
bap_uc_cli_cb_bond_data cb_bond_data;
/// Callback function called when an error has been received for an ASE
bap_uc_cli_cb_error cb_error;
/// Callback function called when a client characteristic configuration value has been received from a peer
/// server device
bap_uc_cli_cb_cfg cb_cfg;
/// Callback function called when state of a CIS has been updated
bap_uc_cli_cb_cis_state cb_cis_state;
/// Callback function called when state of an ASE has been update and state is Idle or Releasing
bap_uc_cli_cb_state_empty cb_state_empty;
/// Callback function called when state of an ASE has been update and state is Codec Configured
bap_uc_cli_cb_state_codec cb_state_codec;
/// Callback function called when state of an ASE has been update and state is QoS Configured
bap_uc_cli_cb_state_qos cb_state_qos;
/// Callback function called when state of an ASE has been update and state is Enable or Streaming or Disabling
bap_uc_cli_cb_state_metadata cb_state_metadata;
/// Callback function called when service changed indication has been received for Audio Stream Control Service
/// from a peer server device
bap_uc_cli_cb_svc_changed cb_svc_changed;
} bap_uc_cli_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
#if (GAF_BAP_UC_CLI)
/**
****************************************************************************************
* @brief Enable use of Audio Stream Control Service as Client and start discovery of the service in peer server device
* database
*
* @param[in] con_lid Connection local index
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_discover(uint8_t con_lid);
/**
****************************************************************************************
* @brief Enable use of BAP Unicast Client module and set bonding information after reconnection with peer server
* device
*
* @param[in] con_lid Connection local index
* @param[in] p_ascs_info Pointer to Audio Stream Control Service content description
* structure
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_restore_bond_data(uint8_t con_lid, bap_uc_cli_ascs_t* p_ascs_info);
/**
****************************************************************************************
* @brief Restore bond data about an ASE in Codec Configured state
*
* @param[in] con_lid Connection local index
* @param[in] ase_instance_idx ASE instance index
* @param[in] ase_lid ASE local index
* @param[in] direction Direction (@see enum gaf_direction)
* @param[in] dp_id Data Path ID
* @param[in] p_codec_id Pointer to Codec ID
* @param[in] ctl_delay_us Controller Delay in microseconds
* @param[in] p_cfg Pointer to Codec Configuration structure
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_restore_bond_data_codec(uint8_t con_lid, uint8_t ase_instance_idx, uint8_t ase_lid,
uint8_t direction, uint8_t dp_id, gaf_codec_id_t* p_codec_id,
uint32_t ctl_delay_us, void* p_cfg);
/**
****************************************************************************************
* @brief Create a group
*
* @param[in] cig_id CIG ID
* @param[in] p_param Pointer to Group parameters structure
* @param[out] p_grp_lid Pointer at which allocated Group local index is returned
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_create_group(uint8_t cig_id, bap_uc_cli_grp_param_t* p_param, uint8_t* p_grp_lid);
/**
****************************************************************************************
* @brief Remove a group
*
* @param[in] grp_lid Group local index
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_remove_group(uint8_t grp_lid);
/**
****************************************************************************************
* @brief Configure Codec for an ASE
*
* @param[in] con_lid Connection local index
* @param[in] ase_instance_idx ASE instance index
* @param[in] ase_lid ASE local index
* @param[in] direction Direction (@see enum gaf_direction)
* @param[in] dp_id Data Path ID
* @param[in] p_codec_id Pointer to Codec ID
* @param[in] tgt_latency Target Latency (@see enum bap_uc_tgt_latency)
* @param[in] tgt_phy Target PHY (@see enum bap_uc_tgt_phy)
* @param[in] ctl_delay_us Controller Delay in microseconds
* @param[in] p_cfg Pointer to Codec Configuration structure
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_configure_codec(uint8_t con_lid, uint8_t ase_instance_idx, uint8_t ase_lid, uint8_t direction,
uint8_t dp_id, gaf_codec_id_t* p_codec_id, uint8_t tgt_latency,
uint8_t tgt_phy, uint32_t ctl_delay_us, void* p_cfg);
/**
****************************************************************************************
* @brief Configure QoS for an ASE
*
* @param[in] ase_lid ASE local index
* @param[in] grp_lid Group local index
* @param[in] cis_id CIS ID
* @param[in] p_qos_cfg Pointer to QoS configuration structure
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_configure_qos(uint8_t ase_lid, uint8_t grp_lid, uint8_t cis_id, bap_uc_cli_qos_cfg_t* p_qos_cfg);
/**
****************************************************************************************
* @brief Enable an ASE
*
* @param[in] ase_lid ASE local index
* @param[in] p_metadata Pointer to Metadata structure
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_enable(uint8_t ase_lid, bap_metadata_cfg_t* p_metadata);
/**
****************************************************************************************
* @brief Update metadata for an ASE
*
* @param[in] ase_lid ASE local index
* @param[in] p_metadata Pointer to Metadata structure
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_update_metadata(uint8_t ase_lid, bap_metadata_cfg_t* p_metadata);
/**
****************************************************************************************
* @brief Disable an ASE (stop streaming)
*
* @param[in] ase_lid ASE local index
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_disable(uint8_t ase_lid);
/**
****************************************************************************************
* @brief Release an ASE
*
* @param[in] ase_lid ASE local index
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_release(uint8_t ase_lid);
/**
****************************************************************************************
* @brief Get quality information about an established CIS
*
* @param[in] ase_lid ASE local index
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_get_quality(uint8_t ase_lid);
#if (GAF_VS)
/**
****************************************************************************************
* @brief Get quality information about an established CIS
*
* @param[in] ase_lid ASE local index
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_vs_set_trigger(uint8_t ase_lid, uint8_t enable, uint32_t trigger_offset_us);
#endif //(GAF_VS)
#if (GAF_DBG)
/**
****************************************************************************************
* @brief Get value of an ASE characteristic instance
*
* @param[in] con_lid Connection local index
* @param[in] ase_instance_idx ASE instance index
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_get_state(uint8_t con_lid, uint8_t ase_instance_idx);
/**
****************************************************************************************
* @brief Get Client Characteristic Configuration Descriptor value for either an ASE or ASE Control Point
* characteristic of a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] ase_instance_idx ASE instance index for ASE characteristic
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_get_cfg(uint8_t con_lid, uint8_t char_type, uint8_t ase_instance_idx);
/**
****************************************************************************************
* @brief Set Client Characteristic Configuration Descriptor value for either an ASE or ASE Control Point
* characteristic of a peer server device
*
* @param[in] con_lid Connection local index
* @param[in] char_type Characteristic type
* @param[in] ase_instance_idx ASE instance index for ASE characteristic
* @param[in] enable Indicate if sending of events must be enabled (!= 0) or disabled
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_cli_set_cfg(uint8_t con_lid, uint8_t char_type, uint8_t ase_instance_idx, uint8_t enable);
#endif //(GAF_DBG)
#endif //(GAF_BAP_UC_CLI)
/// @}
#endif // BAP_UC_CLI_H_
@@ -0,0 +1,461 @@
/**
****************************************************************************************
*
* @file bap_uc_cli_msg.h
*
* @brief Basic Audio Profile - Unicast Client - Message API Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_UC_CLI_MSG_H_
#define BAP_UC_CLI_MSG_H_
/**
****************************************************************************************
* @addtogroup BAP_UC_CLI_MSG Basic Audio Profile - Unicast Client - Message API Definitions
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap_msg.h" // Basic Audio Profile Message API Definitions
#include "bap_uc_cli.h" // Basic Audio Profile - Unicast Client Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for BAP_UC_CLI_RESTORE_BOND_DATA request message
typedef struct bap_uc_cli_restore_bond_data_req
{
/// Request code (@see enum bap_uc_cli_req_code)
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Audio Stream Control Service content description
bap_uc_cli_ascs_t ascs_info;
} bap_uc_cli_restore_bond_data_req_t;
/// Structure for BAP_UC_CLI_RESTORE_BOND_DATA_CODEC request message
typedef struct bap_uc_cli_restore_bond_data_codec_req
{
/// Request code (@see enum bap_uc_cli_req_code)
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// ASE local index
uint8_t ase_lid;
/// ASE instance index
uint8_t ase_instance_idx;
/// Direction (@see enum gaf_direction)
uint8_t direction;
/// Data Path ID
uint8_t dp_id;
/// Codec ID
gaf_codec_id_t codec_id;
/// Controller Delay in microseconds
uint32_t ctl_delay_us;
/// Length of Codec Configuration value
uint16_t cfg_len;
/// Codec Configuration value, length is cfg_len
/// To be casted as @see bap_lc3_cfg_t for LC3
/// To be casted as @see bap_vendor_codec_cfg_t for Vendor Codec
uint8_t cfg[__ARRAY_EMPTY];
} bap_uc_cli_restore_bond_data_codec_req_t;
/// Structure for BAP_UC_CLI_CREATE_GROUP request message
typedef struct bap_uc_cli_create_group_req
{
/// Request code (@see enum bap_uc_cli_req_code)
uint16_t req_code;
/// CIG ID
uint8_t cig_id;
/// Group parameters
bap_uc_cli_grp_param_t params;
} bap_uc_cli_create_group_req_t;
/// Structure for BAP_UC_CLI_REMOVE_GROUP request message
typedef struct bap_uc_cli_remove_group_req
{
/// Request code (@see enum bap_uc_cli_req_code)
uint16_t req_code;
/// Group local index
uint8_t grp_lid;
} bap_uc_cli_remove_group_req_t;
/// Structure for response message
typedef struct bap_uc_cli_rsp
{
/// Request code (@see enum bap_uc_cli_req_code)
uint16_t req_code;
/// Status
uint16_t status;
union
{
/// Local index
uint8_t lid;
/// Connection local index
uint8_t con_lid;
/// Group local index
uint8_t grp_lid;
} lid;
/// ASE local index
uint8_t ase_lid;
} bap_uc_cli_rsp_t;
/// Structure for BAP_UC_CLI_DISCOVER command message
typedef struct bap_uc_cli_discover_cmd
{
/// Command code (@see enum bap_uc_cli_cmd_code)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
} bap_uc_cli_discover_cmd_t;
/// Structure for BAP_UC_CLI_CONFIGURE_CODEC command message
typedef struct bap_uc_cli_configure_codec_cmd
{
/// Command code (@see enum bap_uc_cli_cmd_code)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// ASE local index
uint8_t ase_lid;
/// ASE instance index
uint8_t ase_instance_idx;
/// Direction (@see enum gaf_direction)
uint8_t direction;
/// Data Path ID
uint8_t dp_id;
/// Target Latency (@see enum bap_uc_tgt_latency)
uint8_t tgt_latency;
/// Target PHY (@see enum bap_uc_tgt_phy)
uint8_t tgt_phy;
/// Target PHY
/// Codec ID
gaf_codec_id_t codec_id;
/// Controller Delay in microseconds
uint32_t ctl_delay_us;
/// Length of Codec Configuration value
uint16_t cfg_len;
/// Codec Configuration value, length is cfg_len
/// To be casted as @see bap_lc3_cfg_t for LC3
/// To be casted as @see bap_vendor_codec_cfg_t for Vendor Codec
uint8_t cfg[__ARRAY_EMPTY];
} bap_uc_cli_configure_codec_cmd_t;
/// Structure for BAP_UC_CLI_CONFIGURE_QOS command message
typedef struct bap_uc_cli_configure_qos_cmd
{
/// Command code (@see enum bap_uc_cli_cmd_code)
uint16_t cmd_code;
/// ASE local index
uint8_t ase_lid;
/// Group local index
uint8_t grp_lid;
/// CIS ID
uint8_t cis_id;
/// QoS Configuration
bap_uc_cli_qos_cfg_t qos_cfg;
} bap_uc_cli_configure_qos_cmd_t;
/// Structure for BAP_UC_CLI_ENABLE command message
typedef struct bap_uc_cli_enable_cmd
{
/// Command code (@see enum bap_uc_cli_cmd_code)
uint16_t cmd_code;
/// ASE local index
uint8_t ase_lid;
/// Metadata
bap_metadata_cfg_t metadata;
} bap_uc_cli_enable_cmd_t;
/// Structure for BAP_UC_CLI_UPDATE_METADATA command message
typedef struct bap_uc_cli_update_metadata_cmd
{
/// Command code (@see enum bap_uc_cli_cmd_code)
uint16_t cmd_code;
/// ASE local index
uint8_t ase_lid;
/// Metadata
bap_metadata_cfg_t metadata;
} bap_uc_cli_update_metadata_cmd_t;
/// Structure for BAP_UC_CLI_DISABLE command message
typedef struct bap_uc_cli_disable_cmd
{
/// Command code (@see enum bap_uc_cli_cmd_code)
uint16_t cmd_code;
/// ASE local index
uint8_t ase_lid;
} bap_uc_cli_disable_cmd_t;
/// Structure for BAP_UC_CLI_RELEASE command message
typedef struct bap_uc_cli_release_cmd
{
/// Command code (@see enum bap_uc_cli_cmd_code)
uint16_t cmd_code;
/// ASE local index
uint8_t ase_lid;
} bap_uc_cli_release_cmd_t;
/// Structure for BAP_UC_CLI_GET_QUALITY command message
typedef struct bap_uc_cli_get_quality_cmd
{
/// Command code (@see enum bap_uc_cli_cmd_code)
uint16_t cmd_code;
/// ASE local index
uint8_t ase_lid;
} bap_uc_cli_get_quality_cmd_t;
/// Structure for BAP_UC_CLI_VS_SET_TRIGGER command message
typedef struct bap_uc_cli_vs_set_trigger_cmd
{
/// Command code (@see enum bap_uc_srv_cmd_code)
uint16_t cmd_code;
/// ASE local index
uint8_t ase_lid;
/// Indicate if periodic trigger must be enabled or disabled
uint8_t enable;
/// Trigger offset in microseconds
/// - For source direction, trigger offset is applied using SDU at source reference
/// - For sink direction, trigger offset is applied using SDU at direction reference
/// (SDU at source + transport latency)
uint32_t trigger_offset_us;
} bap_uc_cli_vs_set_trigger_cmd_t;
/// Structure for BAP_UC_CLI_GET_CFG command message
typedef struct bap_uc_cli_get_cfg_cmd
{
/// Command code (@see enum bap_uc_cli_cmd_code)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
/// ASE instance index
/// Meaningful only if configuration for an instance of the ASE characteristic is requested
uint8_t ase_instance_idx;
} bap_uc_cli_get_cfg_cmd_t;
/// Structure for BAP_UC_CLI_SET_CFG command message
typedef struct bap_uc_cli_set_cfg_cmd
{
/// Command code (@see enum bap_uc_cli_cmd_code)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
/// ASE instance index
/// Meaningful only if configuration for an instance of the ASE characteristic is requested
uint8_t ase_instance_idx;
/// Indicate if sending of notifications must be enabled (!= 0) or disabled for the indicated characteristic
uint8_t enable;
} bap_uc_cli_set_cfg_cmd_t;
/// Structure for BAP_UC_CLI_GET_STATE command message
typedef struct bap_uc_cli_get_state_cmd
{
/// Command code (@see enum bap_uc_cli_cmd_code)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
/// ASE instance index
/// Meaningful only if configuration for an instance of the ASE characteristic is requested
uint8_t ase_instance_idx;
} bap_uc_cli_get_state_cmd_t;
/// Structure for command complete event message
typedef struct bap_uc_cli_cmp_evt
{
/// Command code (@see enum bap_uc_cli_cmd_code)
uint16_t cmd_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
union
{
/// ASE parameter
uint8_t ase_param;
/// ASE instance index
uint8_t ase_instance_idx;
/// ASE local index
uint8_t ase_lid;
} u;
/// Characteristic type
uint8_t char_type;
} bap_uc_cli_cmp_evt_t;
/// Structure for BAP_UC_CLI_GET_QUALITY command complete event message
typedef struct bap_uc_cli_get_quality_cmp_evt
{
/// Command code (@see enum bap_uc_cli_cmd_code)
/// - BAP_UC_CLI_GET_QUALITY
uint16_t cmd_code;
/// Status
uint16_t status;
/// ASE local index
uint8_t ase_lid;
/// Number of packets transmitted and unacked
uint32_t tx_unacked_packets;
/// Number of flushed transmitted packets
uint32_t tx_flushed_packets;
/// Number of packets transmitted during last subevent
uint32_t tx_last_subevent_packets;
/// Number of retransmitted packets
uint32_t retx_packets;
/// Number of packets received with a CRC error
uint32_t crc_error_packets;
/// Number of unreceived packets
uint32_t rx_unrx_packets;
/// Number of duplicate packets received
uint32_t duplicate_packets;
} bap_uc_cli_get_quality_cmp_evt_t;
/// Structure for BAP_UC_CLI_BOND_DATA indication message
typedef struct bap_uc_cli_bond_data_ind
{
/// Indication code (@see enum bap_uc_cli_ind_code)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Audio Stream Control Service content description
bap_uc_cli_ascs_t ascs_info;
} bap_uc_cli_bond_data_ind_t;
/// Structure for BAP_UC_CLI_CFG indication message
typedef struct bap_uc_cli_cfg_ind
{
/// Indication code (@see enum bap_uc_cli_ind_code)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Characteristic type
uint8_t char_type;
/// ASE instance index
/// Meaningful only if configuration for an instance of the ASE characteristic is requested
uint8_t ase_instance_idx;
/// Enabled
uint8_t enabled;
} bap_uc_cli_cfg_ind_t;
/// Structure for BAP_UC_CLI_CIS_STATE indication message
typedef struct bap_uc_cli_cis_state_ind
{
/// Indication code (@see enum bap_uc_cli_ind_code)
uint16_t ind_code;
/// ASE local index for Sink direction
uint8_t ase_lid_sink;
/// ASE local index for Source direction
uint8_t ase_lid_src;
/// Group local index
uint8_t grp_lid;
/// CIS ID
uint8_t cis_id;
/// Connection handle allocated for the CIS by Controller
/// GAP_INVALID_CONHDL indicates that CIS has been lost
uint16_t conhdl;
} bap_uc_cli_cis_state_ind_t;
/// Structure for BAP_UC_CLI_ASE_STATE_EMPTY indication message
typedef struct bap_uc_cli_state_empty_ind
{
/// Indication code (@see enum bap_uc_cli_ind_code)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// ASE instance index
uint8_t ase_instance_idx;
/// ASE local index
uint8_t ase_lid;
/// ASE State
uint8_t state;
} bap_uc_cli_state_empty_ind_t;
/// Structure for BAP_UC_CLI_STATE_CODEC indication message
typedef struct bap_uc_cli_state_codec_ind
{
/// Indication code (@see enum bap_uc_cli_ind_code)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// ASE instance index
uint8_t ase_instance_idx;
/// ASE local index
uint8_t ase_lid;
/// Direction
uint8_t direction;
/// Codec ID
gaf_codec_id_t codec_id;
/// QoS Requirements
bap_qos_req_t qos_req;
/// Length of Codec Configuration value
uint16_t cfg_len;
/// Codec Configuration value, length is cfg_len
/// To be casted as @see bap_lc3_cfg_t for LC3
/// To be casted as @see bap_vendor_codec_cfg_t for Vendor Codec
uint8_t cfg[__ARRAY_EMPTY];
} bap_uc_cli_state_codec_ind_t;
/// Structure for BAP_UC_CLI_STATE_QOS indication message
typedef struct bap_uc_cli_state_qos_ind
{
/// Indication code (@see enum bap_uc_cli_ind_code)
uint16_t ind_code;
/// ASE local index
uint8_t ase_lid;
/// QoS Configuration
bap_qos_cfg_t qos_cfg;
} bap_uc_cli_state_qos_ind_t;
/// Structure for BAP_UC_CLI_STATE_METADATA indication message
typedef struct bap_uc_cli_state_metadata_ind
{
/// Indication code (@see enum bap_uc_cli_ind_code)
uint16_t ind_code;
/// ASE local index
uint8_t ase_lid;
/// State
uint8_t state;
/// Metadata
bap_metadata_cfg_t metadata;
} bap_uc_cli_state_metadata_ind_t;
/// Structure for BAP_UC_CLI_SVC_CHANGED indication message
typedef struct bap_uc_cli_svc_changed_ind
{
/// Indication code (@see enum bap_uc_cli_ind_code)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
} bap_uc_cli_svc_changed_ind_t;
/// Structure for BAP_UC_CLI_ERROR indication message
typedef struct bap_uc_cli_error_ind
{
/// Indication code (@see enum bap_uc_cli_ind_code)
uint16_t ind_code;
/// ASE local index
uint8_t ase_lid;
/// Operation code
uint8_t opcode;
/// Response code
uint8_t rsp_code;
/// Reason
uint8_t reason;
} bap_uc_cli_error_ind_t;
/// @}
#endif // BAP_UC_CLI_MSG_H_
@@ -0,0 +1,420 @@
/**
****************************************************************************************
*
* @file bap_uc_srv.h
*
* @brief Basic Audio Profile - Unicast Server - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_UC_SRV_H_
#define BAP_UC_SRV_H_
/**
****************************************************************************************
* @addtogroup BAP_UC_SRV Basic Audio Profile - Unicast Server
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Definitions
#include "bap_uc.h" // Basic Audio Profile - Unicast Definitions
/*
* DEFINES
****************************************************************************************
*/
/// Maximum number of ASE characteristics that can be supported
#define BAP_UC_SRV_NB_ASES_MAX (15)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for BAP Unicast Server
enum bap_uc_srv_cmd_code
{
BAP_UC_SRV_DISABLE = GAF_CODE(BAP, UC_SRV, 0),
BAP_UC_SRV_RELEASE = GAF_CODE(BAP, UC_SRV, 1),
BAP_UC_SRV_GET_QUALITY = GAF_CODE(BAP, UC_SRV, 2),
BAP_UC_SRV_VS_SET_TRIGGER = GAF_CODE(BAP, UC_SRV, 3),
};
/// List of GAF_REQ command codes for BAP Unicast Server
enum bap_uc_srv_req_code
{
BAP_UC_SRV_RESTORE_BOND_DATA = GAF_CODE(BAP, UC_SRV, 0),
BAP_UC_SRV_RESTORE_BOND_DATA_CODEC = GAF_CODE(BAP, UC_SRV, 1),
BAP_UC_SRV_CONFIGURE_CODEC = GAF_CODE(BAP, UC_SRV, 2),
BAP_UC_SRV_UPDATE_METADATA = GAF_CODE(BAP, UC_SRV, 3),
};
/// List of GAF_IND indication codes for BAP Unicast Server
enum bap_uc_srv_ind_code
{
BAP_UC_SRV_BOND_DATA = GAF_CODE(BAP, UC_SRV, 0),
BAP_UC_SRV_ASE_STATE = GAF_CODE(BAP, UC_SRV, 1),
BAP_UC_SRV_CIS_STATE = GAF_CODE(BAP, UC_SRV, 2),
};
/// List of GAF_REQ_IND request indication codes for BAP Unicast Server
enum bap_uc_srv_req_ind_code
{
BAP_UC_SRV_CONFIGURE_CODEC_RI = GAF_CODE(BAP, UC_SRV, 0),
BAP_UC_SRV_ENABLE = GAF_CODE(BAP, UC_SRV, 1),
BAP_UC_SRV_UPDATE_METADATA_RI = GAF_CODE(BAP, UC_SRV, 2),
BAP_UC_SRV_RELEASE_RI = GAF_CODE(BAP, UC_SRV, 3),
};
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called each time a command has been completed
*
* @param[in] cmd_code Command code (@see enum bap_uc_srv_cmd_code)
* @param[in] status Status
* @param[in] ase_lid ASE local index
****************************************************************************************
*/
typedef void (*bap_uc_srv_cb_cmp_evt)(uint16_t cmd_code, uint16_t status, uint8_t ase_lid);
/**
****************************************************************************************
* @brief Callback function called each time BAP_UC_SRV_GET_QUALITY command has been completed
*
* @param[in] status Status
* @param[in] ase_lid ASE local index
* @param[in] tx_unacked_packets Number of packets transmitted and unacked
* @param[in] tx_flushed_packets Number of flushed transmitted packets
* @param[in] tx_last_subevent_packets Number of packets transmitted during last subevent
* @param[in] retx_packets Number of retransmitted packets
* @param[in] crc_error_packets Number of packets received with a CRC error
* @param[in] rx_unrx_packets Number of unreceived packets
* @param[in] duplicate_packets Number of duplicate packet received
****************************************************************************************
*/
typedef void (*bap_uc_srv_cb_quality_cmp_evt)(uint16_t status, uint8_t ase_lid, uint32_t tx_unacked_packets,
uint32_t tx_flushed_packets, uint32_t tx_last_subevent_packets,
uint32_t retransmitted_packets, uint32_t crc_error_packets,
uint32_t rx_unreceived_packets, uint32_t duplicate_packets);
/**
****************************************************************************************
* @brief Callback function called when client configuration for Audio Stream Control Service has been updated
*
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field
* @param[in] ase_cli_cfg_bf ASE Client configuration bit field
****************************************************************************************
*/
typedef void (*bap_uc_srv_cb_bond_data)(uint8_t con_lid, uint8_t cli_cfg_bf, uint16_t ase_cli_cfg_bf);
/**
****************************************************************************************
* @brief Callback function called when state of an ASE has been updated
*
* @param[in] ase_lid ASE local index
* @param[in] con_lid Connection local index
* @param[in] state State (@see enum bap_uc_ase_state)
* @param[in] direction Direction (@see enum gaf_direction)
****************************************************************************************
*/
typedef void (*bap_uc_srv_cb_ase_state)(uint8_t ase_lid, uint8_t con_lid, uint8_t state, uint8_t direction);
/**
****************************************************************************************
* @brief Callback function called when state of a CIS has been updated
*
* @param[in] ase_lid_sink ASE local index for Sink direction
* @param[in] ase_lid_src ASE local index for Source direction
* @param[in] CIG ID CIG ID
* @param[in] CIS ID CIS ID
* @param[in] conhdl Connection handle
****************************************************************************************
*/
typedef void (*bap_uc_srv_cb_cis_state)(uint8_t ase_lid_sink, uint8_t ase_lid_src, uint8_t cig_id, uint8_t cis_id,
uint16_t conhdl);
/**
****************************************************************************************
* @brief Callback function called when a client device successfully write ASE Control Point characteristic with
* Configure Codec operation
*
* @param[in] con_lid Connection local index
* @param[in] ase_instance_idx ASE instance index
* @param[in] ase_lid ASE local index
* @param[in] direction Direction (@see enum gaf_direction)
* @param[in] tgt_latency Target Latency (@see enum bap_uc_tgt_latency)
* @param[in] tgt_phy Target PHY (@see enum bap_uc_tgt_phy)
* @param[in] p_codec_id Pointer to Codec ID
* @param[in] p_codec_cfg Pointer to Codec Configuration
* To be casted as @see bap_lc3_cfg_ptr_t for LC3
* To be casted as @see bap_vendor_codec_cfg_ptr_t for Vendor Codec
****************************************************************************************
*/
typedef void (*bap_uc_srv_cb_configure_codec_req)(uint8_t con_lid, uint8_t ase_instance_idx, uint8_t ase_lid,
uint8_t direction, uint8_t tgt_latency, uint8_t tgt_phy,
gaf_codec_id_t* p_codec_id, void* p_codec_cfg);
/**
****************************************************************************************
* @brief Callback function called when a client device successfully write ASE Control Point characteristic with
* Enable operation
*
* @param[in] ase_lid ASE local index
* @param[in] p_metadata Pointer to Metadata structure
****************************************************************************************
*/
typedef void (*bap_uc_srv_cb_enable_req)(uint8_t ase_lid, bap_metadata_cfg_ptr_t* p_metadata);
/**
****************************************************************************************
* @brief Callback function called when a client device successfully write ASE Control Point characteristic with
* Update Metadata operation
*
* @param[in] ase_lid ASE local index
* @param[in] p_metadata Pointer to Metadata structure
****************************************************************************************
*/
typedef void (*bap_uc_srv_cb_update_metadata_req)(uint8_t ase_lid, bap_metadata_cfg_ptr_t* p_metadata);
/**
****************************************************************************************
* @brief Callback function called when a client device successfully write ASE Control Point characteristic with
* Release operation
*
* @param[in] ase_lid ASE local index
****************************************************************************************
*/
typedef void (*bap_uc_srv_cb_release_req)(uint8_t ase_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Audio Stream Control Service Server
typedef struct bap_uc_srv_cb
{
/// Callback function called each time a command has been completed
bap_uc_srv_cb_cmp_evt cb_cmp_evt;
/// Callback function called each time BAP_UC_SRV_GET_QUALITY command has been completed
bap_uc_srv_cb_quality_cmp_evt cb_quality_cmp_evt;
/// Callback function called when client configuration for Audio Stream Control Service has been updated
bap_uc_srv_cb_bond_data cb_bond_data;
/// Callback function called when state of an ASE has been updated
bap_uc_srv_cb_ase_state cb_ase_state;
/// Callback function called when state of a CIS has been updated
bap_uc_srv_cb_cis_state cb_cis_state;
/// Callback function called when a client device successfully write ASE Control Point characteristic with
/// Configure Codec operation
bap_uc_srv_cb_configure_codec_req cb_configure_codec_req;
/// Callback function called when a client device successfully write ASE Control Point characteristic with
/// Enable operation
bap_uc_srv_cb_enable_req cb_enable_req;
/// Callback function called when a client device successfully write ASE Control Point characteristic with
/// Update Metadata operation
bap_uc_srv_cb_update_metadata_req cb_update_metadata_req;
/// Callback function called when a client device successfully write ASE Control Point characteristic with
/// Release operation
bap_uc_srv_cb_release_req cb_release_req;
} bap_uc_srv_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
#if (GAF_BAP_UC_SRV)
/**
****************************************************************************************
* @brief Set bonding information related to Audio Stream Control Service after connection with a peer device
*
* @param[in] con_lid Connection local index
* @param[in] cli_cfg_bf Client configuration bit field for Audio Stream Control Service
* Each bit correspond to a characteristic in the range [0, BAP_UC_CHAR_TYPE_ASE[
* @param[in] ase_cli_cfg_bf Client configuration bit field for instances of the ASE characteristics
* Each bit correspond to an instance of the ASE characteristic
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_srv_restore_bond_data(uint8_t con_lid, uint8_t cli_cfg_bf, uint16_t ase_cli_cfg_bf);
/**
****************************************************************************************
* @brief Set stored Codec Configuration for an ASE after connection with a peer device
*
* @param[in] con_lid Connection local index
* @param[in] ase_lid ASE local index
* @param[in] ase_instance_idx ASE instance index
* @param[in] direction Direction (@see enum gaf_direction)
* @param[in] p_codec_id Pointer to Codec ID
* @param[in] p_qos_req Pointer to QoS Requirements structure
* @param[in] ctl_delay_us Controller delay in microseconds
* @param[in] dp_id Data Path ID
* @param[in] p_cfg Pointer to Codec Configuration
* To be casted as @see bap_lc3_cfg_t for LC3
* To be casted as @see bap_vendor_codec_cfg_t for Vendor Codec
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_srv_restore_bond_data_codec(uint8_t con_lid, uint8_t ase_lid, uint8_t ase_instance_lid,
uint8_t direction, gaf_codec_id_t* p_codec_id, bap_qos_req_t* p_qos_req,
uint32_t ctl_delay_us, uint8_t dp_id, void* p_cfg);
/**
****************************************************************************************
* @brief Configure Codec for an ASE
*
* @param[in] con_lid Connection local index
* @param[in] ase_lid ASE local index
* @param[in] ase_instance_idx ASE instance index
* @param[in] direction Direction (@see enum gaf_direction)
* @param[in] p_codec_id Pointer to Codec ID
* @param[in] p_qos_req Pointer to QoS Requirements structure
* @param[in] ctl_delay_us Controller delay in microseconds
* @param[in] dp_id Data Path ID
* @param[in] p_cfg Pointer to Codec Configuration
* To be casted as @see bap_lc3_cfg_ptr_t for LC3
* To be casted as @see bap_vendor_codec_cfg_ptr_t for Vendor Codec
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_srv_configure_codec(uint8_t con_lid, uint8_t ase_lid, uint8_t ase_instance_idx, uint8_t direction,
gaf_codec_id_t* p_codec_id, bap_qos_req_t* p_qos_req, uint32_t ctl_delay_us,
uint8_t dp_id, void* p_cfg);
/**
****************************************************************************************
* @brief Update Metadata for an ASE
*
* @param[in] ase_lid ASE local index
* @param[in] p_metadata Pointer to Metadata structure
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_srv_update_metadata(uint8_t ase_lid, bap_metadata_cfg_t* p_metadata);
/**
****************************************************************************************
* @brief Disable an ASE
*
* @param[in] ase_lid ASE local index
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_srv_disable(uint8_t ase_lid);
/**
****************************************************************************************
* @brief Release an ASE
*
* @param[in] ase_lid ASE local index
* @param[in] idle Indicate if ASE next state will be Idle or Codec Configured
*
* @return An error status
****************************************************************************************
*/
uint16_t bap_uc_srv_release(uint8_t ase_lid, bool idle);
/**
****************************************************************************************
* @brief Get link quality information for stream an ASE is part of
*
* @param[in] ase_lid ASE local index
****************************************************************************************
*/
uint16_t bap_uc_srv_get_quality(uint8_t ase_lid);
#if (GAF_VS)
/**
****************************************************************************************
* @brief Vendor specific command allowing to set a periodic trigger
*
* @param[in] ase_lid ASE local index
* @param[in] enable Indicate if periodic trigger must be enabled or disabled
* @param[in] trigger_offset_us Trigger offset in microseconds
* - For source direction, trigger offset is applied using SDU at source reference
* - For sink direction, trigger offset is applied using SDU at direction reference
* (SDU at source + transport latency)
****************************************************************************************
*/
uint16_t bap_uc_srv_vs_set_trigger(uint8_t ase_lid, uint8_t enable, uint32_t trigger_offset_us);
#endif //(GAF_VS)
/**
****************************************************************************************
* @brief Confirmation for BAP_UC_SRV_CONFIGURE_CODEC request indication
*
* @param[in] rsp_code Response code (@see enum bap_uc_cp_rsp_code)
* @param[in] reason Reason (@see enum bap_uc_cp_reason)
* @param[in] ase_lid ASE local index
* @param[in] p_qos_req Pointer to QoS Requirements structure
* @param[in] p_codec_cfg Pointer to Codec Configuration
* To be casted as @see bap_lc3_cfg_ptr_t for LC3
* To be casted as @see bap_vendor_codec_cfg_ptr_t for Vendor Codec
* @param[in] ctl_delay_us Controller delay in microseconds
* @param[in] dp_id Data Path ID
****************************************************************************************
*/
void bap_uc_srv_configure_codec_cfm(uint8_t rsp_code, uint8_t reason, uint8_t ase_lid, bap_qos_req_t* p_qos_req,
void* p_codec_cfg, uint32_t ctl_delay_us, uint8_t dp_id);
/**
****************************************************************************************
* @brief Confirmation for BAP_UC_SRV_ENABLE request indication
*
* @param[in] rsp_code Response code (@see enum bap_uc_cp_rsp_code)
* @param[in] reason Reason (@see enum bap_uc_cp_reason)
* @param[in] p_metadata Pointer to Metadata structure
****************************************************************************************
*/
void bap_uc_srv_enable_cfm(uint8_t rsp_code, uint8_t reason, bap_metadata_cfg_t* p_metadata);
/**
****************************************************************************************
* @brief Confirmation for BAP_UC_SRV_UPDATE_METADATA request indication
*
* @param[in] rsp_code Response code (@see enum bap_uc_cp_rsp_code)
* @param[in] reason Reason (@see enum bap_uc_cp_reason)
* @param[in] p_metadata Pointer to Metadata structure
****************************************************************************************
*/
void bap_uc_srv_update_metadata_cfm(uint8_t rsp_code, uint8_t reason, bap_metadata_cfg_t* p_metadata);
/**
****************************************************************************************
* @brief Confirmation for BAP_UC_SRV_RELEASE request indication
*
* @param[in] rsp_code Response code (@see enum bap_uc_cp_rsp_code)
* @param[in] reason Reason (@see enum bap_uc_cp_reason)
* @param[in] idle Indicate if next state of ASE being released will be Idle or Codec Configured
****************************************************************************************
*/
void bap_uc_srv_release_cfm(uint8_t rsp_code, uint8_t reason, bool idle);
#endif //(GAF_BAP_UC_SRV)
/// @}
#endif // BAP_UC_SRV_H_
@@ -0,0 +1,413 @@
/**
****************************************************************************************
*
* @file bap_uc_srv_msg.h
*
* @brief Basic Audio Profile - Unicast Server - Message API Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_UC_SRV_MSG_H_
#define BAP_UC_SRV_MSG_H_
/**
****************************************************************************************
* @addtogroup BAP_UC_SRV_MSG Basic Audio Profile - Unicast Server - Message API Definitions
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap_msg.h" // Basic Audio Profile Message API Definitions
#include "bap_uc_srv.h" // Basic Audio Profile - Unicast Server Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for BAP_UC_SRV_RESTORE_BOND_DATA request message
typedef struct bap_uc_srv_restore_bond_data_req
{
/// Request code (@see enum bap_uc_srv_req_code)
/// - BAP_UC_SRV_RESTORE_BOND_DATA
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field for Audio Stream Control Service
/// Each bit correspond to a characteristic in the range [0, BAP_UC_CHAR_TYPE_ASE[
uint8_t cli_cfg_bf;
/// Client configuration bit field for instances of the ASE characteristics
/// Each bit correspond to an instance of the ASE characteristic
uint16_t ase_cli_cfg_bf;
} bap_uc_srv_restore_bond_data_req_t;
/// Structure for BAP_UC_SRV_RESTORE_BOND_DATA_CODEC request message
typedef struct bap_uc_srv_restore_bond_data_codec_req
{
/// Request code (@see enum bap_uc_srv_req_code)
/// - BAP_UC_SRV_RESTORE_BOND_DATA_CODEC
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// ASE local index
uint8_t ase_lid;
/// ASE instance index
uint8_t ase_instance_idx;
/// Direction (@see enum gaf_direction)
uint8_t direction;
/// Data Path ID
uint8_t dp_id;
/// Codec ID
gaf_codec_id_t codec_id;
/// QoS Requirements
bap_qos_req_t qos_req;
/// Controller delay in microseconds
uint32_t ctl_delay_us;
/// Length of Codec Configuration structure value
uint16_t cfg_len;
/// Codec Configuration structure value, length is cfg_len
/// To be casted as @see bap_lc3_cfg_t for LC3
/// To be casted as @see bap_vendor_codec_cfg_t for Vendor Codec
uint8_t cfg[__ARRAY_EMPTY];
} bap_uc_srv_restore_bond_data_codec_req_t;
/// Structure for BAP_UC_SRV_CONFIGURE_CODEC request message
typedef struct bap_uc_srv_configure_codec_req
{
/// Request code (@see enum bap_uc_srv_req_code)
/// - BAP_UC_SRV_CONFIGURE_CODEC
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// ASE local index
uint8_t ase_lid;
/// ASE instance index
uint8_t ase_instance_idx;
/// Direction
uint8_t direction;
/// Data Path ID
uint8_t dp_id;
/// Codec ID
gaf_codec_id_t codec_id;
/// QoS Requirements
bap_qos_req_t qos_req;
/// Controller delay in microseconds
uint32_t ctl_delay_us;
/// Length of Codec Configuration structure value
uint16_t cfg_len;
/// Codec Configuration structure value, length is cfg_len
/// To be casted as @see bap_lc3_cfg_t for LC3
/// To be casted as @see bap_vendor_codec_cfg_t for Vendor Codec
uint8_t cfg[__ARRAY_EMPTY];
} bap_uc_srv_configure_codec_req_t;
/// Structure for BAP_UC_SRV_UPDATE_METADATA request message
typedef struct bap_uc_srv_update_metadata_req
{
/// Request code (@see enum bap_uc_srv_req_code)
/// - BAP_UC_SRV_UPDATE_METADATA
uint16_t req_code;
/// ASE local index
uint8_t ase_lid;
/// Metadata structure
bap_metadata_cfg_t metadata;
} bap_uc_srv_update_metadata_req_t;
/// Structure for response message
typedef struct bap_uc_srv_rsp
{
/// Request code (@see enum bap_uc_srv_req_code)
uint16_t req_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
/// ASE local index
uint8_t ase_lid;
} bap_uc_srv_rsp_t;
/// Structure for BAP_UC_SRV_DISABLE command message
typedef struct bap_uc_srv_disable_cmd
{
/// Command code (@see enum bap_uc_srv_cmd_code)
/// - BAP_UC_SRV_DISABLE
uint16_t cmd_code;
/// ASE local index
uint8_t ase_lid;
} bap_uc_srv_disable_cmd_t;
/// Structure for BAP_UC_SRV_RELEASE command message
typedef struct bap_uc_srv_release_cmd
{
/// Command code (@see enum bap_uc_srv_cmd_code)
/// - BAP_UC_SRV_RELEASE
uint16_t cmd_code;
/// ASE local index
uint8_t ase_lid;
/// Indicate if ASE next state will be Idle or Codec Configured
uint8_t idle;
} bap_uc_srv_release_cmd_t;
/// Structure for BAP_UC_SRV_VS_SET_TRIGGER command message
typedef struct bap_uc_srv_vs_set_trigger_cmd
{
/// Command code (@see enum bap_uc_srv_cmd_code)
/// - BAP_UC_SRV_VS_SET_TRIGGER
uint16_t cmd_code;
/// ASE local index
uint8_t ase_lid;
/// Indicate if periodic trigger must be enabled or disabled
uint8_t enable;
/// Trigger offset in microseconds
/// - For source direction, trigger offset is applied using SDU at source reference
/// - For sink direction, trigger offset is applied using SDU at direction reference
/// (SDU at source + transport latency)
uint32_t trigger_offset_us;
} bap_uc_srv_vs_set_trigger_cmd_t;
/// Structure for BAP_UC_SRV_GET_QUALITY command message
typedef struct bap_uc_srv_get_quality_cmd
{
/// Command code (@see enum bap_uc_srv_cmd_code)
/// - BAP_UC_SRV_GET_QUALITY
uint16_t cmd_code;
/// ASE local index
uint8_t ase_lid;
} bap_uc_srv_get_quality_cmd_t;
/// Structure for command complete event message
typedef struct bap_uc_srv_cmp_evt
{
/// Command code (@see enum bap_uc_srv_cmd_code)
uint16_t cmd_code;
/// Status
uint16_t status;
/// ASE local index
uint8_t ase_lid;
} bap_uc_srv_cmp_evt_t;
/// Structure for BAP_UC_SRV_GET_QUALITY command complete event message
typedef struct bap_uc_srv_get_quality_cmp_evt
{
/// Command code (@see enum bap_uc_srv_cmd_code)
/// - BAP_UC_SRV_GET_QUALITY
uint16_t cmd_code;
/// Status
uint16_t status;
/// ASE local index
uint8_t ase_lid;
/// Number of packets transmitted and unacked
uint32_t tx_unacked_packets;
/// Number of flushed transmitted packets
uint32_t tx_flushed_packets;
/// Number of packets transmitted during last subevent
uint32_t tx_last_subevent_packets;
/// Number of retransmitted packets
uint32_t retx_packets;
/// Number of packets received with a CRC error
uint32_t crc_error_packets;
/// Number of unreceived packets
uint32_t rx_unrx_packets;
/// Number of duplicate packets received
uint32_t duplicate_packets;
} bap_uc_srv_get_quality_cmp_evt_t;
/// Structure for BAP_UC_SRV_BOND_DATA indication message
typedef struct bap_uc_srv_bond_data_ind
{
/// Indication code (@see enum bap_uc_srv_ind_code)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Client configuration bit field for Audio Stream Control Service
/// Each bit correspond to a characteristic in the range [0, BAP_UC_CHAR_TYPE_ASE[
uint8_t cli_cfg_bf;
/// Client configuration bit field for instances of the ASE characteristics
/// Each bit correspond to an instance of the ASE characteristic
uint16_t ase_cli_cfg_bf;
} bap_uc_srv_bond_data_ind_t;
/// Structure for BAP_UC_SRV_ASE_STATE indication message
typedef struct bap_uc_srv_ase_state_ind
{
/// Indication code (@see enum bap_uc_srv_ind_code)
uint16_t ind_code;
/// ASE local index
uint8_t ase_lid;
/// Connection local index
uint8_t con_lid;
/// State (@see enum bap_uc_ase_state)
uint8_t state;
/// Direction (@see enum gaf_direction)
uint8_t direction;
} bap_uc_srv_ase_state_ind_t;
/// Structure for BAP_UC_SRV_CIS_STATE indication message
typedef struct bap_uc_srv_cis_state_ind
{
/// Indication code (@see enum bap_uc_srv_ind_code)
uint16_t ind_code;
/// ASE local index for Sink direction
uint8_t ase_lid_sink;
/// ASE local index for Source direction
uint8_t ase_lid_src;
/// CIG ID
uint8_t cig_id;
/// CIS ID
uint8_t cis_id;
/// Connection handle allocated by the controller
/// GAP_INVALID_CONHDL means that the CIS is not established
uint16_t conhdl;
} bap_uc_srv_cis_state_ind_t;
/// Structure for BAP_UC_SRV_CONFIGURE_CODEC request indication message
typedef struct bap_uc_srv_configure_codec_req_ind
{
/// Request indication code (@see enum bap_uc_srv_req_ind_code)
/// - BAP_UC_SRV_CONFIGURE_CODEC_RI
uint16_t req_ind_code;
/// Connection local index
uint8_t con_lid;
/// ASE instance index
uint8_t ase_instance_idx;
/// ASE local index
uint8_t ase_lid;
/// Direction (@see enum gaf_direction)
uint8_t direction;
/// Target Latency (@see enum bap_uc_tgt_latency)
uint8_t tgt_latency;
/// Target PHY (@see enum bap_uc_tgt_phy)
uint8_t tgt_phy;
/// Codec ID
gaf_codec_id_t codec_id;
/// Length of Codec Configuration value
uint16_t cfg_len;
/// Codec Configuration value, length is cfg_len
/// To be casted as @see bap_lc3_cfg_t for LC3
/// To be casted as @see bap_vendor_codec_cfg_t for Vendor Codec
uint8_t cfg[__ARRAY_EMPTY];
} bap_uc_srv_configure_codec_req_ind_t;
/// Structure for BAP_UC_SRV_ENABLE request indication message
typedef struct bap_uc_srv_enable_req_ind
{
/// Request indication code (@see enum bap_uc_srv_req_ind_code)
/// - BAP_UC_SRV_ENABLE
uint16_t req_ind_code;
/// ASE local index
uint8_t ase_lid;
/// Metadata structure
bap_metadata_cfg_t metadata;
} bap_uc_srv_enable_req_ind_t;
/// Structure for BAP_UC_SRV_UPDATE_METADATA request indication message
typedef struct bap_uc_srv_update_metadata_req_ind
{
/// Request indication code (@see enum bap_uc_srv_req_ind_code)
/// - BAP_UC_SRV_UPDATE_METADATA_RI
uint16_t req_ind_code;
/// ASE local index
uint8_t ase_lid;
/// Metadata structure
bap_metadata_cfg_t metadata;
} bap_uc_srv_update_metadata_req_ind_t;
/// Structure for BAP_UC_SRV_RELEASE request indication message
typedef struct bap_uc_srv_release_req_ind
{
/// Request indication code (@see enum bap_uc_srv_req_ind_code)
/// - BAP_UC_SRV_RELEASE_RI
uint16_t req_ind_code;
/// ASE local index
uint8_t ase_lid;
} bap_uc_srv_release_req_ind_t;
/// Structure for BAP_UC_SRV_CONFIGURE_CODEC confirmation message
typedef struct bap_uc_srv_configure_codec_cfm
{
/// Request indication code (@see enum bap_uc_srv_req_ind_code)
/// - BAP_UC_SRV_CONFIGURE_CODEC_RI
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Response code (@see enum bap_uc_cp_rsp_code)
uint8_t rsp_code;
/// Reason (@see enum bap_uc_cp_reason)
uint8_t reason;
/// ASE local index
uint8_t ase_lid;
/// Data Path ID
uint8_t dp_id;
/// Codec ID
gaf_codec_id_t codec_id;
/// QoS Requirements
bap_qos_req_t qos_req;
/// Controller Delay in microseconds
uint32_t ctl_delay_us;
/// Length of Codec Configuration value
uint16_t cfg_len;
/// Codec Configuration value, length is cfg_len
/// To be casted as @see bap_lc3_cfg_t for LC3
/// To be casted as @see bap_vendor_codec_cfg_t for Vendor Codec
uint8_t cfg[__ARRAY_EMPTY];
} bap_uc_srv_configure_codec_cfm_t;
/// Structure for BAP_UC_SRV_ENABLE confirmation message
typedef struct bap_uc_srv_enable_cfm
{
/// Request indication code (@see enum bap_uc_srv_req_ind_code)
/// - BAP_UC_SRV_ENABLE
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Response code (@see enum bap_uc_cp_rsp_code)
uint8_t rsp_code;
/// Reason (@see enum bap_uc_cp_reason)
uint8_t reason;
/// Metadata structure
bap_metadata_cfg_t metadata;
} bap_uc_srv_enable_cfm_t;
/// Structure for BAP_UC_SRV_UPDATE_METADATA confirmation message
typedef struct bap_uc_srv_update_metadata_cfm
{
/// Request indication code (@see enum bap_uc_srv_req_ind_code)
/// - BAP_UC_SRV_UPDATE_METADATA_RI
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Response code (@see enum bap_uc_cp_rsp_code)
uint8_t rsp_code;
/// Reason (@see enum bap_uc_cp_reason)
uint8_t reason;
/// Metadata structure
bap_metadata_cfg_t metadata;
} bap_uc_srv_update_metadata_cfm_t;
/// Structure for BAP_UC_SRV_RELEASE confirmation message
typedef struct bap_uc_srv_release_cfm
{
/// Request indication code (@see enum bap_uc_srv_req_ind_code)
/// - BAP_UC_SRV_RELEASE_RI
uint16_t req_ind_code;
/// Status
uint16_t status;
/// Response code (@see enum bap_uc_cp_rsp_code)
uint8_t rsp_code;
/// Reason (@see enum bap_uc_cp_reason)
uint8_t reason;
/// Indicate if ASE next state will be Idle or Codec Configured
uint8_t idle;
} bap_uc_srv_release_cfm_t;
/// @}
#endif // BAP_UC_SRV_MSG_H_
+57
View File
@@ -0,0 +1,57 @@
/**
****************************************************************************************
*
* @file cap.h
*
* @brief Common Audio Profile - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef CAP_H_
#define CAP_H_
/**
****************************************************************************************
* @addtogroup CAP Common Audio Profile
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf_cfg.h" // GAF Configuration
/*
* MACROS
****************************************************************************************
*/
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Module type values
enum cap_module_type
{
/// Common
CAP_MODULE_COMMON = 0,
/// Common Audio Profile Server
CAP_MODULE_CAPS = 1,
/// Common Audio Profile Client
CAP_MODULE_CAPC = 2,
CAP_MODULE_MAX,
};
/// @}
#endif // CAP_H_
@@ -0,0 +1,43 @@
/**
****************************************************************************************
*
* @file cap_msg.h
*
* @brief Common Audio Profile - Definition of Kernel Messages
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef CAP_MSG_H_
#define CAP_MSG_H_
/**
****************************************************************************************
* @addtogroup CAP Common Audio Profile - Definition of Kernel Messages
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "cap.h" // CAP Definitions
#if (GAF_CAP)
#include "gaf_msg.h" // Generic Audio Framework API Message Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
#endif //(GAF_CAP)
/// @}
#endif // CAP_MSG_H_
+159
View File
@@ -0,0 +1,159 @@
/**
****************************************************************************************
*
* @file capc.h
*
* @brief Common Audio Profile - Client - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef CAPC_H_
#define CAPC_H_
/**
****************************************************************************************
* @addtogroup CAPC Common Audio Profile - Client
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "cap.h" // Common Audio Profile Definitions
#include "prf_types.h" // Profile common types
#if (GAF_CAPC)
#include "gaf.h" // Generic Audio Framework Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_CMD command codes for Common Audio Profile Client
enum capc_cmd_codes
{
CAPC_DISCOVER = GAF_CODE(CAP, CAPC, 0),
};
/// List of GAF_REQ request codes for Common Audio Profile - Client
enum capc_msg_req_codes
{
CAPC_CONFIGURE = GAF_CODE(CAP, CAPC, 0),
CAPC_RESTORE_BOND_DATA = GAF_CODE(CAP, CAPC, 1),
};
/// List of GAF_IND indication codes for Common Audio Profile - Client
enum capc_msg_ind_codes
{
CAPC_BOND_DATA = GAF_CODE(CAP, CAPC, 0),
CAPC_SVC_CHANGED = GAF_CODE(CAP, CAPC, 1),
};
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called each time a CAPC command has been completed
*
* @param[in] cmd_code Command code
* @param[in] status Status
* @param[in] con_lid Local index
****************************************************************************************
*/
typedef void (*capc_cb_cmp_evt)(uint16_t cmd_code, uint16_t status, uint8_t con_lid);
/**
****************************************************************************************
* @brief Callback function called when Common Audio Service has been discovered
*
* @param[in] con_lid Connection local index
* @param[in] p_svc_info Pointer to Common Audio Service information
* @param[in] csis_shdl Start handle of included Coordinated Set Identification Service
* @param[in] csis_ehdl End handle of included Coordinated Set Identification Service
****************************************************************************************
*/
typedef void (*capc_cb_bond_data)(uint8_t con_lid, prf_svc_t* p_svc_info,
uint16_t csis_shdl, uint16_t csis_ehdl);
/**
****************************************************************************************
* @brief Callback function called when a service changed indication has been received from a Server device
*
* @param[in] con_lid Connection local index
****************************************************************************************
*/
typedef void (*capc_cb_svc_changed)(uint8_t con_lid);
/*
* CALLBACK SET DEFINITION
****************************************************************************************
*/
/// Set of callback functions for Common Audio Profile - Client role
typedef struct capc_cb
{
/// Callback function called when a command has been completed
capc_cb_cmp_evt cb_cmp_evt;
/// Callback function called when Common Audio Service has been discovered
capc_cb_bond_data cb_bond_data;
/// Callback function called when a service changed indication has been received from a Server device
capc_cb_svc_changed cb_svc_changed;
} capc_cb_t;
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure use of Common Audio Profile block as Client
*
* @param[in] p_cb Pointer to set of callback functions for communication with upper
* layer
*
* @return An error status
****************************************************************************************
*/
uint16_t capc_configure(const capc_cb_t* p_cb);
/**
****************************************************************************************
* @brief Enable use of Common Audio Profile as Client as discover Common Audio Service in
* a Server device database
*
* @param[in] con_lid Connection local index
*
* @return An error status
****************************************************************************************
*/
uint16_t capc_discover(uint8_t con_lid);
/**
****************************************************************************************
* @brief Enable use of Common Audio Profile as Client when discovery has already been performed
*
* @param[in] con_lid Connection local index
* @param[in] p_svc_info Pointer to service information
*
* @return An error status
****************************************************************************************
*/
uint16_t capc_restore_bond_data(uint8_t con_lid, prf_svc_t* p_svc_info);
#endif //(GAF_CAPC)
/// @}
#endif // CAPC_H_
+111
View File
@@ -0,0 +1,111 @@
/**
****************************************************************************************
*
* @file capc_msg.h
*
* @brief Common Audio Profile - Client - Message API Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef CAPC_MSG_H_
#define CAPC_MSG_H_
/**
****************************************************************************************
* @addtogroup CAPC_MSG Common Audio Profile - Client - Message API Definitions
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "cap_msg.h" // Message API Definitions
#include "capc.h" // Common Audio Profile - Client Definitions
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for CAPC_CONFIGURE request message
typedef struct capc_configure_req
{
/// Request code (@see enum capc_msg_req_codes)
uint16_t req_code;
} capc_configure_req_t;
/// Structure for CAPC_RESTORE_BOND_DATA request message
typedef struct capc_restore_bond_data_req
{
/// Request code (@see enum capc_msg_req_codes)
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// Service information
prf_svc_t svc_info;
} capc_restore_bond_data_req_t;
/// Structure for response message
typedef struct capc_rsp
{
/// Request code (@see enum capc_msg_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
} capc_rsp_t;
/// Structure for CAPC_DISCOVER command message
typedef struct capc_discover_cmd
{
/// Command code (@see enum capc_cmd_codes)
uint16_t cmd_code;
/// Connection local index
uint8_t con_lid;
} capc_discover_cmd_t;
/// Structure for GAF_CMP_EVT message
typedef struct capc_cmp_evt
{
/// Command code (@see enum capc_cmd_codes)
uint16_t cmd_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
} capc_cmp_evt_t;
/// Structure for CAPC_BOND_DATA indication message
typedef struct capc_bond_data_ind
{
/// Indication code (@see enum capc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
/// Common Audio Service Information
prf_svc_t svc_info;
/// Start handle of included Coordinated Set Identification Service
uint16_t csis_shdl;
/// End handle of included Coordinated Set Identification Service
uint16_t csis_ehdl;
} capc_bond_data_ind_t;
/// Structure for CAPC_SVC_CHANGED indication message
typedef struct capc_svc_changed_ind
{
/// Indication code (@see enum capc_ind_codes)
uint16_t ind_code;
/// Connection local index
uint8_t con_lid;
} capc_svc_changed_ind_t;
/// @}
#endif // CAPC_MSG_H_
+75
View File
@@ -0,0 +1,75 @@
/**
****************************************************************************************
*
* @file caps.h
*
* @brief Common Audio Profile - Server - Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef CAPS_H_
#define CAPS_H_
/**
****************************************************************************************
* @addtogroup CAPS Common Audio Profile - Server
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "cap.h" // Common Audio Profile Definitions
#if (GAF_CAPS)
#include "gaf.h" // Generic Audio Framework Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_REQ request codes for Common Audio Profile - Server
enum caps_msg_req_codes
{
CAPS_CONFIGURE = GAF_CODE(CAP, CAPS, 0),
CAPS_ENABLE = GAF_CODE(CAP, CAPS, 1),
};
/*
* API FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure use of Common Audio Profile as Server
*
* @return An error status
****************************************************************************************
*/
uint16_t caps_configure(void);
/**
****************************************************************************************
* @brief Enable use of Common Audio Profile as Server
*
* @param[in] set_lid Coordinated Set local index
*
* @return An error status
****************************************************************************************
*/
uint16_t caps_enable(uint8_t set_lid);
#endif //(GAF_CAPS)
/// @}
#endif // CAPS_H_
@@ -0,0 +1,68 @@
/**
****************************************************************************************
*
* @file caps_msg.h
*
* @brief Common Audio Profile - Server - Message API Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef CAPS_MSG_H_
#define CAPS_MSG_H_
/**
****************************************************************************************
* @addtogroup CAPS_MSG Common Audio Profile - Server - Message API Definitions
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "cap_msg.h" // Message API Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for CAPS_CONFIGURE request message
typedef struct caps_configure_req
{
/// Request code (@see enum caps_msg_req_codes)
uint16_t req_code;
} caps_configure_req_t;
/// Structure for CAPS_ENABLE request message
typedef struct caps_enable_req
{
/// Request code (@see enum caps_msg_req_codes)
uint16_t req_code;
/// Coordinated Set local index
uint8_t set_lid;
} caps_enable_req_t;
/// Structure for response message
typedef struct caps_rsp
{
/// Request code (@see enum caps_msg_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
} caps_rsp_t;
/// @}
#endif // CAPS_MSG_H_
+426
View File
@@ -0,0 +1,426 @@
/**
****************************************************************************************
*
* @file gaf.h
*
* @brief Generic Audio Framework - Header file
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef GAF_H_
#define GAF_H_
/**
****************************************************************************************
* @addtogroup GAF Generic Audio Framework
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf_cfg.h" // Generic Audio Framework Configuration
#include "gap.h" // GAP defines
#include "prf_types.h" // Profile Definitions
#include "prf_utils.h" // Profile Utilitaries
/*
* DEFINES
****************************************************************************************
*/
/// Maximum number of ASE (must not be higher than 7 due to uint8_t size, see ASCS block)
#define GAF_ASE_NB_MAX (7)
/// Length of Codec ID value
#define GAF_CODEC_ID_LEN (5)
/// Length of Vendor Specific Part of Codec ID
#define GAF_CODEC_ID_VENDOR_SPEC_LEN (GAF_CODEC_ID_LEN - 1)
/// Invalid local index
#define GAF_INVALID_LID (0xFF)
/// Length of Advertising service data length
#define GAF_ADV_SVC_DATA_HEAD_LENGTH (3)
/// Length of Broadcast Audio Scan Service advertising data
#define GAF_ADV_AUDIO_SCAN_SVC_DATA_LENGTH (7)
// Minimum length for basic audio announcement
#define GAF_ADV_GRP_MIN_LEN (11)
#define GAF_ADV_SUBGRP_MIN_LEN (4)
#define GAF_ADV_STREAM_MIN_LEN (3)
/*
* MACROS
****************************************************************************************
*/
/// Mask for GAF error code
#define GAF_ERR_CODE(idx) (0x0100 | idx)
/// Generate a command/request/request indication/indication code
#define GAF_CODE(layer, module, idx) ((GAF_LAYER_ ## layer << 12) | (layer ##_MODULE_ ## module << 8) | idx)
/// Retrieve layer from message code
#define GAF_LAYER(code) ((code & 0xF000) >> 12)
/// Retrieve module from message code
#define GAF_MODULE(code) ((code & 0x0F00) >> 8)
/// Retrieve code index from message code
#define GAF_CODE_IDX(code) (code & 0x00FF)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// GAF Layers
enum gaf_layers
{
/// Generic Audio Framework
GAF_LAYER_GAF = 0,
/// Isochronous Access Profile
GAF_LAYER_IAP = 1,
/// Basic Audio Profile
GAF_LAYER_BAP = 2,
/// Common Audio Profile
GAF_LAYER_CAP = 3,
/// Audio Content Control
GAF_LAYER_ACC = 4,
/// Audio Rendering Control
GAF_LAYER_ARC = 5,
/// Audio Topology Control
GAF_LAYER_ATC = 6,
GAF_LAYER_MAX,
};
/// Module type values
enum gaf_module_type
{
/// Common
GAF_MODULE_COMMON = 0,
GAF_MODULE_MAX,
};
/// Error codes
enum gaf_err
{
/// No error
GAF_ERR_NO_ERROR = 0,
/// Invalid parameters
GAF_ERR_INVALID_PARAM = GAF_ERR_CODE(0x01),
/// Command disallowed
GAF_ERR_COMMAND_DISALLOWED = GAF_ERR_CODE(0x02),
/// Unknown command
GAF_ERR_UNKNOWN_COMMAND = GAF_ERR_CODE(0x03),
/// Unknown request
GAF_ERR_UNKNOWN_REQUEST = GAF_ERR_CODE(0x04),
/// Insufficient resources
GAF_ERR_INSUFFICIENT_RESOURCES = GAF_ERR_CODE(0x05),
/// Invalid connection
GAF_ERR_INVALID_CONNECTION = GAF_ERR_CODE(0x06),
/// Busy
GAF_ERR_BUSY = GAF_ERR_CODE(0x07),
/// Failed
GAF_ERR_FAILED = GAF_ERR_CODE(0x08),
/// Read procedure successful but read value was not correct
GAF_ERR_READ_ERROR = GAF_ERR_CODE(0x09),
/// Indicated direction is valid but not supported
GAF_ERR_DIRECTION_NOT_SUPPORTED = GAF_ERR_CODE(0x0A),
/// Invalid Output
GAF_ERR_INVALID_OUTPUT = GAF_ERR_CODE(0x0B),
/// Invalid Input
GAF_ERR_INVALID_INPUT = GAF_ERR_CODE(0x0C),
/// Invalid PAC
GAF_ERR_INVALID_PAC = GAF_ERR_CODE(0x0D),
/// Optional feature not supported by peer device
GAF_ERR_PEER_NOT_SUPPORT = GAF_ERR_CODE(0x0E),
/// Invalid Source
GAF_ERR_INVALID_SRC = GAF_ERR_CODE(0x0F),
/// Invalid ASE
GAF_ERR_INVALID_ASE = GAF_ERR_CODE(0x10),
/// Link Group already exists
GAF_ERR_LINK_GROUP_EXISTS = GAF_ERR_CODE(0x11),
/// Link already exists
GAF_ERR_LINK_EXISTS = GAF_ERR_CODE(0x12),
/// Invalid Link
GAF_ERR_INVALID_LINK = GAF_ERR_CODE(0x13),
/// Not configured
GAF_ERR_NOT_CONFIGURED = GAF_ERR_CODE(0x14),
/// Internal error
GAF_ERR_INTERNAL_ERROR = GAF_ERR_CODE(0x15),
/// No ASE available
GAF_ERR_NO_AVA_ASE = GAF_ERR_CODE(0x16),
/// Invalid Bearer
GAF_ERR_INVALID_BEARER = GAF_ERR_CODE(0x17),
/// Invalid Call
GAF_ERR_INVALID_CALL = GAF_ERR_CODE(0x18),
/// Invalid Media
GAF_ERR_INVALID_MEDIA = GAF_ERR_CODE(0x19),
/// Optional feature not supported locally
GAF_ERR_LOCAL_NOT_SUPPORT = GAF_ERR_CODE(0x1A),
/// Discovery error
GAF_ERR_DISC_ERROR = GAF_ERR_CODE(0x1B),
/// Invalid Record
GAF_ERR_INVALID_RECORD = GAF_ERR_CODE(0x1C),
/// Invalid ASE ID
GAF_ERR_INVALID_ASE_ID = GAF_ERR_CODE(0x1D),
/// Disconnection has occurred on the ACL link during the procedure
GAF_ERR_DISCONNECTED = GAF_ERR_CODE(0x1E),
};
/// ASE Direction
enum gaf_direction
{
/// Sink direction
GAF_DIRECTION_SINK = 0,
/// Source direction
GAF_DIRECTION_SRC,
GAF_DIRECTION_MAX,
};
/// Link Direction
enum gaf_link_direction
{
/// Monodirectional link as sink (from server point of view)
GAF_LINK_DIRECTION_MONODIR_SINK = 0x01,
/// Monodirectional link as source (from server point of view)
GAF_LINK_DIRECTION_MONODIR_SRC = 0x02,
/// Bidirectional link
GAF_LINK_DIRECTION_BIDIR = GAF_LINK_DIRECTION_MONODIR_SINK | GAF_LINK_DIRECTION_MONODIR_SRC,
};
/// Direction requirements bit field
enum gaf_direction_bf
{
/// Required for sink direction
GAF_DIRECTION_BF_SINK_POS = 0,
GAF_DIRECTION_BF_SINK_BIT = 0x01,
/// Required for source direction
GAF_DIRECTION_BF_SRC_POS = 1,
GAF_DIRECTION_BF_SRC_BIT = 0x02,
/// Required for both directions
GAF_DIRECTION_BF_BOTH = GAF_DIRECTION_BF_SRC_BIT + GAF_DIRECTION_BF_SINK_BIT,
};
/// Codec Type values
enum gaf_codec_type
{
/// LC3 Codec
GAF_CODEC_TYPE_LC3 = 0x00,
/// Maximum SIG Codec
GAF_CODEC_TYPE_SIG_MAX,
/// Same codec as broadcast group codec use for broadcast subgroup
GAF_CODEC_TYPE_SAME = 0xFE,
/// Vendor Specific Codec
GAF_CODEC_TYPE_VENDOR = 0xFF,
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Codec Identifier
typedef struct gaf_codec_id
{
/// Codec ID value
uint8_t codec_id[GAF_CODEC_ID_LEN];
} gaf_codec_id_t;
/// Data value in LTV format
typedef struct gaf_ltv
{
/// Length of data value
uint8_t len;
/// Data value
uint8_t data[__ARRAY_EMPTY];
} gaf_ltv_t;
/// Codec Information structure
typedef struct gaf_codec_info
{
/// Codec ID
uint8_t codec_id[GAF_CODEC_ID_LEN];
/// Codec Specific Capabilities value length
uint8_t codec_capa_len;
/// Codec Specific Capabilities value
uint8_t data[__ARRAY_EMPTY];
} gaf_codec_info_t;
/// Codec Information structure (pointer version)
typedef struct gaf_codec_info_ptr
{
/// Codec ID
uint8_t codec_id[GAF_CODEC_ID_LEN];
/// Codec Specific Capabilities value length
uint8_t codec_capa_len;
/// Pointer to Codec Specific Capabilities value
uint8_t* p_codec_capa;
} gaf_codec_info_ptr_t;
/// Codec Configuration structure
typedef struct gaf_codec_cfg
{
/// Codec ID
uint8_t codec_id[GAF_CODEC_ID_LEN];
/// Length of Codec Specific Configuration
uint8_t codec_cfg_len;
/// Codec Specific Configuration
uint8_t codec_cfg[__ARRAY_EMPTY];
} gaf_codec_cfg_t;
/// Codec Configuration structure (pointer version)
typedef struct gaf_codec_cfg_ptr
{
/// Codec ID
uint8_t codec_id[GAF_CODEC_ID_LEN];
/// Length of Codec Specific Configuration
uint8_t codec_cfg_len;
/// Pointer to Codec Specific Configuration
uint8_t* p_codec_cfg;
} gaf_codec_cfg_ptr_t;
/// QoS Requirements structure
typedef struct gaf_qos_req
{
/// Minimum SDU interval in microseconds
/// From 255us (0xFF) to 16777215us (0xFFFFFF)
uint32_t sdu_intv_min_us;
/// Maximum SDU interval in microseconds
/// From 255us (0xFF) to 16777215us (0xFFFFFF)
uint32_t sdu_intv_max_us;
/// Maximum SDU size
/// From 0 to 4095 bytes (0xFFF)
uint16_t max_sdu_size;
/// Minimum transport latency in milliseconds
/// From 5ms (0x5) to 4000ms (0xFA0)
uint16_t trans_latency_min_ms;
/// Maximum transport latency in milliseconds
/// From 5ms (0x5) to 4000ms (0xFA0)
uint16_t trans_latency_max_ms;
/// Indicate if Unframed ISOAL PDUs or Framed ISOAL PDUs are preferred
uint8_t pref_framing;
/// Indicate preferred PHY
uint8_t pref_phy;
/// Maximum number of retransmissions for each CIS Data PDU
/// From 0 to 15
uint8_t retx_nb;
/// Minimum presentation delay in microseconds
uint32_t pres_delay_min_us;
/// Maximum presentation delay in microseconds
uint32_t pres_delay_max_us;
} gaf_qos_req_t;
/// Full QoS Requirement structure
typedef struct gaf_qos_req_full
{
/// QoS Requirements structure
gaf_qos_req_t qos_req;
/// Codec Configuration structure
gaf_codec_cfg_t codec_cfg;
} gaf_qos_req_full_t;
/// Full QoS Requirement structure (pointer version)
typedef struct gaf_qos_req_full_ptr
{
/// QoS Requirements structure
gaf_qos_req_t qos_req;
/// Codec Configuration structure
gaf_codec_cfg_ptr_t codec_cfg;
} gaf_qos_req_full_ptr_t;
/// QoS Configuration structure
typedef struct gaf_qos_cfg
{
/// ISOAL PDU framing arrangement
uint8_t framing;
/// PHY
uint8_t phy;
/// Maximum number of retransmissions for each CIS Data PDU
/// From 0 to 15
uint8_t retx_nb;
/// Maximum SDU size
/// From 0 to 4095 bytes (0xFFF)
uint16_t max_sdu_size;
/// Transport latency in milliseconds
/// From 5ms (0x5) to 4000ms (0xFA0)
uint16_t trans_latency_ms;
/// Presentation delay in microseconds
uint32_t pres_delay_us;
/// SDU interval in microseconds
/// From 255us (0xFF) to 16777215us (0xFFFFFF)
uint32_t sdu_intv_us;
} gaf_qos_cfg_t;
/// ASE Configuration structure
typedef struct gaf_ase_cfg
{
/// QoS Configuration structure
gaf_qos_cfg_t qos_cfg;
/// CIG ID
uint8_t cig_id;
/// CIS ID
uint8_t cis_id;
} gaf_ase_cfg_t;
/// Content Configuration structure
typedef struct gaf_content_cfg
{
/// Content type intended to be used on the ASE
uint16_t active_content_bf;
/// Number of Content Control IDs (CCIDs) in use for the ASE
uint8_t nb_ccids;
/// List of CCIDs
uint8_t ccids[__ARRAY_EMPTY];
} gaf_content_cfg_t;
/// Content Configuation structure (pointer version)
typedef struct gaf_content_cfg_ptr
{
/// Content type intended to be used on the ASE
uint16_t active_content_bf;
/// Number of Content Control IDs (CCIDs) in use for the ASE
uint8_t nb_ccids;
/// Pointer to list of CCIDs
uint8_t* p_ccids;
} gaf_content_cfg_ptr_t;
/// Broadcast code used for stream encryption
typedef struct gaf_bcast_code_t
{
/// Broadcast Code value
uint8_t bcast_code[GAP_KEY_LEN];
} gaf_bcast_code_t;
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called when a command has been completed.
*
* @param[in] cmd_code Command code
* @param[in] status Status
****************************************************************************************
*/
typedef void (*gaf_cb_cmp_evt)(uint16_t cmd_code, uint16_t status);
/// @}
#endif // GAF_H_
+438
View File
@@ -0,0 +1,438 @@
/**
****************************************************************************************
*
* @file gaf_cfg.h
*
* @brief Generic Audio Framework - Configuration
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef GAF_CFG_H_
#define GAF_CFG_H_
/**
****************************************************************************************
* @addtogroup GAF - Generic Audio Framework
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "rwip_config.h" // RW IP Configuration
#include <stdint.h> // Standard Integer Definitions
#include <stdbool.h> // Standard Boolean definitions
#include "co_math.h" // Common Math Functions Definitions
/*
* COMPILATION FLAGS
****************************************************************************************
*/
#if (BLE_EMB_PRESENT)
/// Number of streams that can be created using IAP
#define IAP_NB_STREAMS (BLE_ISO_CHANNEL_MAX)
#else //(BLE_EMB_PRESENT)
/// Number of streams that can be created using IAP
#define IAP_NB_STREAMS (3)
#endif //(BLE_EMB_PRESENT)
/// Unicast mode supported
#if defined(CFG_CIS)
#define GAF_UNICAST_SUPP (1)
#else //(defined(CFG_CIS))
#define GAF_UNICAST_SUPP (0)
#endif //(defined(CFG_CIS))
/// Broadcast mode supported
#if defined(CFG_BIS)
#define GAF_BROADCAST_SUPP (1)
#if (BLE_OBSERVER)
#define GAF_BROADCAST_SLV_SUPP (1)
#else
#define GAF_BROADCAST_SLV_SUPP (0)
#endif //(BLE_OBSERVER)
#if (BLE_BROADCASTER)
#define GAF_BROADCAST_MST_SUPP (1)
#else
#define GAF_BROADCAST_MST_SUPP (0)
#endif //(BLE_OBSERVER)
#else //(defined(CFG_BIS))
#define GAF_BROADCAST_SUPP (0)
#endif //(defined(CFG_BIS))
/// IAP supported
#if (CFG_IAP_INTF_NB != 0)
#define GAF_IAP (1)
#else //(CFG_IAP_INTF_NB != 0)
#define GAF_IAP (0)
#endif //(CFG_IAP_INTF_NB != 0)
/// ARC supported
#if defined(CFG_ARC_VCS) || defined(CFG_ARC_VCC) || defined(CFG_ARC_MICS) || defined(CFG_ARC_MICC) || \
defined(CFG_ARC_AICS) || defined(CFG_ARC_AICC) || defined(CFG_ARC_VOCS) || defined(CFG_ARC_VOCC)
#define GAF_ARC (1)
#if defined(CFG_ARC_VCS)
#define GAF_ARC_VCS (1)
#else //(defined(CFG_ARC_VCS))
#define GAF_ARC_VCS (0)
#endif //(defined(CFG_ARC_VCS))
#if defined(CFG_ARC_VCC)
#define GAF_ARC_VCC (1)
#else //(defined(CFG_ARC_VCC))
#define GAF_ARC_VCC (0)
#endif //(defined(CFG_ARC_VCC))
#if defined(CFG_ARC_MICS)
#define GAF_ARC_MICS (1)
#else //(defined(CFG_ARC_MICS))
#define GAF_ARC_MICS (0)
#endif //(defined(CFG_ARC_MICS))
#if defined(CFG_ARC_MICC)
#define GAF_ARC_MICC (1)
#else //(defined(CFG_ARC_MICC))
#define GAF_ARC_MICC (0)
#endif //(defined(CFG_ARC_MICC))
#if defined(CFG_ARC_AICS)
#define GAF_ARC_AICS (1)
#else //(defined(CFG_ARC_AICS))
#define GAF_ARC_AICS (0)
#endif //(defined(CFG_ARC_AICS))
#if defined(CFG_ARC_AICC)
#define GAF_ARC_AICC (1)
#else //(defined(CFG_ARC_AICC))
#define GAF_ARC_AICC (0)
#endif //(defined(CFG_ARC_AICC))
#if defined(CFG_ARC_VOCS)
#define GAF_ARC_VOCS (1)
#else //(defined(CFG_ARC_VOCS))
#define GAF_ARC_VOCS (0)
#endif //(defined(CFG_ARC_VOCS))
#if defined(CFG_ARC_VOCC)
#define GAF_ARC_VOCC (1)
#else //(defined(CFG_ARC_VOCC))
#define GAF_ARC_VOCC (0)
#endif //(defined(CFG_ARC_VOCC))
#if (GAF_ARC_VCS || GAF_ARC_MICS || GAF_ARC_AICS || GAF_ARC_VOCS)
#define GAF_ARC_SRV (1)
#else //(GAF_ARC_VCS || GAF_ARC_MICS || GAF_ARC_AICS || GAF_ARC_VOCS)
#define GAF_ARC_SRV (0)
#endif //(GAF_ARC_VCS || GAF_ARC_MICS || GAF_ARC_AICS || GAF_ARC_VOCS)
#if (GAF_ARC_VCC || GAF_ARC_MICC || GAF_ARC_AICC || GAF_ARC_VOCC)
#define GAF_ARC_CLI (1)
#else //(GAF_ARC_VCC || GAF_ARC_MICC || GAF_ARC_AICC || GAF_ARC_VOCC)
#define GAF_ARC_CLI (0)
#endif //(GAF_ARC_VCC || GAF_ARC_MICC || GAF_ARC_AICC || GAF_ARC_VOCC)
#else //(defined(CFG_ARC_VCS) || defined(CFG_ARC_VCC) ...)
#define GAF_ARC (0)
#define GAF_ARC_SRV (0)
#define GAF_ARC_CLI (0)
#define GAF_ARC_VCS (0)
#define GAF_ARC_VCC (0)
#define GAF_ARC_MICS (0)
#define GAF_ARC_MICC (0)
#define GAF_ARC_AICS (0)
#define GAF_ARC_AICC (0)
#define GAF_ARC_VOCS (0)
#define GAF_ARC_VOCC (0)
#endif //(defined(CFG_ARC_VCS) || defined(CFG_ARC_VCC) ...)
/// ACC supported
#if defined(CFG_ACC_TBS) || defined(CFG_ACC_TBC) || defined(CFG_ACC_MCS) || defined(CFG_ACC_MCC)
#define GAF_ACC (1)
#if defined(CFG_ACC_TBS)
#define GAF_ACC_TBS (1)
#else //(defined(CFG_ACC_TBS))
#define GAF_ACC_TBS (0)
#endif //(defined(CFG_ACC_TBS))
#if defined(CFG_ACC_TBC)
#define GAF_ACC_TBC (1)
#else //(defined(CFG_ACC_TBC))
#define GAF_ACC_TBC (0)
#endif //(defined(CFG_ACC_TBC))
#if defined(CFG_ACC_MCS)
#define GAF_ACC_MCS (1)
#else //(defined(CFG_ACC_MCS))
#define GAF_ACC_MCS (0)
#endif //(defined(CFG_ACC_MCS))
#if defined(CFG_ACC_MCC)
#define GAF_ACC_MCC (1)
#else //(defined(CFG_ACC_MCC))
#define GAF_ACC_MCC (0)
#endif //(defined(CFG_ACC_MCC))
#if (GAF_ACC_MCS)
#if defined(CFG_ACC_OTS)
#define GAF_ACC_OTS (1)
#else //(defined(CFG_ACC_OTS))
#define GAF_ACC_OTS (0)
#endif //(defined(CFG_ACC_OTS))
#else //(GAF_ACC_MCS)
#define GAF_ACC_OTS (0)
#endif //(GAF_ACC_MCS)
#if (GAF_ACC_MCC)
#if defined(CFG_ACC_OTC)
#define GAF_ACC_OTC (1)
#else //(defined(CFG_ACC_OTC))
#define GAF_ACC_OTC (0)
#endif //(defined(CFG_ACC_OTC))
#else //(GAF_ACC_MCC)
#define GAF_ACC_OTC (0)
#endif //(GAF_ACC_MCC)
#if (GAF_ACC_TBS || GAF_ACC_MCS || GAF_ACC_OTS)
#define GAF_ACC_SRV (1)
#else //(GAF_ACC_TBS || GAF_ACC_MCS || GAF_ACC_OTS)
#define GAF_ACC_SRV (0)
#endif //(GAF_ACC_TBS || GAF_ACC_MCS || GAF_ACC_OTS)
#if (GAF_ACC_TBC || GAF_ACC_MCC || GAF_ACC_OTC)
#define GAF_ACC_CLI (1)
#else //(GAF_ACC_TBC || GAF_ACC_MCC || GAF_ACC_OTC)
#define GAF_ACC_CLI (0)
#endif //(GAF_ACC_TBC || GAF_ACC_MCC || GAF_ACC_OTC)
#else //(defined(CFG_ACC_TBS) || defined(CFG_ACC_TBC) ...)
#define GAF_ACC (0)
#define GAF_ACC_SRV (0)
#define GAF_ACC_CLI (0)
#define GAF_ACC_TBS (0)
#define GAF_ACC_TBC (0)
#define GAF_ACC_MCS (0)
#define GAF_ACC_MCC (0)
#define GAF_ACC_OTS (0)
#define GAF_ACC_OTC (0)
#endif //(defined(CFG_ACC_TBS) || defined(CFG_ACC_TBC) ...)
/// ATC supported
#if defined(CFG_ATC_RAAS) || defined(CFG_ATC_RAAS) || defined(CFG_ATC_CSISM) || defined(CFG_ATC_CSISC)
#define GAF_ATC (1)
#if defined(CFG_ATC_RAAS)
#define GAF_ATC_RAAS (1)
#else //(defined(CFG_ATC_RAAS))
#define GAF_ATC_RAAS (0)
#endif //(defined(CFG_ATC_RAAS))
#if defined(CFG_ATC_RAAC)
#define GAF_ATC_RAAC (1)
#else //(defined(CFG_ATC_RAAC))
#define GAF_ATC_RAAC (0)
#endif //(defined(CFG_ATC_RAAC))
#if defined(CFG_ATC_CSISM)
#define GAF_ATC_CSISM (1)
#else //(defined(CFG_ATC_CSISM))
#define GAF_ATC_CSISM (0)
#if defined(CFG_CAPS)
#undef CFG_CAPS
#endif //(defined(CFG_CAPS))
#endif //(defined(CFG_ATC_CSISM))
#if defined(CFG_ATC_CSISC)
#define GAF_ATC_CSISC (1)
#else //(defined(CFG_ATC_CSISC))
#define GAF_ATC_CSISC (0)
#if defined(CFG_CAPC)
#undef CFG_CAPC
#endif //(defined(CFG_CAPC))
#endif //(defined(CFG_ATC_CSISC))
#if (GAF_ATC_RAAS || GAF_ATC_CSISM)
#define GAF_ATC_SRV (1)
#else //(GAF_ATC_RAAS || GAF_ATC_CSISM)
#define GAF_ATC_SRV (0)
#endif //(GAF_ATC_RAAS || GAF_ATC_CSISM)
#if (GAF_ATC_RAAC || GAF_ATC_CSISC)
#define GAF_ATC_CLI (1)
#else //(GAF_ATC_RAAC || GAF_ATC_CSISC)
#define GAF_ATC_CLI (0)
#endif //(GAF_ATC_RAAC || GAF_ATC_CSISC)
#else //(defined(CFG_ATC_RAAS) || defined(CFG_ATC_RAAS) ...)
#define GAF_ATC (0)
#define GAF_ATC_SRV (0)
#define GAF_ATC_CLI (0)
#define GAF_ATC_RAAS (0)
#define GAF_ATC_RAAC (0)
#define GAF_ATC_CSISM (0)
#define GAF_ATC_CSISC (0)
#endif //(defined(CFG_ATC_RAAS) || defined(CFG_ATC_RAAS) ...)
#if defined(CFG_CAPS) || defined(CFG_CAPC)
#define GAF_CAP (1)
#if defined(CFG_CAPS)
#define GAF_CAPS (1)
#else
#define GAF_CAPS (0)
#endif //(defined(CFG_CAPS))
#if defined(CFG_CAPC)
#define GAF_CAPC (1)
#else
#define GAF_CAPC (0)
#endif //(defined(CFG_CAPS))
#else
#define GAF_CAP (0)
#define GAF_CAPS (0)
#define GAF_CAPC (0)
#endif //(defined(CFG_CAPS) || defined(CFG_CAPC))
#if (defined(CFG_BAP_UC_SRV) || defined(CFG_BAP_UC_CLI) || defined(CFG_BAP_CAPA_SRV) || defined(CFG_BAP_CAPA_CLI) || \
defined(CFG_BAP_BC_SRC) || defined(CFG_BAP_BC_SINK) || defined(CFG_BAP_BC_SCAN) || defined(CFG_BAP_BC_DELEG) || \
defined(CFG_BAP_BC_ASSIST))
#define GAF_BAP (1)
#if defined(CFG_BAP_UC_SRV)
#define GAF_BAP_UC_SRV (1)
#else
#define GAF_BAP_UC_SRV (0)
#endif //(defined(CFG_BAP_UC_SRV))
#if defined(CFG_BAP_UC_CLI)
#define GAF_BAP_UC_CLI (1)
#else
#define GAF_BAP_UC_CLI (0)
#endif //(defined(CFG_BAP_UC_CLI))
#if defined(CFG_BAP_CAPA_SRV)
#define GAF_BAP_CAPA_SRV (1)
#else
#define GAF_BAP_CAPA_SRV (0)
#endif //(defined(CFG_BAP_CAPA_SRV))
#if defined(CFG_BAP_CAPA_CLI)
#define GAF_BAP_CAPA_CLI (1)
#else
#define GAF_BAP_CAPA_CLI (0)
#endif //(defined(CFG_BAP_CAPA_CLI))
#if (defined(CFG_BAP_BC_SRC) && GAF_BROADCAST_SUPP)
#define GAF_BAP_BC_SRC (1)
#else
#define GAF_BAP_BC_SRC (0)
#endif //(defined(CFG_BAP_BC_SRC) && GAF_BROADCAST_SUPP)
#if (defined(CFG_BAP_BC_ASSIST) && GAF_BROADCAST_SUPP)
#define GAF_BAP_BC_ASSIST (1)
#else
#define GAF_BAP_BC_ASSIST (0)
#endif //(defined(GAF_BAP_BC_ASSIST) && GAF_BROADCAST_SUPP)
#if (defined(CFG_BAP_BC_DELEG) && GAF_BROADCAST_SUPP)
#define GAF_BAP_BC_DELEG (1)
#else
#define GAF_BAP_BC_DELEG (0)
#endif //(defined(GAF_BAP_BC_DELEG) && GAF_BROADCAST_SUPP)
#if ((defined(CFG_BAP_BC_SINK) || CFG_BAP_BC_DELEG) && GAF_BROADCAST_SUPP)
#define GAF_BAP_BC_SINK (1)
#else
#define GAF_BAP_BC_SINK (0)
#endif //((defined(CFG_BAP_BC_SINK) || CFG_BAP_BC_DELEG) && GAF_BROADCAST_SUPP)
#if ((defined(CFG_BAP_BC_SCAN) || GAF_BAP_BC_SINK || CFG_BAP_BC_ASSIST || CFG_BAP_BC_DELEG) && GAF_BROADCAST_SUPP)
#define GAF_BAP_BC_SCAN (1)
#else
#define GAF_BAP_BC_SCAN (0)
#endif //((defined(CFG_BAP_BC_SCAN) || GAF_BAP_BC_SINK || CFG_BAP_BC_ASSIST || CFG_BAP_BC_DELEG) && GAF_BROADCAST_SUPP)
#else
#define GAF_BAP (0)
#define GAF_BAP_UC_SRV (0)
#define GAF_BAP_UC_CLI (0)
#define GAF_BAP_CAPA_SRV (0)
#define GAF_BAP_CAPA_CLI (0)
#define GAF_BAP_BC_SRC (0)
#define GAF_BAP_BC_SINK (0)
#define GAF_BAP_BC_SCAN (0)
#define GAF_BAP_BC_ASSIST (0)
#define GAF_BAP_BC_DELEG (0)
#endif //(defined(CFG_BAP_UC_SRV) || defined(CFG_BAP_UC_CLI) || defined(CFG_BAP_CAPA_SRV) ...)
#if defined(CFG_GAF_API_MSG)
#define GAF_API_MSG (1)
#else
#define GAF_API_MSG (0)
#endif //(defined(CFG_GAF_API_MSG))
// Support of Debug functions
#if defined(CFG_GAF_DBG)
#define GAF_DBG (1)
#else
#define GAF_DBG (0)
#endif //(defined(CFG_GAF_DBG))
// Support of Vendor Specific functions
#if defined(CFG_GAF_VS)
#define GAF_VS (1)
#else
#define GAF_VS (0)
#endif //(defined(CFG_GAF_VS))
// GAF Adaptation layer
#if (GAF_BAP_BC_SRC)
#define GAF_AL_PER_ADV (1)
#else
#define GAF_AL_PER_ADV (0)
#endif //(GAF_BAP_BC_SRC)
#if (GAF_BAP_BC_SINK || GAF_BAP_BC_ASSIST)
#define GAF_AL_PER_SYNC (1)
#else
#define GAF_AL_PER_SYNC (0)
#endif //(GAF_BAP_BC_SINK || GAF_BAP_BC_ASSIST)
#if (GAF_AL_PER_SYNC && GAF_BAP_BC_ASSIST)
#define GAF_AL_PAST (1)
#else
#define GAF_AL_PAST (0)
#endif //(GAF_AL_PER_SYNC && GAF_BAP_BC_ASSIST)
#if (GAF_BAP_BC_SINK || GAF_BAP_BC_SCAN || GAF_BAP_BC_ASSIST || GAF_AL_PER_SYNC)
#define GAF_AL_SCAN (1)
#else
#define GAF_AL_SCAN (0)
#endif //(GAF_BAP_BC_SINK || GAF_BAP_BC_SCAN || GAF_BAP_BC_ASSIST || GAF_AL_PER_SYNC)
#if(GAF_BAP_BC_DELEG)
#define GAF_AL_ADV (1)
#else
#define GAF_AL_ADV (0)
#endif //(GAF_BAP_BC_DELEG)
#if (GAF_AL_PER_ADV || GAF_AL_PER_SYNC || GAF_AL_SCAN || GAF_AL_ADV)
#define GAF_AL (1)
#define GAF_AL_ACT_MAX (BLE_ACTIVITY_MAX)
#else
#define GAF_AL (0)
#endif //(GAF_AL_PER_ADV)
/// @} GAF
#endif // GAF_CFG_H_
+138
View File
@@ -0,0 +1,138 @@
/**
****************************************************************************************
*
* @file gaf_msg.h
*
* @brief Generic Audio Framework - Definition of Kernel Messages
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef GAF_MSG_H_
#define GAF_MSG_H_
/**
****************************************************************************************
* @addtogroup GAF Generic Audio Framework - Definition of Kernel Messages
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf.h" // GAF Definitions
#include "rwip_task.h" // RW IP Task Definition
#if (GAF_API_MSG)
#include "ke_task.h" // Kernel Tasks Definitions
/*
* MESSAGE API
****************************************************************************************
*/
/// List of GAF message IDs
enum acc_msg_ids
{
/// GAF Command
GAF_CMD = MSG_ID(GAF, 0),
/// GAF Command complete event
GAF_CMP_EVT = MSG_ID(GAF, 1),
/// GAF Request
GAF_REQ = MSG_ID(GAF, 2),
/// GAF Response
GAF_RSP = MSG_ID(GAF, 3),
/// GAF Indication
GAF_IND = MSG_ID(GAF, 4),
/// GAF Request Indication
GAF_REQ_IND = MSG_ID(GAF, 5),
/// GAF Confirmation
GAF_CFM = MSG_ID(GAF, 6),
};
/// List of GAF_IND indication codes
enum gaf_msg_ind_codes
{
GAF_UNKNOWN_MSG = GAF_CODE(GAF, COMMON, 0),
};
/// Basic structure for XXX_CMD message
typedef struct gaf_cmd
{
/// Command code
uint16_t cmd_code;
} gaf_cmd_t;
/// Basic structure for XXX_CMP_EVT message
typedef struct gaf_cmp_evt
{
/// Command code
uint16_t cmd_code;
/// Status
uint16_t status;
} gaf_cmp_evt_t;
/// Basic structure for XXX_REQ message
typedef struct gaf_req
{
/// Request code
uint16_t req_code;
} gaf_req_t;
/// Basic structure for XXX_RSP message
typedef struct gaf_rsp
{
/// Request code
uint16_t req_code;
/// Status
uint16_t status;
} gaf_rsp_t;
/// Basic structure for XXX_IND message
typedef struct gaf_ind
{
/// Indication code
uint16_t ind_code;
} gaf_ind_t;
/// Basic structure for XXX_REQ_IND message
typedef struct gaf_req_ind
{
/// Request Indication code
uint16_t req_ind_code;
} gaf_req_ind_t;
/// Basic structure for XXX_CFM message
typedef struct gaf_cfm
{
/// Request Indication code
uint16_t req_ind_code;
/// Status
uint16_t status;
} gaf_cfm_t;
/// Structure for GAF_UNKNOWN_MSG indication message
typedef struct gaf_unknown_msg_ind
{
/// Indication code (@see enum gaf_msg_ind_codes)
uint16_t ind_code;
/// Message ID
ke_msg_id_t msg_id;
} gaf_unknown_msg_ind_t;
#endif //(GAF_API_MSG)
/// @}
#endif // GAF_MSG_H_
File diff suppressed because it is too large Load Diff
+617
View File
@@ -0,0 +1,617 @@
/**
****************************************************************************************
*
* @file iap_msg.h
*
* @brief Isochronous Access Profile - Definition of Kernel Messages
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef IAP_MSG_H_
#define IAP_MSG_H_
/**
****************************************************************************************
* @addtogroup IAP Isochronous Access Profile - Definition of Kernel Messages
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "iap.h" // IAP Definitions
#include "gaf.h" // GAF Defines
/*
* ENUMERATIONS
****************************************************************************************
*/
/// List of GAF_IND indication codes
enum iap_msg_ind_codes
{
/// Unicast group management indications
IAP_US_ENABLED = GAF_CODE(IAP, UG, 0),
IAP_US_DISABLED = GAF_CODE(IAP, UG, 1),
/// Broadcast group management indications
IAP_BG_ENABLED = GAF_CODE(IAP, BG, 0),
IAP_BG_DISABLED = GAF_CODE(IAP, BG, 1),
IAP_BG_SYNC_ADDED = GAF_CODE(IAP, BG, 2),
/// Data path management indications
IAP_DP_UPDATE = GAF_CODE(IAP, DP, 0),
/// Test mode management indications
IAP_TM_CNT = GAF_CODE(IAP, TM, 0),
};
/*
* API MESSAGES
****************************************************************************************
*/
/// Structure for GAF_CMD message
typedef struct iap_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
} iap_cmd_t;
/// Structure for GAF_CMP_EVT message
typedef struct iap_cmp_evt
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Status
uint16_t status;
/// Group local index
uint8_t group_lid;
/// Stream local index
uint8_t stream_lid;
} iap_cmp_evt_t;
/// Structure for GAF_REQ message
typedef struct iap_req
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
} iap_req_t;
/// Structure for GAF_RSP message
typedef struct iap_rsp
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
} iap_rsp_t;
/// Structure for GAF_IND message
typedef struct iap_ind
{
/// Indication code
uint16_t ind_code;
} iap_ind_t;
/// Structure for IAP_UG_ADD request message
typedef struct iap_ug_add_req
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Unicast group information
iap_ug_param_t group_info;
/// CIG ID
uint8_t cig_id;
} iap_ug_add_req_t;
/// Structure for IAP_UG_ADD response message
typedef struct iap_ug_add_rsp
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
/// CIG ID
uint8_t cig_id;
/// Allocated Group local index
uint8_t group_lid;
} iap_ug_add_rsp_t;
/// Structure for IAP_US_CONFIG request message
typedef struct iap_us_config_req
{
/// Command code (@see enum iap_req_codes)
uint16_t req_code;
/// Group local index
uint8_t group_lid;
/// CIS IS
uint8_t cis_id;
/// Unicast stream information
iap_us_param_t stream_info;
} iap_us_config_req_t;
/// Structure for IAP_US_CONFIG response message
typedef struct iap_us_config_rsp
{
/// Command code (@see enum iap_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
/// Group local index
uint8_t group_lid;
/// CIS IS
uint8_t cis_id;
/// Allocated Stream local index
uint8_t stream_lid;
} iap_us_config_rsp_t;
/// Structure for IAP_US_PREPARE request message
typedef struct iap_us_prepare_req
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Connection local index
uint8_t con_lid;
/// CIG ID
uint8_t cig_id;
/// CIS ID
uint8_t cis_id;
} iap_us_prepare_req_t;
/// Structure for IAP_US_PREPARE response message
typedef struct iap_us_prepare_rsp
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
/// Connection local index
uint8_t con_lid;
/// CIG ID
uint8_t cig_id;
/// CIS ID
uint8_t cis_id;
/// Group local index
uint8_t group_lid;
/// Stream local index
uint8_t stream_lid;
} iap_us_prepare_rsp_t;
/// Structure for IAP_US_BIND request message
typedef struct iap_us_bind_req
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Stream local index
uint8_t stream_lid;
/// Connection local index
uint8_t con_lid;
} iap_us_bind_req_t;
/// Structure for IAP_UG_UPDATE command message
typedef struct iap_ug_update_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Group local index
uint8_t group_lid;
} iap_ug_update_cmd_t;
/// Structure for IAP_US_ENABLE command message
typedef struct iap_us_enable_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Group local index
uint8_t group_lid;
} iap_us_enable_cmd_t;
/// Structure for IAP_US_DISABLE command message
typedef struct iap_us_disable_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Stream local index
uint8_t stream_lid;
} iap_us_disable_cmd_t;
/// Structure for IAP_US_RELEASE request message
typedef struct iap_us_release_req
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Stream local index
uint8_t stream_lid;
} iap_us_release_req_t;
/// Structure for IAP_UG_REMOVE command message
typedef struct iap_ug_remove_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Group local index
uint8_t group_lid;
} iap_ug_remove_cmd_t;
/// Structure for IAP_BG_ADD request message
typedef struct iap_bg_add_req
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Group information
iap_bg_param_t group_info;
/// BIG Handle
uint8_t big_handle;
/// Number of streams in the group
uint8_t nb_streams;
} iap_bg_add_req_t;
/// Structure for IAP_BG_ADD response message
typedef struct iap_bg_add_rsp
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
/// BIG Handle
uint8_t big_handle;
/// Number of streams in the group
uint8_t nb_streams;
/// Allocated group local index
uint8_t group_lid;
/// List of allocated stream local indexes
uint8_t stream_lids[__ARRAY_EMPTY];
} iap_bg_add_rsp_t;
/// Structure for IAP_BG_ENABLE command message
typedef struct iap_bg_enable_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Group local index
uint8_t group_lid;
/// Advertising activity local index
uint8_t adv_actv_lid;
/// Indicate if streams are encrypted (!=0) or not (=0)
uint8_t encrypted;
/// Code used to generate the encryption key for encrypting payloads of all streams
uint8_t broadcast_code[16];
} iap_bg_enable_cmd_t;
/// Structure for IAP_BG_SYNC command message
typedef struct iap_bg_sync_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Synchronization timeout in multiple of 10ms
uint16_t sync_timeout_10ms;
/// BIG handle
uint8_t big_handle;
/// Synchronization activity local index
uint8_t sync_actv_lid;
/// Maximum number of subevents the controller should use to receive data payloads in each interval
uint8_t mse;
/// Indicate if streams are encrypted (!=0) or not (=0)
uint8_t encrypted;
/// Code used to generate the encryption key for encrypting payloads of all streams
uint8_t broadcast_code[16];
/// Stream position bit field to synchronize with.
uint32_t stream_pos_bf;
} iap_bg_sync_cmd_t;
/// Structure for IAP_BG_SYNC_ADDED indication message
typedef struct iap_bg_sync_added_ind
{
/// Indication code (@see enum iap_ind_codes)
uint16_t ind_code;
/// BIG handle
uint8_t big_handle;
/// Number of streams to synchronize with
uint8_t nb_streams;
/// Group local index
uint8_t group_lid;
/// List of stream local indexes
uint8_t stream_lids[__ARRAY_EMPTY];
} iap_bg_sync_added_ind_t;
/// Structure for IAP_BG_DISABLE command message
typedef struct iap_bg_disable_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Group local index
uint8_t group_lid;
} iap_bg_disable_cmd_t;
/// Structure for IAP_BG_REMOVE command message
typedef struct iap_bg_remove_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Group local index
uint8_t group_lid;
} iap_bg_remove_cmd_t;
/// Structure for IAP_DP_VS_SET_TRIGGER command message
typedef struct iap_dp_vs_set_trigger_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Stream local index
uint8_t stream_lid;
/// Direction (0 = TX, 1 = RX)
uint8_t direction;
/// Enable
uint8_t enable;
/// Trigger offset in microseconds
/// For TX direction, trigger offset is applied using SDU at source reference
/// For RX direction, trigger offset is applied using SDU at destination reference
/// (SDU at source + transport latency)
int32_t trigger_offset_us;
} iap_dp_vs_set_trigger_cmd_t;
/// Structure for IAP_UG_TEST_ADD request message
typedef struct iap_ug_test_add_req
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Unicast group test information structure
iap_ug_test_param_t group_info;
/// CIG ID
uint8_t cig_id;
} iap_ug_test_add_req_t;
/// Structure for IAP_US_TEST_CONFIG request message
typedef struct iap_us_test_config_req
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Group local index
uint8_t group_lid;
/// CIS IS
uint8_t cis_id;
/// Unicast stream information
iap_us_test_param_t stream_info;
} iap_us_test_config_req_t;
/// Structure for IAP_BG_TEST_ADD request message
typedef struct iap_bg_test_add_req
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Broadcast group test information structure
iap_bg_test_param_t group_info;
/// BIG Handle
uint8_t big_handle;
/// Number of streams in the group
uint8_t nb_streams;
/// Indicate if streams are encrypted (!=0) or not (=0)
uint8_t encrypted;
/// Code used to generate encryption key used to encrypt payloads
uint8_t broadcast_code[16];
} iap_bg_test_add_req_t;
/// Structure for IAP_DP_CONFIG request message
typedef struct iap_dp_config_req
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Stream local index
uint8_t stream_lid;
/// Direction
uint8_t direction;
/// Controller Delay in microseconds
uint32_t ctl_delay_us;
/// Codec ID
uint8_t codec_id[GAF_CODEC_ID_LEN];
/// Datapath ID
uint8_t dp_id;
/// Codec Configuration length
uint8_t codec_cfg_len;
/// Additional Codec Configuration length
uint8_t add_codec_cfg_len;
/// Codec Configuration followed by additional Codec Configuration
uint8_t codec_cfg[__ARRAY_EMPTY];
} iap_dp_config_req_t;
/// Structure for IAP_DP_SETUP request message
typedef struct iap_dp_setup_req
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Stream local index
uint8_t stream_lid;
/// Direction
uint8_t direction;
} iap_dp_setup_req_t;
/// Structure for IAP_DP_REMOVE request message
typedef struct iap_dp_remove_req
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Stream local index
uint8_t stream_lid;
/// Direction bit field
uint8_t direction_bf;
} iap_dp_remove_req_t;
/// Structure for IAP_TM_START command message
typedef struct iap_tm_start_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Stream local index
uint8_t stream_lid;
/// Transmit (!=0) or receive (=0) test payload
uint8_t transmit;
/// Payload type
uint8_t payload_type;
} iap_tm_start_cmd_t;
/// Structure for IAP_TM_CNT_GET command message
typedef struct iap_tm_cnt_get_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Stream local index
uint8_t stream_lid;
} iap_tm_cnt_get_cmd_t;
/// Structure for IAP_TM_STOP command message
typedef struct iap_tm_stop_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Stream local index
uint8_t stream_lid;
} iap_tm_stop_cmd_t;
/// Structure for IAP_GET_QUALITY command message
typedef struct iap_get_quality_cmd
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Stream local index
uint8_t stream_lid;
} iap_get_quality_cmd_t;
/// Structure for IAP_QUALITY command complete event message
typedef struct iap_get_quality_cmp_evt
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Status
uint16_t status;
/// Stream local index
uint8_t stream_lid;
/// Number of unacked transmitted packets
uint32_t tx_unacked_packets;
/// Number of flushed transmitted packets
uint32_t tx_flushed_packets;
/// Number of packets transmitted during last subevent
uint32_t tx_last_subevent_packets;
/// Number of retransmitted packets
uint32_t retransmitted_packets;
/// Number of packets received with a CRC error
uint32_t crc_error_packets;
/// Number of unreceived packets
uint32_t rx_unreceived_packets;
/// Number of duplicate packets received
uint32_t duplicate_packets;
} iap_get_quality_cmp_evt_t;
/// Structure for IAP_INTF_REGISTER command complete event message
typedef struct iap_register_cmp_evt
{
/// Command code (@see enum iap_cmd_codes)
uint16_t cmd_code;
/// Status
uint16_t status;
/// Allocated interface local index
uint8_t intf_lid;
} iap_register_cmp_evt_t;
/// Structure for IAP_US_DISABLED indication message
typedef struct iap_us_disabled_ind
{
/// Indication code (@see enum iap_msg_ind_codes)
uint16_t ind_code;
/// Stream local index
uint8_t stream_lid;
/// Reason
uint8_t reason;
} iap_us_disabled_ind_t;
/// Structure for IAP_BG_DISABLED indication message
typedef struct iap_bg_disabled_ind
{
/// Indication code (@see enum iap_msg_ind_codes)
uint16_t ind_code;
/// Group local index
uint8_t group_lid;
/// Reason
uint8_t reason;
} iap_bg_disabled_ind_t;
/// Structure for IAP_US_ENABLED indication message
typedef struct iap_us_enabled_ind
{
/// Indication code (@see enum iap_msg_ind_codes)
uint16_t ind_code;
/// Group local index
uint8_t group_lid;
/// Stream local index
uint8_t stream_lid;
/// Group configuration
iap_ug_config_t ug_config;
/// Stream configuration
iap_us_config_t us_config;
} iap_us_enabled_ind_t;
/// Structure for IAP_BG_ENABLED indication message
typedef struct iap_bg_enabled_ind
{
/// Indication code (@see enum iap_msg_ind_codes)
uint16_t ind_code;
/// Group local index
uint8_t group_lid;
/// Group configuration
iap_bg_config_t config;
} iap_bg_enabled_ind_t;
/// Structure for IAP_DP_UPDATE indication message
typedef struct iap_dp_update_ind
{
/// Indication code (@see enum iap_msg_ind_codes)
uint16_t ind_code;
/// Stream local index
uint8_t stream_lid;
/// Data path update type
uint8_t dp_update;
/// Direction for setup update, direction bit field for remove update
uint8_t direction;
/// Status
uint16_t status;
} iap_dp_update_ind_t;
/// Structure for IAP_TM_CNT indication message
typedef struct iap_tm_cnt_ind
{
/// Indication code (@see enum iap_msg_ind_codes)
uint16_t ind_code;
/// Stream local index
uint8_t stream_lid;
/// Number of received packets
uint32_t nb_rx;
/// Number of missed packets
uint32_t nb_missed;
/// Number of failed packets
uint32_t nb_failed;
} iap_tm_cnt_ind_t;
/// Structure for IAP_DBG_FEATURES response message
typedef struct iap_dbg_features_rsp
{
/// Request code (@see enum iap_req_codes)
uint16_t req_code;
/// Status
uint16_t status;
/// Number of streams supported
uint8_t nb_streams;
/// Unicast supported
uint8_t unicast;
/// Broadcast supported
uint8_t broadcast;
} iap_dbg_features_rsp_t;
/// @}
#endif // IAP_MSG_H_
+66
View File
@@ -0,0 +1,66 @@
########################################################################################
#
# @file SCompile
#
# @brief Compilation instructions for Host GAF build
#
# Copyright (C) RivieraWaves 2019-2019
#
#########################################################################################
#-----------------------------------------------------------
# Paths
#-----------------------------------------------------------
gaf_src_dir = os.path.join(ble_ip_gaf_dir, 'src')
gaf_api_dir = os.path.join(ble_ip_gaf_dir, 'api')
gaf_inc_dir = os.path.join(ble_ip_gaf_dir, 'inc')
gaf_cfg_dir = os.path.join(ble_ip_gaf_dir, 'config')
gaf_iap_src_dir = os.path.join(gaf_src_dir, 'iap')
gaf_acc_src_dir = os.path.join(gaf_src_dir, 'acc')
gaf_arc_src_dir = os.path.join(gaf_src_dir, 'arc')
gaf_atc_src_dir = os.path.join(gaf_src_dir, 'atc')
gaf_bap_src_dir = os.path.join(gaf_src_dir, 'bap')
gaf_cap_src_dir = os.path.join(gaf_src_dir, 'cap')
gaf_iap_api_dir = os.path.join(gaf_api_dir, 'iap')
gaf_acc_api_dir = os.path.join(gaf_api_dir, 'acc')
gaf_arc_api_dir = os.path.join(gaf_api_dir, 'arc')
gaf_atc_api_dir = os.path.join(gaf_api_dir, 'atc')
gaf_bap_api_dir = os.path.join(gaf_api_dir, 'bap')
gaf_cap_api_dir = os.path.join(gaf_api_dir, 'cap')
#-----------------------------------------------------------
# Compilation Flags
#-----------------------------------------------------------
gaf_def_list += ['CFG_BLE_HOST_ISO']
#-----------------------------------------------------------
# Include List
#-----------------------------------------------------------
gaf_inc_list += [gaf_src_dir]
gaf_inc_list += [gaf_api_dir]
gaf_inc_list += [gaf_inc_dir]
gaf_inc_list += [gaf_iap_src_dir]
gaf_inc_list += [gaf_acc_src_dir]
gaf_inc_list += [gaf_arc_src_dir]
gaf_inc_list += [gaf_atc_src_dir]
gaf_inc_list += [gaf_bap_src_dir]
gaf_inc_list += [gaf_cap_src_dir]
gaf_inc_list += [gaf_iap_api_dir]
gaf_inc_list += [gaf_acc_api_dir]
gaf_inc_list += [gaf_arc_api_dir]
gaf_inc_list += [gaf_atc_api_dir]
gaf_inc_list += [gaf_bap_api_dir]
gaf_inc_list += [gaf_cap_src_dir]
gaf_inc_list += scutils.file_list_read(env, os.path.join(gaf_cfg_dir, 'includelist.txt'), gaf_api_dir)
#-----------------------------------------------------------
# Source List
#-----------------------------------------------------------
src_list = scutils.file_list_read(env, os.path.join(gaf_cfg_dir, 'sourcelist.txt'), 'src')
gaf_src_list += scutils.build_object(env, src_list, ble_ip_gaf_dir, os.path.join(obj_dir, 'gaf'))
+819
View File
@@ -0,0 +1,819 @@
/**
****************************************************************************************
*
* @file gaf_al.h
*
* @brief GAF adaptation layer of the Generic Access profile - Native API
*
* Copyright (C) RivieraWaves 2009-2020
*
****************************************************************************************
*/
#ifndef _GAF_AL_H_
#define _GAF_AL_H_
/**
****************************************************************************************
* @addtogroup GAF_AL
* @ingroup GAF
* @brief GAF adaptation layer of the Generic Access profile
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf_cfg.h"
#if (GAF_AL)
#include "co_buf.h" // buffer usage
#include "gap.h" // GAP types
/*
* DEFINES
****************************************************************************************
*/
/// Default TX power used for advertising
#define GAF_AL_ADV_TX_POWER_DEFAULT (-70)
/// Maximum AD Type pattern size.
#define GAF_AL_SCAN_PATTERN_SIZE_MAX (5)
/// type of advertising data
enum gaf_al_adv_data_type
{
/// Advertising data
GAF_AL_ADV_DATA_ADV,
/// Periodic advertising data
GAF_AL_ADV_DATA_PER_ADV,
/// Scan response data
GAF_AL_ADV_DATA_SCAN_RSP,
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Advertising parameters
typedef struct gaf_al_adv_param
{
/// Minimum advertising interval in multiple of 0.625ms. Must be higher than 20ms.
uint32_t adv_intv_min_slot;
/// Maximum advertising interval in multiple of 0.625ms. Must be higher than 20ms.
uint32_t adv_intv_max_slot;
/// Discovery mode (@see enum gapm_adv_disc_mode)
uint8_t disc_mode;
/// Own address type (@see enum gapm_own_addr)
uint8_t own_addr_type;
/// Channel Map
uint8_t chnl_map;
/// PHY for primary advertising. Only LE 1M and LE Codec PHYs are allowed
uint8_t phy_prim;
/// PHY for secondary advertising
uint8_t phy_second;
/// Maximum number of advertising events the controller can skip before sending the
/// AUX_ADV_IND packets. 0 means that AUX_ADV_IND PDUs shall be sent prior each
/// advertising events
uint8_t max_skip;
/// Advertising SID
uint8_t adv_sid;
/// Maximum power level at which the advertising packets have to be transmitted
/// (between -127 and 126 dBm)
int8_t max_tx_pwr;
} gaf_al_adv_param_t;
/// Periodic advertising parameters
typedef struct gaf_al_per_adv_param
{
/// Minimum advertising interval in multiple of 0.625ms. Must be higher than 20ms.
uint32_t adv_intv_min_slot;
/// Maximum advertising interval in multiple of 0.625ms. Must be higher than 20ms.
uint32_t adv_intv_max_slot;
/// Minimum periodic advertising interval in multiple of 1.25ms. Must be higher than 7.5ms
uint32_t per_adv_intv_min_frame;
/// Maximum periodic advertising interval in multiple of 1.25ms. Must be higher than 7.5ms
uint32_t per_adv_intv_max_frame;
/// Discovery mode (@see enum gapm_adv_disc_mode)
uint8_t disc_mode;
/// Own address type (@see enum gapm_own_addr)
uint8_t own_addr_type;
/// Channel Map
uint8_t chnl_map;
/// PHY for primary advertising. Only LE 1M and LE Codec PHYs are allowed
uint8_t phy_prim;
/// PHY for secondary advertising
uint8_t phy_second;
/// Maximum number of advertising events the controller can skip before sending the
/// AUX_ADV_IND packets. 0 means that AUX_ADV_IND PDUs shall be sent prior each
/// advertising events
uint8_t max_skip;
/// Advertising SID
uint8_t adv_sid;
/// Maximum power level at which the advertising packets have to be transmitted
/// (between -127 and 126 dBm)
int8_t max_tx_pwr;
} gaf_al_per_adv_param_t;
/// Adaptation layer scan parameters
typedef struct gaf_al_scan_param
{
/// Scan interval in multiple of 0.625ms - Must be higher than 2.5ms
uint16_t interval_slot;
/// Scan window in multiple of 0.625ms - Must be higher than 2.5ms
uint16_t window_slot;
} gaf_al_scan_param_t;
/// Metadata present in advertising report
typedef struct gaf_al_adv_report_metadata
{
/// Bit field providing information about the received report (@see enum gapm_adv_report_info)
uint8_t info;
/// Transmitter device address
gap_bdaddr_t trans_addr;
/// Target address (in case of a directed advertising report)
gap_bdaddr_t target_addr;
/// TX power (in dBm)
int8_t tx_pwr;
/// RSSI (between -127 and +20 dBm)
int8_t rssi;
/// Primary PHY on which advertising report has been received
uint8_t phy_prim;
/// Secondary PHY on which advertising report has been received
uint8_t phy_second;
/// Advertising SID
/// Valid only for periodic advertising report
uint8_t adv_sid;
/// Periodic advertising interval (in unit of 1.25ms, min is 7.5ms)
/// Valid only for periodic advertising report
uint16_t period_adv_intv;
} gaf_al_adv_report_metadata_t;
/*
* MACROS
****************************************************************************************
*/
/*
* GLOBAL VARIABLE DECLARATIONS
****************************************************************************************
*/
/*
* ADAPTATION LAYER CONFIGURATION API
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Configure adaptation layer to be used by a GAF layer.
*
* @return Status of function execution (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_configure(void);
/**
****************************************************************************************
* @brief Retrieve GAP activity index associated with activity local identifier
*
* @param[in] act_lid Activity local identifier
*
* @return GAP Activity Index (GAP_INVALID_ACTV_IDX if no association exists)
****************************************************************************************
*/
uint8_t gaf_al_actv_idx_get(uint8_t act_lid);
/*
* ADVERTISING CONTROL API
****************************************************************************************
*/
#if (GAF_AL_ADV)
/// Advertising activity callback
typedef struct gaf_al_adv_cb
{
/**
****************************************************************************************
* @brief Callback function called as result of @see gaf_al_adv_start function.
*
* if succeed the advertising is started.
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] status Start status code (@see enum gaf_err)
****************************************************************************************
*/
void (*cb_start_cmp)(uint8_t act_lid, uint16_t dummy, uint16_t status);
/**
****************************************************************************************
* @brief Callback function called as result of @see gaf_al_adv_stop function or if
* the advertising is stopped due to an external event.
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] reason Stop reason (@see enum gaf_err)
****************************************************************************************
*/
void (*cb_stopped)(uint8_t act_lid, uint16_t dummy, uint16_t reason);
/**
****************************************************************************************
* @brief Callback function called as result of @see gaf_al_adv_data_upd function
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] status Data update satus code (@see enum gaf_err)
****************************************************************************************
*/
void (*cb_data_upd_cmp)(uint8_t act_lid, uint16_t dummy, uint16_t status);
} gaf_al_adv_cb_t;
/**
****************************************************************************************
* @brief Create a Advertising activity.
*
* @param[in] dummy Dummy parameter returned in callbacks
* @param[in] p_adv_params Pointer to advertising parameters
* @param[in] p_cb Pointer to callback functions used to return
* procedure execution status
* @param[out] p_act_lid Pointer to activity local identifier return
*
* @return Status of activity creation (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_adv_create(uint16_t dummy, const gaf_al_adv_param_t* p_adv_params,
const gaf_al_adv_cb_t* p_cb, uint8_t* p_act_lid);
/**
****************************************************************************************
* @brief Remove a Advertising activity.
*
* Advertising activity must be in stopped state to execute this function
*
* @param[in] act_lid Activity local identifier
*
* @return Status of activity remove (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_adv_remove(uint8_t act_lid);
/**
****************************************************************************************
* @brief Start a Advertising activity.
*
* If function execution succeed, @see cb_start_cmp callback will be executed once
* Advertising is started or if an error occurs.
*
* @param[in] act_lid Activity local identifier
* @param[in] p_adv_data Pointer to buffer that contains advertising data
* @param[in] timeout_s Timeout duration in seconds
* 0 means that Requests will last until stopped by the upper layer
*
* @return Status of activity start (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_adv_start(uint8_t act_lid, co_buf_t* p_adv_data, uint16_t timeout_s);
/**
****************************************************************************************
* @brief Stop an advertising activity.
*
* If function execution succeed, @see cb_stopped callback will be executed once
* advertising is stopped or if an error occurs.
*
* @param[in] act_lid Activity local identifier
*
* @return Status of activity stop (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_adv_stop(uint8_t act_lid);
/**
****************************************************************************************
* @brief Update data advertising data
*
* If function execution succeed, @see cb_data_upd_cmp callback will be executed once
* advertising data procedure is over.
*
* Advertising activity must be started to update data.
*
* @param[in] act_lid Activity local identifier
* @param[in] data_type Type of advertising data (@see enum gaf_al_adv_data_type)
* @param[in] p_adv_data Pointer to buffer that contains advertising data
*
* @return Status of advertising activity data update (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_adv_data_upd(uint8_t act_lid, uint8_t data_type, co_buf_t* p_data);
#endif // (GAF_AL_ADV)
/*
* PERIODIC ADV CONTROL API
****************************************************************************************
*/
#if (GAF_AL_PER_ADV)
/// Periodic advertising activity callback
typedef struct gaf_al_per_adv_cb
{
/**
****************************************************************************************
* @brief Callback function called as result of @see gaf_al_per_adv_start function.
*
* if succeed the periodic advertising is started.
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] status Start status code (@see enum gaf_err)
****************************************************************************************
*/
void (*cb_start_cmp)(uint8_t act_lid, uint16_t dummy, uint16_t status);
/**
****************************************************************************************
* @brief Callback function called as result of @see gaf_al_per_adv_stop function or if
* the periodic advertising is stopped due to an external event.
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] reason Stop reason (@see enum gaf_err)
****************************************************************************************
*/
void (*cb_stopped)(uint8_t act_lid, uint16_t dummy, uint16_t reason);
/**
****************************************************************************************
* @brief Callback function called as result of @see gaf_al_per_adv_data_upd function
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] status Data update satus code (@see enum gaf_err)
****************************************************************************************
*/
void (*cb_data_upd_cmp)(uint8_t act_lid, uint16_t dummy, uint16_t status);
} gaf_al_per_adv_cb_t;
/**
****************************************************************************************
* @brief Create a periodic advertising activity.
*
* @param[in] dummy Dummy parameter returned in callbacks
* @param[in] p_per_adv_params Pointer to periodic advertising parameters
* @param[in] p_cb Pointer to callback functions used to return
* procedure execution status
* @param[out] p_act_lid Pointer to activity local identifier return
*
* @return Status of activity creation (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_per_adv_create(uint16_t dummy, const gaf_al_per_adv_param_t* p_per_adv_params,
const gaf_al_per_adv_cb_t* p_cb, uint8_t* p_act_lid);
/**
****************************************************************************************
* @brief Remove a periodic advertising activity.
*
* Periodic advertising activity must be in stopped state to execute this function
*
* @param[in] act_lid Activity local identifier
*
* @return Status of activity remove (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_per_adv_remove(uint8_t act_lid);
/**
****************************************************************************************
* @brief Start a periodic advertising activity.
*
* If function execution succeed, @see cb_start_cmp callback will be executed once
* periodic advertising is started or if an error occurs.
*
* @param[in] act_lid Activity local identifier
* @param[in] p_adv_data Pointer to buffer that contains advertising data
* @param[in] p_per_adv_data Pointer to buffer that contains periodic advertising data
*
* @return Status of activity start (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_per_adv_start(uint8_t act_lid, co_buf_t* p_adv_data, co_buf_t* p_per_adv_data);
/**
****************************************************************************************
* @brief Stop a periodic advertising activity.
*
* If function execution succeed, @see cb_stopped callback will be executed once
* periodic advertising is stopped or if an error occurs.
*
* @param[in] act_lid Activity local identifier
*
* @return Status of activity stop (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_per_adv_stop(uint8_t act_lid);
/**
****************************************************************************************
* @brief Update data broadcasted on a periodic advertising data
*
* If function execution succeed, @see cb_data_upd_cmp callback will be executed once
* periodic advertising data procedure is over.
*
* Periodic advertising activity must be started to update data.
*
* @param[in] act_lid Activity local identifier
* @param[in] data_type Type of advertising data (@see enum gaf_al_adv_data_type)
* @param[in] p_per_adv_data Pointer to buffer that contains advertising or
* periodic advertising data
*
* @return Status of periodic advertising activity data update (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_per_adv_data_upd(uint8_t act_lid, uint8_t data_type, co_buf_t* p_data);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t gaf_al_per_adv_get_addr(uint8_t act_lid, uint8_t** pp_addr, uint8_t* p_addr_type, uint8_t* p_adv_sid);
#endif // (GAF_AL_PER_ADV)
/*
* SCAN CONTROL API
****************************************************************************************
*/
#if (GAF_AL_SCAN)
/// Scan activity callback
typedef struct gaf_al_scan_cb
{
/**
****************************************************************************************
* @brief Callback function called as result of @see gaf_al_scan_start function.
* If succeed the scan is started.
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] status Start status code (@see enum gaf_err)
****************************************************************************************
*/
void (*cb_start_cmp)(uint8_t act_lid, uint16_t dummy, uint16_t status);
/**
****************************************************************************************
* @brief Callback function called as result of @see gaf_al_scan_stop function or if
* the scan is stopped due to an external event.
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] reason Stop reason (@see enum gaf_err)
****************************************************************************************
*/
void (*cb_stopped)(uint8_t act_lid, uint16_t dummy, uint16_t reason);
/**
****************************************************************************************
* @brief Function called when an advertising report is received that matches pattern (if present)
*
* @note Advertising report can be received by several scanner, buffer that contains report
* is not supposed to be altered or put in a list.
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] p_adv_report Pointer to advertising data report.
* In metadata some information about advertising report can be found
* (@see gaf_al_adv_report_metadata_t)
****************************************************************************************
*/
void (*cb_report)(uint8_t act_lid, uint16_t dummy, co_buf_t* p_adv_report);
} gaf_al_scan_cb_t;
/**
****************************************************************************************
* @brief Create a Scan activity.
*
* @param[in] dummy Dummy parameter returned in callbacks
* @param[in] type Scan type (@see enum gapm_scan_type)
* @param[in] pattern_size Advertising data pattern size, 0 = disable, Max GAF_AL_SCAN_PATTERN_SIZE_MAX
* @param[in] p_pattern Pointer to advertising data pattern (byte 0 represents AD Type)
* If pattern matches, advertising report is triggered
* @param[in] p_1m_param Pointer to 1M PHY parameters (NULL means not enabled for that PHY)
* @param[in] p_coded_param Pointer to LE Coded PHY parameters (NULL means not enabled for that PHY)
* @param[in] p_cb Pointer to callback functions used to return
* procedure execution status
* @param[out] p_act_lid Pointer to activity local identifier return
*
* @return Status of activity creation (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_scan_create(uint16_t dummy, uint8_t type, uint8_t pattern_size, const uint8_t* p_pattern,
const gaf_al_scan_param_t* p_1m_param, const gaf_al_scan_param_t* p_coded_param,
const gaf_al_scan_cb_t* p_cb, uint8_t* p_act_lid);
/**
****************************************************************************************
* @brief Remove a scan activity.
*
* @param[in] act_lid Activity local identifier
*
* @return Status of activity remove (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_scan_remove(uint8_t act_lid);
/**
****************************************************************************************
* @brief Update scan activity with new parameters.
* Parameters are applied only when internal scan activity is restarted
*
* @param[in] act_lid Activity local identifier
* @param[in] p_1m_param Pointer to 1M PHY parameters (NULL means not enabled for that PHY)
* @param[in] p_coded_param Pointer to LE Coded PHY parameters (NULL means not enabled for that PHY)
*
* @return Status of activity creation (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_scan_param_upd(uint8_t act_lid, const gaf_al_scan_param_t* p_1m_param,
const gaf_al_scan_param_t* p_coded_param);
/**
****************************************************************************************
* @brief Start scan activity.
* Since multiple scan activities can be present, GAF adaptation layer try as
* much as possible to respect requested duty cycle.
*
* If function execution succeed, @see cb_start_cmp callback will be executed once
* scan is started or if an error occurs. Callback execution can occurs before
* function return.
*
* @param[in] act_lid Activity local identifier
* @param[in] timeout_s Timeout in seconds
*
* @return Status of activity start (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_scan_start(uint8_t act_lid, uint16_t timeout_s);
/**
****************************************************************************************
* @brief Stop scan activity. if other activity are scanning, scan will continue but no
* more report will be triggered for this activity
*
* If function execution succeed, @see cb_stopped callback will be executed once
* scan stopped or if an error occurs. Callback execution can occurs before
* function return.
*
* @param[in] act_lid Activity local identifier
*
* @return Status of activity stop (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_scan_stop(uint8_t act_lid);
/**
****************************************************************************************
* @brief Enable or disable reception of advertising reports
*
* @param[in] act_lid Activity local identifier
* @param[in] enable True to enable reception of advertising reports,
* False to disable reception
*
* @return Status of activity stop (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_scan_report_ctrl(uint8_t act_lid, bool enable);
#endif // (GAF_AL_SCAN)
/*
* PERIODIC SYNC CONTROL API
****************************************************************************************
*/
#if (GAF_AL_PER_SYNC)
/// Periodic sync activity callback
typedef struct gaf_al_per_sync_cb
{
/**
****************************************************************************************
* @brief Callback function called as result of @see gaf_al_per_sync_scan_start or
* @see gaf_al_per_sync_con_start functions.
* If succeed the periodic sync waits for an establishment
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] status Start status code (@see enum gaf_err)
****************************************************************************************
*/
void (*cb_start_cmp)(uint8_t act_lid, uint16_t dummy, uint16_t status);
/**
****************************************************************************************
* @brief Callback function called as result of @see gaf_al_per_sync_stop function or if
* the periodic sync establishment is canceled or periodic sync is lost
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] reason Stop reason (@see enum gaf_err)
****************************************************************************************
*/
void (*cb_stopped)(uint8_t act_lid, uint16_t dummy, uint16_t reason);
/**
****************************************************************************************
* @brief Callback function called when periodic sync has been established
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] p_adv_addr Pointer to periodic advertising address information
* @param[in] serv_data Only valid for a Periodic Advertising Sync Transfer, else ignore
****************************************************************************************
*/
void (*cb_estab)(uint8_t act_lid, uint16_t dummy, const gap_per_adv_bdaddr_t* p_adv_addr, uint16_t serv_data);
/**
****************************************************************************************
* @brief Function called when a periodic advertising report is received *
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] p_adv_report Pointer to advertising data report.
* In metadata some information about advertising report can be found
* (@see gaf_al_adv_report_metadata_t)
****************************************************************************************
*/
void (*cb_report)(uint8_t act_lid, uint16_t dummy, co_buf_t* p_adv_report);
/**
****************************************************************************************
* @brief Function called when a BIG Info report is received
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] p_report Pointer to structure that contains Big Info data
****************************************************************************************
*/
void (*cb_big_info)(uint8_t act_lid, uint16_t dummy, const gap_big_info_t* p_report);
#if (GAF_AL_PAST)
/**
****************************************************************************************
* @brief Callback function called as result of @see gaf_al_per_sync_scan_tranfer
*
* @param[in] act_lid Activity local identifier
* @param[in] dummy Dummy parameter
* @param[in] status Status code (@see enum gaf_err)
****************************************************************************************
*/
void (*cb_transfer_cmp)(uint8_t act_lid, uint16_t dummy, uint16_t status);
#endif //(GAF_AL_PAST)
} gaf_al_per_sync_cb_t;
/**
****************************************************************************************
* @brief Create a Periodic sync Activity
*
* @param[in] dummy Dummy parameter returned in callbacks
* @param[in] con_sync True to start sync using PAST, using scan otherwise
* @param[in] p_1m_param Pointer to 1M PHY parameters (NULL means not enabled for that PHY)
* @param[in] p_coded_param Pointer to LE Coded PHY parameters (NULL means not enabled for that PHY)
* @param[in] con_lid Connection local identifier (meaningful only for connection sync)
* @param[in] p_adv_addr Pointer to periodic advertising address information (can be null)
* @param[in] p_cb Pointer to callback functions used to return
* procedure execution status
* @param[out] p_act_lid Pointer to activity local identifier return
*
* @return Status of activity creation (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_per_sync_create(uint16_t dummy, bool con_sync, const gaf_al_scan_param_t* p_1m_param,
const gaf_al_scan_param_t* p_coded_param, const gap_per_adv_bdaddr_t* p_adv_addr,
uint8_t con_lid, const gaf_al_per_sync_cb_t* p_cb, uint8_t* p_act_lid);
/**
****************************************************************************************
* @brief Remove a Periodic sync activity.
*
* @param[in] act_lid Activity local identifier
*
* @return Status of activity remove (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_per_sync_remove(uint8_t act_lid);
/**
****************************************************************************************
* @brief Establish a periodic sync
*
* If function execution succeed, @see cb_start_cmp callback will be executed once
* activity is started or if an error occurs.
* Once the periodic sync is established, @see cb_estab callback is executed.
*
* @param[in] act_lid Activity local identifier
* @param[in] sync_to Synchronization timeout for the periodic advertising
* (in unit of 10ms between 100ms and 163.84s)
* @param[in] skip Number of periodic advertising that can be skipped after a successful receive.
* Maximum authorized value is 499
* @param[in] adv_report_en True to enable periodic advertising report, False to disable them by default
* @param[in] biginfo_report_en True to enable BIG Info report, False to disable them by default
* @param[in] timeout_s Scan Timeout in seconds - meaningless for PAST
*
* @return Status of activity start (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_per_sync_start(uint8_t act_lid, uint16_t sync_to, uint16_t skip, bool adv_report_en,
bool biginfo_report_en, uint16_t timeout_s);
/**
****************************************************************************************
* @brief Stop periodic sync activity, according to state of the activity it cancels
* periodic sync establishment or terminate it
*
* If function execution succeed, @see cb_stopped callback will be executed once
* scan stopped or if an error occurs.
*
* @param[in] act_lid Activity local identifier
*
* @return Status of activity stop (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_per_sync_stop(uint8_t act_lid);
/**
****************************************************************************************
* @brief Enable or disable reception of periodic advertising reports
*
* @param[in] act_lid Activity local identifier
* @param[in] adv_report_en True to enable periodic advertising report, False to disable them by default
* @param[in] biginfo_report_en True to enable BIG Info report, False to disable them by default
*
* @return Status of function execution (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_per_sync_report_ctrl(uint8_t act_lid, bool adv_report_en, bool biginfo_report_en);
#if (GAF_AL_PAST)
/**
****************************************************************************************
* @brief Allow to know if synchronization has been established with a given Periodic Advertising. If such a
* synchronization exist, return the Activity local index of the used Periodic Synchronization activity
*
* @param[in] p_adv_addr Pointer to information allowing to identify a Periodic Advertising
* @param[in] p_act_lid Pointer at which the Activity local index is returned is indicated synchronization
* has already been established
*
* @return True if synchronization with the indicated Periodic Advertising has been established, else False
****************************************************************************************
*/
bool gaf_al_per_sync_is_synced(const gap_per_adv_bdaddr_t* p_adv_addr, uint8_t* p_act_lid);
#endif //(GAF_AL_PAST)
/**
****************************************************************************************
* @brief Request to transfer information about an established Periodic Synchronization or about a local Periodic
* Advertising so that a peer device may synchronize with a Periodic Advertising
*
* @param[in] act_lid Activity local index
* @param[in] con_lid Connection local index
*
* @return An error status (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_per_sync_transfer(uint8_t act_lid, uint8_t con_lid);
/**
****************************************************************************************
* @brief Retrieve dummy data information for periodic advertising sync activity
*
* @param[in] act_lid Activity local identifier
* @param[out] p_dummy Pointer to dummy data to return
*
* @return Status of activity stop (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_per_sync_dummy_get(uint8_t act_lid, uint16_t* p_dummy);
#endif // (GAF_AL_PER_SYNC)
#endif // (GAF_AL)
/// @} GAF_AL
#endif /* _GAF_AL_H_ */
+78
View File
@@ -0,0 +1,78 @@
/**
****************************************************************************************
*
* @file gaf_inc.h
*
* @brief Generic Audio Framework - Header file
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef GAF_INC_H_
#define GAF_INC_H_
/**
****************************************************************************************
* @addtogroup GAF - Generic Audio Framework
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include <stdint.h> // Standard Integer Definitions
#include "ke_msg.h" // Kernel Message Definitions
/*
* GLOBAL FUNCTIONS DECLARATION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Initialize Generic Audio Framework
*
* @param[in] init_type Initialization type
****************************************************************************************
*/
void gaf_init(uint8_t init_type);
/**
****************************************************************************************
* @brief Inform Generic Audio Framework block about a connection established
*
* @param[in] con_lid Connection local index
****************************************************************************************
*/
void gaf_connect(uint8_t con_lid);
/**
****************************************************************************************
* @brief Inform Generic Audio Framework block about a disconnection
*
* @param[in] con_lid Connection local index
****************************************************************************************
*/
void gaf_disconnect(uint8_t con_lid);
/**
****************************************************************************************
* @brief Check if connection local index is valid and if indicated connection is well
* established
*
* @param[in] con_lid Connection local index
*
* @return An error status
****************************************************************************************
*/
uint16_t gaf_check_con_lid(uint8_t con_lid);
/// @} GAF_INC
#endif // GAF_INC_H_
@@ -0,0 +1,273 @@
/**
****************************************************************************************
*
* @file gaf_al_int.h
*
* @brief GAF adaptation layer of the Generic Access profile - Internals
*
* Copyright (C) RivieraWaves 2009-2020
*
****************************************************************************************
*/
#ifndef _GAF_AL_INT_H_
#define _GAF_AL_INT_H_
/**
****************************************************************************************
* @addtogroup GAF_AL
* @brief GAF adaptation layer of the Generic Access profile - Internals
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf_cfg.h" // GAF Configuration
#if (GAF_AL)
#include "gaf_al.h" // GAF adaptation layer API
#include "gaf.h" // GAF Defines
#include "gap.h" // GAP defines
/*
*
* DEFINES
****************************************************************************************
*/
/// Number of activities
#define GAF_AL_ACT_NB (GAF_AL_ACT_MAX + GAF_AL_SCAN)
#if(GAF_AL_SCAN)
/// Activity that manages scan
#define GAF_AL_SCAN_MGR_ACT_LID (GAF_AL_ACT_MAX)
#endif // (GAF_AL_SCAN)
/// Type of non-connected activities supported by GAF adaptation layer
enum gaf_al_act_type
{
/// No information about activity type
GAF_AL_ACT_UNKNOWN,
#if(GAF_AL_ADV)
/// Advertising activity
GAF_AL_ACT_ADV,
#endif // (GAF_AL_ADV)
#if(GAF_AL_PER_ADV)
/// Periodic ADV activity
GAF_AL_ACT_PER_ADV,
#endif // (GAF_AL_PER_ADV)
#if(GAF_AL_SCAN)
/// Scan activity
GAF_AL_ACT_SCAN,
/// Scan Manager activity
GAF_AL_ACT_SCAN_MGR,
#endif // (GAF_AL_SCAN)
#if(GAF_AL_PER_SYNC)
/// Periodic Sync activity
GAF_AL_ACT_PER_SYNC = GAF_AL_ACT_SCAN, // equals to a scan activity
#endif // (GAF_AL_PER_SYNC)
};
/// Activity information bit field
enum gaf_al_act_info_bf
{
/// Activity state (depends on activity type)
GAF_AL_ACT_STATE_MASK = 0x07,
GAF_AL_ACT_STATE_LSB = 0,
/// True if a procedure is on-going for current activity, False else
GAF_AL_ACT_PROC_BUSY_BIT = 0x08,
GAF_AL_ACT_PROC_BUSY_POS = 3,
/// Activity procedure state (depends on activity type and procedure)
GAF_AL_ACT_PROC_STATE_MASK = 0xF0,
GAF_AL_ACT_PROC_STATE_LSB = 4,
};
/// Activity procedure transition
enum gaf_al_trans
{
/// Procedure can be started
GAF_AL_TRANS_PROC_START,
/// Procedure is granted to send a GAP command
GAF_AL_TRANS_GAP_CMD_SEND,
/// Procedure receives an expected command complete status
GAF_AL_TRANS_GAP_CMP_EVT,
/// Unexpected error received during procedure execution
GAF_AL_TRANS_ERROR,
};
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback executed to continue procedure execution according to an event transition
*
* @param[in] act_lid Activity local identifier
* @param[in] transition Procedure Event transition type (@see enum gaf_al_transition_type)
* @param[in] status Status of the transition
****************************************************************************************
*/
typedef void (*gaf_al_proc_continue)(uint8_t act_lid, uint8_t transition, uint16_t status);
/// Activity Header
typedef struct gaf_al_act_hdr
{
/// Procedure execution continue callback
gaf_al_proc_continue cb_continue;
/// GAP activity index
uint8_t actv_idx;
/// Type of activity (@see enum gaf_al_act_type)
uint8_t act_type;
/// Activity information bit field (@see enum gaf_al_act_info_bf)
uint8_t info_bf;
} gaf_al_act_hdr_t;
#if (GAF_AL_SCAN)
/// Scanning Activity environment header
typedef struct gaf_al_scan_act_hdr
{
/// Activity Header
gaf_al_act_hdr_t hdr;
/// Activity owner callback set
const gaf_al_scan_cb_t* p_cb;
/// 1M PHY scan parameters
gaf_al_scan_param_t param_1m;
/// LE Coded PHY scan parameters
gaf_al_scan_param_t param_coded;
/// Expire time instant (counter in milliseconds)
uint32_t expire_time;
/// Scan configuration bit field (@see eunm gaf_al_scan_cfg_bf)
uint16_t cfg_bf;
/// Dummy parameter returned in callbacks
uint16_t dummy;
} gaf_al_scan_act_hdr_t;
#endif // (GAF_AL_SCAN)
/*
* MACROS
****************************************************************************************
*/
/*
* GLOBAL VARIABLE DECLARATIONS
****************************************************************************************
*/
/*
* FUNCTIONS DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Create an activity and assign an activity local identifier
*
* @param[in] act_type Type of activity (@see enum gaf_al_act_type)
* @param[in] env_size Environment size to allocate
* @param[in] p_act_lid Pointer to allocated activity local identifier
*
* @return Status of activity creation (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_act_create(uint8_t act_type, uint16_t env_size, uint8_t* p_act_lid);
/**
****************************************************************************************
* @brief Remove an activity. it assumes that activity is cleaned at GAP level
*
* @param[in] act_lid Activity local identifier
*
* @return Status of activity removal (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_act_remove(uint8_t act_lid);
/**
****************************************************************************************
* @brief Retrieve environment data for an activity
*
* @param[in] act_lid Activity local identifier
* @param[in] act_type Type of activity (@see enum gaf_al_act_type)
*
* @return Pointer to the activity environment or NULL if not found
****************************************************************************************
*/
gaf_al_act_hdr_t* gaf_al_act_get(uint8_t act_lid, uint8_t act_type);
/**
****************************************************************************************
* @brief Start a procedure for a specific activty
*
* @param[in] act_lid Activity local identifier
* @param[in] cb_continue Procedure state machine continue loop
*
* @return Status of function execution (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_act_proc_start(uint8_t act_lid, gaf_al_proc_continue cb_continue);
/**
****************************************************************************************
* @brief Mark procedure stopped, this must be handle by procedure itself.
*
* @param[in] act_lid Activity local identifier
*
* @return Status of function execution (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_act_proc_stop(uint8_t act_lid);
/**
****************************************************************************************
* @brief Wait procedure to be granted for GAP command transmission
*
* Command cannot be immediately sent, procedure must wait for GAF_AL_TRANS_GAP_CMD_SEND
* procedure transition before being allowed to send it.
*
* @param[in] act_lid Activity local identifier
*
* @return Status of function execution (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_act_proc_cmd_send(uint8_t act_lid);
#if (GAF_AL_SCAN)
/**
****************************************************************************************
* @brief Internal function used to create a Scan activity.
*
* @param[in] dummy Dummy parameter returned in callbacks
* @param[in] type Scan type (@see enum gapm_scan_type)
* @param[in] pattern_size Advertising data pattern size, 0 = disable, Max GAF_AL_SCAN_PATTERN_SIZE_MAX
* @param[in] p_pattern Pointer to advertising data pattern (byte 0 represents AD Type)
* If pattern matches, advertising report is triggered
* @param[in] p_1m_param Pointer to 1M PHY parameters (NULL means not enabled for that PHY)
* @param[in] p_coded_param Pointer to LE Coded PHY parameters (NULL means not enabled for that PHY)
* @param[in] p_cb Pointer to callback functions used to return
* procedure execution status
* @param[in] env_size Size of environment to allocate
* @param[out] p_act_lid Pointer to activity local identifier return
*
* @return Status of activity creation (@see enum gaf_err)
****************************************************************************************
*/
uint16_t gaf_al_scan_create_int(uint16_t dummy, uint8_t type, uint8_t pattern_size, const uint8_t* p_pattern,
const gaf_al_scan_param_t* p_1m_param, const gaf_al_scan_param_t* p_coded_param,
const gaf_al_scan_cb_t* p_cb, uint16_t env_size, uint8_t* p_act_lid);
#endif // (GAF_AL_SCAN)
#endif // (GAF_AL)
/// @} GAF_AL
#endif /* _GAF_AL_INT_H_ */
@@ -0,0 +1,45 @@
/**
****************************************************************************************
*
* @file arc_int.h
*
* @brief Audio Rendering Control - Internal Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef ARC_INT_H_
#define ARC_INT_H_
/**
****************************************************************************************
* @addtogroup ARC_INT Audio Rendering Control - Internal Definitions
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf_int.h" // Generic Audio Framework Internal Definitions
/*
* INTERNAL FUNCTIONS
****************************************************************************************
*/
#if (GAF_ARC_VOCS)
void arc_srv_vocs_get(uint8_t* p_nb_vocs, uint16_t** pp_vocs_shdl);
#endif //(GAF_ARC_VOCS)
#if (GAF_ARC_AICS)
void arc_srv_aics_get(uint8_t* p_nb_aics, uint16_t** pp_aics_shdl);
#endif //(GAF_ARC_AICS)
/// @}
#endif // ARC_INT_H_
@@ -0,0 +1,233 @@
/**
****************************************************************************************
*
* @file bap_bc_bass_int.h
*
* @brief Basic Audio Profile - Broadcast Audio Scan Service Internals
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_BC_BASS_INT_H_
#define BAP_BC_BASS_INT_H_
/**
****************************************************************************************
* @addtogroup BAP_BC Basic Audio Profile - Broadcast
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap.h" // Basic Audio Profile Definitions
#include "gaf_inc.h" // Generic Audio Framework Included Definitions
/*
* DEFINES
****************************************************************************************
*/
/// Failed to synchronized to BIG value for BIS Sync State
#define BAP_BC_BIG_SYNC_FAILED (0xFFFFFFFF)
/// No preference for synchronization with BIG
#define BAP_BC_BIG_SYNC_NO_PREF (0xFFFFFFFF)
/// Maximum length supported for Metadata
#define BAP_BC_METADATA_LEN_MAX (0xFF)
/// Minimal length of Broadcast Audio Scan Control Point characteristic value
#define BAP_BC_CP_LEN_MIN (1)
/// Maximum length of Broadcast Audio Scan Control Point characteristic value
#define BAP_BC_CP_LEN_MAX (0x18 + BAP_BC_METADATA_LEN_MAX)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Position of fields in Broadcast Audio Scan Control Point characteristic
enum bap_bc_cp_pos
{
/// Operation Code
BAP_BC_CP_OPCODE_POS = 0,
};
/// Position of fields in Broadcast Audio Scan Control Point characteristic value for Add Source operation
enum bap_bc_cp_add_src_pos
{
/// Operation Code
BAP_BC_CP_ADD_SRC_OPCODE_POS = 0,
/// Advertising Address Type
BAP_BC_CP_ADD_SRC_ADV_ADDR_TYPE_POS,
/// Advertiser Address
BAP_BC_CP_ADD_SRC_ADV_ADDR_POS,
/// Advertising SID
BAP_BC_CP_ADD_SRC_ADV_SID_POS = BAP_BC_CP_ADD_SRC_ADV_ADDR_POS + 6,
/// PA Sync
BAP_BC_CP_ADD_SRC_PA_SYNC_POS,
/// BIS Sync
BAP_BC_CP_ADD_SRC_BIS_SYNC_POS,
/// Metadata length
BAP_BC_CP_ADD_SRC_METADATA_LEN_POS = BAP_BC_CP_ADD_SRC_BIS_SYNC_POS + 4,
/// Metadata
BAP_BC_CP_ADD_SRC_METADATA_POS,
/// Length of Broadcast Audio Scan Control Point characteristic value for Add Source operation
BAP_BC_CP_ADD_SRC_MIN_LEN = BAP_BC_CP_ADD_SRC_METADATA_POS,
};
/// Position of fields in Broadcast Audio Scan Control Point characteristic value for Modify Source operation
enum bap_bc_cp_modify_src_pos
{
/// Operation Code
BAP_BC_CP_MODIFY_SRC_OPCODE_POS = 0,
/// Source ID
BAP_BC_CP_MODIFY_SRC_SRC_ID_POS,
/// PA Sync
BAP_BC_CP_MODIFY_SRC_PA_SYNC_POS,
/// BIS Sync
BAP_BC_CP_MODIFY_SRC_BIS_SYNC_POS,
/// Metadata length
BAP_BC_CP_MODIFY_SRC_METADATA_LEN_POS = BAP_BC_CP_MODIFY_SRC_BIS_SYNC_POS + 4,
/// Metadata
BAP_BC_CP_MODIFY_SRC_METADATA_POS,
/// Length of Broadcast Audio Scan Control Point characteristic value for Modify Source operation
BAP_BC_CP_MODIFY_SRC_MIN_LEN = BAP_BC_CP_MODIFY_SRC_METADATA_POS,
};
/// Position of fields in Broadcast Audio Scan Control Point characteristic value for Set Broadcast
/// Code operation
enum bap_bc_cp_set_bcast_code
{
/// Operation Code
BAP_BC_CP_SET_BCAST_CODE_OPCODE_POS = 0,
/// Source ID
BAP_BC_CP_SET_BCAST_CODE_SRC_ID_POS = 1,
/// Broadcast Code
BAP_BC_CP_SET_BCAST_CODE_CODE_POS = 2,
/// Length of Broadcast Audio Scan Control Point characteristic value for Set Broadcast
/// Code operation
BAP_BC_CP_SET_BCAST_CODE_LEN = 18,
};
/// Position of fields in Broadcast Audio Scan Control Point characteristic value for Remove Source
/// operation
enum bap_bc_cp_remove_src
{
/// Operation Code
BAP_BC_CP_REMOVE_SRC_OPCODE_POS = 0,
/// Source ID
BAP_BC_CP_REMOVE_SRC_SRC_ID_POS = 1,
/// Length of Broadcast Audio Scan Control Point characteristic value for Remove Source opearation
BAP_BC_CP_REMOVE_SRC_LEN = 2,
};
/// Values for PA Sync field in Broadcast Audio Scan Control Point characteristic value
enum bap_bc_pa_sync
{
/// Do not synchronize to PA
BAP_BC_PA_SYNC_NO_SYNC = 0,
/// Synchronize to PA
BAP_BC_PA_SYNC_SYNC,
BAP_BC_PA_SYNC_MAX
};
/// Position of fields in Broadcast Receive State characteristic value
enum bap_bc_rx_state_pos
{
/// Source ID
BAP_BC_RX_STATE_SRC_ID_POS = 0,
/// Source Address Type
BAP_BC_RX_STATE_SRC_ADDR_TYPE_POS,
/// Source Address
BAP_BC_RX_STATE_SRC_ADDR_POS,
/// Source Advertising SID
BAP_BC_RX_STATE_SRC_ADV_SID_POS = BAP_BC_RX_STATE_SRC_ADDR_POS + 6,
/// PA Sync State
BAP_BC_RX_STATE_PA_SYNC_STATE_POS,
/// BIS Sync State
BAP_BC_RX_STATE_BIS_SYNC_STATE_POS,
/// BIG Encryption
BAP_BC_RX_STATE_BIG_ENCRYPTION_POS = BAP_BC_RX_STATE_BIS_SYNC_STATE_POS + 4,
/// Metadata length
BAP_BC_RX_STATE_METADATA_LEN_POS,
/// Metadata
BAP_BC_RX_STATE_METADATA_POS,
/// Length of Broadcast Receive State characteristic value
BAP_BC_RX_STATE_MIN_LEN = BAP_BC_RX_STATE_METADATA_POS,
};
/// Source Address Type values // TODO should use the GAP define instead
enum bap_bc_src_addr_type
{
/// Public Device Address
BAP_BC_SRC_ADDR_TYPE_PUBLIC = 0,
/// Random Device Address
BAP_BC_SRC_ADDR_TYPE_RANDOM,
/// Maximum allowed value
BAP_BC_SRC_ADDR_TYPE_MAX,
};
/// Values for PA Sync State subfield in Scan State field in Broadcast Receive State characteristic value
enum bap_bc_rx_state_pa
{
/// Not synchronized to PA
BAP_BC_RX_STATE_PA_NOT_SYNCED = 0,
/// SyncInfo Request
BAP_BC_RX_STATE_PA_SYNCINFO_REQ,
/// Synchronized to PA
BAP_BC_RX_STATE_PA_SYNCED,
/// Failed to synchronize with PA
BAP_BC_RX_STATE_PA_FAILED,
/// No PAST
BAP_BC_RX_STATE_PA_NO_PAST,
BAP_BC_RX_STATE_PA_MAX,
};
/// Values for BIG encryption subfield in Scan State field in Broadcast Receive State characteristic value
enum bap_bc_rx_state_enc
{
/// Not encrypted
BAP_BC_RX_STATE_ENC_NOT_ENCRYPTED = 0,
/// Broadcast code required
BAP_BC_RX_STATE_ENC_CODE_REQUIRED,
/// Decrypting
BAP_BC_RX_STATE_ENC_DECRYPTING,
BAP_BC_RX_STATE_ENC_MAX,
};
/// Operation codes for Broadcast Audio Scan Control Point characteristic
enum bap_bc_opcodes
{
/// Remote Scan Stop
BAP_BC_OPCODE_REMOTE_SCAN_STOP = 0,
/// Remote Scan Start
BAP_BC_OPCODE_REMOTE_SCAN_START,
/// Add Source
BAP_BC_OPCODE_ADD_SRC,
/// Modify Source
BAP_BC_OPCODE_MODIFY_SRC,
/// Set Broadcast Code
BAP_BC_OPCODE_SET_BCAST_CODE,
/// Remove Source
BAP_BC_OPCODE_REMOVE_SRC,
BAP_BC_OPCODE_MAX,
};
/// @}
#endif // BAP_BC_BASS_INT_H_
@@ -0,0 +1,360 @@
/**
****************************************************************************************
*
* @file bap_bc_bass_int.h
*
* @brief Basic Audio Profile - Internals
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_BC_INT_H_
#define BAP_BC_INT_H_
/**
****************************************************************************************
* @addtogroup BAP_BC Basic Audio Profile - Internals
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap.h" // Basic Audio Profile Definitions
#include "gaf_inc.h" // Generic Audio Framework Included Definitions
#if (GAF_BAP_BC_SCAN)
#include "bap_bc_scan.h" // Scan definitions
#endif // (GAF_BAP_BC_SCAN)
/*
* DEFINES
****************************************************************************************
*/
/*
* ENUMERATIONS
****************************************************************************************
*/
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
#if (GAF_BAP_BC_SCAN)
/**
****************************************************************************************
* @brief Internal callback function called each time a Broadcast scan command has been completed
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] src_lid Source Local identifier
* @param[in] cmd_code Command code (@see enum bap_bc_scan_cmd_codes)
* @param[in] status Status of command execution (@see enum gaf_err)
****************************************************************************************
*/
typedef void (*bap_bc_scan_int_cb_cmp_evt)(uint8_t pa_lid, uint8_t src_lid, uint16_t cmd_code, uint16_t status);
/**
****************************************************************************************
* @brief Internal callback function called when periodic sync has been established
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] src_lid Source Local identifier
* @param[in] p_adv_addr Pointer to periodic advertising address information
* @param[in] serv_data Only valid for a Periodic Advertising Sync Transfer, else ignore
****************************************************************************************
*/
typedef void (*bap_bc_scan_int_cb_pa_established)(uint8_t pa_lid, uint8_t src_lid, const gap_per_adv_bdaddr_t* p_adv_addr,
uint16_t serv_data);
/**
****************************************************************************************
* @brief Internal callback function called as result of @see bap_bc_scan_pa_terminate function or if
* the periodic sync establishment is canceled or periodic sync is lost
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] src_lid Source Local identifier
* @param[in] reason Stop reason (@see enum gaf_err)
****************************************************************************************
*/
typedef void (*bap_bc_scan_int_cb_pa_terminated)(uint8_t pa_lid, uint8_t src_lid, uint16_t reason);
/**
****************************************************************************************
* @brief Internal callback function called when a BIG Info report is received
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] src_lid Source Local identifier
* @param[in] p_report Pointer to structure that contains Big Info data
****************************************************************************************
*/
typedef void (*bap_bc_scan_int_cb_big_info_report)(uint8_t pa_lid, uint8_t src_lid, const gap_big_info_t* p_report);
/// Set of callback functions for internal communication with Broadcast Assistant or Delegator module
typedef struct bap_bc_scan_int_cb
{
/// Callback function called when a command has been completed
bap_bc_scan_int_cb_cmp_evt cb_cmp_evt;
/// Callback function called when a Periodic Advertising Sync is established
bap_bc_scan_int_cb_pa_established cb_pa_established;
/// Callback function called when a Periodic Advertising Sync is lost, canceled or terminated
bap_bc_scan_int_cb_pa_terminated cb_pa_terminated;
/// Callback function called when a BIG Info report is received
bap_bc_scan_int_cb_big_info_report cb_big_info_report;
} bap_bc_scan_int_cb_t;
#endif // (GAF_BAP_BC_SCAN)
#if (GAF_BAP_BC_SINK && GAF_BAP_BC_DELEG)
/**
****************************************************************************************
* @brief Callback function called each time a Broadcast sink command has been completed
*
* @param[in] grp_lid Broadcast group local index
* @param[in] src_lid Source Local identifier
* @param[in] cmd_code Command code (@see enum bap_bc_sink_cmd_codes)
* @param[in] status Status of command execution (@see enum gaf_err)
****************************************************************************************
*/
typedef void (*bap_bc_sink_int_cb_cmp_evt)(uint8_t grp_lid, uint8_t src_lid, uint16_t cmd_code, uint16_t status);
/**
****************************************************************************************
* @brief Inform upper layer about status of synchronization with a Broadcast Group
*
* @param[in] grp_lid Broadcast group local index
* @param[in] src_lid Source Local identifier
* @param[in] state Broadcast Sink state (@see enum bap_bc_sink_state)
* @param[in] stream_pos_bf Stream position bit field in broadcast group to receive
****************************************************************************************
*/
typedef void (*bap_bc_sink_int_cb_status)(uint8_t grp_lid, uint8_t src_lid, uint8_t state, uint32_t stream_pos_bf);
/**
****************************************************************************************
* @brief Get information about how to establish BIG Sink:
* - Periodic ADV sync local identifier
* - If encrypted, value of broadcast code
*
* @param[in] grp_lid Broadcast group local index
* @param[in] src_lid Source Local identifier
* @param[out] p_pa_lid Pointer to periodic adv sync local identifier
* @param[out] pp_bcast_code Pointer to broadcast code information, returns NULL if not encrypted
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
typedef uint16_t (*bap_bc_sink_int_cb_info_get)(uint8_t grp_lid, uint8_t src_lid, uint8_t* p_pa_lid,
const gaf_bcast_code_t** pp_bcast_code);
/// Set of callback functions for internal communication with Broadcast Delegator module
typedef struct bap_bc_sink_int_cb
{
/// Callback function called when a command has been completed
bap_bc_sink_int_cb_cmp_evt cb_cmp_evt;
/// Callback function called when status of synchronization with a Broadcast Group changed
bap_bc_sink_int_cb_status cb_status;
/// Callback used to get get information about how to establish BIG Sink
bap_bc_sink_int_cb_info_get cb_info_get;
} bap_bc_sink_int_cb_t;
#endif // (GAF_BAP_BC_SCAN && GAF_BAP_BC_DELEG)
/*
* MACROS
****************************************************************************************
*/
/*
* GLOBAL VARIABLE DECLARATIONS
****************************************************************************************
*/
/*
* FUNCTIONS DECLARATIONS
****************************************************************************************
*/
#if(GAF_BAP_BC_DELEG)
/**
****************************************************************************************
* @brief Retrieve Broadcast Delegator scan interface
*
* @return Scan callback interface (shall not be NULL)
****************************************************************************************
*/
const bap_bc_scan_int_cb_t* bap_bc_deleg_scan_itf_get(void);
/**
****************************************************************************************
* @brief Establish a Periodic Adv Sync initiated by delegator
*
* @param[in] src_lid Source local identifier in delegator
* @param[in] p_adv_addr Pointer to periodic advertising address information
* @param[in] skip Number of periodic advertising that can be skipped after a successful receive.
* Maximum authorized value is 499
* @param[in] report_filter_bf Bit field of filtered report types - The reception of BIGInfo is forced to enable
* (@see enum bap_bc_scan_report_filter_bf)
* @param[in] sync_to Synchronization timeout for the periodic advertising
* (in unit of 10ms between 100ms and 163.84s)
* @param[in] timeout_s Sync establishment timeout in seconds
* @param[out] p_pa_lid Pointer to allocated periodic advertising sync local identifier
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_scan_pa_synchronize_from_deleg(uint8_t src_lid, const gap_per_adv_bdaddr_t* p_adv_addr,
uint16_t skip, uint8_t report_filter_bf, uint16_t sync_to, uint16_t timeout_s,
uint8_t* p_pa_lid);
/**
****************************************************************************************
* @brief Establish a Periodic Adv Sync initiated by delegator
* Upper layer application will be inform about establishment to accept or reject it.
*
* @param[in] src_lid Source local identifier in delegator
* @param[in] con_lid Connection local identifier that requests the sync establishment
* @param[in] p_adv_addr Pointer to periodic advertising address information
* @param[in] past True if sync transfer is expected, False otherwise
*
* @param[out] p_pa_lid Pointer to allocated periodic advertising sync local identifier
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_scan_pa_synchronize_req_from_deleg(uint8_t src_lid, uint8_t con_lid, const gap_per_adv_bdaddr_t* p_adv_addr,
bool past, uint8_t* p_pa_lid);
/**
****************************************************************************************
* @brief Terminate a Periodic Adv Sync initiated by delegator
* Upper layer application will be inform about termination to accept or reject it.
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] src_lid Source local identifier in delegator
* @param[in] con_lid Connection local identifier that requests the sync terminate
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_scan_pa_terminate_req_from_deleg(uint8_t pa_lid, uint8_t src_lid, uint8_t con_lid);
/**
****************************************************************************************
* @brief Retrieve Broadcast delegator sink interface
*
* @return SINK callback interface (shall not be NULL)
****************************************************************************************
*/
const bap_bc_sink_int_cb_t* bap_bc_deleg_sink_itf_get(void);
/**
****************************************************************************************
* @brief Establish a BIG Sink initiated by application through delegator
*
* @param[in] pa_lid Periodic Advertising local index
* @param[in] src_lid Source local identifier in delegator
* @param[in] stream_pos_bf Stream position bit field indicating streams to synchronize with.
* @param[in] p_bcast_code Pointer to broadcast code, NULL if not encrypted
* @param[in] mse Maximum number of subevents the controller should use to received data
* payloads in each interval
* @param[in] timeout Timeout duration (10ms unit) before considering synchronization lost
* (Range 100 ms to 163.84 s).
* @param[out] p_grp_lid Pointer at which allocated Group local index is returned
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_sink_enable_from_deleg(uint8_t pa_lid, uint8_t src_lid, uint32_t stream_pos_bf,
const gaf_bcast_code_t* p_bcast_code, uint8_t mse, uint16_t timeout,
uint8_t* p_grp_lid);
/**
****************************************************************************************
* @brief Establish a BIG Sink initiated by delegator
* Upper layer application will be inform about establishment to accept or reject it.
* and provide Sink parameters
*
* @param[in] src_lid Source local identifier in delegator
* @param[in] con_lid Connection local identifier that requests the sync terminate
* @param[in] stream_pos_bf Stream position bit field indicating streams to synchronize with.
* @param[out] p_grp_lid Pointer at which allocated Group local index is returned
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_sink_enable_req_from_deleg(uint8_t src_lid, uint8_t con_lid, uint32_t stream_pos_bf, uint8_t* p_grp_lid);
/**
****************************************************************************************
* @brief Terminate a BIG Sink initiated by delegator
* Upper layer application will be inform about termination to accept or reject it.
*
* @param[in] grp_lid Broadcast group local index
* @param[in] src_lid Source local identifier in delegator
* @param[in] con_lid Connection local identifier that requests the sync terminate
*
* @return Function execution status code. (@see enum gaf_err)
****************************************************************************************
*/
uint16_t bap_bc_sink_disable_req_from_deleg(uint8_t grp_lid, uint8_t src_lid, uint8_t con_lid);
#endif // (GAF_BAP_BC_DELEG)
#if(GAF_BAP_BC_ASSIST)
/**
****************************************************************************************
* @brief Retrieve Broadcast Assistant scan interface
*
* @return Scan callback interface (shall not be NULL)
****************************************************************************************
*/
const bap_bc_scan_int_cb_t* bap_bc_assist_scan_itf_get(void);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_bc_scan_pa_synchronize_from_assist(const gap_per_adv_bdaddr_t* p_adv_addr, uint8_t* p_pa_lid);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_bc_scan_pa_terminate_from_assist(uint8_t pa_lid);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
bool bap_bc_scan_pa_is_synced(const gap_per_adv_bdaddr_t* p_adv_addr, uint8_t* p_pa_lid);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
bool bap_bc_src_is_local(gap_per_adv_bdaddr_t* p_src_addr, uint8_t* p_pa_lid);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_bc_src_get_grp_addr(uint8_t grp_lid, uint8_t** pp_addr, uint8_t* p_addr_type, uint8_t* p_adv_sid);
#endif // (GAF_BAP_BC_ASSIST)
/// @}
#endif // BAP_BC_INT_H_
@@ -0,0 +1,104 @@
/**
****************************************************************************************
*
* @file bap_capa_pacs_int.h
*
* @brief Basic Audio Profile - Capabilities - Published Audio Capabilities Service Internal Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_CAPA_PACS_INT_H_
#define BAP_CAPA_PACS_INT_H_
/**
****************************************************************************************
* @addtogroup BAP_CAPA Basic Audio Profile - Capabilities
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap.h" // Basic Audio Profile Definitions
#include "gaf_inc.h" // Generic Audio Framework Included Definitions
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Position of fields in Sink/Source PAC characteristic value
enum bap_capa_pac_pos
{
/// Number of PAC record
BAP_CAPA_PAC_NB_RECORDS_POS = 0,
BAP_CAPA_PAC_LEN_MIN,
/// Codec ID
BAP_CAPA_PAC_CODEC_ID_POS = 0,
/// Length of Codec Specific Capabilities
BAP_CAPA_PAC_CODEC_CAPA_LEN_POS = 0,
/// Codec Specific Capabilities
BAP_CAPA_PAC_CODEC_CAPA_POS,
/// Length of Metadata
BAP_CAPA_PAC_METADATA_LEN_POS = 0,
/// Metadata
BAP_CAPA_PAC_METADATA_POS,
BAP_CAPA_PAC_RECORD_LEN_MIN = 2 + GAF_CODEC_ID_LEN,
};
/// Position of fields in Available Audio Contexts and Supported Audio Contexts characteristic value
enum bap_capa_context_pos
{
/// Length of context field for a direction
BAP_CAPA_CONTEXT_DIR_LEN = 2,
/// Contexts for Sink direction
BAP_CAPA_CONTEXT_SINK_POS = 0,
/// Contexts for Source direction
BAP_CAPA_CONTEXT_SRC_POS = BAP_CAPA_CONTEXT_SINK_POS + BAP_CAPA_CONTEXT_DIR_LEN,
/// Length of characteristic value
BAP_CAPA_CONTEXT_LEN = BAP_CAPA_CONTEXT_SRC_POS + BAP_CAPA_CONTEXT_DIR_LEN,
};
/// Position of fields in Sink/Source Audio Locations characteristic value
enum bap_capa_audio_loc_pos
{
/// Length of Sink/Source characteristic value
BAP_CAPA_LOCATION_LEN = 4,
/// Location
BAP_CAPA_LOCATION_POS = 0,
};
/// Descriptor type values for Published Audio Capabilities Service
enum bap_pacs_desc_type
{
/// Available Audio Contexts characteristic
BAP_CAPA_DESC_TYPE_CCC_CONTEXT_AVA = 0,
/// Supported Audio Contexts characteristic
BAP_CAPA_DESC_TYPE_CCC_CONTEXT_SUPP,
/// Sink Audio Locations characteristic
BAP_CAPA_DESC_TYPE_CCC_LOC_SINK,
/// Source Audio Locations characteristic
BAP_CAPA_DESC_TYPE_CCC_LOC_SRC,
/// Sink PAC characteristic
BAP_CAPA_DESC_TYPE_CCC_PAC,
BAP_CAPA_DESC_TYPE_MAX,
};
/// @}
#endif // BAP_CAPA_H_
@@ -0,0 +1,233 @@
/**
****************************************************************************************
*
* @file bap_codec.h
*
* @brief Basic Audio Profile - Codec API
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef _BAP_CODEC_H_
#define _BAP_CODEC_H_
/**
****************************************************************************************
* @addtogroup BAP_CODEC
* @ingroup BAP
* @brief Basic Audio Profile - Codec API
*
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf_cfg.h" // GAF configuration
#if (GAF_BAP)
#include "gaf.h" // GAF types
#include "bap.h" // BAP types
/*
* FUNCTION DECLARATIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Check if a list of values in LTV format is properly formatted
*
* @param[in] data_len Length of data
* @param[in] p_data Pointer to data
*
* @return An error status
* - GAF_ERR_NO_ERROR if data is properly formatted
* - GAF_ERR_INVALID_PARAM if data is not properly formatted
****************************************************************************************
*/
uint16_t bap_codec_check_ltv(uint8_t data_len, const uint8_t* p_data);
/**
****************************************************************************************
* @brief Retrieve length of codec configuration in LTV format
*
* @param[in] p_codec_id Pointer to Codec ID
* @param[in] p_cfg Pointer to Codec configuration data
*
* @return Length of codec configuration in LTV format
****************************************************************************************
*/
uint8_t bap_codec_get_ltv_len_cfg(const gaf_codec_id_t* p_codec_id, const void* p_cfg);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint8_t bap_codec_get_ltv_len_metadata_cfg(const bap_metadata_cfg_t* p_metadata);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_codec_pack_cfg(const gaf_codec_id_t* p_codec_id, const void* p_cfg, uint8_t** pp_cfg_packed,
uint8_t* p_len_cfg_packed);
/**
****************************************************************************************
* Pack the codec configuration to LTV format.
* -> A memory block is allocated by this function
*
* @param[in] p_codec_id Pointer to the Codec ID
* @param[in] p_cfg Pointer to the Code configuration structure
* @param[out] pp_ltv_cfg Pointer to the output result
*
* @return Status of the function execution (@see gaf_err)
****************************************************************************************
*/
uint16_t bap_codec_pack_cfg_ltv(const gaf_codec_id_t* p_codec_id, const void* p_cfg, gaf_ltv_t** pp_ltv_cfg);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_codec_pack_cfg_metadata(bap_metadata_cfg_t* p_metadata, uint8_t* p_data, uint8_t* p_len_packed);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_codec_unpack_cfg(gaf_codec_id_t* p_codec_id, uint8_t data_len, uint8_t* p_data, void* p_params,
void* p_cfg);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_codec_unpack_cfg_metadata(bap_metadata_cfg_ptr_t* p_metadata, uint8_t metadata_len, uint8_t* p_data);
/**
****************************************************************************************
* @brief Check QoS Requirements values
*
* @param[in] p_qos_req Pointer to QoS Requirements structure
*
* @return An error status
* - GAF_ERR_NO_ERROR if all provided values are valid
* - GAF_ERR_INVALID_PARAM if an invalid value has been detected
****************************************************************************************
*/
uint16_t bap_codec_check_qos_req(bap_qos_req_t* p_qos_req);
/**
****************************************************************************************
* @brief Check QoS Configuration values
*
* @param[in] p_qos_cfg Pointer to QoS Configuration structure
*
* @return An error status
* - GAF_ERR_NO_ERROR if all provided values are valid
* - GAF_ERR_INVALID_PARAM if an invalid value has been detected
****************************************************************************************
*/
uint16_t bap_codec_check_qos_cfg(bap_qos_cfg_t* p_qos_cfg);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_codec_check_cfg(gaf_codec_id_t* p_codec_id, void* p_cfg);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_codec_check_params(gaf_codec_id_t* p_codec_id, void* p_params);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_codec_check_cfg_metadata(bap_metadata_cfg_t* p_metadata);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_codec_check_cfg_metadata_ptr(bap_metadata_cfg_ptr_t* p_metadata);
/**
****************************************************************************************
* @brief Check if a Codec ID is Codec ID for LC3
*
* @param[in] p_codec_id Pointer to Codec ID
*
* @return True if Codec ID is for LC3, else false
****************************************************************************************
*/
bool bap_codec_is_lc3(const gaf_codec_id_t* p_codec_id);
#if (GAF_BAP_CAPA_SRV || GAF_BAP_CAPA_CLI)
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_codec_check_capa(const gaf_codec_id_t* p_codec_id, const void* p_capa, uint16_t* p_ltv_len);
#endif //(GAF_BAP_CAPA_SRV || GAF_BAP_CAPA_CLI)
#if (GAF_BAP_CAPA_SRV)
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint8_t bap_codec_pack_capa(const gaf_codec_id_t* p_codec_id, uint8_t* p_data, const void* p_capa);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint8_t bap_codec_pack_capa_metadata(const gaf_codec_id_t* p_codec_id, uint8_t* p_data, const void* p_capa);
#endif //(GAF_BAP_CAPA_SRV)
#if (GAF_BAP_CAPA_CLI)
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_codec_unpack_capa(const gaf_codec_id_t* p_codec_id, void* p_capa, uint8_t codec_capa_len,
const uint8_t *p_codec_capa);
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
uint16_t bap_codec_unpack_capa_metadata(const gaf_codec_id_t* p_codec_id, void* p_capa, uint8_t metadata_len,
const uint8_t *p_metadata);
#endif //(GAF_BAP_CAPA_CLI)
#endif // (GAF_BAP)
/// @} BAP_CODEC
#endif // BAP_CODEC_H_
@@ -0,0 +1,215 @@
/**
****************************************************************************************
*
* @file bap_uc_ascs_int.h
*
* @brief Basic Audio Profile - Unicast - Audio Stream Control Service Internal Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef BAP_UC_ASCS_INT_H_
#define BAP_UC_ASCS_INT_H_
/**
****************************************************************************************
* @addtogroup BAP_UC Basic Audio Profile - Unicast
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "bap.h" // Basic Audio Profile Definitions
#include "gaf_inc.h" // Generic Audio Framework Included Definitions
/*
* DEFINES
****************************************************************************************
*/
/// Minimum ASE ID
#define BAP_UC_ASE_ID_MIN (1)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Position of fields in written ASE Control Point characteristic value
enum bap_uc_cp_pos
{
/// Operation code
BAP_UC_CP_OPCODE_POS = 0,
/// Number of ASEs
BAP_UC_CP_NB_ASES_POS,
/// Minimal length of ASE Control Point characteristic value
BAP_UC_CP_LEN_MIN,
/// --------- Config Codec operation ---------
/// ASE ID
BAP_UC_CP_CODEC_ASE_ID_POS = 0,
/// Direction
BAP_UC_CP_CODEC_DIRECTION_POS,
/// Target Latency
BAP_UC_CP_CODEC_TGT_LATENCY_POS,
/// Target PHY
BAP_UC_CP_CODEC_TGT_PHY_POS,
/// Codec ID
BAP_UC_CP_CODEC_ID_POS,
/// Length of Codec Specific Configuration
BAP_UC_CP_CODEC_SPEC_CFG_LEN_POS = BAP_UC_CP_CODEC_ID_POS + GAF_CODEC_ID_LEN,
/// Minimal length of ASE Control Point characteristic value for Configure Codec operation code
BAP_UC_CP_CODEC_LEN_MIN,
/// Codec Specific Configuration
BAP_UC_CP_CODEC_SPEC_CFG_POS = BAP_UC_CP_CODEC_LEN_MIN,
/// --------- Config QoS operation ---------
/// ASE ID
BAP_UC_CP_QOS_ASE_ID_POS = 0,
/// CIG ID
BAP_UC_CP_QOS_CIG_ID_POS,
/// CIS ID
BAP_UC_CP_QOS_CIS_ID_POS,
/// SDU Interval
BAP_UC_CP_QOS_SDU_INTV_POS,
/// Framing
BAP_UC_CP_QOS_FRAMING_POS = BAP_UC_CP_QOS_SDU_INTV_POS + 3,
/// PHY
BAP_UC_CP_QOS_PHY_POS,
/// Maximum SDU Size
BAP_UC_CP_QOS_MAX_SDU_SIZE_POS,
/// Retransmission Number
BAP_UC_CP_QOS_RETX_NB_POS = BAP_UC_CP_QOS_MAX_SDU_SIZE_POS + 2,
/// Maximum Transport Latency
BAP_UC_CP_QOS_MAX_TRANS_LATENCY_POS,
/// Presentation Delay
BAP_UC_CP_QOS_PRES_DELAY_POS = BAP_UC_CP_QOS_MAX_TRANS_LATENCY_POS + 2,
/// Length of ASE Control Point characteristic value for Configure QoS operation code
BAP_UC_CP_QOS_LEN = BAP_UC_CP_QOS_PRES_DELAY_POS + 3,
/// --------- Enable/Update Metadata operation ---------
/// ASE ID
BAP_UC_CP_METADATA_ASE_ID_POS = 0,
/// Metadata length
BAP_UC_CP_METADATA_METADATA_LEN_POS,
/// Minimal length of ASE Control Point characteristic value for Enable and Update Metadata operation code
BAP_UC_CP_METADATA_LEN_MIN,
/// Metadata
BAP_UC_CP_METADATA_METADATA_POS = BAP_UC_CP_METADATA_LEN_MIN,
};
/// Position of fields in notified ASE characteristic value
enum bap_uc_cp_ntf_pos
{
/// ASE Control Point operation code in error
BAP_UC_CP_NTF_OPCODE_POS = 0,
/// Number of ASEs
BAP_UC_CP_NTF_NB_ASES_POS,
BAP_UC_CP_NTF_LEN_MIN,
/// ASE ID
BAP_UC_CP_NTF_ASE_ID_POS = 0,
/// Response Code
BAP_UC_CP_NTF_RSP_CODE_POS,
/// Reason
BAP_UC_CP_NTF_REASON_POS,
BAP_UC_CP_NTF_PER_ASE_LEN,
};
/// Position of fields in ASE characteristic value
enum bap_uc_ase_pos
{
/// ASE ID
BAP_UC_ASE_ID_POS = 0,
/// ASE State
BAP_UC_ASE_STATE_POS,
/// Minimal length of ASE characteristic value
BAP_UC_ASE_LEN_MIN,
/// --------- Codec Configured State ---------
/// Direction
BAP_UC_ASE_CODEC_DIRECTION_POS = BAP_UC_ASE_LEN_MIN,
/// Preferred SDU Interval Min
BAP_UC_ASE_CODEC_PREF_SDU_INTV_MIN_POS,
/// Preferred SDU Interval Max
BAP_UC_ASE_CODEC_PREF_SDU_INTV_MAX_POS = BAP_UC_ASE_CODEC_PREF_SDU_INTV_MIN_POS + 3,
/// Preferred Framing
BAP_UC_ASE_CODEC_PREF_FRAMING_POS = BAP_UC_ASE_CODEC_PREF_SDU_INTV_MAX_POS + 3,
/// Preferred PHY
BAP_UC_ASE_CODEC_PREF_PHY_POS,
/// Preferred Maximum SDU Size
BAP_UC_ASE_CODEC_PREF_MAX_SDU_SIZE_POS,
/// Preferred Retransmission Number
BAP_UC_ASE_CODEC_PREF_RETX_NB_POS = BAP_UC_ASE_CODEC_PREF_MAX_SDU_SIZE_POS + 2,
/// Preferred Max Transport Latency
BAP_UC_ASE_CODEC_PREF_MAX_TRANS_LATENCY_POS,
/// Presentation Delay Min
BAP_UC_ASE_CODEC_PRES_DELAY_MIN_POS = BAP_UC_ASE_CODEC_PREF_MAX_TRANS_LATENCY_POS + 2,
/// Presentation Delay Max
BAP_UC_ASE_CODEC_PRES_DELAY_MAX_POS = BAP_UC_ASE_CODEC_PRES_DELAY_MIN_POS + 3,
/// Codec ID
BAP_UC_ASE_CODEC_ID_POS = BAP_UC_ASE_CODEC_PRES_DELAY_MAX_POS + 3,
/// Codec Specific Configuration Length
BAP_UC_ASE_CODEC_SPEC_CFG_LEN_POS = BAP_UC_ASE_CODEC_ID_POS + GAF_CODEC_ID_LEN,
/// Minimal length of ASE characteristic value for Codec Configured state
BAP_UC_ASE_CODEC_LEN_MIN,
/// Codec Specific Configuration
BAP_UC_ASE_CODEC_SPEC_CFG_POS = BAP_UC_ASE_CODEC_LEN_MIN,
/// --------- QoS Configured State ---------
/// CIS ID
BAP_UC_ASE_QOS_CIS_ID_POS = BAP_UC_ASE_LEN_MIN,
/// CIG ID
BAP_UC_ASE_QOS_CIG_ID_POS,
/// SDU Interval
BAP_UC_ASE_QOS_SDU_INTV_POS,
/// Framing
BAP_UC_ASE_QOS_FRAMING_POS = BAP_UC_ASE_QOS_SDU_INTV_POS + 3,
/// PHY
BAP_UC_ASE_QOS_PHY_POS,
/// Maximum SDU Size
BAP_UC_ASE_QOS_MAX_SDU_SIZE_POS,
/// Retransmission Number
BAP_UC_ASE_QOS_RETX_NB_POS = BAP_UC_ASE_QOS_MAX_SDU_SIZE_POS + 2,
/// Transport Latency
BAP_UC_ASE_QOS_TRANS_LATENCY_POS,
/// Presentation Delay
BAP_UC_ASE_QOS_PRES_DELAY_POS = BAP_UC_ASE_QOS_TRANS_LATENCY_POS + 2,
/// Length of ASE characteristic additional parameters for QoS Configured state
BAP_UC_ASE_QOS_LEN = BAP_UC_ASE_QOS_PRES_DELAY_POS + 3,
/// --------- Enabling/Streaming/Disabling State ---------
/// CIS ID
BAP_UC_ASE_METADATA_CIS_ID_POS = BAP_UC_ASE_LEN_MIN,
/// CIG ID
BAP_UC_ASE_METADATA_CIG_ID_POS,
/// Metadata length
BAP_UC_ASE_METADATA_METADATA_LEN_POS,
/// Minimal length of ASE characteristic value for Enabling/Streaming/Disabling state
BAP_UC_ASE_METADATA_LEN_MIN,
/// Metadata
BAP_UC_ASE_METADATA_METADATA_POS = BAP_UC_ASE_METADATA_LEN_MIN,
};
/// List of descriptors for Audio Stream Control Service
enum bap_uc_desc_type
{
/// Client Characteristic Configuration descriptor for ASE control point characteristic
BAP_UC_DESC_TYPE_CCC_CP = 0,
/// CLient Characteristic Configuration descriptor for ASE characteristic
BAP_UC_DESC_TYPE_CCC_ASE,
BAP_UC_DESC_TYPE_MAX,
};
/// @}
#endif // BAP_UC_H_
+39
View File
@@ -0,0 +1,39 @@
/**
****************************************************************************************
*
* @file gaf_int.h
*
* @brief Generic Audio Framework - Internal Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef GAF_INT_H_
#define GAF_INT_H_
/**
****************************************************************************************
* @addtogroup GAF_INT Generic Audio Framework - Internal Definitions
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gatt.h" // GATT Definitions
#include "ke_mem.h" // Kernel Memory Definitions
#include "ke_task.h" // Kernel Task Definitions
#include "rwip.h" // RW IP Definitions
#include <string.h> // String Definitions for use of memset and memcpy
#include "gaf.h" // GAF Definitions
#include "gaf_inc.h" // GAF Included Definitions
#include "co_endian.h" // Endianness function Definitions
/// @}
#endif // GAF_INT_H_
+133
View File
@@ -0,0 +1,133 @@
/**
****************************************************************************************
*
* @file gaf_msg_int.h
*
* @brief Generic Audio Framework - Definition of Kernel Messages (Internal)
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef GAF_MSG_INT_H_
#define GAF_MSG_INT_H_
/**
****************************************************************************************
* @addtogroup GAF Generic Audio Framework - Definition of Kernel Messages (Internal)
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf_msg.h" // GAF Definitions
#if (GAF_API_MSG)
/*
* DEFINES
****************************************************************************************
*/
/// Default module type
#define GAF_MSG_MODULE_DFLT (0x0F)
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Structure of callback for GAF module message handlers.
typedef struct gaf_msg_cbs
{
/**
* Message handler module initialization
*
* @param[in] init_type initialization type (@see enum rwip_init_type)
* @param[in] src_id Source task identifier
*/
void (*cb_init)(uint8_t init_type);
/**
* Handler of request message received from upper layer application
*
* @param[in] p_req Pointer to request parameters
* @param[in] src_id Source task identifier
*/
void (*cb_req_msg_handler)(gaf_req_t const* p_req, ke_task_id_t const src_id);
/**
* Handler of command message received from upper layer application
*
* @param[in] p_cmd Pointer to command parameters
* @param[in] src_id Source task identifier
*/
void (*cb_cmd_msg_handler)(gaf_cmd_t const* p_cmd, ke_task_id_t const src_id);
/**
* Handler of request message received from upper layer application
*
* @param[in] p_cfm Pointer to confirmation parameters
* @param[in] src_id Source task identifier
*/
void (*cb_cfm_msg_handler)(gaf_cfm_t const* p_cfm, ke_task_id_t const src_id);
} gaf_msg_cbs_t;
/**
****************************************************************************************
* Get message interface for module callback
*
* @return message callback structure for a given module
****************************************************************************************
*/
typedef const gaf_msg_cbs_t* (*gaf_msg_itf_t) (void);
/**
****************************************************************************************
* Get message interface for specific module in a layer
*
* @param[in] module Module identifier
*
* @return message callback structure for a given module
****************************************************************************************
*/
typedef const gaf_msg_cbs_t* (*gaf_msg_module_itf_t) (uint8_t module);
/*
* INTERNAL FUNCTIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Send a basic response message
*
* @param[in] req_code Request code
* @param[in] status Status
* @param[in] msg_id Message ID
* @param[in] dest_id Message destination ID
****************************************************************************************
*/
void gaf_msg_rsp_send(uint16_t req_code, uint16_t status, ke_msg_id_t msg_id, ke_task_id_t dest_id);
/**
****************************************************************************************
* @brief Send a basic command complete event message
*
* @param[in] cmd_code Code code
* @param[in] status Status
* @param[in] msg_id Message ID
* @param[in] dest_id Message destination ID
****************************************************************************************
*/
void gaf_msg_cmp_evt_send(uint16_t cmd_code, uint16_t status, ke_msg_id_t msg_id, ke_task_id_t dest_id);
#endif //(GAF_API_MSG)
/// @}
#endif // GAF_MSG_H_
@@ -0,0 +1,40 @@
/**
****************************************************************************************
*
* @file iap_cfg.h
*
* @brief Isochronous Access Profile Configuration
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef IAP_CFG_H_
#define IAP_CFG_H_
/**
****************************************************************************************
* @addtogroup IAP_CFG Isochronous Access Profile Configuration
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "gaf_cfg.h" // ISO Layers Configuration
/*
* DEFINES
****************************************************************************************
*/
/// Number of interface available for IAP
#define IAP_INTF_NB (CFG_IAP_INTF_NB)
/// @}
#endif // IAP_CFG_H_
+282
View File
@@ -0,0 +1,282 @@
/**
****************************************************************************************
*
* @file iap_int.h
*
* @brief Isochronous Access Profile - Internal Definitions
*
* Copyright (C) RivieraWaves 2019-2020
*
****************************************************************************************
*/
#ifndef IAP_INT_H_
#define IAP_INT_H_
/**
****************************************************************************************
* @addtogroup IAP Isochronous Access Profile - Internal Definitions
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "co_djob.h" // Delayed Jobs Management
#include "co_utils.h" // Common Utilities Definitions
#include <string.h> // Strings Management
#include "iap.h" // IAP Definitions
#include "iap_cfg.h" // IAP Configuration
/*
* DEFINES
****************************************************************************************
*/
/// Invalid connection handle
#define IAP_INVALID_CON_HDL (0xFFFF)
/*
* ENUMERATIONS
****************************************************************************************
*/
/// Role values
enum iap_roles
{
/// Master role
IAP_ROLE_MASTER = 0,
/// Slave role
IAP_ROLE_SLAVE,
IAP_ROLE_MAX,
};
/*
* CALLBACK FUNCTIONS DEFINITION
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Callback function called when a subprocedure has been completed
*
* @param[in] p_env Pointer to group information
* @param[in] stream_lid Stream local index
* @param[in] status Status
****************************************************************************************
*/
typedef void (*iap_proc_cb)(void* p_env, uint8_t stream_lid, uint16_t status);
/**
****************************************************************************************
* @brief Callback function called during disable procedure
*
* @param[in] p_env Pointer to stream information structure
****************************************************************************************
*/
typedef void (*iap_disable_cb)(void* p_env);
/*
* TYPE DEFINITIONS
****************************************************************************************
*/
/// Procedure structure for a group
typedef struct iap_proc
{
/// List header
co_list_hdr_t hdr;
/// Delayed job
co_djob_t djob;
/// Callback function for delayted end of procedure
iap_proc_cb cb;
/// Pointer to HCI message to be sent
void* p_msg;
/// Command code being processed
uint16_t cmd_code;
/// Opcode for expected command complete event or command status event
uint16_t opcode;
/// Procedure state bit field
uint8_t state_bf;
/// Group or stream local index for which an HCI command has been sent
uint8_t lid;
} iap_proc_t;
/// Test mode information structure for a stream
typedef struct iap_stream_tm
{
/// Status bit field (@see enum iap_tm_status_bf)
uint8_t status_bf;
} iap_stream_tm_t;
/// Data path information structure for a stream
typedef struct iap_stream_dp
{
/// Pointer to Data path configuration for each direction
iap_dp_config_t* p_config[IAP_DP_DIRECTION_MAX];
/// Direction status bit field
uint8_t dir_status_bf[IAP_DP_DIRECTION_MAX];
/// Status bit field
uint8_t status_bf;
} iap_stream_dp_t;
/// Common stream information structure
typedef struct iap_stream_info
{
/// List header
co_list_hdr_t hdr;
/// Data path information - Content set and managed by Data Path Manager
iap_stream_dp_t dp_info;
/// Test mode information - Content set and managed by Test Mode Manager
iap_stream_tm_t tm_info;
/// Callback function used for disable procedure
iap_disable_cb cb_disable;
/// Connection handle for the stream
uint16_t con_hdl;
/// Group local index
uint8_t group_lid;
/// Stream local index
uint8_t stream_lid;
/// State bit field
uint8_t state_bf;
/// CIS ID if stream is a unicast stream or position in the group if stream is a broadcast stream
uint8_t id_pos;
} iap_stream_info_t;
/// Unicast stream specific information structure
typedef struct iap_us_info
{
/// Connection local index for bound connection
uint8_t con_lid;
/// Stream state
uint8_t state_bf;
} iap_us_info_t;
/// Stream information structure for an unicast stream
typedef struct iap_us
{
/// Common stream information
iap_stream_info_t stream_info;
/// Unicast stream specific management information
iap_us_info_t info;
/// Unicast stream configuration
iap_us_config_t cfg;
union
{
/// Stream parameters provided (normal parameters)
iap_us_param_t params;
/// Stream parameters provided by upper layer (test parameters)
iap_us_test_param_t params_test;
} u;
} iap_us_t;
/// Stream information structure for a broadcast stream
typedef struct iap_bs
{
/// Common management information - Updated by stream manager only
iap_stream_info_t stream_info;
} iap_bs_t;
/// Common group information structure
typedef struct iap_group_info
{
/// List of Stream belonging to the group
co_list_t list_streams;
/// Procedure information
iap_proc_t proc;
/// Group configuration bit field
uint8_t group_cfg_bf;
/// Group local index
uint8_t group_lid;
/// Interface index
uint8_t intf_lid;
/// Group Identifier (BIG Handle or CIG ID)
uint8_t id;
/// Number of streams in the group
uint8_t nb_streams;
} iap_group_info_t;
/// Unicast group specific management information structure
typedef struct iap_ug_info
{
/// Number of streams ready to be configured
uint8_t nb_streams_add;
/// Number of bound streams
uint8_t nb_streams_bnd;
/// Number of enabled streams
uint8_t nb_streams_en;
/// Group state
uint8_t state_bf;
/// Pointer to first stream for remove procedure
iap_us_t* p_us_first;
/// Pointer to last stream for remove procedure
iap_us_t* p_us_last;
} iap_ug_info_t;
/// Group information structure for an unicast group
typedef struct iap_ug
{
/// Common management information - Updated by stream manager only
iap_group_info_t common_info;
/// Unicast group specific information
iap_ug_info_t info;
/// Unicast group configuration
iap_ug_config_t cfg;
union
{
/// Group parameters (normal parameters)
iap_ug_param_t params;
/// Group parameters (test parameters)
iap_ug_test_param_t params_test;
} u;
} iap_ug_t;
/// Broadcast group specific group information structure
typedef struct iap_bg_info
{
/// Command code
uint16_t cmd_code;
/// State bit field
uint8_t state_bf;
/// Pointer to Stream information for subprocedure
iap_stream_info_t* p_stream_info_subproc;
} iap_bg_info_t;
/// Group information structure for an broadcast group
typedef struct iap_bg
{
/// Common group information
iap_group_info_t common_info;
/// Specific group information
iap_bg_info_t info;
/// Group configuration
iap_bg_config_t cfg;
union
{
/// Group parameters (normal parameters)
iap_bg_param_t params;
/// Group parameters (test parameters)
iap_bg_test_param_t params_test;
} u;
} iap_bg_t;
/*
* INTERNAL FUNCTIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief TODO [LT]
****************************************************************************************
*/
void iap_tm_disable(iap_stream_info_t* p_stream_info, bool local);
/// @} IAP
#endif // IAP_INT_H_

Some files were not shown because too many files have changed in this diff Show More