Arduino A2DP

Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
BluetoothA2DPSinkMinRAM Class Reference

BluetoothA2DPSinkMinRAM. The BluetoothA2DPSink is using a separate Task with an additinal Queue to write the I2S data. This implementation is using the legacy logic which writes directly to I2S w/o task. This leaves more RAM available to the application. More...

`#include <BluetoothA2DPSink.h>`

Inheritance diagram for BluetoothA2DPSinkMinRAM:

## Public Member Functions
void | bt_i2s_task_start_up (void) override
void | bt_i2s_task_shut_down (void) override
void | i2s_task_handler (void *arg) override
size_t | write_ringbuf (const uint8_t *data, size_t size)
| i2s task with ringubffer
virtual void | set_pin_config (i2s_pin_config_t pin_config)
| Define the pins.
virtual void | set_i2s_port (i2s_port_t i2s_num)
| Define an alternative i2s port other then 0.
virtual void | set_i2s_config (i2s_config_t i2s_config)
| Define the i2s configuration.
virtual void | start (const char *name, bool auto_reconect)
| starts the I2S bluetooth sink with the inidicated name
virtual void | start (const char *name)
| starts the I2S bluetooth sink with the inidicated name More...
virtual void | end (bool release_memory=false)
| ends the I2S bluetooth sink with the indicated name - if you release the memory a future start is not possible
virtual bool | is_connected ()
| Returns true if the state is connected.
virtual esp_a2d_mct_t | get_audio_type ()
| Determine the actual audio type.
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_sample_rate_callback (void(*callback)(uint16_t rate))
| Defines the method which will be called with the sample rate is updated.
virtual void | set_stream_reader (void(*callBack)(const uint8_t *, uint32_t), bool i2s_output=true)
| Define callback which is called when we receive data: This callback provides access to the data.
virtual void | set_on_data_received (void(*callBack)())
| Define callback which is called when we receive data.
virtual void | set_address_validator (bool(*callBack)(esp_bd_addr_t remote_bda))
| Allows you to reject unauthorized addresses.
virtual void | set_volume (uint8_t volume)
| Changes the volume.
virtual int | get_volume ()
| Determines the volume.
virtual void | set_on_volumechange (void(*callBack)(int))
| Set the callback that is called when they change the volume.
virtual void | play ()
| Starts to play music using AVRC.
virtual void | pause ()
| AVRC pause.
virtual void | stop ()
| AVRC stop.
virtual void | next ()
| AVRC next.
virtual void | previous ()
| AVRC previous.
virtual void | fast_forward ()
| AVRC fast_forward.
virtual void | rewind ()
| AVRC rewind.
virtual void | set_channels (i2s_channel_t channels)
| set output to I2S_CHANNEL_STEREO (default) or I2S_CHANNEL_MONO
virtual void | set_mono_downmix (bool enabled)
| mix stereo into single mono signal
virtual void | set_bits_per_sample (int bps)
| Defines the bits per sample for output (if > 16 output will be expanded)
virtual uint16_t | sample_rate ()
| Provides the actually set data rate (in samples per second)
virtual esp_err_t | i2s_mclk_pin_select (const uint8_t pin)
| Defines the pin for the master clock.
virtual void | activate_pin_code (bool active)
| We need to confirm a new seesion by calling confirm_pin_code()
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 int | pin_code ()
| provides the requested pin code (0 = undefined)
virtual void | set_avrc_metadata_attribute_mask (int flags)
| 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
virtual void | set_swap_lr_channels (bool swap)
| swaps the left and right channel
virtual void | set_auto_reconnect (bool reconnect, bool afterNormalDisconnect=false, int count=AUTOCONNECT_TRY_NUM)
| Defines the number of times that the system tries to automatically reconnect to the last system.
void | set_auto_reconnect (bool active)
| activate / deactivate the automatic reconnection to the last address (per default this is on)
virtual esp_bd_addr_t * | get_current_peer_address ()
| Provides the address of the connected device.
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_i2s_stack_size (int size)
| Defines the stack size of the i2s task (in bytes)
void | set_i2s_ringbuffer_size (int size)
| Defines the ringbuffer size used by the i2s task (in bytes)
void | set_i2s_task_priority (UBaseType_t prio)
| Defines the priority of the I2S task.
void | set_rssi_active (bool active)
| Activates the rssi reporting.
esp_bt_gap_cb_param_t::read_rssi_delta_param | get_last_rssi ()
| provides the last rssi parameters
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 | disconnect ()
| Closes the connection.
virtual void | reconnect ()
| Reconnects to the last device.
virtual void | set_connected (bool active)
| Calls disconnect or reconnect.
virtual void | set_volume_control (A2DPVolumeControl *ptr)
| you can define a custom VolumeControl implementation
virtual esp_a2d_audio_state_t | get_audio_state ()
| Determine the actual audio state.
virtual esp_a2d_connection_state_t | get_connection_state ()
| Determine the connection state.
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_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 | debounce (void(*cb)(void), int ms)
| Prevents that the same method is executed multiple times within the indicated time limit.
void | log_free_heap ()
| Logs the free heap.
const char * | to_str (esp_a2d_connection_state_t state)
| converts esp_a2d_connection_state_t to a string
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_bd_addr_t bda)
| converts a esp_bd_addr_t to a string - the string is 18 characters long!
void | set_task_priority (UBaseType_t priority)
| defines the task priority (the default value is configMAX_PRIORITIES - 3)
virtual esp_bd_addr_t * | get_last_peer_address ()
| Provides the address of the last device.

