Blue-Falcon

Kotlin Multiplatform BLE library for iOS, Android, macos, windows and javascript

View the Project on GitHub Reedyuk/blue-falcon

ADR 0006: BLE Device Broadcast Plugin

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.

Context

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:

  1. A platform-agnostic interface (BluetoothAdvertiser) that abstracts peripheral-role advertising and a local GATT server.
  2. Platform implementations on Android (using BluetoothLeAdvertiser + BluetoothGattServer) and iOS/macOS (using CBPeripheralManager).
  3. A broadcast plugin (blue-falcon-plugin-broadcast) that converts a DeviceClone into an AdvertiseConfig and drives the BluetoothAdvertiser.

Platform constraints

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.

Decision

We will introduce a peripheral-role advertising abstraction to Blue Falcon, implemented in three layers:

Layer 1 — Core types (:core)

New types added to library/core/src/commonMain/:

Each engine optionally exposes fun createAdvertiser(): BluetoothAdvertiser. Engines that do not support advertising return a NoOpBluetoothAdvertiser.

Layer 2 — Platform engines

Layer 3 — Broadcast plugin (:plugins:broadcast)

DeviceBroadcastPlugin takes a DeviceClone and a BluetoothAdvertiser and:

  1. Converts DeviceClone → AdvertiseConfig (mapping services, characteristics, descriptors and their values).
  2. Calls advertiser.startAdvertising(config).
  3. Handles incoming characteristicWriteRequests by updating state.
  4. Exposes a broadcastState: StateFlow<BroadcastState> for the UI.

Consequences

Positive

Negative

Neutral

Alternatives Considered

Alternative 1: Merge broadcast into the clone plugin

Add startBroadcast() directly to DeviceClonePlugin.

Pros:

Cons:

Why not chosen: Violates single-responsibility; broadcast is a distinct concern from data capture.

Alternative 2: Expose advertising via BlueFalconEngine directly

Add 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.

Alternative 3: Use a third-party library (e.g. Kable for peripheral role)

Pros:

Cons:

Why not chosen: The required functionality is small enough to implement directly and gives us full control.

Implementation Notes

  1. :core changes are additive and non-breaking.
  2. Each engine adds createAdvertiser() as an extension on the engine class (not part of BlueFalconEngine) to avoid forcing all engines to implement it.
  3. The example app adds a “Broadcast” toggle to the existing clone result dialog.
  4. Android BLUETOOTH_ADVERTISE permission must be added to the example AndroidManifest.xml.

References