Skip to content

Commit 881279f

Browse files
committed
Update stream client example
1 parent 32fa29f commit 881279f

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

examples/NimBLE_Stream_Client/NimBLE_Stream_Client.ino

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct RxOverflowStats {
2929
};
3030

3131
RxOverflowStats g_rxOverflowStats;
32+
uint32_t scanTime = 5000; // Scan duration in milliseconds
3233

3334
NimBLEStream::RxOverflowAction onRxOverflow(const uint8_t* data, size_t len, void* userArg) {
3435
auto* stats = static_cast<RxOverflowStats*>(userArg);
@@ -66,7 +67,7 @@ class ScanCallbacks : public NimBLEScanCallbacks {
6667
Serial.println("Scan ended");
6768
if (!doConnect && !connected) {
6869
Serial.println("Server not found, restarting scan...");
69-
NimBLEDevice::getScan()->start(5, false, true);
70+
NimBLEDevice::getScan()->start(scanTime, false, true);
7071
}
7172
}
7273
} scanCallbacks;
@@ -86,7 +87,7 @@ class ClientCallbacks : public NimBLEClientCallbacks {
8687

8788
// Restart scanning
8889
Serial.println("Restarting scan...");
89-
NimBLEDevice::getScan()->start(5, false, true);
90+
NimBLEDevice::getScan()->start(scanTime, false, true);
9091
}
9192
} clientCallbacks;
9293

@@ -162,13 +163,11 @@ void setup() {
162163
*/
163164
NimBLEScan* pScan = NimBLEDevice::getScan();
164165
pScan->setScanCallbacks(&scanCallbacks, false);
165-
pScan->setInterval(100);
166-
pScan->setWindow(99);
167166
pScan->setActiveScan(true);
168167

169168
/** Start scanning for the server */
170169
Serial.println("Scanning for BLE Stream Server...");
171-
pScan->start(5, false, true);
170+
pScan->start(scanTime, false, true);
172171
}
173172

174173
void loop() {
@@ -188,7 +187,7 @@ void loop() {
188187
} else {
189188
Serial.println("Failed to connect to server, restarting scan...");
190189
pServerDevice = nullptr;
191-
NimBLEDevice::getScan()->start(5, false, true);
190+
NimBLEDevice::getScan()->start(scanTime, false, true);
192191
}
193192
}
194193

0 commit comments

Comments
 (0)