Overview
The Synheart Session Kotlin SDK provides a native SessionEngine that captures heart rate data, computes session metrics on-device, and optionally fuses behavioral signals alongside HR data. The engine is timer-driven, emitting session frames at configurable intervals and delivering a session summary when complete. The SDK supports pluggableBiosignalProvider (for HR sources) and BehaviorProvider (for behavioral signals) via reflection-based wrappers.
Installation
Maven Central
Local Module
Requirements
- Android API 21+
- Kotlin 1.9+
Quick Start
Mock Mode (Development)
Real BLE Heart Rate Data
Health Connect Heart Rate Data
Session Configuration
SessionConfig
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
sessionId | String | No | UUID | Unique session identifier |
mode | SessionMode | Yes | - | Session mode (FOCUS or BREATHING) |
durationSec | Int | Yes | - | Session duration in seconds |
profile | ComputeProfile | No | 60s/5s | Window and emit configuration |
includeRawSamples | Boolean | No | false | Enable raw biosignal frame streaming |
windowLabel | String? | No | null | Optional label for the session window |
ComputeProfile
| Parameter | Type | Default | Description |
|---|---|---|---|
windowSec | Int | 60 | Sliding window size in seconds |
emitIntervalSec | Int | 5 | Session frame emission interval in seconds |
rawEmitIntervalSec | Int? | null | Raw biosignal frame interval (defaults to emitIntervalSec) |
Session Events
The engine callback receivesMap<String, Any> dictionaries with a "type" key.
session_started
session_frame
Contains flat metrics computed over the sliding window:| Field | Type | Description |
|---|---|---|
hr_mean_bpm | Double | Mean heart rate (BPM) |
hr_sdnn_ms | Double | SDNN of RR intervals (ms) |
rmssd_ms | Double | RMSSD approximation (ms) |
sample_count | Int | Number of HR samples in window |
start_ms | Long | Window start timestamp (ms) |
end_ms | Long | Window end timestamp (ms) |
motion_rms_g | Double | RMS acceleration in g-force (optional, when accelerometer available) |
motion_sample_count | Int | Number of accelerometer samples in interval (optional) |
biosignal_frame
Emitted whenincludeRawSamples = true. Contains raw biosignal samples for live display:
session_summary
session_error
| Code | Description |
|---|---|
permission_denied | Health data permissions not granted |
sensor_unavailable | Heart rate sensor not available |
low_battery | Device battery too low |
os_terminated | Operating system terminated the session |
invalid_state | Invalid session state (e.g., duplicate start) |
Behavioral Signals
TheSessionEngine accepts an optional BehaviorProvider that fuses behavioral data into session frames.
Mock Behavior (Development)
Production (via synheart-behavior)
"behavior" key is only present in frames when a BehaviorProvider is configured and returns data.
Architecture
Custom Provider
Any class implementingBiosignalProvider can drive the session engine:
API Reference
SessionEngine
| Constructor | Description |
|---|---|
SessionEngine() | Default mock biosignal provider, no behavior |
SessionEngine(provider) | Custom biosignal provider |
SessionEngine(provider, behaviorProvider) | Custom biosignal + behavioral providers |
SessionEngine(behaviorProvider = bp) | Default mock biosignal + behavioral provider |
| Method | Description |
|---|---|
start(config, callback) | Start a session. Throws if already running. |
stop(sessionId) | Stop a running session. |
getStatus() | Returns status map or null if no active session. |
Resources
- Repository: synheart-session-kotlin
- Issues: GitHub Issues
Author: Israel Goytom