Blue-Falcon

June 3, 2026 ยท View on GitHub

CI Maven Central Kotlin License

Android iOS macOS Raspberry Pi JavaScript Windows

A Bluetooth Low Energy (BLE) Kotlin Multiplatform library for iOS, Android, MacOS, Raspberry Pi, Windows, and JavaScript.

Blue Falcon provides a unified API for Bluetooth LE operations across all platforms. Each platform implementation compiles to native code, ensuring optimal performance and seamless integration with platform-specific APIs.

๐ŸŽ‰ Version 3.0+ introduces a plugin-based engine architecture inspired by Ktor, enabling extensibility. The 2.x API is still available via a compatibility layer โ€” see the Migration Guide.

โœจ Features

  • ๐Ÿ”Œ Plugin Architecture - Extensible engine system with official and community plugins
  • ๐Ÿ“ฑ Cross-Platform - Single API for iOS, Android, macOS, JavaScript, Windows, and Raspberry Pi
  • ๐Ÿ”„ Legacy Support - 2.x API available via compatibility layer (see Migration Guide)
  • โšก Native Performance - Compiles to platform-native code (Obj-C, JVM, JS, etc.)
  • ๐Ÿ”ง Flexible APIs - Choose between Flow-based reactive API or delegate callbacks
  • ๐ŸŽฏ Type-Safe - Full Kotlin type safety across all platforms

๐Ÿ“ฆ Installation

Upgrading from 2.x? See the Migration Guide โ€” most apps require zero code changes.

Core + Engine

commonMain.dependencies {
    implementation("dev.bluefalcon:blue-falcon-core:3.4.2")
}

// Add platform-specific engines
androidMain.dependencies {
    implementation("dev.bluefalcon:blue-falcon-engine-android:3.4.2")
}

iosMain.dependencies {
    implementation("dev.bluefalcon:blue-falcon-engine-ios:3.4.2")
}

Optional Plugins

commonMain.dependencies {
    // Logging support
    implementation("dev.bluefalcon:blue-falcon-plugin-logging:3.4.2")
    
    // Automatic retry with exponential backoff
    implementation("dev.bluefalcon:blue-falcon-plugin-retry:3.4.2")
    
    // Service/characteristic caching
    implementation("dev.bluefalcon:blue-falcon-plugin-caching:3.4.2")
}

๐Ÿš€ Quick Start

import dev.bluefalcon.core.*
import dev.bluefalcon.plugins.logging.*

// Configure with DSL
val blueFalcon = BlueFalcon {
    engine = AndroidEngine(context)  // or iOSEngine(), macOSEngine(), etc.
    
    install(LoggingPlugin) {
        level = LogLevel.DEBUG
    }
    
    install(RetryPlugin) {
        maxAttempts = 3
        initialDelay = 500
    }
}

// Reactive Flow API
launch {
    blueFalcon.peripherals.collect { devices ->
        devices.forEach { device ->
            println("Device: ${device.name}")
        }
    }
}

// Start scanning
blueFalcon.scan()

๐Ÿ“š Documentation

Architecture

  • ADR 0001 - Windows Platform Support
  • ADR 0002 - Plugin-Based Engine Architecture

๐ŸŽฏ Platform Support

PlatformEngine ModuleStatusNotes
Androidblue-falcon-engine-androidโœ… StableFull BLE support including L2CAP, bonding
iOSblue-falcon-engine-iosโœ… StableCoreBluetooth wrapper
macOSblue-falcon-engine-macosโœ… StableCoreBluetooth wrapper
JavaScriptblue-falcon-engine-jsโœ… StableWeb Bluetooth API
Windowsblue-falcon-engine-windowsโœ… StableWinRT via JNI (Windows 10 1803+)
Raspberry Piblue-falcon-engine-rpiโœ… StableBlessed library (BlueZ)

Platform Requirements

Android

  • Minimum SDK: 24 (Android 7.0)
  • Target SDK: 33 (Android 13)

iOS

  • Minimum: iOS 13.0+
  • Xcode 14.0+

macOS

  • Minimum: macOS 10.15+

JavaScript

  • Modern browsers with Web Bluetooth support
  • HTTPS required (security policy)

Windows

  • Windows 10 version 1803 (April 2018 Update) or later
  • JDK 11+
Building bluefalcon-windows.dll (from source)

If you are building Blue Falcon's Windows implementation from source, build the native DLL with CMake:

cd library\src\windowsMain\cpp
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -A x64
cmake --build . --config Release

The resulting bluefalcon-windows.dll is generated in the Release directory. Copy it to your Java library path or to library/src/windowsMain/resources/.

For full Windows setup and troubleshooting, see:

  • library/src/windowsMain/WINDOWS.md
  • library/src/windowsMain/cpp/README.md

Raspberry Pi

  • Linux with BlueZ 5.0+
  • JDK 11+

