streamToLsl

fun DeviceSession.streamToLsl(scope: CoroutineScope, outputMode: OutputMode = OutputMode.NORMAL, software: Map<String, String> = emptyMap(), digitalInput: Boolean = false): Job

Stream this device into a fresh LSL outlet on scope; returns the pump Job.

The stream follows the BrainAccess Board LSL contract v1: source_id is the device's advertised BLE name (DeviceSession.name), the stream name is BrainAccessLslOutlet.contractStreamName (<name>_<MODEL>_BrainAccess), and the header carries DeviceSession.streamMetadata built from the device's current config (active labels, srate, impedance vs normal units), its resolved DeviceSession.hardware and the Device Information strings. software adds entries to versions (e.g. "board" to the app version). Samples are streamed with stream(outputMode, digitalInput); outputMode is published as brainaccess/test_signal. With digitalInput the device stream is started with the digital input (firmware 3.8.1+; otherwise com.neurotec.brainaccess.core.BrainAccessError.DigitalInputNotSupported is thrown on collection) and the contract's Digital column (type TRIG, 0/1 per sample) is declared after the gyro columns. Collection starts the device stream; cancel the returned Job (or scope) to stop streaming and close the outlet.

Samples are timestamped from the headset's clock (DeviceSession.sampleHostTimeNs, firmware 3.8.0+): the first seconds of a stream are held until the clock fit exists, and a headset without it (or impedance mode) falls back to stamping at push time after 5 s; see BrainAccessLslOutlet.

Requires liblsl on the runtime classpath (see BrainAccessLslOutlet).