API Reference
Core Types
Fundamental data types — BioDevice, BioSample, SignalData, TimeSeries, and BiosignalType.
The foundational data models used throughout the SDK.
BioDevice
Represents a discovered or connected BLE device.
public struct BioDevice: Equatable, Hashable {
public let id: UUID
public let name: String
public init(id: UUID, name: String)
}| Property | Type | Description |
|---|---|---|
id | UUID | CoreBluetooth peripheral identifier |
name | String | Advertised device name |
BioSample
A single biosignal sample received from a device.
public struct BioSample: Equatable {
public let signalName: String
public let data: SignalData
public let timestamp: TimeInterval
public init(signalName: String, data: SignalData, timestamp: TimeInterval)
}| Property | Type | Description |
|---|---|---|
signalName | String | Signal identifier (e.g., "ecg", "ppg", "heart_rate") |
data | SignalData | The sample payload — waveform array or scalar value |
timestamp | TimeInterval | Unix timestamp of the sample |
Convenience Properties
public var isECG: Bool { get }
public var isPPG: Bool { get }
public var isEDA: Bool { get }
public var isTemp: Bool { get }
public var isHeartRate: Bool { get }
public var isSpO2: Bool { get }
// Extract data
public var waveform: [Double]? { get } // Non-nil for waveform signals
public var scalarValue: Double? { get } // Non-nil for scalar signalsExample:
sdk.events
.compactMap { event -> BioSample? in
guard case .sample(_, let sample) = event else { return nil }
return sample
}
.filter { $0.isHeartRate }
.sink { sample in
if let bpm = sample.scalarValue {
print("Heart rate: \(bpm) BPM")
}
}SignalData
The payload of a BioSample — either a waveform array or a single scalar value.
public enum SignalData: Equatable {
case waveform([Double])
case scalar(Double)
public var jsonValue: Any { get }
}| Case | Description |
|---|---|
.waveform([Double]) | Array of samples (ECG, PPG, EDA waveforms) |
.scalar(Double) | Single value (heart rate, temperature, SpO2) |
TimeSeries
A timestamped array of values, used by chart components.
public struct TimeSeries: Equatable {
public let timestamp: TimeInterval
public let values: [Double]
public init(timestamp: TimeInterval, values: [Double])
}| Property | Type | Description |
|---|---|---|
timestamp | TimeInterval | Unix timestamp for this data point |
values | [Double] | Signal values at this timestamp |
BioDeviceSpec
Device specification sent to the backend when starting a session.
public struct BioDeviceSpec: Codable, Sendable {
public let user_device_id: Int?
public let device_id: String?
public let device_profile_id: String?
public let make: String?
public let model: String?
public let firmware: String?
public let sampling_profile_name: String?
public let battery: Int?
public init(
user_device_id: Int? = nil,
device_id: String?,
device_profile_id: String? = nil,
make: String?,
model: String?,
firmware: String?,
sampling_profile_name: String?,
battery: Int?
)
}BiosignalType
Enumeration of supported biosignal types.
public enum BiosignalType: String, Hashable, CaseIterable {
case ecg = "ecg"
case ppg = "ppg"
case eda = "eda"
case temp = "temp"
case heartRate = "heart_rate"
case hrv = "hrv"
case spo2 = "spo2"
case accel = "accel"
case gyro = "gyro"
case respiratoryRate = "respiratory_rate"
case bloodPressure = "blood_pressure"
}// Parse from a string
public static func from(_ string: String) -> BiosignalType?BioError
SDK-level errors.
public enum BioError: Error {
case notConfigured
case invalidOperation(String)
}| Case | Description |
|---|---|
.notConfigured | SDK method called before initialization |
.invalidOperation(String) | Invalid operation attempted, with description |