arduino-audio-tools
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
AudioBLEClient Class Reference

A simple BLE client that implements the serial protocol, so that it can be used to send and recevie audio. In BLE terminology this is a Central. More...

#include <AudioBLEClient.h>

Inheritance diagram for AudioBLEClient:
AudioBLEStream AudioBLEStream AudioStream AudioStream BaseStream AudioInfoSupport AudioInfoSource BaseStream AudioInfoSupport AudioInfoSource Stream Stream Print Print

Public Member Functions

 AudioBLEClient (int mtu=242)
 
 AudioBLEClient (int mtu=517)
 
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
 
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
 
int available () override
 
int available () override
 
int availableForWrite () override
 
int availableForWrite () override
 
virtual bool begin ()
 
bool begin (const char *localName, int seconds)
 starts a BLE client
 
bool begin (const char *localName, int seconds)
 starts a BLE client
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
bool connected () override
 
bool connected () override
 
void end () override
 
void end () override
 
virtual void flush () override
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
 operator bool ()
 
size_t readBytes (uint8_t *data, size_t len) override
 
size_t readBytes (uint8_t *data, size_t len) override
 
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
 
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
 
void setAudioInfo (AudioInfo info)
 Defines the input AudioInfo.
 
void setAudioInfoActive (bool flag)
 
void setAudioInfoUUID (const char *uuid)
 
void setConfirmWrite (bool flag)
 
void setConfirmWrite (bool flag)
 
void setFramed (bool flag)
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
void setRxUUID (const char *uuid)
 
void setServiceUUID (const char *uuid)
 
void setTxUUID (const char *uuid)
 
void setWriteThrottle (int ms)
 
void setWriteThrottle (int ms)
 
AudioInfo toInfo (const uint8_t *str)
 
StrView toStr (AudioInfo info)
 
size_t write (const uint8_t *data, size_t len) override
 
size_t write (const uint8_t *data, size_t len) override
 
virtual size_t write (uint8_t ch) override
 
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
 

Protected Member Functions

int getMTU () override
 
virtual int not_supported (int out, const char *msg="")
 
void notifyAudioChange (AudioInfo info)
 
void onConnect (BLEClient *pClient) override
 
void onDisconnect (BLEClient *pClient) override
 
void onResult (BLEAdvertisedDevice advertisedDevice) override
 
bool readAudioInfoCharacteristic ()
 
bool readAudioInfoCharacteristic ()
 
void refillReadBuffer ()
 
virtual void setAudioInfo (const uint8_t *data, size_t size)
 
bool setupBLEClient ()
 
bool setupBLEClient ()
 
void writeAudioInfoCharacteristic (AudioInfo info) override
 
void writeAudioInfoCharacteristic (AudioInfo info) override
 
void writeChannel2Characteristic (const uint8_t *data, size_t len)
 
void writeChannel2Characteristic (const uint8_t *data, size_t len)
 

Static Protected Member Functions

static void notifyCallback (BLERemoteCharacteristic *pBLERemoteCharacteristic, uint8_t *pData, size_t length, bool isNotify)
 
static void onInfoUpdated (BLEDevice central, BLECharacteristic characteristic)
 

Protected Attributes

int _timeout = 10
 
BLEAdvertisedDevice advertised_device
 
char audio_info_str [40]
 
const char * BLE_AUDIO_SERVICE_UUID = "6e400001-b5a3-f393-e0a9-e50e24dcca9e"
 
const char * BLE_CH1_UUID = "6e400002-b5a3-f393-e0a9-e50e24dcca9e"
 
const char * BLE_CH2_UUID = "6e400003-b5a3-f393-e0a9-e50e24dcca9e"
 
const char * BLE_INFO_UUID = "6e400004-b5a3-f393-e0a9-e50e24dcca9e"
 
const char * ble_server_name = nullptr
 
BLEUUID BLUEID_AUDIO_SERVICE_UUID {BLE_AUDIO_SERVICE_UUID}
 
BLEUUID BLUEID_CH1_UUID {BLE_CH1_UUID}
 
BLEUUID BLUEID_CH2_UUID {BLE_CH2_UUID}
 
BLEUUID BLUEID_INFO_UUID {BLE_INFO_UUID}
 
BLECharacteristic ch01_char
 
BLERemoteCharacteristic * ch01_char = nullptr
 
BLECharacteristic ch02_char
 
BLERemoteCharacteristic * ch02_char = nullptr
 
AudioInfo info
 
BLECharacteristic info_char
 
BLERemoteCharacteristic * info_char = nullptr
 
bool is_audio_info_active = false
 
volatile bool is_client_connected = false
 
bool is_client_set_up = false
 
bool is_framed = false
 
bool is_notify_active = true
 
bool is_started = false
 
uint16_t max_transfer_size = 0
 
Vector< AudioInfoSupport * > notify_vector
 
BLEAdvertising * p_advertising = nullptr
 
BLEClient * p_client = nullptr
 
BLERemoteService * p_remote_service = nullptr
 
BLEAddress * p_server_address = nullptr
 
BLEDevice peripheral
 
RingBuffer< uint8_t > tmp_in {0}
 
RingBuffer< uint8_t > tmp_out {0}
 
SingleBuffer< uint8_t > write_buffer {0}
 
bool write_confirmation_flag = false
 
int write_throttle = 0
 

Detailed Description

A simple BLE client that implements the serial protocol, so that it can be used to send and recevie audio. In BLE terminology this is a Central.

Author
Phil Schatzmann

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