Arduino A2DP

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
BluetoothA2DPSink Class Reference
ESP32 A2DP

A2DP Bluethooth Sink - We initialize and start the Bluetooth A2DP Sink. The example https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/bluedroid/classic_bt/a2dp_sink was refactered into a C++ class. More...

`#include <BluetoothA2DPSink.h>`

Inheritance diagram for BluetoothA2DPSink:

## Public Member Functions
| BluetoothA2DPSink ()
| Default Constructor: output via callback or Legacy I2S.
| BluetoothA2DPSink (audio_tools::AudioOutput &output)
| Output AudioOutput using AudioTools library.
| BluetoothA2DPSink (audio_tools::AudioStream &output)
| Output AudioStream using AudioTools library.
| BluetoothA2DPSink (BluetoothA2DPOutput &out)
| Define output scenario class.
| BluetoothA2DPSink (Print &output)
| Output to Arduino Print.
virtual | ~BluetoothA2DPSink ()
| Destructor - stops the playback and releases all resources.
virtual void | activate_pin_code (bool active)
| We need to confirm a new seesion by calling confirm_pin_code()
virtual uint16_t | channels ()
| Provides the actually set number of channels (1=mono,2=stereo)
virtual void | clean_last_connection ()
| clean last connection (delete)
virtual void | confirm_pin_code ()
| confirms the connection request by returning the receivedn pin code
virtual void | confirm_pin_code (int code)
| confirms the connection request by returning the indicated pin code
virtual bool | connect_to (esp_bd_addr_t peer)
| Connnects to the indicated address.
virtual void | debounce (void(*cb)(void), int ms)
void | delay_ms (uint32_t millis)
| calls vTaskDelay to pause for the indicated number of milliseconds
virtual void | disconnect ()
| Closes the connection.
virtual void | end (bool release_memory=false)
virtual void | fast_forward ()
| AVRC fast_forward.
virtual esp_a2d_audio_state_t | get_audio_state ()
| Determine the actual audio state.
virtual esp_a2d_mct_t | get_audio_type ()
| Determine the actual audio type.
virtual esp_a2d_connection_state_t | get_connection_state ()
| Determine the connection state.
virtual esp_bd_addr_t * | get_current_peer_address ()
| Provides the address of the connected device.
virtual esp_bd_addr_t * | get_last_peer_address ()
| Provides the address of the last device.
esp_bt_gap_cb_param_t::read_rssi_delta_param | get_last_rssi ()
| provides the last rssi parameters
unsigned long | get_millis ()
| Provides the time in milliseconds since the last system boot.
virtual const char * | get_name ()
| Provides the actual SSID name.
BluetoothA2DPOutput * | get_output ()
| Provides access to the output class.
virtual const char * | get_peer_name ()
| Get the name of the connected source device.
virtual int | get_volume ()
| Determines the volume.
virtual bool | is_avrc_connected ()
| returns true if the avrc service is connected
bool | is_avrc_peer_rn_cap (esp_avrc_rn_event_ids_t cmd)
bool | is_avrc_peer_rn_cap_available ()
| Returns true if the is_avrc_peer_rn_cap() method can be called.
virtual bool | is_connected ()
| Checks if A2DP is connected.
bool | is_output_active ()
| Checks if output is active.
void | log_free_heap ()
| Logs the free heap.
virtual void | next ()
| AVRC next.
virtual void | pause ()
| AVRC pause.
virtual int | pin_code ()
| provides the requested pin code (0 = undefined)
virtual void | play ()
| Starts to play music using AVRC.
virtual void | previous ()
| AVRC previous.
virtual bool | reconnect ()
| Reconnects to the last device.
virtual void | rewind ()
| AVRC rewind.
virtual uint16_t | sample_rate ()
| Provides the actually set data rate (in samples per second)
virtual void | set_address_validator (bool(*callBack)(esp_bd_addr_t remote_bda))
| Allows you to reject unauthorized addresses.
void | set_auto_reconnect (bool active)
virtual void | set_auto_reconnect (bool reconnect, int count=AUTOCONNECT_TRY_NUM)
virtual void | set_avrc_connection_state_callback (void(*callback)(bool))
| Define a callback method which provides connection state of AVRC service.
virtual void | set_avrc_metadata_attribute_mask (int flags)
virtual void | set_avrc_metadata_callback (void(*callback)(uint8_t, const uint8_t *))
| Define a callback method which provides the meta data.
virtual void | set_avrc_rn_events (std::vector< esp_avrc_rn_event_ids_t > events)
virtual void | set_avrc_rn_play_pos_callback (void(*callback)(uint32_t play_pos), uint32_t notif_interval=10)
virtual void | set_avrc_rn_playstatus_callback (void(*callback)(esp_avrc_playback_stat_t playback))
virtual void | set_avrc_rn_track_change_callback (void(*callback)(uint8_t *id))
virtual void | set_avrc_rn_volumechange (void(*callBack)(int))
| Set the callback that is called when remote changes the volume.
virtual void | set_avrc_rn_volumechange_completed (void(*callBack)(int))
void | set_bluedroid_config_t (esp_bluedroid_config_t cfg)
| Defines the esp_bluedroid_config_t: Available from IDF 5.2.1.
bool | set_codec (A2DPCodec codec, void(*encoded_cb)(const uint8_t *data, size_t len)=nullptr)
virtual void | set_connectable (bool connectable)
| Bluetooth connectable.
virtual void | set_connected (bool active)
| Calls disconnect or reconnect.
virtual void | set_default_bt_mode (esp_bt_mode_t mode)
virtual void | set_discoverability (esp_bt_discovery_mode_t d)
| Bluetooth discoverability.
void | set_event_queue_size (int size)
| Defines the queue size of the event task.
void | set_event_stack_size (int size)
| Defines the stack size of the event task (in bytes)
void | set_max_write_delay_ms (int delay)
| defines a small delay after each write: default is 0 ms
void | set_max_write_size (int size)
| defines the max write size: default is A2DP_I2S_MAX_WRITE_SIZE
virtual void | set_mono_downmix (bool enabled)
| mix stereo into single mono signal
virtual void | set_on_audio_state_changed (void(*callBack)(esp_a2d_audio_state_t state, void *), void *obj=nullptr)
| Set the callback that is called when the audio state is changed.
virtual void | set_on_audio_state_changed_post (void(*callBack)(esp_a2d_audio_state_t state, void *), void *obj=nullptr)
virtual void | set_on_connection_state_changed (void(*callBack)(esp_a2d_connection_state_t state, void *), void *obj=nullptr)
| Set the callback that is called when the connection state is changed.
virtual void | set_on_data_received (void(*callBack)())
| Define callback which is called when we receive data.
virtual void | set_on_volumechange (void(*callBack)(int))
void | set_output (audio_tools::AudioOutput &output)
| Output AudioOutput using AudioTools library.
void | set_output (audio_tools::AudioStream &output)
| Output AudioStream using AudioTools library.
void | set_output (BluetoothA2DPOutput &output)
| Defines the output class: by default we use BluetoothA2DPOutputDefault.
void | set_output (Print &output)
| Output to Arduino Print.
void | set_output_active (bool flag)
| Activate/Deactivate output e.g. to I2S.
void | set_peer_name_callback (void(*callback)(char *peer_name))
| Defines the callback that is called when we get the peer name.
virtual void | set_raw_stream_reader (void(*callBack)(const uint8_t *, uint32_t))
void | set_reconnect_delay (int delay)
void | set_rssi_active (bool active)
| Activates the rssi reporting.
void | set_rssi_callback (void(*callback)(esp_bt_gap_cb_param_t::read_rssi_delta_param &rssi))
| Defines the callback that is called when we get an new rssi value.
virtual void | set_sample_rate_callback (void(*callback)(uint16_t rate))
| Defines the method which will be called with the sample rate is updated.
void | set_spp_active (bool flag)
| Activates SSP (Serial protocol)
void | set_spp_config (esp_spp_cfg_t cfg)
| Set SPP configuration (only before start)
virtual void | set_stream_reader (void(*callBack)(const uint8_t *, uint32_t), bool i2s_output=true)
virtual void | set_swap_lr_channels (bool swap)
| swaps the left and right channel
void | set_task_core (BaseType_t core)
void | set_task_priority (UBaseType_t priority)
| defines the task priority (the default value is configMAX_PRIORITIES - 10)
virtual void | set_volume (uint8_t volume)
| Changes the volume.
virtual void | set_volume_control (A2DPVolumeControl *ptr)
| you can define a custom VolumeControl implementation
virtual void | start (const char *name)
| starts the I2S bluetooth sink with the inidicated name
virtual void | start (const char *name, bool auto_reconect)
| starts the I2S bluetooth sink with the inidicated name
virtual void | stop ()
| AVRC stop.
const char * | to_str (esp_a2d_audio_state_t state)
| converts a esp_a2d_audio_state_t to a string
const char * | to_str (esp_a2d_connection_state_t state)
| converts esp_a2d_connection_state_t to a string
const char * | to_str (esp_avrc_playback_stat_t state)
| converts esp_avrc_playback_stat_t to a string
const char * | to_str (esp_bd_addr_t bda)
| converts a esp_bd_addr_t to a string - the string is 18 characters long!
const char * | to_str (esp_bt_gap_discovery_state_t state)
| converts esp_bt_gap_discovery_state_t to a string
bool | update_rssi ()
| Requests an update of the rssi delta value.
virtual void | volume_down ()
| AVRC decrease the volume.
virtual void | volume_up ()
| AVRC increase the volume.

