Kotlin Multiplatform BLE library for iOS, Android, macos, windows and javascript
Status: Accepted
Date: 2026-05-15
Deciders: Andrew Reed
Technical Story: After ADR 0005 introduced device cloning (capturing a remote peripheral’s GATT tree and advertisement data), a natural extension is to replay that captured profile — advertising as the cloned device and serving its characteristic values to connecting centrals.
The clone plugin (ADR 0005) produces a DeviceClone value containing the full GATT service tree, characteristic values, descriptor values, advertisement metadata (local name, service UUIDs, manufacturer data), and peripheral metadata (RSSI, MTU, platform).
Currently Blue Falcon has no peripheral/server-role BLE capability. All engines implement only the central (client) role via BlueFalconEngine. Adding broadcast capability requires:
BluetoothAdvertiser) that abstracts peripheral-role advertising and a local GATT server.BluetoothLeAdvertiser + BluetoothGattServer) and iOS/macOS (using CBPeripheralManager).blue-falcon-plugin-broadcast) that converts a DeviceClone into an AdvertiseConfig and drives the BluetoothAdvertiser.| Platform | Advertising | GATT server | Manufacturer data | MAC spoof |
|---|---|---|---|---|
| Android API 21+ | ✅ BluetoothLeAdvertiser |
✅ BluetoothGattServer |
✅ | ❌ (randomised ≥ API 23) |
| iOS (foreground) | ⚠️ CBPeripheralManager — only local name + service UUIDs allowed |
✅ | ❌ | ❌ |
| iOS (background) | ⚠️ service UUIDs only | ✅ | ❌ | ❌ |
| macOS | ✅ full advertisement packet | ✅ | ✅ | ❌ |
| Windows | ⚠️ BluetoothLEAdvertisementPublisher only, no stable GATT server API |
❌ | ✅ | ❌ |
MAC address spoofing is not possible on any modern platform; all other aspects of the cloned profile can be replayed.
We will introduce a peripheral-role advertising abstraction to Blue Falcon, implemented in three layers:
:core)New types added to library/core/src/commonMain/:
BluetoothAdvertiser — interface with startAdvertising(AdvertiseConfig), stopAdvertising(), updateCharacteristicValue(), and reactive flows state: StateFlow<AdvertiserState> and characteristicWriteRequests: SharedFlow<CharacteristicWriteRequest>.AdvertiseConfig — advertising configuration: local name, service UUIDs, manufacturer data, and a list of GattServiceConfig.GattServiceConfig / GattCharacteristicConfig / GattDescriptorConfig — GATT server tree definition.CharacteristicProperty — enum of READ, WRITE, WRITE_NO_RESPONSE, NOTIFY, INDICATE.AdvertiserState — enum of Idle, Advertising, Error.CharacteristicWriteRequest — event emitted when a central writes to a hosted characteristic.Each engine optionally exposes fun createAdvertiser(): BluetoothAdvertiser. Engines that do not support advertising return a NoOpBluetoothAdvertiser.
:engines:android — AndroidBluetoothAdvertiser using BluetoothLeAdvertiser + BluetoothGattServer.:engines:ios — IosBluetoothAdvertiser using CBPeripheralManager.:engines:macos — MacosBluetoothAdvertiser using CBPeripheralManager.:engines:windows — WindowsBluetoothAdvertiser advertising-only (no GATT server); returns UnsupportedOperationException on updateCharacteristicValue.:plugins:broadcast)DeviceBroadcastPlugin takes a DeviceClone and a BluetoothAdvertiser and:
DeviceClone → AdvertiseConfig (mapping services, characteristics, descriptors and their values).advertiser.startAdvertising(config).characteristicWriteRequests by updating state.broadcastState: StateFlow<BroadcastState> for the UI.BluetoothAdvertiser interface, not on any engine directly.createAdvertiser() on each engine is optional and clearly documented per-platform.BLUETOOTH_ADVERTISE on API 31+).NoOpBluetoothAdvertiser is provided for platforms/contexts where advertising is unsupported, allowing the broadcast plugin to compile everywhere.BluetoothAdvertiser implementation, not in the plugin — the plugin updates values via updateCharacteristicValue().Add startBroadcast() directly to DeviceClonePlugin.
Pros:
Cons:
Why not chosen: Violates single-responsibility; broadcast is a distinct concern from data capture.
BlueFalconEngine directlyAdd startAdvertising() methods alongside the existing central-role methods.
Pros:
Cons:
Why not chosen: The central and peripheral roles are fundamentally different; keeping them separate mirrors the underlying platform APIs and is cleaner.
Pros:
Cons:
Why not chosen: The required functionality is small enough to implement directly and gives us full control.
:core changes are additive and non-breaking.createAdvertiser() as an extension on the engine class (not part of BlueFalconEngine) to avoid forcing all engines to implement it.BLUETOOTH_ADVERTISE permission must be added to the example AndroidManifest.xml.