Skip to content

Add hasClient for BluetoothSerial #1183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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