## Protected Member Functions
void | app_a2d_callback (esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param) override
| callback function for A2DP source
virtual void | app_alloc_meta_buffer (esp_avrc_ct_cb_param_t *param)
void | app_gap_callback (esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param) override
void | app_rc_ct_callback (esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *param) override
| callback function for AVRCP controller
virtual void | app_rc_tg_callback (esp_avrc_tg_cb_event_t event, esp_avrc_tg_cb_param_t *param) override
virtual bool | app_send_msg (bt_app_msg_t *msg)
virtual void | app_task_handler (void *arg)
virtual void | app_task_shut_down ()
virtual void | app_task_start_up ()
virtual bool | app_work_dispatch (app_callback_t p_cback, uint16_t event, void *p_params, int param_len)
virtual void | app_work_dispatched (bt_app_msg_t *msg)
virtual void | audio_data_callback (const uint8_t *data, uint32_t len)
virtual void | av_hdl_a2d_evt (uint16_t event, void *p_param)
virtual void | av_hdl_avrc_evt (uint16_t event, void *p_param)
virtual void | av_hdl_avrc_tg_evt (uint16_t event, void *p_param) override
void | av_hdl_stack_evt (uint16_t event, void *p_param) override
virtual void | av_new_track ()
virtual void | av_notify_evt_handler (uint8_t event_id, esp_avrc_rn_param_t *event_parameter)
virtual void | av_play_pos_changed ()
virtual void | av_playback_changed ()
virtual esp_err_t | bluedroid_init ()
virtual void | bt_i2s_task_shut_down (void)
virtual void | bt_i2s_task_start_up (void)
virtual bool | bt_start ()
| Startup logic as implemented by Arduino.
esp_err_t | esp_a2d_connect (esp_bd_addr_t peer) override
esp_err_t | esp_a2d_disconnect (esp_bd_addr_t remote_bda) override
virtual void | execute_avrc_command (int cmd)
virtual const char * | get_connected_source_name ()
| Get the name of the connected source device (obsolete): use get_peer_name()
virtual void | get_last_connection ()
virtual void | handle_audio_cfg (uint16_t event, void *p_param)
virtual void | handle_audio_state (uint16_t event, void *p_param)
virtual void | handle_avrc_connection_state (bool connected)
virtual void | handle_connection_state (uint16_t event, void *p_param)
virtual bool | has_last_connection ()
virtual void | i2s_task_handler (void *arg)
| dummy functions needed for BluetoothA2DPSinkQueued
size_t | i2s_write_data (const uint8_t *data, size_t item_size)
| writes the data to i2s
virtual int | init_bluetooth ()
virtual void | init_i2s ()
virtual void | init_nvs ()
virtual bool | is_reconnect (esp_a2d_disc_rsn_t type)
virtual bool | isSource ()
virtual const char * | last_bda_nvs_name ()
virtual bool | read_address (const char *name, esp_bd_addr_t &bda)
virtual void | set_i2s_active (bool active)
virtual void | set_last_connection (esp_bd_addr_t bda)
virtual void | set_scan_mode_connectable (bool connectable)
| Defines if the bluetooth is connectable.
void | set_scan_mode_connectable_default () override
virtual A2DPVolumeControl * | volume_control ()
| provides access to the VolumeControl object
virtual void | volume_set_by_controller (uint8_t volume)
virtual void | volume_set_by_local_host (uint8_t volume)
virtual bool | write_address (const char *name, esp_bd_addr_t bda)
virtual size_t | write_audio (const uint8_t *data, size_t size)
| output audio data e.g. to i2s or to queue

