Examples#

The repository includes Example/BrainAccessExample.xcodeproj, a SwiftUI scan → connect → stream harness with device info and firmware update. It is included in the distribution zip as a starting point, not as a published app.

What it demonstrates#

  • Scanning for BrainAccess advertisements.

  • Connecting and handshaking to DeviceState.ready.

  • Streaming EegChunk packets.

  • Showing battery, contact, missed-sample and hardware-generation state.

  • Firmware update with a board check: the headset’s DIS Model Number must name the board the firmware_<MODEL>.bin image is built for.

  • Exercising the same SDK calls as a consumer app without adding UI dependencies to the SDK.

Run the example#

  1. Open Example/BrainAccessExample.xcodeproj in Xcode on a Mac. Its package reference is the parent folder: the source package in the repository, or the bundle’s binary Package.swift in the distribution zip.

  2. Select your team under Signing & Capabilities.

  3. Run on a physical iPhone. The simulator cannot exercise CoreBluetooth scanning.

The project already sets NSBluetoothAlwaysUsageDescription. Example/README.md covers the firmware images.

Minimal console-only check#

For non-UI integration checks inside an existing app target, this body exercises the same SDK path:

import BrainAccessKit

func printFirstChunk() async {
    let client = BrainAccessClient(transport: CoreBluetoothTransport())
    do {
        for await device in client.scan() {
            let session = try await client.connect(device).get()
            for try await chunk in session.stream() {
                print(chunk.channels, chunk.sampleCount)
                break
            }
            await client.disconnect(device.id)
            break
        }
    } catch {
        print(error.localizedDescription)
    }
}