Files
swiftcontrol/lib/bluetooth/ble_command_queue_config.dart
Jonas Acker f731360c80 feat(ble): migrate to universal_ble 3.1 from pub.dev
- Drop the universal_ble git fork (app, prop_public) for ^3.1.0.
- iOS/macOS: pass AppleConnectionOptions (notify on connection,
  disconnection and notification) on every connect via a shared
  bleConnectionPlatformConfig(), replacing what the fork forced natively,
  so a backgrounded app keeps being woken.
- Adapt onConnectionChange / onValueChange to the new single-object
  callbacks (BleConnectionChange / BleCharacteristicValue).
- RoutingBlePlatform / FakeUniversalBlePlatform: new platform interface
  members (descriptor read/write, connect/discover platformConfig),
  forward the new connection error codes and connection-parameter
  changes, case-insensitive peripheral lookup for canonical lower-case ids.
- Pin the command queues instead of the new QueueType.auto default:
  per-device for central (keeps per-device ordering, no cross-device
  head-of-line blocking), none for peripheral (as before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 19:35:19 +02:00

23 lines
1.1 KiB
Dart

import 'package:universal_ble/universal_ble.dart';
/// Pins how universal_ble schedules GATT commands, instead of relying on the
/// 3.x default (`QueueType.auto`: per-device on Android/Web/Linux, fully
/// parallel on iOS/macOS/Windows).
///
/// Central role: [QueueType.perDevice] on every platform. Each device's
/// protocol code (handshakes, subscribe-then-write sequences, fire-and-forget
/// shift/haptic writes) was written against one GATT operation in flight per
/// device at a time — what the 2.x global queue guaranteed — so that ordering
/// is kept everywhere. Unlike the old global queue, a slow or stalled command
/// on one device (e.g. a trainer write waiting for its timeout) no longer holds
/// up the controllers.
///
/// Peripheral role (the emulated trainer/controller BikeControl advertises):
/// [QueueType.none], i.e. notifications are handed to the platform directly,
/// as before the peripheral queue existed. Its callers already pace and order
/// their notifications.
void configureBleCommandQueues() {
UniversalBle.queueType = QueueType.perDevice;
UniversalBlePeripheral.queueType = QueueType.none;
}