## Protected Attributes
bool(* | address_validator )(esp_bd_addr_t remote_bda) = nullptr
TaskHandle_t | app_task_handle = nullptr
QueueHandle_t | app_task_queue = nullptr
esp_a2d_audio_state_t | audio_state = ESP_A2D_AUDIO_STATE_STOPPED
void(* | audio_state_callback )(esp_a2d_audio_state_t state, void *obj) = nullptr
void(* | audio_state_callback_post )(esp_a2d_audio_state_t state, void *obj) = nullptr
void * | audio_state_obj = nullptr
void * | audio_state_obj_post = nullptr
esp_a2d_mct_t | audio_type
bool | avrc_connection_state = false
void(* | avrc_connection_state_callback )(bool connected) = nullptr
void(* | avrc_metadata_callback )(uint8_t, const uint8_t *) = nullptr
int | avrc_metadata_flags
std::vector< esp_avrc_rn_event_ids_t > | avrc_rn_events
void(* | avrc_rn_play_pos_callback )(uint32_t) = nullptr
void(* | avrc_rn_playstatus_callback )(esp_avrc_playback_stat_t) = nullptr
void(* | avrc_rn_track_change_callback )(uint8_t *) = nullptr
void(* | avrc_rn_volchg_complete_callback )(int) = nullptr
esp_bluedroid_config_t | bluedroid_config {.ssp_en = true}
void(* | bt_connected )() = nullptr
void(* | bt_dis_connected )() = nullptr
esp_bt_mode_t | bt_mode = ESP_BT_MODE_CLASSIC_BT
const char * | bt_name = {0}
void(* | bt_volumechange )(int) = nullptr
bool | codec_sep_registered = false
int | connection_rety_count = 0
esp_a2d_connection_state_t | connection_state
void(* | connection_state_callback )(esp_a2d_connection_state_t state, void *obj) = nullptr
void * | connection_state_obj = nullptr
void(* | data_received )() = nullptr
uint32_t | debounce_ms = 0
unsigned int | default_reconnect_timout = 10000
A2DPDefaultVolumeControl | default_volume_control
A2DPCodec | desired_codec = A2DP_CODEC_SBC
esp_bt_discovery_mode_t | discoverability = ESP_BT_GENERAL_DISCOVERABLE
void(* | encoded_stream_reader )(const uint8_t *, size_t) = nullptr
int | event_queue_size = 20
int | event_stack_size = 3072
bool | is_autoreconnect_allowed = false
bool | is_bluedroid_initialized = false
volatile bool | is_i2s_active = false
bool | is_output = true
bool | is_pin_code_active = false
bool | is_start_disabled = false
bool | is_target_status_active = true
bool | is_volume_used = false
esp_bd_addr_t | last_connection = {0, 0, 0, 0, 0, 0}
esp_bt_gap_cb_param_t::read_rssi_delta_param | last_rssi_delta
const char * | m_a2d_audio_state_str [4] = {"Suspended", "Started", "Suspended", "Suspended"}
const char * | m_a2d_conn_state_str [4]
const char * | m_avrc_playback_state_str [5]
uint8_t | m_channels = 2
const char * | m_esp_bt_gap_discovery_state_t [2] = {"Stopped", "Started"}
uint32_t | m_pkt_cnt = 0
uint16_t | m_sample_rate = 44100
int | max_write_delay_ms = A2DP_I2S_MAX_WRITE_DELAY_MS
int | max_write_size = A2DP_I2S_MAX_WRITE_SIZE
uint32_t | notif_interval_s = 10
BluetoothA2DPOutput * | out = &out_default
BluetoothA2DPOutputDefault | out_default
esp_bd_addr_t | peer_bd_addr
void(* | peer_name_callback )(char *peer_name)
int | pin_code_int = 0
PinCodeRequest | pin_code_request = Undefined
char | pin_code_str [20] = {0}
void(* | raw_stream_reader )(const uint8_t *, uint32_t) = nullptr
int | reconnect_delay = 1000
ReconnectStatus | reconnect_status = NoReconnect
unsigned long | reconnect_timout = 0
char | remote_name [ESP_BT_GAP_MAX_BDNAME_LEN+1]
bool | rssi_active = false
void(* | rssi_callback )(esp_bt_gap_cb_param_t::read_rssi_delta_param &rssi)
esp_avrc_rn_evt_cap_mask_t | s_avrc_peer_rn_cap = {0}
uint8_t | s_volume = 0
_lock_t | s_volume_lock
bool | s_volume_notify
void(* | sample_rate_callback )(uint16_t rate) = nullptr
bool | spp_active = false
esp_spp_cfg_t | spp_cfg = BT_SPP_DEFAULT_CONFIG()
void(* | stream_reader )(const uint8_t *, uint32_t) = nullptr
bool | swap_left_right = false
BaseType_t | task_core = 1
UBaseType_t | task_priority = configMAX_PRIORITIES - 10
int | try_reconnect_max_count = AUTOCONNECT_TRY_NUM
A2DPVolumeControl * | volume_control_ptr = nullptr
uint8_t | volume_value = 0

