From 3a4ec66d41615cbb1c3e830cb6e761cdc4cca9d3 Mon Sep 17 00:00:00 2001 From: copercini Date: Fri, 9 Mar 2018 07:16:18 -0300 Subject: [PATCH] Add hasClient for BluetoothSerial (#1183) * Add hasClient for BluetoothSerial * Add SPP_TAG --- libraries/BluetoothSerial/keywords.txt | 2 +- libraries/BluetoothSerial/src/BluetoothSerial.cpp | 9 +++++++++ libraries/BluetoothSerial/src/BluetoothSerial.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libraries/BluetoothSerial/keywords.txt b/libraries/BluetoothSerial/keywords.txt index 25c4c7e5..563e35d7 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 eff913fe..49cb7cbc 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; @@ -188,6 +189,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 12281ed7..128bcfb3 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);