Kotlin Multiplatform BLE library for iOS, Android, macos, windows and javascript
Status: ✅ Implemented
Date: 2026-05-15
Deciders: Andrew Reed, Community Contributors
Technical Story: Feature request to clone a BLE device — capturing advertisement data, services, characteristics, and descriptors into a portable snapshot that can be replayed or used for testing/simulation.
During development and testing of BLE applications, engineers frequently need to:
Currently, there is no built-in way to capture a full device profile (advertisement info + GATT table) through Blue Falcon. Developers resort to manual note-taking, platform-specific tools (nRF Connect, LightBlue), or custom one-off scripts.
With the plugin architecture from ADR 0002, we can provide this as an optional plugin that hooks into discovery, connection, and characteristic read events to build a complete device clone.
A BLE device clone in this context is a read-only snapshot containing:
This is not about spoofing or impersonating a BLE device on the radio layer — it is a data capture for development, testing, and documentation purposes.
We will implement a BLE device cloning plugin (blue-falcon-plugin-clone) that captures a complete snapshot of a connected BLE peripheral’s advertisement data and GATT table.
The plugin will:
DeviceClone data model that can be exported to JSON and re-imported.CloneCallback interface for progress reporting (useful when reading many characteristics sequentially).@Serializable
data class DeviceClone(
val peripheralId: String,
val peripheralName: String?,
val capturedAt: String, // ISO-8601 timestamp
val platform: String,
val rssi: Float?,
val mtuSize: Int?,
val advertisement: AdvertisementClone,
val services: List<ServiceClone>
)
@Serializable
data class AdvertisementClone(
val localName: String?,
val manufacturerData: ByteArray?,
val serviceUuids: List<String>,
val txPowerLevel: Int?
)
@Serializable
data class ServiceClone(
val uuid: String,
val name: String?,
val characteristics: List<CharacteristicClone>
)
@Serializable
data class CharacteristicClone(
val uuid: String,
val name: String?,
val properties: List<String>, // e.g. ["read", "write", "notify"]
val value: ByteArray?,
val descriptors: List<DescriptorClone>
)
@Serializable
data class DescriptorClone(
val uuid: String,
val value: ByteArray?
)
class DeviceClonePlugin(
private val config: CloneConfig = CloneConfig()
) : BlueFalconPlugin {
suspend fun cloneDevice(peripheral: BluetoothPeripheral): DeviceClone
fun exportToJson(clone: DeviceClone): String
fun importFromJson(json: String): DeviceClone
}
data class CloneConfig(
val readCharacteristicValues: Boolean = true,
val readDescriptorValues: Boolean = true,
val includeAdvertisementData: Boolean = true,
val readTimeoutMs: Long = 5000,
val callback: CloneCallback? = null
)
interface CloneCallback {
fun onCloneProgress(current: Int, total: Int, message: String)
fun onCloneComplete(clone: DeviceClone)
fun onCloneError(error: Throwable)
}
null values.expect/actual helpers.dev.bluefalcon:blue-falcon-plugin-clonekotlinx.serialization (already a common Kotlin Multiplatform dependency)Add cloning directly to the core BlueFalcon class.
Pros:
Cons:
kotlinx.serialization as a core dependencyWhy not chosen: The plugin architecture exists precisely for optional features like this.
Simply dump raw platform-specific GATT data to a log or text format.
Pros:
Cons:
Why not chosen: A structured, serializable data model is essential for the use cases (testing, sharing, future simulation).
Recommend users use nRF Connect, LightBlue, or similar platform tools.
Pros:
Cons:
Why not chosen: Integration with Blue Falcon’s plugin system enables programmatic use within applications, CI pipelines, and test frameworks.
library/plugins/clone/kotlinx.serialization for JSON import/exportcloneDevice() function requires the peripheral to be connected with services discoveredonPeripheralDiscovered plugin event to cache scan resultsexpect/actual helper or an extension on BluetoothCharacteristicDeviceClone data to simulate a peripheral for unit tests