## Friends
void | ccall_audio_data_callback (const uint8_t *data, uint32_t len)
| Callback for music stream.
void | ccall_audio_encoded_callback (esp_a2d_conn_hdl_t conn_hdl, esp_a2d_audio_buff_t *audio_buf)
void | ccall_av_hdl_a2d_evt (uint16_t event, void *p_param)
| a2dp event handler
void | ccall_av_hdl_avrc_evt (uint16_t event, void *p_param)
| avrc event handler
void | ccall_i2s_task_handler (void *arg)
| task hander for i2s

## Detailed Description

A2DP Bluethooth Sink - We initialize and start the Bluetooth A2DP Sink. The example https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/bluedroid/classic_bt/a2dp_sink was refactered into a C++ class.

Author
  Phil Schatzmann

Copyright
  Apache License Version 2

## Constructor & Destructor Documentation

## ◆ BluetoothA2DPSink()

BluetoothA2DPSink::BluetoothA2DPSink | ( |  | ) |

Default Constructor: output via callback or Legacy I2S.

Constructor

## Member Function Documentation

## ◆ app_a2d_callback()

void BluetoothA2DPSink::app_a2d_callback | ( | esp_a2d_cb_event_t | event,
|  | esp_a2d_cb_param_t * | param
| ) |  |
| override protected virtual