๐Ÿ—๏ธ Architecture

Blue Falcon 3.0 uses a three-layer architecture:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Your Application Code           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Core (Interfaces + Plugin System)      โ”‚
โ”‚  โ€ข BlueFalcon API                        โ”‚
โ”‚  โ€ข Plugin Registry                       โ”‚
โ”‚  โ€ข Type Definitions                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Platform Engines (6 implementations)   โ”‚
โ”‚  โ€ข AndroidEngine                         โ”‚
โ”‚  โ€ข iOSEngine, macOSEngine               โ”‚
โ”‚  โ€ข JSEngine                              โ”‚
โ”‚  โ€ข WindowsEngine                         โ”‚
โ”‚  โ€ข RPiEngine                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Native Platform APIs                    โ”‚
โ”‚  โ€ข Android Bluetooth                     โ”‚
โ”‚  โ€ข CoreBluetooth (iOS/macOS)            โ”‚
โ”‚  โ€ข Web Bluetooth                         โ”‚
โ”‚  โ€ข Windows WinRT                         โ”‚
โ”‚  โ€ข BlueZ (Linux)                         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Official Plugins

  • LoggingPlugin - Configurable logging with custom loggers
  • RetryPlugin - Automatic retry with exponential backoff
  • CachingPlugin - Service/characteristic discovery caching

See the Plugin Development Guide to create your own!

๐Ÿค Contributing

We welcome contributions! Blue Falcon follows a structured decision-making process:

Proposing Major Changes

For significant architectural changes or new features:

  1. Create an Architecture Decision Record (ADR)

    # Use the ADR template
    cp docs/adr/ADR-TEMPLATE.md docs/adr/XXXX-your-proposal.md
    
  2. Let AI help you write it

    • Use GitHub Copilot or your preferred AI assistant
    • Reference existing ADRs for context
    • See Contributing Guide for details
  3. Submit a Pull Request

    • Link to your ADR
    • Discuss with maintainers
    • Implement once approved

Quick Contributions

For bug fixes, docs, or small improvements:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a Pull Request

See CONTRIBUTING.md for detailed guidelines.

๐Ÿ“– Examples

blueFalcon.clearPeripherals()

// Check scanning state val scanning: Boolean = blueFalcon.isScanning


#### Observing Discovered Devices

```kotlin
// Observe discovered peripherals via StateFlow
blueFalcon.peripherals.collect { peripherals: Set<BluetoothPeripheral> ->
    // update your UI with the discovered devices
}

// Observe Bluetooth manager state (Ready / NotReady)
blueFalcon.managerState.collect { state: BluetoothManagerState ->
    when (state) {
        BluetoothManagerState.Ready -> { /* Bluetooth is available */ }
        BluetoothManagerState.NotReady -> { /* Bluetooth is unavailable */ }
    }
}

Connection Management

// Connect to a peripheral (autoConnect = false for direct connection)
blueFalcon.connect(bluetoothPeripheral, autoConnect = false)

// Disconnect from a peripheral
blueFalcon.disconnect(bluetoothPeripheral)

// Check current connection state
val state: BluetoothPeripheralState = blueFalcon.connectionState(bluetoothPeripheral)
// Returns: Connecting, Connected, Disconnected, Disconnecting, or Unknown

// Request connection priority (Android-specific, no-op on other platforms)
blueFalcon.requestConnectionPriority(bluetoothPeripheral, ConnectionPriority.High)
// Options: ConnectionPriority.Balanced, ConnectionPriority.High, ConnectionPriority.Low

// Retrieve a previously known peripheral by identifier
val peripheral: BluetoothPeripheral? = blueFalcon.retrievePeripheral("device-identifier")
// Android: MAC address format (e.g., "00:11:22:33:44:55")
// iOS/Native: UUID format (e.g., "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")

Service & Characteristic Discovery

When autoDiscoverAllServicesAndCharacteristics is true (default), services and characteristics are discovered automatically after connection. You can also trigger discovery manually:

// Discover services (optionally filter by service UUIDs)
blueFalcon.discoverServices(bluetoothPeripheral, serviceUUIDs = emptyList())

// Discover characteristics for a specific service (optionally filter by UUIDs)
blueFalcon.discoverCharacteristics(
    bluetoothPeripheral,
    bluetoothService,
    characteristicUUIDs = emptyList()
)

Reading & Writing Characteristics

// Read a characteristic value
blueFalcon.readCharacteristic(bluetoothPeripheral, bluetoothCharacteristic)

// Write a string value
blueFalcon.writeCharacteristic(
    bluetoothPeripheral,

For the complete API including descriptors, MTU, L2CAP, and bonding, see the API Reference.

๐Ÿ“„ License

Blue Falcon is released under the MIT License.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support


Made with โค๏ธ by the Blue Falcon community