357 lines
12 KiB
C
357 lines
12 KiB
C
#ifndef _GAF_API_H
|
|
#define _GAF_API_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "gap_api.h"
|
|
|
|
/// Length of Codec ID value
|
|
#define GAF_CODEC_ID_LEN (5)
|
|
|
|
#define GAF_KEY_LEN (16)
|
|
|
|
/// Event ID for callback
|
|
enum gaf_cb_event_id
|
|
{
|
|
GAF_BAP_CONFIGURED,
|
|
GAF_BAP_BC_SRC_GROUP_ADDED,
|
|
GAF_BAP_BC_SRC_GROUP_SET,
|
|
GAF_BAP_BC_SRC_SUBGROUP_SET,
|
|
GAF_BAP_BC_SRC_STREAM_SET,
|
|
GAF_BAP_BC_SRC_PA_ENABLED,
|
|
GAF_BAP_BC_SRC_ENABLED,
|
|
GAF_BAP_BC_SRC_STREAM_STARTED,
|
|
GAF_BAP_BC_SCAN_STARTED,
|
|
GAF_BAP_BC_SCAN_STOPPED,
|
|
GAF_BAP_BC_SCAN_PA_SYNC_STARTED,
|
|
GAF_BAP_BC_SCAN_PARAM_SET,
|
|
GAF_BAP_BC_SCAN_TIMEOUT,
|
|
GAF_BAP_BC_SCAN_REPORT,
|
|
GAF_BAP_BC_SCAN_PA_ESTABLISHED,
|
|
GAF_BAP_BC_SCAN_PA_TERMINATED,
|
|
GAF_BAP_BC_SCAN_PA_REPORT,
|
|
GAF_BAP_BC_SCAN_BIG_INFO_REPORT,
|
|
GAF_BAP_BC_SCAN_GROUP_REPORT,
|
|
GAF_BAP_BC_SCAN_SUBGROUP_REPORT,
|
|
GAF_BAP_BC_SCAN_STREAM_REPORT,
|
|
GAF_BAP_BC_SINK_ENABLED,
|
|
GAF_BAP_BC_SINK_STREAM_STARTED,
|
|
GAF_BAP_BC_SINK_ISO_DATA,
|
|
GAF_UNHANDLED_MSG,
|
|
};
|
|
|
|
/// 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,
|
|
};
|
|
|
|
/// Codec Identifier
|
|
typedef struct gaf_codec_id
|
|
{
|
|
/// Codec ID value
|
|
uint8_t codec_id[GAF_CODEC_ID_LEN];
|
|
} gaf_codec_id_t;
|
|
|
|
/// Broadcast code used for stream encryption
|
|
typedef struct gaf_bcast_code_t
|
|
{
|
|
/// Broadcast Code value
|
|
uint8_t bcast_code[GAF_KEY_LEN];
|
|
} gaf_bcast_code_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;
|
|
|
|
/// 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;
|
|
|
|
/// BIG Info Report
|
|
typedef struct gaf_big_info
|
|
{
|
|
/// Value of the SDU interval in microseconds (Range 0x0000FF-0x0FFFFF)
|
|
uint32_t sdu_interval;
|
|
/// Value of the ISO Interval (1.25 ms unit)
|
|
uint16_t iso_interval;
|
|
/// Value of the maximum PDU size (Range 0x0000-0x00FB)
|
|
uint16_t max_pdu;
|
|
/// VValue of the maximum SDU size (Range 0x0000-0x0FFF)
|
|
uint16_t max_sdu;
|
|
/// Number of BIS present in the group (Range 0x01-0x1F)
|
|
uint8_t num_bis;
|
|
/// Number of sub-events (Range 0x01-0x1F)
|
|
uint8_t nse;
|
|
/// Burst number (Range 0x01-0x07)
|
|
uint8_t bn;
|
|
/// Pre-transmit offset (Range 0x00-0x0F)
|
|
uint8_t pto;
|
|
/// Initial retransmission count (Range 0x01-0x0F)
|
|
uint8_t irc;
|
|
/// PHY used for transmission (0x01: 1M, 0x02: 2M, 0x03: Coded, All other values: RFU)
|
|
uint8_t phy;
|
|
/// Framing mode (0x00: Unframed, 0x01: Framed, All other values: RFU)
|
|
uint8_t framing;
|
|
/// True if broadcast isochronous group is encrypted, False otherwise
|
|
bool encrypted;
|
|
} gaf_big_info_t;
|
|
|
|
typedef struct gaf_iso_data {
|
|
uint16_t sdu_seq;
|
|
uint16_t length;
|
|
uint8_t *buffer;
|
|
bool ts_exist;
|
|
uint32_t ts;
|
|
} gaf_iso_data_t;
|
|
|
|
typedef union _gaf_callback_param {
|
|
uint16_t status;
|
|
struct {
|
|
struct gap_ble_addr addr;
|
|
uint8_t adv_sid;
|
|
uint8_t length;
|
|
uint8_t *data;
|
|
} scan_report;
|
|
struct {
|
|
uint8_t pa_lid;
|
|
struct gap_ble_addr addr;
|
|
uint8_t adv_sid;
|
|
} scan_pa_establised;
|
|
struct {
|
|
uint8_t pa_lid;
|
|
uint8_t reason;
|
|
} scan_pa_terminated;
|
|
struct {
|
|
uint8_t pa_lid;
|
|
uint8_t length;
|
|
uint8_t *data;
|
|
} scan_pa_report;
|
|
struct {
|
|
uint8_t pa_lid;
|
|
struct gaf_big_info *big_info;
|
|
} scan_big_info_report;
|
|
struct {
|
|
uint8_t pa_lid;
|
|
uint8_t nb_subgroup;
|
|
uint8_t nb_stream;
|
|
uint32_t pres_delay_us;
|
|
} scan_group_report;
|
|
struct {
|
|
uint8_t pa_lid;
|
|
uint8_t subgroup_lid;
|
|
gaf_codec_id_t *codec_id;
|
|
uint32_t stream_pos_bf;
|
|
uint8_t cfg_len;
|
|
uint8_t metadata_len;
|
|
uint8_t *cfg;
|
|
uint8_t *metadata;
|
|
} scan_subgroup_report;
|
|
struct {
|
|
uint8_t pa_lid;
|
|
uint32_t stream_pos;
|
|
uint8_t cfg_len;
|
|
uint8_t *cfg;
|
|
} scan_stream_report;
|
|
struct {
|
|
uint8_t stream_lid;
|
|
bool ts_exist;
|
|
uint32_t ts;
|
|
uint16_t sdu_seq;
|
|
uint16_t length;
|
|
uint8_t *buffer;
|
|
} sink_iso_data;
|
|
struct {
|
|
uint16_t msg_type;
|
|
uint16_t cmd_code;
|
|
uint16_t status;
|
|
} unhandled_msg;
|
|
} gaf_callback_param_t;
|
|
|
|
typedef void (*gaf_callback_t)(uint8_t event, gaf_callback_param_t *param);
|
|
|
|
void gaf_cfg(gaf_callback_t cb);
|
|
|
|
void gaf_bap_capa_record_add(uint8_t pac_id, uint8_t record_id, gaf_codec_id_t *codec_id, uint16_t cap_len, uint8_t *cap);
|
|
|
|
void gaf_bap_capa_record_remove(uint8_t record_id);
|
|
|
|
void gaf_bap_uc_srv_codec_configure(uint8_t con_lid, uint8_t ase_lid, uint8_t ase_instance_idx, uint8_t direction, uint8_t dp_id,
|
|
gaf_codec_id_t *codec_id, bap_qos_req_t *qos_req, uint32_t ctl_delay_us,
|
|
uint16_t cfg_len, uint8_t *cfg);
|
|
|
|
void gaf_bap_uc_srv_codec_configure_cfm(uint16_t status, uint8_t rsp_code, uint8_t reason, uint8_t ase_lid, uint8_t dp_id,
|
|
gaf_codec_id_t *codec_id, bap_qos_req_t *qos_req, uint32_t ctl_delay_us,
|
|
uint16_t cfg_len, uint8_t *cfg);
|
|
|
|
void gaf_bap_bc_src_group_add(uint8_t nb_stream, uint8_t nb_subgroups,
|
|
bap_bc_grp_param_t *grp_param,
|
|
bap_bc_adv_param_t *adv_param,
|
|
bap_bc_per_adv_param_t *per_adv_param);
|
|
|
|
void gaf_bap_bc_src_group_set(uint8_t grp_lid, uint32_t pres_delay_us, gaf_codec_id_t *codec_id,
|
|
uint8_t cfg_len, uint8_t metadata_len, uint8_t *val);
|
|
|
|
void gaf_bap_bc_src_subgroup_set(uint8_t grp_lid, uint8_t sgrp_lid,
|
|
uint8_t metadata_len, uint8_t *metadata);
|
|
|
|
void gaf_bap_bc_src_stream_set(uint8_t grp_lid, uint8_t sgrp_lid, uint8_t stream_lid, uint32_t ctl_delay_us, uint8_t dp_id,
|
|
uint8_t cfg_len, uint8_t *cfg);
|
|
|
|
void gaf_bap_bc_src_pa_enable(uint8_t grp_lid, uint8_t adv_data_len, uint8_t per_adv_data_len, uint8_t *data);
|
|
|
|
void gaf_bap_bc_src_enable(uint8_t grp_lid, uint8_t encrypted, gaf_bcast_code_t *bcast_code);
|
|
|
|
void gaf_bap_bc_src_stream_start(uint8_t grp_lid, uint32_t stream_lid_bf);
|
|
|
|
void gaf_bap_bc_src_send_data(uint8_t grp_lid, uint8_t stream_lid, gaf_iso_data_t *data);
|
|
|
|
void gaf_bap_bc_scan_set_param(uint16_t intv_1m_slot, uint16_t intv_coded_slot,
|
|
uint16_t wd_1m_slot, uint16_t wd_coded_slot);
|
|
|
|
void gaf_bap_bc_scan_start(uint16_t timeout_s);
|
|
|
|
void gaf_bap_bc_scan_stop(void);
|
|
|
|
void gaf_bap_bc_scan_pa_sync(struct gap_ble_addr *addr, uint8_t adv_sid, uint16_t skip, uint8_t report_filter_bf, uint16_t sync_to, uint16_t timeout_s);
|
|
|
|
void gaf_bap_bc_sink_enable(uint8_t pa_lid, uint8_t mse, uint32_t stream_pos_bf,
|
|
uint16_t timeout_s,
|
|
uint8_t encrypted,
|
|
gaf_bcast_code_t *bcast_code);
|
|
|
|
void gaf_bap_bc_sink_stream_start(uint8_t grp_lid, uint8_t stream_pos, uint32_t ctl_delay_us,
|
|
gaf_codec_id_t *codec_id,
|
|
uint8_t dp_id, uint8_t cfg_len,
|
|
uint8_t *cfg);
|
|
|
|
#endif // _GAF_API_H
|
|
|