callback function for A2DP source

Implements BluetoothA2DPCommon.

## ◆ app_gap_callback()

void BluetoothA2DPSink::app_gap_callback | ( | esp_bt_gap_cb_event_t | event,
|  | esp_bt_gap_cb_param_t * | param
| ) |  |
| override protected virtual

Implements BluetoothA2DPCommon.

## ◆ app_rc_ct_callback()

void BluetoothA2DPSink::app_rc_ct_callback | ( | esp_avrc_ct_cb_event_t | event,
|  | esp_avrc_ct_cb_param_t * | param
| ) |  |
| override protected virtual

callback function for AVRCP controller

Implements BluetoothA2DPCommon.

## ◆ app_rc_tg_callback()

void BluetoothA2DPSink::app_rc_tg_callback | ( | esp_avrc_tg_cb_event_t | event,
|  | esp_avrc_tg_cb_param_t * | param
| ) |  |
| override protected virtual

Implements BluetoothA2DPCommon.

## ◆ audio_data_callback()

void BluetoothA2DPSink::audio_data_callback | ( | const uint8_t * | data,
|  | uint32_t | len
| ) |  |
| protected virtual

Wrappbed methods called from callbacks

## ◆ av_hdl_avrc_tg_evt()

void BluetoothA2DPSink::av_hdl_avrc_tg_evt | ( | uint16_t | event,
|  | void * | p_param
| ) |  |
| override protected virtual

Implements BluetoothA2DPCommon.

## ◆ av_hdl_stack_evt()

