Skip to content

Add BleCommandQueue to UniversalBlePeripheral - #288

Merged
fotiDim merged 6 commits into
mainfrom
add-queue-to-universal-ble-peripheral
Aug 24, 2026
Merged

Add BleCommandQueue to UniversalBlePeripheral#288
fotiDim merged 6 commits into
mainfrom
add-queue-to-universal-ble-peripheral

Conversation

@fotiDim

@fotiDim fotiDim commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

This PR adds command queuing support to peripheral mode.

@fotiDim
fotiDim force-pushed the add-queue-to-universal-ble-peripheral branch from e9f6277 to c0d6b28 Compare August 24, 2026 11:13
@navidecklabs
navidecklabs requested a lite review from Copilot August 24, 2026 11:39
@fotiDim
fotiDim requested a review from rohitsangwan01 August 24, 2026 11:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.) with BleCommandQueue and expose queueType, timeout, clearQueue, and onQueueUpdate.
  • 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 on callLog.
      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 calling clearQueue() 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.

Comment thread test/ble_peripheral_command_queue_test.dart Outdated
@fotiDim
fotiDim merged commit 27fc7d1 into main Aug 24, 2026
2 checks passed
@fotiDim
fotiDim deleted the add-queue-to-universal-ble-peripheral branch August 24, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants