網頁

2019年1月18日 星期五

DIY - ESP32:ESP32 藍牙(Bluetooth)A2DP API 函數結構件及其它(七十四)

DIY - ESP32:ESP32 藍牙(Bluetooth)A2DP API 函數結構件及其它(七十四):

除了 ESP32 藍牙(Bluetooth)的 A2DP(Main API)的 API 函數模塊外,還有泛型型別定義(Type Definitions)和枚舉(Enumerations)。

1. Structure
1.1. struct esp_a2d_mcc_t
A2DP media codec capabilities union.
Public Members
Description
esp_a2d_mct_t type
A2DP media codec type
union esp_a2d_mcc_t::@1 esp_a2d_mcc_t::cie
A2DP codec information element

2. Macros
ESP_A2D_MCT_SBC
Media codec types supported by A2DP.
Macros
Description
ESP_A2D_MCT_M12
MPEG-1, 2 Audio
ESP_A2D_MCT_M24
MPEG-2, 4 AAC
ESP_A2D_MCT_ATRAC
ATRAC family
ESP_A2D_MCT_NON_A2DP
ESP_A2D_CIE_LEN_SBC
ESP_A2D_CIE_LEN_M12
ESP_A2D_CIE_LEN_M24
ESP_A2D_CIE_LEN_ATRAC

3. Type Definitions
Type Definitions
Description
typedef uint8_t esp_a2d_mct_t
typedef void (*esp_a2d_cb_t)(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *para
A2DP profile callback function type.

Parameters
event: : Event type
param: : Pointer to callback parameter
typedef void (*esp_a2d_sink_data_cb_t)(const uint8_t *buf, uint32_t len)
A2DP profile data callback function.

Parameters
buf: : data received from A2DP source device and is PCM format decoder from SBC decoder; buf references to a static memory block and can be overwritten by upcoming data
len: : size(in bytes) in buf
typedef int32_t (*esp_a2d_source_data_cb_t)(uint8_t *buf, int32_t len)
A2DP source data read callback function.

Return
size of bytes read successfully, if the argument len is -1, this value is ignored.

Parameters
buf: : buffer to be filled with PCM data stream from higher layer
len: : size(in bytes) of data block to be copied to buf. -1 is an indication to user that data buffer shall be flushed

4. Enumerations
4.1. enum esp_a2d_connection_state_t
Bluetooth A2DP connection states.
Enumeration
Description
ESP_A2D_CONNECTION_STATE_DISCONNECTED = 0
connection released
ESP_A2D_CONNECTION_STATE_CONNECTING
connecting remote device
ESP_A2D_CONNECTION_STATE_CONNECTED
connection established
ESP_A2D_CONNECTION_STATE_DISCONNECTING
disconnecting remote device

4.2. enum esp_a2d_disc_rsn_t
Bluetooth A2DP disconnection reason.
Enumeration
Description
ESP_A2D_DISC_RSN_NORMAL = 0
Finished disconnection that is initiated by local or remote device
ESP_A2D_DISC_RSN_ABNORMAL
Abnormal disconnection caused by signal loss

4.3. enum esp_a2d_audio_state_t
Bluetooth A2DP datapath states.
Enumeration
Description
ESP_A2D_AUDIO_STATE_REMOTE_SUSPEND = 0
audio stream datapath suspended by remote device
ESP_A2D_AUDIO_STATE_STOPPED
audio stream datapath stopped
ESP_A2D_AUDIO_STATE_STARTED
audio stream datapath started

4.4. enum esp_a2d_media_ctrl_ack_t
A2DP media control command acknowledgement code.
Enumeration
Description
ESP_A2D_MEDIA_CTRL_ACK_SUCCESS = 0
media control command is acknowledged with success
ESP_A2D_MEDIA_CTRL_ACK_FAILURE
media control command is acknowledged with failure
ESP_A2D_MEDIA_CTRL_ACK_BUSY
media control command is rejected, as previous command is not yet acknowledged

4.5. enum esp_a2d_media_ctrl_t
A2DP media control commands.
Enumeration
Description
ESP_A2D_MEDIA_CTRL_NONE = 0
dummy command
ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY
check whether AVDTP is connected, only used in A2DP source
ESP_A2D_MEDIA_CTRL_START
command to set up media transmission channel
ESP_A2D_MEDIA_CTRL_STOP
command to stop media transmission
ESP_A2D_MEDIA_CTRL_SUSPEND
command to suspend media transmission

4.6. enum esp_a2d_cb_event_t
A2DP callback events.
Enumeration
Description
ESP_A2D_CONNECTION_STATE_EVT = 0
connection state changed event
ESP_A2D_AUDIO_STATE_EVT
audio stream transmission state changed event
ESP_A2D_AUDIO_CFG_EVT
audio codec is configured, only used for A2DP SINK
ESP_A2D_MEDIA_CTRL_ACK_EVT
acknowledge event in response to media control commands

5. Unions
union esp_a2d_cb_param_t.
#include
A2DP state callback parameters.
Unions
Description
struct esp_a2d_cb_param_t::a2d_conn_stat_param conn_stat
A2DP connection status
struct esp_a2d_cb_param_t::a2d_audio_stat_param audio_stat
audio stream playing state
struct esp_a2d_cb_param_t::a2d_audio_cfg_param audio_cfg
media codec configuration information
struct esp_a2d_cb_param_t::media_ctrl_stat_param media_ctrl_stat
status in acknowledgement to media control commands
struct a2d_audio_cfg_param
#include
ESP_A2D_AUDIO_CFG_EVT.

Public Members
esp_bd_addr_t remote_bda - remote bluetooth device address
esp_a2d_mcc_t mcc - A2DP media codec capability information
struct a2d_audio_stat_param
#include
ESP_A2D_AUDIO_STATE_EVT.

Public Members
esp_a2d_audio_state_t state - one of the values from esp_a2d_audio_state_t
esp_bd_addr_t remote_bda - remote bluetooth device address
struct a2d_conn_stat_param
#include
ESP_A2D_CONNECTION_STATE_EVT

Public Members
esp_a2d_connection_state_t state - one of values from esp_a2d_connection_state_t
esp_bd_addr_t remote_bda - remote bluetooth device address
esp_a2d_disc_rsn_t disc_rsn - reason of disconnection for “DISCONNECTED”
struct media_ctrl_stat_param
#include
ESP_A2D_MEDIA_CTRL_ACK_EVT.
Public Members
esp_a2d_media_ctrl_t cmd - media control commands to acknowledge
esp_a2d_media_ctrl_ack_t status -   acknowledgement to media control commands

Header File: bt/bluedroid/api/include/api/esp_a2dp_api.h
參考網址:https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/bluetooth/esp_a2dp.html

2019年 1月 18日 天氣報告
氣溫:18.2@ 19:30
相對濕度:百分之 80%
天氣:多雲

沒有留言:

張貼留言