ftrst-tui
A terminal studio for LED light-stimulation headsets with live EEG beside them. Control the lights, script sequences, and let the brainwaves steer the light.
Two devices, one question: what is the light actually doing to the brain? A nine-LED light-stimulation headset can drive a state and an EEG headset can measure one, but neither knows the other exists.
ftrst-tui puts them in the same process on the same clock — drive the lights, script sequences, read four EEG channels beside them — and writes down what the device accepted instead of assuming it. It runs offline, needs no account, and every session is a file you own.
Two devices, one process
A nine-LED lightbox and an EEG headset from different manufacturers, each with its own phone app and neither aware the other exists. ftrst-tui opens both connections and keeps them on one clock, so a flash and the brainwave it produced can be read in the same window.
Nothing between you and the hardware
The stock app plays fixed sessions and reports nothing back — not the frame it sent, not what the box accepted. Here the frame is written field by field and the confirmation comes from the device, so an interface can no longer claim a success the hardware never gave.
Streamed while recorded, not after
The lights take new frames while the EEG is still being captured. Change the pattern mid-recording and the change lands in the signal with a timestamp — which is what makes one light pattern testable against another instead of comparable only in hindsight.
The signal can choose the light
Nothing requires a human to pick the next pattern. The estimator reads the wearer’s band power and selects the frame, closing the loop between what the brain is doing and what the light does next.
- Lightbox → its own app: fixed sessions, no readout
- EEG headset → its own app, on its own clock
- Nothing ties a flash to the brainwave it caused
- Both devices opened by the same program
- Lights and signal on a single timeline
- Every frame written down, timestamped, exportable
Prerequisites
Everything you need is either off-the-shelf or in the same three crates, and none of it requires an account. Two questions, one device each: what did the app send (the phone), and did the device really accept it (the dongle).
Hardware
- NeuroVizr lightbox
- the device under test: nine LEDs over Nordic UART, no published command set
- Muse 2 EEG headset
- the documented half — a consumer EEG device with an open library to read as a reference
- nRF52840 (Nordic Semiconductor)
- a programmable BLE central: connect, subscribe, write one known frame, then watch the box confirm it
- Rooted Android 12 phone
- the capture point — HCI snoop log on, driven over USB with adb
Software
- nRF Connect for Android
- Nordic's own BLE explorer: connect to a device, read the GATT table, then write a characteristic by hand before any code is written
- tshark (Wireshark CLI)
- decode the btsnoop capture: filter ATT writes and notifies, dump values as hex, and check whether the capture admits its own truncation
- adb (Android platform tools)
- tap through the vendor app, pull the HCI log, read the in-memory ring out of dumpsys
- ftrst-tui
- the terminal studio itself — the app that owns both devices; the two libraries it is built on are named below
One barrier worth writing down: the vendor's app ships through Google Play with a licensing check, and a build that fails that check will not start even with Bluetooth working. The session here was captured with an older build of the same app — published before the check existed and still hosted — which runs without it.
If you reproduce this, expect the current release to refuse; find the earlier one, and confirm from the GATT table that you are talking to the same service before you trust a single byte.
The problem, in two parts
Part one is measurement: how do you understand the impact of the NeuroVizr lightbox on a brain? Its own app plays a fixed session and reports nothing back — not what the device accepted, not what the wearer did.
Part two is integration: two completely separate resources have to become one instrument. One of them is a closed light device with no published command set; the other is an EEG headset with an open library. Joined, they produce something neither has alone — a trackable mental stimulus, where every flash is timestamped against the signal it caused.
Why a terminal interface
Because it takes the display off the list of requirements. A TUI needs a shell and nothing else: the same binary runs on macOS, Linux and Windows, over SSH on a headless box, and on something as small as a Raspberry Pi with no screen at all — driving the light and forwarding the session log.
A graphical application would need a windowing system on every target and a machine capable of rendering it. Running anywhere, including on hardware small enough to sit under the lightbox, is part of the point rather than a compromise.
What it can do
Find and connect
Scans from inside the app, classifies each device by advertised service, name and GATT table, and connects it to the role its family implies. Identity before connection is stated as a hypothesis, not a fact.
Configure and fire
Every field of the command is a row you can adjust - configuration, duration, frequency start/end, sweep time, brightness on/off - and Enter sends exactly that frame.
Map the LEDs
A sweep-and-observe procedure that turns "which code lights which LED" into recorded data on disk, because it cannot be decoded from the bytes.
Play sequences
Built-in routines plus any file dropped in the sequences directory - JSONL, JSON array or bare hex lines - paced by each item's own duration.
Watch the EEG
Four channels, band power, and a state estimate with a confidence and an alpha peak, live beside the light controls in the same window.
Close the loop
The light follows the measured state, with three objectives, hysteresis, write spacing and a safety band enforced as a test.
Stream it
A local WebSocket datastream takes hex, JSON commands or whole sequences from any language and replies with the live state.
Log it
A session CSV at roughly 400 ms cadence, including artifact-marked windows, so a session is analysable after the fact.
Run without hardware
Both sources fall back to a simulator that reproduces the device's real behaviour, so the app is reviewable and testable with no radio.
The libraries
Two libraries came out of the work. Neither is a vendored copy of something else: the light protocol had no SDK to wrap, and the EEG client is the smallest thing that could read four channels without the vendor's stack.
The light protocol: 16-byte frame encoding, the confirmation ledger that grades every code as wire-only or hardware-proven, the LED map, and the simulator.
source not yet publicThe EEG client: BLE discovery for the headset, the four channels, band power, and the artifact windowing the estimator reads.
source not yet public