void BluetoothA2DPSink::av_hdl_stack_evt | ( | uint16_t | event,
|  | void * | p_param
| ) |  |
| override protected virtual

Implements BluetoothA2DPCommon.

## ◆ bt_start()

bool BluetoothA2DPCommon::bt_start | ( |  | ) |
| protected virtual inherited

Startup logic as implemented by Arduino.

Returns
  true
  false

## ◆ debounce()

void BluetoothA2DPCommon::debounce | ( | void(*)(void) | cb,
|  | int | ms
| ) |  |
| virtual inherited

Prevents that the same method is executed multiple times within the indicated time limit

## ◆ end()

void BluetoothA2DPSink::end | ( | bool | release_memory = `false` | ) |
| virtual

ends the I2S bluetooth sink with the indicated name - if you release the memory a future start is not possible

Reimplemented from BluetoothA2DPCommon.

## ◆ esp_a2d_connect()

esp_err_t BluetoothA2DPSink::esp_a2d_connect | ( | esp_bd_addr_t | peer | ) |
| inline override protected virtual

Implements BluetoothA2DPCommon.

## ◆ esp_a2d_disconnect()

esp_err_t BluetoothA2DPSink::esp_a2d_disconnect | ( | esp_bd_addr_t | remote_bda | ) |
| inline override protected virtual

Implements BluetoothA2DPCommon.

## ◆ get_volume()

int BluetoothA2DPSink::get_volume | ( |  | ) |
| virtual

Determines the volume.

Reimplemented from BluetoothA2DPCommon.

## ◆ i2s_task_handler()

virtual void BluetoothA2DPSink::i2s_task_handler | ( | void * | arg | ) |
| inline protected virtual

dummy functions needed for BluetoothA2DPSinkQueued

Reimplemented in BluetoothA2DPSinkQueued.

## ◆ is_avrc_peer_rn_cap()

bool BluetoothA2DPSink::is_avrc_peer_rn_cap | ( | esp_avrc_rn_event_ids_t | cmd | ) |
| inline

Provides the result of the last result for the esp_avrc_tg_get_rn_evt_cap() callback (Available from ESP_IDF_4)

## ◆ isSource()

virtual bool BluetoothA2DPSink::isSource | ( |  | ) |
| inline protected virtual

Implements BluetoothA2DPCommon.

## ◆ last_bda_nvs_name()

virtual const char * BluetoothA2DPSink::last_bda_nvs_name | ( |  | ) |
| inline protected virtual

Implements BluetoothA2DPCommon.

## ◆ set_auto_reconnect() [1/2]

void BluetoothA2DPCommon::set_auto_reconnect | ( | bool | active | ) |
| inherited

activate / deactivate the automatic reconnection to the last address (per default this is on)

## ◆ set_auto_reconnect() [2/2]

virtual void BluetoothA2DPSink::set_auto_reconnect | ( | bool | reconnect,
|  | int | count = `AUTOCONNECT_TRY_NUM`
| ) |  |
| inline virtual

Defines the number of times that the system tries to automatically reconnect to the last system

## ◆ set_avrc_metadata_attribute_mask()

virtual void BluetoothA2DPSink::set_avrc_metadata_attribute_mask | ( | int | flags | ) |
| inline virtual

defines the requested metadata: eg. ESP_AVRC_MD_ATTR_TITLE | ESP_AVRC_MD_ATTR_ARTIST | ESP_AVRC_MD_ATTR_ALBUM | ESP_AVRC_MD_ATTR_TRACK_NUM | ESP_AVRC_MD_ATTR_NUM_TRACKS | ESP_AVRC_MD_ATTR_GENRE | ESP_AVRC_MD_ATTR_PLAYING_TIME

## ◆ set_avrc_rn_events()

virtual void BluetoothA2DPCommon::set_avrc_rn_events | ( | std::vector< esp_avrc_rn_event_ids_t > | events | ) |
| inline virtual inherited

