UNPKG

elm327

Version:

Node.js/TypeScript library for ELM327 OBD2 adapters over USB, Bluetooth and WiFi

156 lines 4.08 kB
/** * Represents an OBD2 command with its decoder logic. */ export interface OBD2Command { name: string; pid: string; description: string; decoder: (data: string) => number | string | boolean | string[] | Record<string, unknown>; unit?: string; } /** * Represents a decoded OBD2 response. */ export interface OBD2Response { command: string; value: number | string | boolean | string[] | Record<string, unknown>; unit: string | undefined; timestamp: Date; } /** * Configuration options for establishing an OBD2 connection. */ export interface ConnectionConfig { type: 'bluetooth' | 'serial' | 'wifi'; address?: string; port?: string | number; host?: string; baudRate?: number; timeout?: number; lineEnding?: string; /** * Flow Control configuration for ISO-TP multiframe messages (Mode 09, VIN, etc.) * Only used with CAN-based protocols (6-B). */ flowControl?: { /** Flow Control header (AT FC SH) - typically the ECU response ID + 8 (e.g., 0x7E0 -> 0x7E8) */ header?: string; /** Flow Control data bytes (AT FC SD) - up to 5 bytes */ data?: string; /** Flow Control mode (AT FC SM) - 0: normal, 1: continuous, etc. */ mode?: number; /** Enable/disable flow control (AT CFC) - true = on, false = off */ enabled?: boolean; }; /** * Clone compatibility mode for older ELM327 v1.5/v2.1 clones. * - 'auto': Detect and adjust automatically (default) * - 'strict': Full feature set, may fail on old clones * - 'lenient': Skip unsupported commands, longer delays * - 'minimal': Only essential commands (ATZ, ATE0, ATSP0) */ cloneCompatibility?: 'auto' | 'strict' | 'lenient' | 'minimal'; } /** * Information about the connected OBD2 adapter. */ export interface OBD2AdapterInfo { protocol: string; version: string; device: string; } /** * Supported OBD2 protocols for manual selection. */ export declare enum OBD2Protocol { AUTO = "0", SAE_J1850_PWM = "1", SAE_J1850_VPW = "2", ISO_9141_2 = "3", ISO_14230_4_KWP = "4", ISO_14230_4_KWP_FAST = "5", ISO_15765_4_CAN = "6", ISO_15765_4_CAN_B = "7", ISO_15765_4_CAN_C = "8", ISO_15765_4_CAN_D = "9", SAE_J1939_CAN = "A", USER1_CAN = "B", USER2_CAN = "C" } /** * Diagnostic request modes (SAE J1979 / OBD-II) */ export declare enum DiagnosticMode { CURRENT_DATA = 1, FREEZE_FRAME = 2, STORED_DTC = 3, CLEAR_DTC = 4, O2_TEST_RESULTS = 5, ONBOARD_MONITORING = 6, PENDING_DTC = 7, CONTROL_COMPONENT = 8, VEHICLE_INFO = 9, PERMANENT_DTC = 10 } /** * Configuration for a diagnostic request */ export interface DiagnosticRequestConfig { bus?: number; id?: number; mode: DiagnosticMode | number; pid?: number; multipleResponses?: boolean; frequency?: number; payload?: string; name?: string; } /** * Response from a diagnostic request */ export interface DiagnosticResponse { bus: number; id: number; mode: number | undefined; pid?: number; success: boolean; negativeResponseCode?: number; negativeResponseMessage?: string; value?: number | string; payload?: string; frame?: number; totalSize?: number; timestamp: Date; } /** * Log format options for file-based logging. */ export declare enum LogFormat { RAW = "raw", PRETTY = "pretty", JSON = "json" } /** * Log level for filtering log entries. */ export declare enum LogLevel { INFO = "INFO", DEBUG = "DEBUG", WARN = "WARN", ERROR = "ERROR", RAW_DATA = "RAW_DATA", COMMAND = "COMMAND", RESPONSE = "RESPONSE" } /** * Configuration for file-based logging. */ export interface LoggerConfig { enabled?: boolean; filePath: string; format?: LogFormat; levels?: LogLevel[]; /** Maximum number of lines to keep in the log file. Oldest lines are trimmed first. Default: 0 (unlimited) */ maxLines?: number; } //# sourceMappingURL=types.d.ts.map