## Protected Member Functions
virtual int | init_bluetooth ()
virtual void | init_i2s ()
virtual void | app_task_start_up (void)
virtual void | app_task_shut_down (void)
virtual bool | app_send_msg (app_msg_t *msg)
virtual bool | app_work_dispatch (app_callback_t p_cback, uint16_t event, void *p_params, int param_len)
virtual void | app_work_dispatched (app_msg_t *msg)
virtual void | app_alloc_meta_buffer (esp_avrc_ct_cb_param_t *param)
virtual void | av_new_track ()
virtual void | init_nvs ()
virtual void | execute_avrc_command (int cmd)
virtual const char * | last_bda_nvs_name ()
virtual bool | is_reconnect (esp_a2d_disc_rsn_t type)
virtual void | app_task_handler (void *arg)
virtual void | app_a2d_callback (esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param)
virtual void | app_gap_callback (esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
virtual void | app_rc_ct_callback (esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *param)
virtual void | audio_data_callback (const uint8_t *data, uint32_t len)
virtual void | av_hdl_stack_evt (uint16_t event, void *p_param)
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 | handle_connection_state (uint16_t event, void *p_param)
virtual void | handle_audio_state (uint16_t event, void *p_param)
virtual void | handle_audio_cfg (uint16_t event, void *p_param)
virtual void | av_notify_evt_handler (uint8_t event_id, uint32_t event_parameter)
size_t | i2s_write_data (const uint8_t *data, size_t item_size)
| writes the data to i2s
virtual void | get_last_connection ()
virtual void | set_last_connection (esp_bd_addr_t bda)
virtual void | clean_last_connection ()
virtual void | connect_to_last_device ()
virtual bool | has_last_connection ()
virtual void | set_scan_mode_connectable (bool connectable)
virtual A2DPVolumeControl * | volume_control ()
| provides access to the VolumeControl object

## Protected Attributes
xQueueHandle | app_task_queue = nullptr
xTaskHandle | app_task_handle = nullptr
xTaskHandle | s_bt_i2s_task_handle = nullptr
RingbufHandle_t | s_ringbuf_i2s = nullptr
i2s_config_t | i2s_config
i2s_pin_config_t | pin_config
const char * | bt_name = nullptr
uint32_t | m_pkt_cnt = 0
esp_a2d_mct_t | audio_type
char | pin_code_str [20] = {0}
bool | is_i2s_output = true
bool | player_init = false
i2s_channel_t | i2s_channels = I2S_CHANNEL_STEREO
i2s_port_t | i2s_port = I2S_NUM_0
int | connection_rety_count = 0
_lock_t | s_volume_lock
uint8_t | s_volume = 0
bool | s_volume_notify
int | pin_code_int = 0
PinCodeRequest | pin_code_request = Undefined
bool | is_pin_code_active = false
int | avrc_metadata_flags = 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
void(* | bt_volumechange )(int) = nullptr
void(* | bt_dis_connected )() = nullptr
void(* | bt_connected )() = nullptr
void(* | data_received )() = nullptr
void(* | stream_reader )(const uint8_t *, uint32_t) = nullptr
void(* | avrc_metadata_callback )(uint8_t, const uint8_t *) = nullptr
bool(* | address_validator )(esp_bd_addr_t remote_bda) = nullptr
void(* | sample_rate_callback )(uint16_t rate) =nullptr
bool | swap_left_right = false
int | try_reconnect_max_count = AUTOCONNECT_TRY_NUM
bool | reconnect_on_normal_disconnect = false
bool | end_in_progress = false
int | event_queue_size = 20
int | event_stack_size = 3072
int | i2s_stack_size = 2048
int | i2s_ringbuffer_size = 4 * 1024
UBaseType_t | i2s_task_priority = configMAX_PRIORITIES - 3
esp_bt_gap_cb_param_t::read_rssi_delta_param | last_rssi_delta
bool | rssi_active = false
void(* | rssi_callbak )(esp_bt_gap_cb_param_t::read_rssi_delta_param &rssi) = nullptr
esp_bd_addr_t | peer_bd_addr
bool | is_auto_reconnect =true
bool | is_connecting = true
uint32_t | debounce_ms = 0
A2DPDefaultVolumeControl | default_volume_control
A2DPVolumeControl * | volume_control_ptr = nullptr
esp_bd_addr_t | last_connection = {0,0,0,0,0,0}
bool | is_start_disabled = false
void(* | connection_state_callback )(esp_a2d_connection_state_t state, void *obj) = nullptr
void(* | audio_state_callback )(esp_a2d_audio_state_t state, void *obj) = nullptr
void * | connection_state_obj = nullptr
void * | audio_state_obj = nullptr
const char * | m_a2d_conn_state_str [4] = {"Disconnected", "Connecting", "Connected", "Disconnecting"}
const char * | m_a2d_audio_state_str [3] = {"Suspended", "Stopped", "Started"}
esp_a2d_audio_state_t | audio_state = ESP_A2D_AUDIO_STATE_STOPPED
esp_a2d_connection_state_t | connection_state = ESP_A2D_CONNECTION_STATE_DISCONNECTED
UBaseType_t | task_priority = configMAX_PRIORITIES - 10
uint8_t | volume_value = 0
bool | is_volume_used = false

## Static Protected Attributes
static const esp_spp_mode_t | esp_spp_mode = ESP_SPP_MODE_CB

## Detailed Description

BluetoothA2DPSinkMinRAM. The BluetoothA2DPSink is using a separate Task with an additinal Queue to write the I2S data. This implementation is using the legacy logic which writes directly to I2S w/o task. This leaves more RAM available to the application.

## Member Function Documentation

## ◆ app_task_handler()

void BluetoothA2DPSink::app_task_handler | ( | void * | arg | ) |
| protected virtual inherited

Wrappbed methods called from callbacks

## ◆ start()

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

starts the I2S bluetooth sink with the inidicated name

Main function to start the Bluetooth Processing

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

- src/BluetoothA2DPSink.h