Blue-Falcon

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

View the Project on GitHub Reedyuk/blue-falcon

Blue Falcon Examples

This directory contains example projects demonstrating Blue Falcon usage across different platforms and architectures.

📁 Available Examples

1. ArchitecturePOC

Platform: Kotlin Multiplatform
Language: Kotlin
Description: Proof-of-concept demonstrating the Blue Falcon 3.0 architecture

Features:

Location: ArchitecturePOC/
See: ArchitecturePOC/README.md for details


2. Plugin-Example

Platform: Kotlin Multiplatform
Language: Kotlin
Description: Examples of creating custom Blue Falcon plugins

Features:

Location: Plugin-Example/
See: Plugin-Example/README.md for details


3. Engine-Example

Platform: Kotlin Multiplatform
Language: Kotlin
Description: Example of creating a custom platform engine

Features:

Location: Engine-Example/
See: Engine-Example/README.md for details


4. ComposeMultiplatform-3.0-Example

Platform: Compose Multiplatform (Android + iOS)
Language: Kotlin
Description: Production-ready example with Compose UI using Blue Falcon 3.0 API

Features:

Location: ComposeMultiplatform-3.0-Example/
See: ComposeMultiplatform-3.0-Example/README.md for details

Key Highlights:

val blueFalcon = BlueFalcon {
    install(LoggingPlugin) { level = LogLevel.DEBUG }
    install(RetryPlugin) { maxRetries = 3 }
}

// Collect devices as Flow
blueFalcon.peripherals.collect { devices ->
    // Update UI
}

// Use suspend functions
blueFalcon.scan()
blueFalcon.connect(device)

5. ComposeMultiplatform-Legacy-Example

Platform: Compose Multiplatform (Android + iOS)
Language: Kotlin
Description: Production-ready example with Compose UI using Blue Falcon 2.x (legacy) API

Features:

Location: ComposeMultiplatform-Legacy-Example/
See: ComposeMultiplatform-Legacy-Example/README.md for details

Key Pattern:

class BleDelegate: BlueFalconDelegate {
    override fun didConnect(peripheral: BluetoothPeripheral) {
        // Handle connection via callback
    }
}

val blueFalcon = BlueFalcon(context, delegate)
blueFalcon.scan()

⚠️ Note: This is the legacy API. For new projects, use ComposeMultiplatform-3.0-Example instead


6. JS-Example

Platform: JavaScript (Web Browser)
Language: Kotlin/JS
Description: Web Bluetooth API example

Features:

Location: JS-Example/

Running:

cd JS-Example
./gradlew jsBrowserDevelopmentRun
# Open http://localhost:8080

Requirements:


🎯 Quick Start Patterns

Legacy API (2.x - Backward Compatible)

val blueFalcon = BlueFalcon(log = null, ApplicationContext())

blueFalcon.delegates.add(object : BlueFalconDelegate {
    override fun didDiscoverDevice(
        peripheral: BluetoothPeripheral, 
        advertisementData: Map<AdvertisementDataRetrievalKeys, Any>
    ) {
        println("Found: ${peripheral.name}")
    }
})

blueFalcon.scan()

Modern API (3.0)

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

val blueFalcon = BlueFalcon {
    engine = AndroidEngine(context)
    
    install(LoggingPlugin) {
        level = LogLevel.DEBUG
    }
}

launch {
    blueFalcon.peripherals.collect { devices ->
        devices.forEach { println("Device: ${it.name}") }
    }
}

blueFalcon.scan()

📚 Documentation

For complete guides and API documentation:


🤝 Contributing Examples

Want to contribute an example? We’d love to have:

Guidelines:

  1. Follow the existing example structure
  2. Include a detailed README.md
  3. Provide working, tested code
  4. Document platform requirements
  5. Submit a Pull Request

See CONTRIBUTING.md for details.