Skip to content

Commit

Permalink
Add hasClient for BluetoothSerial (#1183)
Browse files Browse the repository at this point in the history
* Add hasClient for BluetoothSerial

* Add SPP_TAG
  • Loading branch information
copercini authored and me-no-dev committed Mar 9, 2018
1 parent e9ee0ab commit 3a4ec66
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libraries/BluetoothSerial/keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ BluetoothSerial KEYWORD1
#######################################

SerialBT KEYWORD2

hasClient KEYWORD2

#######################################
# Constants (LITERAL1)
Expand Down
9 changes: 9 additions & 0 deletions libraries/BluetoothSerial/src/BluetoothSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()){
Expand Down
1 change: 1 addition & 0 deletions libraries/BluetoothSerial/src/BluetoothSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3a4ec66

Please sign in to comment.