Skip to content

Commit 3a4ec66

Browse files
copercinime-no-dev
authored andcommitted
Add hasClient for BluetoothSerial (espressif#1183)
* Add hasClient for BluetoothSerial * Add SPP_TAG
1 parent e9ee0ab commit 3a4ec66

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

libraries/BluetoothSerial/keywords.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ BluetoothSerial KEYWORD1
1919
#######################################
2020

2121
SerialBT KEYWORD2
22-
22+
hasClient KEYWORD2
2323

2424
#######################################
2525
# Constants (LITERAL1)

libraries/BluetoothSerial/src/BluetoothSerial.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "esp_spp_api.h"
3030

3131
#define SPP_SERVER_NAME "ESP32_SPP_SERVER"
32+
#define SPP_TAG "BluetoothSerial"
3233

3334
#define QUEUE_SIZE 256
3435
uint32_t client;
@@ -188,6 +189,14 @@ int BluetoothSerial::peek(void)
188189
return -1;
189190
}
190191

192+
bool BluetoothSerial::hasClient(void)
193+
{
194+
if (client)
195+
return true;
196+
197+
return false;
198+
}
199+
191200
int BluetoothSerial::read(void)
192201
{
193202
if (available()){

libraries/BluetoothSerial/src/BluetoothSerial.h

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class BluetoothSerial: public Stream
4040
bool begin(String localName=String());
4141
int available(void);
4242
int peek(void);
43+
bool hasClient(void);
4344
int read(void);
4445
size_t write(uint8_t c);
4546
size_t write(const uint8_t *buffer, size_t size);

0 commit comments

Comments
 (0)