Case study · CLEIO

Multi-day clinical EEG recordings that survive crashes and dropouts

A senior DEVSFLOW engineer embedded in CLEIO's Android team, on a companion app for a wearable EEG device.

6 monthsof device work done before the hardware arrived
No studies lostto app crashes since the crash-safe lifecycle shipped
2–3 daysper recording, protected against crashes and dropouts
← All case studies
“…a dependable, communicative, and professional consultant…integrated smoothly into the project team, ramped up on the project context efficiently, and consistently delivered against the cadence set by the client.”
GabrielDirector of Software Development, CLEIO
Client
CLEIO, a health technology company that builds companion applications for EEG headsets
Engagement
Embedded: one senior Android engineer inside CLEIO's team. CLEIO owns the roadmap and technical direction
Status
Ongoing
Platform
Native Android (Kotlin)
01

The brief

CLEIO was building a tablet companion app for a wearable EEG device, used to run clinical recordings that last two to three days.

CLEIO's Android team needed another senior engineer who could work in Bluetooth and hardware-connected code from the first week, inside their existing process.

What was at stake

02

Our approach

Decision 01Simulate the hardware before it exists
Context
The device wasn't available yet, and every device feature needed something realistic to run against.
Decision
A realistic simulator behind the same interface the app uses for the real device, able to replay real data and inject faults such as dropouts. QA can run scenarios without touching code.
Tradeoff
A second component to maintain, kept in step with the device protocol.
One interface, two devices behind it
One interface, two devices behind itEvery device feature talks to one well-defined interface, with a simulator or the real device behind it. Before the hardware arrived, the simulator replayed real recorded data for the happy path and dropped packets on demand to create gaps, so QA could test both without touching code. Switching to the real device is a setting, with no rebuild. A simulator can't show behavior below the contract, such as phone-specific Bluetooth quirks and radio timing; that still needs the real device.App codeevery device featureDevice interfaceone contractQA picks a scenarioSimulatorreplays real datahappy path +dropped packetsReal deviceover Bluetooth LEonce hardware arrivedswitch in settings,no rebuild
Every device feature talks to one well-defined interface, with a simulator or the real device behind it. Before the hardware arrived, the simulator replayed real recorded data for the happy path and dropped packets on demand to create gaps, so QA could test both without touching code. Switching to the real device is a setting, with no rebuild. A simulator can't show behavior below the contract, such as phone-specific Bluetooth quirks and radio timing; that still needs the real device.
Decision 02Make the study's state explicit and its progress durable
Context
A multi-day recording passes through several stages, and a crash at any point must not lose its place.
Decision
One state machine for the study, with its status saved durably at each milestone, so after a crash the app reconnects and resumes recording or finishes the study.
Tradeoff
Every new feature has to declare which states it is valid in. In return, the whole app agrees on where the study is.
A crash doesn't end the study
A crash doesn't end the studyThe study's status is saved once the device confirms that recording has started or stopped. After a crash, the next launch reads that status, reconnects, and either resumes recording or finishes the study.Start recordingDevice confirmsStatus saveddurably✕ crashNext launchReads saved statusReconnects and resumesrecording, or finishes the study
The study's status is saved once the device confirms that recording has started or stopped. After a crash, the next launch reads that status, reconnects, and either resumes recording or finishes the study.
Decision 03Treat missing data as normal
Context
The tablet and the device will sometimes be apart during a multi-day recording.
Decision
Detect gaps and recover them from the device.
Tradeoff
More moving parts in the data path, but gaps show up and can be recovered.
03

How we worked with the team

04

For your tech lead

The technical patterns behind this work are written up in our own engineering notes, without client detail:

Next step

Tell us about your team and the device, and we'll tell you who could start in your Bluetooth code.

Book a 30-minute technical callor email info@devsflow.ca