Arduino A2DP
|
A2DP Bluetooth Source. More...
#include <BluetoothA2DPSource.h>
Public Member Functions | |
BluetoothA2DPSource () | |
Constructor. | |
~BluetoothA2DPSource () | |
Destructor. | |
virtual void | clean_last_connection () |
clean last connection (delete) | |
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. | |
void | end (bool releaseMemory=false) override |
Ends the processing and releases the resources. | |
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 esp_bd_addr_t * | get_last_peer_address () |
Provides the address of the last device. | |
unsigned long | get_millis () |
Provides the time in milliseconds since the last system boot. | |
virtual const char * | get_name () |
Provides the actual SSID name. | |
virtual int | get_volume () |
Determines the actual volume. | |
virtual bool | is_connected () |
Checks if A2DP is connected. | |
virtual bool | is_discovery_active () |
void | log_free_heap () |
Logs the free heap. | |
virtual bool | reconnect () |
Reconnects to the last device. | |
virtual void | set_auto_reconnect (bool active) |
virtual void | set_auto_reconnect (esp_bd_addr_t addr) |
automatically tries to reconnect to the indicated address | |
virtual void | set_avrc_passthru_command_callback (void(*cb)(uint8_t key, bool isReleased)) |
Define the handler fur button presses on the remote bluetooth speaker. | |
virtual void | set_avrc_rn_events (std::vector< esp_avrc_rn_event_ids_t > events) |
void | set_bluedroid_config_t (esp_bluedroid_config_t cfg) |
Defines the esp_bluedroid_config_t: Available from IDF 5.2.1. | |
virtual void | set_connectable (bool connectable) |
Bluetooth connectable. | |
virtual void | set_connected (bool active) |
Calls disconnect or reconnect. | |
virtual void | set_data_callback (int32_t(cb)(uint8_t *data, int32_t len)) |
Defines the data callback. | |
virtual void | set_data_callback_in_frames (int32_t(cb)(Frame *data, int32_t len)) |
Defines the data callback. | |
virtual void | set_data_source (Stream &data) |
Defines a single Arduino Stream (e.g. File) as audio source. | |
virtual void | set_data_source_callback (Stream &(*next_stream)()) |
Provide a callback which provides streams. | |
virtual void | set_default_bt_mode (esp_bt_mode_t mode) |
virtual void | set_discoverability (esp_bt_discovery_mode_t d) |
Bluetooth discoverability. More... | |
virtual void | set_discovery_mode_callback (void(*callback)(esp_bt_gap_discovery_state_t discoveryMode)) |
Define callback to be notified about bt discovery mode state changes. | |
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) | |
virtual void | set_local_name (const char *name) |
Defines the local name. | |
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. More... | |
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. More... | |
void | set_pin_code (const char *pin_code, esp_bt_pin_type_t pin_type) |
Defines the pin code. If nothing is defined we use "1234". | |
virtual void | set_reset_ble (bool doInit) |
Defines if the BLE should be reset on start. | |
virtual void | set_ssid_callback (bool(*callback)(const char *ssid, esp_bd_addr_t address, int rrsi)) |
Define callback to be notified about the found ssids. | |
virtual void | set_ssp_enabled (bool active) |
activate Secure Simple Pairing | |
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_valid_cod_service (uint16_t filter) |
virtual void | set_volume (uint8_t volume) |
Sets the volume (range 0 - 127) | |
virtual void | set_volume_control (A2DPVolumeControl *ptr) |
you can define a custom VolumeControl implementation | |
virtual void | start () |
virtual void | start (const char *name) |
Starts the A2DP source. | |
virtual void | start (const char *name, music_data_frames_cb_t callback) |
Obsolete: use the start w/o callback and set the callback separately. | |
virtual void | start (music_data_frames_cb_t callback) |
Obsolete: use the start w/o callback and set the callback separately. | |
virtual void | start (std::vector< const char * > names) |
Starts the first available A2DP source. | |
virtual void | start (std::vector< const char * > names, music_data_frames_cb_t callback) |
Obsolete: use the start w/o callback and set the callback separately. | |
virtual void | start_raw (const char *name, music_data_cb_t callback=nullptr) |
Obsolete: use the start w/o callback and set the callback separately. | |
virtual void | start_raw (music_data_cb_t callback=nullptr) |
Obsolete: use the start w/o callback and set the callback separately. | |
virtual void | start_raw (std::vector< const char * > names, music_data_cb_t callback=nullptr) |
Obsolete: use the start w/o callback and set the callback separately. | |
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 More... | |
const char * | to_str (esp_bd_addr_t bda) |
converts a esp_bd_addr_t to a string - the string is 18 characters long! | |
Protected Member Functions | |
virtual void | a2d_app_heart_beat (void *arg) |
void | app_a2d_callback (esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param) override |
callback function for A2DP source | |
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 void | app_work_dispatched (bt_app_msg_t *msg) |
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 esp_err_t | bluedroid_init () |
virtual void | bt_app_av_media_proc (uint16_t event, void *param) |
virtual void | bt_app_av_sm_hdlr (uint16_t event, void *param) |
A2DP application state machine. | |
virtual void | bt_app_av_state_connected_hdlr (uint16_t event, void *param) |
virtual void | bt_app_av_state_connecting_hdlr (uint16_t event, void *param) |
virtual void | bt_app_av_state_disconnecting_hdlr (uint16_t event, void *param) |
virtual void | bt_app_av_state_unconnected_hdlr (uint16_t event, void *param) |
A2DP application state machine handler for each state. | |
virtual bool | bt_app_work_dispatch (bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback) |
virtual void | bt_av_hdl_avrc_ct_evt (uint16_t event, void *p_param) |
avrc CT event handler | |
virtual void | bt_av_notify_evt_handler (uint8_t event, esp_avrc_rn_param_t *param) |
virtual void | bt_av_volume_changed (void) |
virtual bool | bt_start () |
Startup logic as implemented by Arduino. More... | |
esp_err_t | esp_a2d_connect (esp_bd_addr_t peer) override |
esp_err_t | esp_a2d_disconnect (esp_bd_addr_t peer) override |
virtual void | filter_inquiry_scan_result (esp_bt_gap_cb_param_t *param) |
virtual int32_t | get_audio_data (uint8_t *data, int32_t len) |
provides the audio data to be sent | |
virtual int32_t | get_audio_data_volume (uint8_t *data, int32_t len) |
provides the audio after applying the volume | |
virtual void | get_last_connection () |
virtual bool | get_name_from_eir (uint8_t *eir, uint8_t *bdname, uint8_t *bdname_len) |
virtual bool | has_last_connection () |
virtual void | init_nvs () |
virtual bool | is_valid_cod_service (uint32_t cod) |
virtual bool | isSource () |
virtual const char * | last_bda_nvs_name () |
virtual void | process_user_state_callbacks (uint16_t event, void *param) |
virtual bool | read_address (const char *name, esp_bd_addr_t &bda) |
virtual void | reset_last_connection () |
resets the last connectioin so that we can reconnect | |
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 |
const char * | to_state_str (int state) |
converts a APP_AV_STATE_ENUM to a string | |
virtual A2DPVolumeControl * | volume_control () |
provides access to the VolumeControl object | |
virtual bool | write_address (const char *name, esp_bd_addr_t bda) |
Protected Attributes | |
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 |
std::vector< esp_avrc_rn_event_ids_t > | avrc_rn_events |
esp_bluedroid_config_t | bluedroid_config {.ssp_en = true} |
esp_bt_mode_t | bt_mode = ESP_BT_MODE_CLASSIC_BT |
const char * | bt_name = {0} |
std::vector< const char * > | bt_names |
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 |
uint32_t | debounce_ms = 0 |
unsigned int | default_reconnect_timout = 10000 |
A2DPDefaultVolumeControl | default_volume_control |
const char * | dev_name = "ESP32_A2DP_SRC" |
esp_bt_discovery_mode_t | discoverability = ESP_BT_GENERAL_DISCOVERABLE |
bool | discovery_active = false |
void(* | discovery_mode_callback )(esp_bt_gap_discovery_state_t discoveryMode) |
int | event_queue_size = 20 |
int | event_stack_size = 3072 |
int32_t(* | get_data_cb )(uint8_t *data, int32_t len) = nullptr |
callback for data | |
int32_t(* | get_data_in_frames_cb )(Frame *data, int32_t len) = nullptr |
Stream &(* | get_next_stream_cb )() = nullptr |
bool | is_autoreconnect_allowed = false |
bool | is_passthru_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} |
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] |
Stream * | p_stream = nullptr |
void(* | passthru_command_callback )(uint8_t, bool) = nullptr |
esp_bd_addr_t | peer_bd_addr |
esp_bt_pin_code_t | pin_code |
uint32_t | pin_code_len |
esp_bt_pin_type_t | pin_type |
ReconnectStatus | reconnect_status = NoReconnect |
unsigned long | reconnect_timout = 0 |
bool | reset_ble = false |
APP_AV_STATE | s_a2d_last_state |
APP_AV_STATE | s_a2d_state = APP_AV_STATE_IDLE |
esp_avrc_rn_evt_cap_mask_t | s_avrc_peer_rn_cap |
int | s_connecting_heatbeat_count |
int | s_intv_cnt = 0 |
int | s_media_state = 0 |
uint8_t | s_peer_bdname [ESP_BT_GAP_MAX_BDNAME_LEN+1] |
uint32_t | s_pkt_cnt |
TimerHandle_t | s_tmr |
bool(* | ssid_callback )(const char *ssid, esp_bd_addr_t address, int rrsi) = nullptr |
bool | ssp_enabled = false |
BaseType_t | task_core = 1 |
UBaseType_t | task_priority = configMAX_PRIORITIES - 10 |
uint16_t | valid_cod_services |
A2DPVolumeControl * | volume_control_ptr = nullptr |
uint8_t | volume_value = 0 |
A2DP Bluetooth Source.
|
protectedvirtual |
Switch state to APP_AV_STATE_UNCONNECTED when connecting lasts more than 2 heart beat intervals.
|
protectedvirtualinherited |
Startup logic as implemented by Arduino.
|
virtualinherited |
Prevents that the same method is executed multiple times within the indicated time limit
|
inlinevirtual |
Provides the current discovery state: returns true when the discovery is in progress
|
protectedvirtual |
returns true for ESP_BT_COD_SRVC_RENDERING,ESP_BT_COD_SRVC_AUDIO,ESP_BT_COD_SRVC_TELEPHONY
|
inlinevirtual |
activate / deactivate the automatic reconnection to the last address (per default this is on)
|
inlinevirtualinherited |
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
|
inlinevirtualinherited |
Defines the default bt mode. The default is ESP_BT_MODE_CLASSIC_BT: use this e.g. to set to ESP_BT_MODE_BTDM
|
virtualinherited |
Bluetooth discoverability.
Defines if the bluetooth is discoverable.
|
virtualinherited |
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.
|
virtualinherited |
Set the callback that is called after the audio state has changed. This callback is called after the I2S bus has changed.
|
virtualinherited |
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.
|
inlineinherited |
Defines the core which is used to start the tasks (to process the events and audio queue)
|
inlinevirtual |
Defines the valid esp_bt_cod_srvc_t values that are used to identify an audio service. e.g (ESP_BT_COD_SRVC_RENDERING | ESP_BT_COD_SRVC_AUDIO | ESP_BT_COD_SRVC_TELEPHONY)
|
inlinevirtual |
Starts the A2DP source w/o indicating any names: use the ssid callback to select the device
|
inherited |
converts esp_avrc_playback_stat_t to a string
converts a esp_a2d_audio_state_t to a string
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protected |