Skip to content

Commit 84dec8c

Browse files
committed
Make stream class MCU and OS agnostic
1 parent 853f812 commit 84dec8c

8 files changed

Lines changed: 402 additions & 370 deletions

File tree

examples/NimBLE_Stream_Client/NimBLE_Stream_Client.ino

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,6 @@ bool connectToServer() {
124124
return false;
125125
}
126126

127-
/** Start the stream (begins internal buffers and tasks) */
128-
if (!bleStream.begin()) {
129-
Serial.println("Failed to start BLE stream!");
130-
bleStream.deinit();
131-
pClient->disconnect();
132-
return false;
133-
}
134-
135127
Serial.println("BLE Stream initialized successfully!");
136128
connected = true;
137129
return true;

examples/NimBLE_Stream_Echo/NimBLE_Stream_Echo.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ void setup() {
3030
NimBLEUUID(uint16_t(0xfeed)), // Characteristic UUID
3131
true, // canWrite
3232
false); // secure
33-
bleStream.begin();
3433

3534
// Start advertising
3635
NimBLEDevice::getAdvertising()->start();
@@ -39,7 +38,7 @@ void setup() {
3938

4039
void loop() {
4140
// Echo any received data back to the client
42-
if (bleStream.hasSubscriber() && bleStream.available()) {
41+
if (bleStream.ready() && bleStream.available()) {
4342
Serial.print("Echo: ");
4443
while (bleStream.available()) {
4544
char c = bleStream.read();

examples/NimBLE_Stream_Server/NimBLE_Stream_Server.ino

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ void setup() {
7171
return;
7272
}
7373

74-
/** Start the stream (begins internal buffers and tasks) */
75-
if (!bleStream.begin()) {
76-
Serial.println("Failed to start BLE stream!");
77-
return;
78-
}
79-
8074
/**
8175
* Create advertising instance and add service UUID
8276
* This makes the stream service discoverable
@@ -94,8 +88,8 @@ void setup() {
9488

9589
void loop() {
9690
// Check if a client is subscribed (connected and listening)
97-
if (bleStream.hasSubscriber()) {
98-
91+
if (bleStream.ready()) {
92+
9993
// Send a message every 2 seconds using Stream methods
10094
static unsigned long lastSend = 0;
10195
if (millis() - lastSend > 2000) {

examples/STREAM_EXAMPLES.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ Both server and client support configuration before calling `begin()`:
110110
```cpp
111111
bleStream.setTxBufSize(2048); // TX buffer size
112112
bleStream.setRxBufSize(2048); // RX buffer size
113-
bleStream.setTxTaskStackSize(4096); // Task stack size
114-
bleStream.setTxTaskPriority(1); // Task priority
115113
```
116114

117115
## Compatibility

0 commit comments

Comments
 (0)