Define the vector of esp_avrc_rn_event_ids_t with e.g. ESP_AVRC_RN_PLAY_STATUS_CHANGE | ESP_AVRC_RN_TRACK_CHANGE | ESP_AVRC_RN_TRACK_REACHED_END | ESP_AVRC_RN_TRACK_REACHED_START | ESP_AVRC_RN_PLAY_POS_CHANGED | ESP_AVRC_RN_BATTERY_STATUS_CHANGE | ESP_AVRC_RN_SYSTEM_STATUS_CHANGE | ESP_AVRC_RN_APP_SETTING_CHANGE | ESP_AVRC_RN_NOW_PLAYING_CHANGE | ESP_AVRC_RN_AVAILABLE_PLAYERS_CHANGE | ESP_AVRC_RN_ADDRESSED_PLAYER_CHANGE | ESP_AVRC_RN_UIDS_CHANGE|ESP_AVRC_RN_VOLUME_CHANGE

## ◆ set_avrc_rn_play_pos_callback()

virtual void BluetoothA2DPSink::set_avrc_rn_play_pos_callback | ( | void(*)(uint32_t play_pos) | callback,
|  | uint32_t | notif_interval = `10`
| ) |  |
| inline virtual

Define a callback method which provides esp_avrc_rn_param_t play position notifications, at a modifiable interval over 1s

## ◆ set_avrc_rn_playstatus_callback()

virtual void BluetoothA2DPSink::set_avrc_rn_playstatus_callback | ( | void(*)(esp_avrc_playback_stat_t playback) | callback | ) |
| inline virtual

Define a callback method which provides esp_avrc_playback_stat_t playback status notifications

## ◆ set_avrc_rn_track_change_callback()

virtual void BluetoothA2DPSink::set_avrc_rn_track_change_callback | ( | void(*)(uint8_t *id) | callback | ) |
| inline virtual

Define a callback method which provides an 8bit array for track change notifications Typically the last bit is 1 when there is a track change (so can be cast to a uint8_t)

## ◆ set_avrc_rn_volumechange_completed()

void BluetoothA2DPSink::set_avrc_rn_volumechange_completed | ( | void(*)(int) | callBack | ) |
| virtual

set the callback that the local volume change is notification is received and complete

## ◆ set_codec()

bool BluetoothA2DPSink::set_codec | ( | A2DPCodec | codec,
|  | void(*)(const uint8_t *data, size_t len) | encoded_cb = `nullptr`
| ) |  |

DRAFT: select codec AND set encoded frame callback in one call. If encoded_cb is not nullptr it registers the encoded frame reader. Returns result of internal registration

## ◆ set_default_bt_mode()

virtual void BluetoothA2DPCommon::set_default_bt_mode | ( | esp_bt_mode_t | mode | ) |
| inline virtual inherited

Defines the default bt mode. The default is ESP_BT_MODE_CLASSIC_BT: use this e.g. to set to ESP_BT_MODE_BTDM

## ◆ set_discoverability()

void BluetoothA2DPCommon::set_discoverability | ( | esp_bt_discovery_mode_t | d | ) |
| virtual inherited

Bluetooth discoverability.

Defines if the bluetooth is discoverable.

## ◆ set_on_audio_state_changed()

void BluetoothA2DPCommon::set_on_audio_state_changed | ( | void(*)(esp_a2d_audio_state_t state, void *) | callBack,
|  | void * | obj = `nullptr`
| ) |  |
| virtual inherited

Set the callback that is called when the audio state is changed.

Set the callback that is called when the audio state is changed This callback is called before the I2S bus is changed.

## ◆ set_on_audio_state_changed_post()

void BluetoothA2DPCommon::set_on_audio_state_changed_post | ( | void(*)(esp_a2d_audio_state_t state, void *) | callBack,
|  | void * | obj = `nullptr`
| ) |  |
| virtual inherited

Set the callback that is called after the audio state has changed. This callback is called after the I2S bus has changed.

## ◆ set_on_connection_state_changed()

void BluetoothA2DPCommon::set_on_connection_state_changed | ( | void(*)(esp_a2d_connection_state_t state, void *) | callBack,
|  | void * | obj = `nullptr`
| ) |  |
| virtual inherited

Set the callback that is called when the connection state is changed.

Set the callback that is called when the connection state is changed This callback is called before the I2S bus is changed.

## ◆ set_on_volumechange()

void BluetoothA2DPSink::set_on_volumechange | ( | void(*)(int) | callBack | ) |
| virtual

Set the callback that is called when they change the volume (kept for compatibility)

