Add BleCommandQueue to UniversalBlePeripheral - #288
Merged
Conversation
fotiDim
force-pushed
the
add-queue-to-universal-ble-peripheral
branch
from
August 24, 2026 11:13
e9f6277 to
c0d6b28
Compare
rohitsangwan01
approved these changes
Aug 24, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds command-queuing support to UniversalBlePeripheral so peripheral-mode operations can be serialized globally, per-device, or run in parallel—mirroring the existing central-side UniversalBle queue behavior.
Changes:
- Wrap peripheral commands (
addService,startAdvertising,updateCharacteristicValue, etc.) withBleCommandQueueand exposequeueType,timeout,clearQueue, andonQueueUpdate. - Add unit tests covering global vs per-device queuing and queue cancellation.
- Update iOS/macOS and Android peripheral plugins for case-insensitive deviceId lookups and add iOS/macOS handling for CoreBluetooth transmit-queue exhaustion.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/ble_peripheral_command_queue_test.dart | Adds tests validating peripheral command queue serialization, per-device isolation, and cancellation behavior. |
| README.md | Documents the new peripheral command queue configuration and usage patterns. |
| lib/src/universal_ble_peripheral.dart | Introduces BleCommandQueue integration and new queue configuration surface for peripheral APIs. |
| darwin/universal_ble/Sources/universal_ble/UniversalBlePeripheralPlugin.swift | Updates iOS/macOS peripheral notify path (including queue-full failure handling) and deviceId lookup behavior. |
| darwin/universal_ble/Sources/universal_ble/UniversalBlePeripheralExtensions.swift | Extends peripheral error type to support new failure mode. |
| CHANGELOG.md | Notes the new peripheral queue feature and iOS/macOS transmit queue handling. |
| android/src/main/kotlin/com/navideck/universal_ble/UniversalBlePeripheralPlugin.kt | Updates Android peripheral notify target selection with case-insensitive deviceId lookup. |
Suppressed comments (2)
test/ble_peripheral_command_queue_test.dart:107
- This uses a fixed 10ms delay to wait for queued work, which can be timing-dependent and flaky. Prefer
pumpEventQueue()to flush microtasks/event-queue deterministically before asserting oncallLog.
await Future<void>.delayed(const Duration(milliseconds: 10));
test/ble_peripheral_command_queue_test.dart:149
- This fixed-duration delay makes the test depend on wall-clock scheduling; on loaded environments it can race and fail. Use
pumpEventQueue()to allow the queued command to start before callingclearQueue()and asserting cancellation.
await Future<void>.delayed(const Duration(milliseconds: 10));
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds command queuing support to peripheral mode.