/** * Shared value types for the Device Adapter contract. * * These types are the ONLY things business logic should depend on. Swapping a * real BLE implementation for the simulator (or a future firmware protocol) * must not require any changes above this boundary (spec §10.4, §11.3). */ /** High-level connection lifecycle state. */ export declare enum ConnectionState { Disconnected = "disconnected", Scanning = "scanning", Connecting = "connecting", Connected = "connected", Reconnecting = "reconnecting" } /** Device status reported alongside measurements. */ export declare enum DeviceStatus { Ok = "ok", LowBattery = "low_battery", Calibrating = "calibrating", Error = "error" } /** Categorized device error codes (mapped from firmware error codes). */ export declare enum DeviceErrorCode { ConnectionLost = "connection_lost", LowBattery = "low_battery", CalibrationFailed = "calibration_failed", SensorFault = "sensor_fault", Timeout = "timeout", Unknown = "unknown" } /** A device discovered during a scan. */ export interface DiscoveredDevice { /** Stable identifier (BLE peripheral id / serial). */ id: string; name: string; /** Received signal strength indicator, if available. */ rssi?: number; serialNumber?: string; } /** Full device metadata once connected. */ export interface DeviceInfo { id: string; serialNumber: string; name: string; hardwareModel: string; hardwareRevision: string; firmwareVersion: string; batteryLevel: number; } /** Battery snapshot. */ export interface BatteryStatus { level: number; charging: boolean; } /** A single angle measurement emitted on the stream. */ export interface AngleSample { /** Angle in degrees. */ angle: number; /** Epoch milliseconds when the sample was produced. */ timestamp: number; status: DeviceStatus; } /** A device error event. */ export interface DeviceError { code: DeviceErrorCode; message: string; timestamp: number; /** Whether the SDK will attempt automatic recovery (e.g. reconnect). */ recoverable: boolean; } /** Result of a calibration routine. */ export interface CalibrationResult { success: boolean; /** Angle offset applied after calibration, in degrees. */ offset: number; timestamp: number; } /** Options accepted by {@link DeviceAdapter.startAngleStream}. */ export interface AngleStreamOptions { /** Target emission frequency in Hz (best effort). Default 20. */ frequencyHz?: number; } /** Options accepted by {@link DeviceAdapter.scanDevices}. */ export interface ScanOptions { /** Stop scanning automatically after this many milliseconds. */ timeoutMs?: number; } /** * The event map exposed by the adapter. Consumers subscribe with * {@link DeviceAdapter.on} and receive strongly-typed payloads. */ export interface DeviceAdapterEventMap { angle: AngleSample; connectionStateChanged: ConnectionState; battery: BatteryStatus; error: DeviceError; calibration: CalibrationResult; } export type DeviceAdapterEvent = keyof DeviceAdapterEventMap; export type Unsubscribe = () => void;