From a7c3a4705971555f5009dac779f7f49fd236008b Mon Sep 17 00:00:00 2001 From: copercini Date: Mon, 5 Mar 2018 20:42:46 -0300 Subject: [PATCH 1/2] Add hasClient for BluetoothSerial --- libraries/BluetoothSerial/keywords.txt | 2 +- libraries/BluetoothSerial/src/BluetoothSerial.cpp | 8 ++++++++ libraries/BluetoothSerial/src/BluetoothSerial.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libraries/BluetoothSerial/keywords.txt b/libraries/BluetoothSerial/keywords.txt index 25c4c7e5a33..563e35d7933 100644 --- a/libraries/BluetoothSerial/keywords.txt +++ b/libraries/BluetoothSerial/keywords.txt @@ -19,7 +19,7 @@ BluetoothSerial KEYWORD1 ####################################### SerialBT KEYWORD2 - +hasClient KEYWORD2 ####################################### # Constants (LITERAL1) diff --git a/libraries/BluetoothSerial/src/BluetoothSerial.cpp b/libraries/BluetoothSerial/src/BluetoothSerial.cpp index eff913fee98..5be7dd8e456 100644 --- a/libraries/BluetoothSerial/src/BluetoothSerial.cpp +++ b/libraries/BluetoothSerial/src/BluetoothSerial.cpp @@ -188,6 +188,14 @@ int BluetoothSerial::peek(void) return -1; } +bool BluetoothSerial::hasClient(void) +{ + if (client) + return true; + + return false; +} + int BluetoothSerial::read(void) { if (available()){ diff --git a/libraries/BluetoothSerial/src/BluetoothSerial.h b/libraries/BluetoothSerial/src/BluetoothSerial.h index 12281ed7123..128bcfb3bc9 100644 --- a/libraries/BluetoothSerial/src/BluetoothSerial.h +++ b/libraries/BluetoothSerial/src/BluetoothSerial.h @@ -40,6 +40,7 @@ class BluetoothSerial: public Stream bool begin(String localName=String()); int available(void); int peek(void); + bool hasClient(void); int read(void); size_t write(uint8_t c); size_t write(const uint8_t *buffer, size_t size); From d511b3cd7c659f02e481fe1f3d84d8bcb8d67dd1 Mon Sep 17 00:00:00 2001 From: copercini Date: Tue, 6 Mar 2018 20:33:03 -0300 Subject: [PATCH 2/2] Add SPP_TAG --- libraries/BluetoothSerial/src/BluetoothSerial.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/BluetoothSerial/src/BluetoothSerial.cpp b/libraries/BluetoothSerial/src/BluetoothSerial.cpp index 5be7dd8e456..49cb7cbc568 100644 --- a/libraries/BluetoothSerial/src/BluetoothSerial.cpp +++ b/libraries/BluetoothSerial/src/BluetoothSerial.cpp @@ -29,6 +29,7 @@ #include "esp_spp_api.h" #define SPP_SERVER_NAME "ESP32_SPP_SERVER" +#define SPP_TAG "BluetoothSerial" #define QUEUE_SIZE 256 uint32_t client;