Arduino A2DP
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BluetoothA2DPCommon Class Referenceabstract

Common Bluetooth A2DP functions. More...

#include <BluetoothA2DPCommon.h>

Inheritance diagram for BluetoothA2DPCommon:
BluetoothA2DPSink BluetoothA2DPSource BluetoothA2DPSinkQueued

Public Member Functions

virtual ~BluetoothA2DPCommon ()=default
 Destructor.
 
void set_auto_reconnect (bool active)
 activate / deactivate the automatic reconnection to the last address (per default this is on)
 
virtual void disconnect ()
 Closes the connection.
 
virtual bool reconnect ()
 Reconnects to the last device.
 
virtual bool connect_to (esp_bd_addr_t peer)
 Connnects to the indicated address.
 
virtual void set_connected (bool active)
 Calls disconnect or reconnect.
 
virtual void end (bool releaseMemory=false)
 Closes the connection and stops A2DP.
 
virtual bool is_connected ()
 Checks if A2DP is connected.
 
virtual void set_volume (uint8_t volume)
 Sets the volume (range 0 - 255)
 
virtual int get_volume ()
 Determines the actual volume.
 
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. 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_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 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!
 
const char * to_str (esp_avrc_playback_stat_t state)
 converts esp_avrc_playback_stat_t to a string More...
 
void set_task_priority (UBaseType_t priority)
 defines the task priority (the default value is configMAX_PRIORITIES - 10)
 
void set_task_core (BaseType_t core)
 Defines the core which is used to start the tasks (to process the events and audio queue)
 
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 esp_bd_addr_t * get_last_peer_address ()
 Provides the address of the last device.
 
virtual void set_discoverability (esp_bt_discovery_mode_t d)
 Bluetooth discoverability. More...
 
virtual void set_connectable (bool connectable)
 Bluetooth connectable.
 
virtual const char * get_name ()
 Provides the actual SSID name.
 
virtual void clean_last_connection ()
 clean last connection (delete)
 
virtual void set_default_bt_mode (esp_bt_mode_t mode)
 Defines the default bt mode. The default is ESP_BT_MODE_CLASSIC_BT: use this e.g. to set to ESP_BT_MODE_BTDM.
 

Protected Member Functions

virtual esp_err_t esp_a2d_connect (esp_bd_addr_t peer)=0
 
virtual const char * last_bda_nvs_name ()=0
 
virtual void get_last_connection ()
 
virtual void set_last_connection (esp_bd_addr_t bda)
 
virtual bool has_last_connection ()
 
virtual void set_scan_mode_connectable (bool connectable)
 Defines if the bluetooth is connectable.
 
virtual void set_scan_mode_connectable_default ()=0
 
virtual A2DPVolumeControlvolume_control ()
 provides access to the VolumeControl object
 

Protected Attributes

const char * bt_name = {0}
 
esp_bd_addr_t peer_bd_addr
 
ReconnectStatus reconnect_status = NoReconnect
 
unsigned long reconnect_timout =0
 
unsigned int default_reconnect_timout =10000
 
bool is_autoreconnect_allowed = false
 
uint32_t debounce_ms = 0
 
A2DPDefaultVolumeControl default_volume_control
 
A2DPVolumeControlvolume_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(* audio_state_callback_post )(esp_a2d_audio_state_t state, void *obj) = nullptr
 
void * connection_state_obj = nullptr
 
void * audio_state_obj = nullptr
 
void * audio_state_obj_post = nullptr
 
const char * m_a2d_conn_state_str [4] = {"Disconnected", "Connecting", "Connected", "Disconnecting"}
 
const char * m_a2d_audio_state_str [3] = {"Suspended", "Stopped", "Started"}
 
const char * m_avrc_playback_state_str [5] = {"stopped", "playing", "paused", "forward seek", "reverse seek"}
 
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
 
BaseType_t task_core = 1
 
int event_queue_size = 20
 
int event_stack_size = 3072
 
esp_bt_mode_t bt_mode = ESP_BT_MODE_CLASSIC_BT
 
esp_bt_discovery_mode_t discoverability = ESP_BT_GENERAL_DISCOVERABLE
 

Detailed Description

Common Bluetooth A2DP functions.

Author
Phil Schatzmann

Member Function Documentation

◆ set_discoverability()

void BluetoothA2DPCommon::set_discoverability ( esp_bt_discovery_mode_t  d)
virtual

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

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

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

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.

◆ to_str()

const char * BluetoothA2DPCommon::to_str ( esp_avrc_playback_stat_t  state)

converts esp_avrc_playback_stat_t to a string

converts a esp_a2d_audio_state_t to a string


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