## ◆ set_raw_stream_reader()

void BluetoothA2DPSink::set_raw_stream_reader | ( | void(*)(const uint8_t *, uint32_t) | callBack | ) |
| virtual

Define a callback that is called before the volume changes: this callback provides access to the data

## ◆ set_reconnect_delay()

void BluetoothA2DPSink::set_reconnect_delay | ( | int | delay | ) |
| inline

Defines the delay that is added to delay the startup when we automatically reconnect

## ◆ set_scan_mode_connectable_default()

void BluetoothA2DPSink::set_scan_mode_connectable_default | ( |  | ) |
| inline override protected virtual

Implements BluetoothA2DPCommon.

## ◆ set_stream_reader()

void BluetoothA2DPSink::set_stream_reader | ( | void(*)(const uint8_t *, uint32_t) | callBack,
|  | bool | i2s_output = `true`
| ) |  |
| virtual

Define callback which is called when we receive data: This callback provides access to the data

## ◆ set_task_core()

void BluetoothA2DPCommon::set_task_core | ( | BaseType_t | core | ) |
| inline inherited

Defines the core which is used to start the tasks (to process the events and audio queue): default is 1

## ◆ set_volume()

void BluetoothA2DPSink::set_volume | ( | uint8_t | volume | ) |
| virtual

Changes the volume.

Reimplemented from BluetoothA2DPCommon.

## ◆ start()

void BluetoothA2DPSink::start | ( | const char * | name | ) |
| virtual

starts the I2S bluetooth sink with the inidicated name

Main function to start the Bluetooth Processing

## ◆ to_str()

const char * BluetoothA2DPCommon::to_str | ( | esp_avrc_playback_stat_t | state | ) |
| inherited

converts esp_avrc_playback_stat_t to a string

converts a esp_a2d_audio_state_t to a string

## ◆ write_audio()

virtual size_t BluetoothA2DPSink::write_audio | ( | const uint8_t * | data,
|  | size_t | size
| ) |  |
| inline protected virtual

output audio data e.g. to i2s or to queue

Reimplemented in BluetoothA2DPSinkQueued.

## Member Data Documentation

## ◆ avrc_metadata_flags

int BluetoothA2DPSink::avrc_metadata_flags
| protected

Initial value:
=
ESP_AVRC_MD_ATTR_TITLE | ESP_AVRC_MD_ATTR_ARTIST |
ESP_AVRC_MD_ATTR_ALBUM | ESP_AVRC_MD_ATTR_TRACK_NUM |
ESP_AVRC_MD_ATTR_NUM_TRACKS | ESP_AVRC_MD_ATTR_GENRE

## ◆ avrc_rn_events

std::vector<esp_avrc_rn_event_ids_t> BluetoothA2DPCommon::avrc_rn_events
| protected inherited

Initial value:
= {
ESP_AVRC_RN_VOLUME_CHANGE}

## ◆ connection_state

esp_a2d_connection_state_t BluetoothA2DPCommon::connection_state
| protected inherited

Initial value:
=
ESP_A2D_CONNECTION_STATE_DISCONNECTED
ESP_A2D_CONNECTION_STATE_DISCONNECTED
@ ESP_A2D_CONNECTION_STATE_DISCONNECTED
Definition external_lists.h:17

## ◆ m_a2d_conn_state_str

const char* BluetoothA2DPCommon::m_a2d_conn_state_str[4]
| protected inherited

Initial value:
= {"Disconnected", "Connecting",
"Connected", "Disconnecting"}

## ◆ m_avrc_playback_state_str

const char* BluetoothA2DPCommon::m_avrc_playback_state_str[5]
| protected inherited

Initial value:
= {"stopped", "playing", "paused",
"forward seek", "reverse seek"}

## ◆ peer_name_callback

void(* BluetoothA2DPSink::peer_name_callback) (char *peer_name)
| protected

Initial value:
=
nullptr

## ◆ rssi_callback

void(* BluetoothA2DPSink::rssi_callback) (esp_bt_gap_cb_param_t::read_rssi_delta_param &rssi)
| protected

Initial value:
=
nullptr

The documentation for this class was generated from the following files:

- src/BluetoothA2DPSink.h
- src/BluetoothA2DPSink.cpp