diff --git a/_audio_b_l_e_client_8h_source.html b/_audio_b_l_e_client_8h_source.html
index d8ea132c05..97c2a41171 100644
--- a/_audio_b_l_e_client_8h_source.html
+++ b/_audio_b_l_e_client_8h_source.html
@@ -83,147 +83,174 @@
12 static AudioBLEClient *selfAudioBLEClient =
nullptr;
- 23 public BLEAdvertisedDeviceCallbacks {
-
-
- 26 selfAudioBLEClient =
this;
-
-
- 30 bool begin(
const char *serverName,
int seconds) {
-
- 32 ble_server_name = serverName;
-
- 34 BLEDevice::init(
"client");
-
-
-
- 38 BLEScan *pBLEScan = BLEDevice::getScan();
- 39 pBLEScan->setAdvertisedDeviceCallbacks(
this);
- 40 pBLEScan->setActiveScan(
true);
- 41 pBLEScan->start(seconds);
-
-
-
-
-
-
-
-
-
- 51 size_t readBytes(uint8_t *data,
size_t dataSize)
override {
-
-
- 54 auto str = ch02_char->readValue();
- 55 memcpy(data, str.c_str(), str.length());
-
-
-
- 59 int available()
override {
return BLE_BUFFER_SIZE; }
-
- 61 size_t write(
const uint8_t *data,
size_t dataSize)
override {
- 62 ch01_char->writeValue((uint8_t *)data, dataSize,
false);
-
-
-
- 66 int availableForWrite()
override {
return BLE_BUFFER_SIZE; }
-
- 68 virtual bool connected()
override {
return is_client_connected; }
-
-
-
- 72 BLEClient *p_client =
nullptr;
- 73 BLEAdvertising *p_advertising =
nullptr;
- 74 BLERemoteService *p_remote_service =
nullptr;
- 75 BLEAddress *p_server_address =
nullptr;
- 76 BLERemoteCharacteristic *ch01_char =
nullptr;
- 77 BLERemoteCharacteristic *ch02_char =
nullptr;
- 78 BLERemoteCharacteristic *info_char =
nullptr;
- 79 BLEAdvertisedDevice advertised_device;
- 80 bool is_client_connected =
false;
-
- 82 void writeAudioInfoCharacteristic(AudioInfo info)
override {
-
-
- 85 info_char->writeValue((uint8_t *)&info,
sizeof(AudioInfo));
-
-
-
- 89 void onResult(BLEAdvertisedDevice advertisedDevice)
override {
-
-
- 92 if (advertisedDevice.getName() == ble_server_name) {
-
- 94 advertised_device = advertisedDevice;
-
- 96 advertised_device.getScan()->stop();
-
-
-
- 100 LOGI(
"Device '%s' found: Connecting!",
- 101 advertised_device.toString().c_str());
-
-
-
-
-
- 107 static void notifyCallback(BLERemoteCharacteristic *pBLERemoteCharacteristic,
- 108 uint8_t *pData,
size_t length,
bool isNotify) {
-
- 110 if (pBLERemoteCharacteristic->getUUID().toString() ==
- 111 selfAudioBLEClient->BLE_INFO_UUID) {
- 112 selfAudioBLEClient->setAudioInfo(pData, length);
-
-
-
- 116 bool setupBLEClient() {
-
-
- 119 if (p_client ==
nullptr)
- 120 p_client = BLEDevice::createClient();
-
-
- 123 LOGI(
"Connecting to %s ...",
- 124 advertised_device.getAddress().toString().c_str());
-
- 126 p_client->connect(&advertised_device);
- 127 if (!p_client->isConnected()) {
- 128 LOGE(
"connect failed");
-
-
- 131 p_client->setMTU(max_transfer_size);
-
- 133 LOGI(
"Connected to server: %s", is_client_connected ?
"true" :
"false");
-
-
-
- 137 if (p_remote_service ==
nullptr) {
- 138 p_remote_service = p_client->getService(BLE_SERIAL_SERVICE_UUID);
- 139 if (p_remote_service ==
nullptr) {
- 140 LOGE(
"Failed to find our service UUID: %s", BLE_SERIAL_SERVICE_UUID);
-
-
-
+ 23 public BLEClientCallbacks,
+ 24 public BLEAdvertisedDeviceCallbacks {
+
+
+ 27 selfAudioBLEClient =
this;
+
+
+
+
+ 33 bool begin(
const char *serverName,
int seconds) {
+
+ 35 ble_server_name = serverName;
+
+ 37 BLEDevice::init(
"client");
+
+
+
+ 41 BLEScan *pBLEScan = BLEDevice::getScan();
+ 42 pBLEScan->setAdvertisedDeviceCallbacks(
this);
+ 43 pBLEScan->setActiveScan(
true);
+ 44 pBLEScan->start(seconds);
+
+
+
+
+
+
+
+
+
+ 54 size_t readBytes(uint8_t *data,
size_t dataSize)
override {
+
+ 56 if (!is_client_connected || !is_client_set_up)
return 0;
+ 57 if (!ch01_char->canRead())
return 0;
+
+
+ 60 auto str = ch01_char->readValue();
+ 61 if (str.length() > 0){
+ 62 memcpy(data, str.c_str(), str.length());
+
+
+
+
+ 67 int available()
override {
return BLE_BUFFER_SIZE; }
+
+ 69 size_t write(
const uint8_t *data,
size_t dataSize)
override {
+
+ 71 if (!is_client_connected || !is_client_set_up)
return 0;
+ 72 if (ch02_char->canWrite()) {
+ 73 ch02_char->writeValue((uint8_t *)data, dataSize,
false);
+
+
+
+
+
+ 79 int availableForWrite()
override {
return BLE_BUFFER_SIZE; }
+
+ 81 virtual bool connected()
override {
return is_client_connected; }
+
+
+
+ 85 BLEClient *p_client =
nullptr;
+ 86 BLEAdvertising *p_advertising =
nullptr;
+ 87 BLERemoteService *p_remote_service =
nullptr;
+ 88 BLEAddress *p_server_address =
nullptr;
+ 89 BLERemoteCharacteristic *ch01_char =
nullptr;
+ 90 BLERemoteCharacteristic *ch02_char =
nullptr;
+ 91 BLERemoteCharacteristic *info_char =
nullptr;
+ 92 BLEAdvertisedDevice advertised_device;
+ 93 volatile bool is_client_connected =
false;
+ 94 bool is_client_set_up =
false;
+
+ 96 virtual void onConnect(BLEClient *pClient) {
+
+ 98 is_client_connected =
true;
+
+ 100 virtual void onDisconnect(BLEClient *pClient) {
+
+ 102 is_client_connected =
false;
+
+
+ 105 void writeAudioInfoCharacteristic(AudioInfo info)
override {
+
+
+ 108 info_char->writeValue((uint8_t *)&info,
sizeof(AudioInfo));
+
+
+
+ 112 void onResult(BLEAdvertisedDevice advertisedDevice)
override {
+
+
+ 115 if (advertisedDevice.getName() == ble_server_name) {
+
+ 117 advertised_device = advertisedDevice;
+
+ 119 advertised_device.getScan()->stop();
+
+
+
+ 123 LOGI(
"Device '%s' found: Connecting!",
+ 124 advertised_device.toString().c_str());
+
+
+
+
+
+ 130 static void notifyCallback(BLERemoteCharacteristic *pBLERemoteCharacteristic,
+ 131 uint8_t *pData,
size_t length,
bool isNotify) {
+
+ 133 if (pBLERemoteCharacteristic->getUUID().toString() ==
+ 134 selfAudioBLEClient->BLE_INFO_UUID) {
+ 135 selfAudioBLEClient->setAudioInfo(pData, length);
+
+
+
+ 139 bool setupBLEClient() {
+
+
+ 142 if (p_client ==
nullptr)
+ 143 p_client = BLEDevice::createClient();
- 145 if (ch01_char ==
nullptr) {
- 146 ch01_char = p_remote_service->getCharacteristic(BLE_CH1_UUID);
-
-
- 149 if (ch02_char ==
nullptr) {
- 150 ch02_char= p_remote_service->getCharacteristic(BLE_CH2_UUID);
-
-
- 153 if (is_audio_info_active && info_char ==
nullptr) {
- 154 info_char = p_remote_service->getCharacteristic(BLE_INFO_UUID);
- 155 info_char->registerForNotify(notifyCallback);
+
+ 146 p_client->setClientCallbacks(
this);
+
+
+ 149 LOGI(
"Connecting to %s ...",
+ 150 advertised_device.getAddress().toString().c_str());
+
+ 152 p_client->connect(&advertised_device);
+ 153 if (!p_client->isConnected()) {
+ 154 LOGE(
"connect failed");
+
- 157 is_client_connected =
true;
- 158 return is_client_connected;
-
-
-
-
-
-
+
+ 158 LOGI(
"Setting mtu to %d", max_transfer_size);
+ 159 p_client->setMTU(max_transfer_size);
+
+
+
+ 163 if (p_remote_service ==
nullptr) {
+ 164 p_remote_service = p_client->getService(BLE_SERIAL_SERVICE_UUID);
+ 165 if (p_remote_service ==
nullptr) {
+ 166 LOGE(
"Failed to find our service UUID: %s", BLE_SERIAL_SERVICE_UUID);
+
+
+
+
+ 171 if (ch01_char ==
nullptr) {
+ 172 ch01_char = p_remote_service->getCharacteristic(BLE_CH1_UUID);
+
+
+ 175 if (ch02_char ==
nullptr) {
+ 176 ch02_char = p_remote_service->getCharacteristic(BLE_CH2_UUID);
+
+
+ 179 if (is_audio_info_active && info_char ==
nullptr) {
+ 180 info_char = p_remote_service->getCharacteristic(BLE_INFO_UUID);
+ 181 info_char->registerForNotify(notifyCallback);
+
+ 183 LOGI(
"Connected to server: %s", is_client_connected ?
"true" :
"false");
+ 184 is_client_set_up =
true;
+ 185 return is_client_connected;
+
+
+
+
+
+
diff --git a/classaudio__tools_1_1_audio_b_l_e_client-members.html b/classaudio__tools_1_1_audio_b_l_e_client-members.html
index 4ffad39a4e..f22aad2af9 100644
--- a/classaudio__tools_1_1_audio_b_l_e_client-members.html
+++ b/classaudio__tools_1_1_audio_b_l_e_client-members.html
@@ -100,43 +100,46 @@
info_char (defined in AudioBLEClient) | AudioBLEClient | protected |
is_audio_info_active (defined in AudioBLEStream) | AudioBLEStream | protected |
is_client_connected (defined in AudioBLEClient) | AudioBLEClient | protected |
- is_framed (defined in AudioBLEStream) | AudioBLEStream | protected |
- is_started (defined in AudioBLEStream) | AudioBLEStream | protected |
- max_transfer_size (defined in AudioBLEStream) | AudioBLEStream | protected |
- not_supported(int out, const char *msg="") (defined in AudioStream) | AudioStream | inlineprotectedvirtual |
- notifyCallback(BLERemoteCharacteristic *pBLERemoteCharacteristic, uint8_t *pData, size_t length, bool isNotify) (defined in AudioBLEClient) | AudioBLEClient | inlineprotectedstatic |
- onResult(BLEAdvertisedDevice advertisedDevice) override (defined in AudioBLEClient) | AudioBLEClient | inlineprotected |
- operator bool() (defined in AudioBLEStream) | AudioBLEStream | inline |
- operator=(AudioBLEStream const &other)=delete (defined in AudioBLEStream) | AudioBLEStream | protected |
- operator=(AudioStream const &)=delete (defined in AudioStream) | AudioStream | |
- p_advertising (defined in AudioBLEClient) | AudioBLEClient | protected |
- p_client (defined in AudioBLEClient) | AudioBLEClient | protected |
- p_notify (defined in AudioStream) | AudioStream | protected |
- p_remote_service (defined in AudioBLEClient) | AudioBLEClient | protected |
- p_server_address (defined in AudioBLEClient) | AudioBLEClient | protected |
- readBytes(uint8_t *data, size_t dataSize) override (defined in AudioBLEClient) | AudioBLEClient | inlinevirtual |
- readSilence(uint8_t *buffer, size_t length) | AudioStream | inlinevirtual |
- refillReadBuffer() (defined in AudioStream) | AudioStream | inlineprotected |
- setAudioInfo(AudioInfo info) (defined in AudioBLEStream) | AudioBLEStream | inlinevirtual |
- setAudioInfo(const uint8_t *data, size_t size) (defined in AudioBLEStream) | AudioBLEStream | inlineprotectedvirtual |
- setAudioInfoActive(bool flag) (defined in AudioBLEStream) | AudioBLEStream | inline |
- setAudioInfoUUID(const char *uuid) (defined in AudioBLEStream) | AudioBLEStream | inline |
- setFramed(bool flag) (defined in AudioBLEStream) | AudioBLEStream | inline |
- setNotifyAudioChange(AudioInfoSupport &bi) override (defined in AudioStream) | AudioStream | inlinevirtual |
- setRxUUID(const char *uuid) (defined in AudioBLEStream) | AudioBLEStream | inline |
- setServiceUUID(const char *uuid) (defined in AudioBLEStream) | AudioBLEStream | inline |
- setTxUUID(const char *uuid) (defined in AudioBLEStream) | AudioBLEStream | inline |
- setupBLEClient() (defined in AudioBLEClient) | AudioBLEClient | inlineprotected |
- tmp_in (defined in AudioStream) | AudioStream | protected |
- tmp_out (defined in AudioStream) | AudioStream | protected |
- toInfo(const uint8_t *str) (defined in AudioBLEStream) | AudioBLEStream | inline |
- toStr(AudioInfo info) (defined in AudioBLEStream) | AudioBLEStream | inline |
- validate(AudioInfo &info) (defined in AudioInfoSupport) | AudioInfoSupport | inlinevirtual |
- write(const uint8_t *data, size_t dataSize) override (defined in AudioBLEClient) | AudioBLEClient | inlinevirtual |
- write(uint8_t ch) override (defined in AudioStream) | AudioStream | inlinevirtual |
- writeAudioInfoCharacteristic(AudioInfo info) override (defined in AudioBLEClient) | AudioBLEClient | inlineprotectedvirtual |
- writeSilence(size_t len) | AudioStream | inlinevirtual |
- ~AudioStream()=default (defined in AudioStream) | AudioStream | virtual |
+ is_client_set_up (defined in AudioBLEClient) | AudioBLEClient | protected |
+ is_framed (defined in AudioBLEStream) | AudioBLEStream | protected |
+ is_started (defined in AudioBLEStream) | AudioBLEStream | protected |
+ max_transfer_size (defined in AudioBLEStream) | AudioBLEStream | protected |
+ not_supported(int out, const char *msg="") (defined in AudioStream) | AudioStream | inlineprotectedvirtual |
+ notifyCallback(BLERemoteCharacteristic *pBLERemoteCharacteristic, uint8_t *pData, size_t length, bool isNotify) (defined in AudioBLEClient) | AudioBLEClient | inlineprotectedstatic |
+ onConnect(BLEClient *pClient) (defined in AudioBLEClient) | AudioBLEClient | inlineprotectedvirtual |
+ onDisconnect(BLEClient *pClient) (defined in AudioBLEClient) | AudioBLEClient | inlineprotectedvirtual |
+ onResult(BLEAdvertisedDevice advertisedDevice) override (defined in AudioBLEClient) | AudioBLEClient | inlineprotected |
+ operator bool() (defined in AudioBLEStream) | AudioBLEStream | inline |
+ operator=(AudioBLEStream const &other)=delete (defined in AudioBLEStream) | AudioBLEStream | protected |
+ operator=(AudioStream const &)=delete (defined in AudioStream) | AudioStream | |
+ p_advertising (defined in AudioBLEClient) | AudioBLEClient | protected |
+ p_client (defined in AudioBLEClient) | AudioBLEClient | protected |
+ p_notify (defined in AudioStream) | AudioStream | protected |
+ p_remote_service (defined in AudioBLEClient) | AudioBLEClient | protected |
+ p_server_address (defined in AudioBLEClient) | AudioBLEClient | protected |
+ readBytes(uint8_t *data, size_t dataSize) override (defined in AudioBLEClient) | AudioBLEClient | inlinevirtual |
+ readSilence(uint8_t *buffer, size_t length) | AudioStream | inlinevirtual |
+ refillReadBuffer() (defined in AudioStream) | AudioStream | inlineprotected |
+ setAudioInfo(AudioInfo info) (defined in AudioBLEStream) | AudioBLEStream | inlinevirtual |
+ setAudioInfo(const uint8_t *data, size_t size) (defined in AudioBLEStream) | AudioBLEStream | inlineprotectedvirtual |
+ setAudioInfoActive(bool flag) (defined in AudioBLEStream) | AudioBLEStream | inline |
+ setAudioInfoUUID(const char *uuid) (defined in AudioBLEStream) | AudioBLEStream | inline |
+ setFramed(bool flag) (defined in AudioBLEStream) | AudioBLEStream | inline |
+ setNotifyAudioChange(AudioInfoSupport &bi) override (defined in AudioStream) | AudioStream | inlinevirtual |
+ setRxUUID(const char *uuid) (defined in AudioBLEStream) | AudioBLEStream | inline |
+ setServiceUUID(const char *uuid) (defined in AudioBLEStream) | AudioBLEStream | inline |
+ setTxUUID(const char *uuid) (defined in AudioBLEStream) | AudioBLEStream | inline |
+ setupBLEClient() (defined in AudioBLEClient) | AudioBLEClient | inlineprotected |
+ tmp_in (defined in AudioStream) | AudioStream | protected |
+ tmp_out (defined in AudioStream) | AudioStream | protected |
+ toInfo(const uint8_t *str) (defined in AudioBLEStream) | AudioBLEStream | inline |
+ toStr(AudioInfo info) (defined in AudioBLEStream) | AudioBLEStream | inline |
+ validate(AudioInfo &info) (defined in AudioInfoSupport) | AudioInfoSupport | inlinevirtual |
+ write(const uint8_t *data, size_t dataSize) override (defined in AudioBLEClient) | AudioBLEClient | inlinevirtual |
+ write(uint8_t ch) override (defined in AudioStream) | AudioStream | inlinevirtual |
+ writeAudioInfoCharacteristic(AudioInfo info) override (defined in AudioBLEClient) | AudioBLEClient | inlineprotectedvirtual |
+ writeSilence(size_t len) | AudioStream | inlinevirtual |
+ ~AudioStream()=default (defined in AudioStream) | AudioStream | virtual |