Implement queue (#11)
* Implement queue * Enable queue by default, remove queue from web and update readme * Rename useQueue to queuesRequests * Rename queuesRequests and improve readme * Rename _executeMethod and improve readme * Rename to _isQueueEnabled --------- Co-authored-by: Foti Dim <fdimanidis@gmail.com>
This commit is contained in:
@@ -14,6 +14,8 @@ A cross-platform (Android/iOS/macOS/Windows/Linux/Web) Bluetooth Low Energy (BLE
|
||||
- [Reading & Writing data](#reading--writing-data)
|
||||
- [Pairing](#pairing)
|
||||
- [Bluetooth Availability](#bluetooth-availability)
|
||||
- [Command Queue](#command-queue)
|
||||
- [Timeout](#timeout)
|
||||
|
||||
### API Support Matrix
|
||||
|
||||
@@ -147,6 +149,28 @@ UniversalBle.onAvailabilityChange = (state) {
|
||||
UniversalBle.enableBluetooth();
|
||||
```
|
||||
|
||||
## Command Queue
|
||||
|
||||
By default, all commands will be executed in a queue. Each command will wait for the previous one to finish.
|
||||
Some platforms (e.g. Android) will fail to send consecutive commands without any delay between them so it is a good idea to leave to queue enabled.
|
||||
|
||||
```dart
|
||||
// Disable queue
|
||||
UniversalBle.queuesCommands = false;
|
||||
```
|
||||
|
||||
## Timeout
|
||||
|
||||
By default, all commands have a timeout of 10 seconds.
|
||||
|
||||
```dart
|
||||
// Change timeout
|
||||
UniversalBle.timeout = const Duration(seconds: 10);
|
||||
|
||||
// Disable timeout
|
||||
UniversalBle.timeout = null;
|
||||
```
|
||||
|
||||
## Platform-Specific Setup
|
||||
|
||||
### Android
|
||||
@@ -191,7 +215,7 @@ UniversalBle.startScan(
|
||||
```dart
|
||||
// Create a class that extends UniversalBlePlatform
|
||||
class UniversalBleMock extends UniversalBlePlatform {
|
||||
// Implement all methods
|
||||
// Implement all commands
|
||||
}
|
||||
|
||||
UniversalBle.setInstance(UniversalBleMock());
|
||||
|
||||
Reference in New Issue
Block a user