/** * Core keyer abstractions: enums, interfaces, protocol adapter factory, and CWKeyer. * * This module has no dependency on any specific serial transport. It imports only * the transport-agnostic SerialSession interface and the Web Serial helper functions * needed to implement CWKeyer.connect() / connectStandalone(). Both the browser and * universal entry points include this module unchanged. */ import { type SerialSession } from "./serial-session"; export type { SerialSession }; export declare enum KeyingMode { IAMBIC_B = 0, IAMBIC_A = 1, ULTIMATIC = 2, BUG = 3 } export interface KeyerMode { paddleEcho?: boolean; bufferEcho?: boolean; paddleBreak?: boolean; keyingMode?: KeyingMode; } /** * ProtocolAdapter defines the interface for a keyer protocol adapter that translates between raw serial data and high-level keyer commands and status updates. * Each supported keyer type (e.g. Winkeyer) will have its own implementation of this interface that knows how to encode/decode the specific command and status * formats for that keyer. The Keyer class uses a ProtocolAdapter to interact with the underlying serial session without needing to know the details of the specific * keyer protocol. This separation allows to add support for new keyer types in the future by simply implementing new ProtocolAdapter classes. * * The ProtocolAdapter interface includes only methods for handling incoming serial data, opening the connection, retrieving version information, initializing the keyer, * breaking (stopping CW and clearing buffers), sending CW text, setting WPM speed, setting detailed keying charateristics (weighting, dit:dash ratio) and setting sidetone * frequency. It does NOT implement all keyer features, only those necessary for application automation. * * By design decision it does not include any methods related to manual sending. * * The current version also intentionally does not handle buffered speed control and PTT parameters and control. * This may change in the future. * */ export interface ProtocolAdapter { handleIncomingData(data: Uint8Array): void; open(): Promise; getVersion(): Promise; init(): Promise; break(): Promise; sendCw(text: string): Promise; setWpm(wpm: number): Promise; setSidetoneFrequency(freq: number): Promise; setWeighting(weighting: number): Promise; setDashRatio(ratio: number): Promise; setKeyerMode(mode: KeyerMode): Promise; setExtendedOptions(options: Record): Promise; getWpm(): number | undefined; getWeighting(): number; getKeyerMode(): KeyerMode; getDashRatio(): number; getSidetoneFrequency(): number; close(): Promise; } export interface KeyerStatus { keyerType?: string; isOpen?: boolean; version?: string; emit?: boolean; full?: boolean; wpm?: number; busy?: boolean; break?: boolean; } interface StatusListener { (status: KeyerStatus): void; } interface EchoListener { (ascii: string): void; } export declare class CWKeyer { private readonly keyerType; private readonly browser; private readonly webSerial; protected session: SerialSession | null; private protocolAdapter; private status; private statusListeners; private echoListeners; private versionText; private echoText; protected constructor(keyerType: string); static create(keyerType: string): CWKeyer; suggestDefaultBaudrate(): number; isBrowser(): boolean; hasWebSerial(): boolean; /** * Requests a Web Serial port via the browser dialog, opens it, and connects. * Browser-only. */ connect(baud: number): Promise; /** * Connects using any pre-built SerialSession. Works in both browser and * Node.js. Use this with createNodeSerialSession() for standalone/test use. */ connectWithSession(session: SerialSession): Promise; disconnect(): Promise; close(): Promise; sendBytes(data: Uint8Array): Promise; init(): Promise; break(): Promise; sendCw(text: string): Promise; setWpm(wpm: number): Promise; setKeyerMode(mode: KeyerMode): Promise; getVersion(): string | null; getWpm(): number | undefined; getWeighting(): number; getKeyerMode(): KeyerMode; getDashRatio(): number; getSidetoneFrequency(): number; getEchoAscii(): string; getStatus(): KeyerStatus; on(eventName: "status" | "echo", listener: StatusListener | EchoListener): void; off(eventName: "status" | "echo", listener: StatusListener | EchoListener): void; setStatus(status: KeyerStatus): void; echoAscii(ascii: string): void; private emitStatus; private assertConnected; setWeighting(weighting: number): Promise; setDashRatio(ratio: number): Promise; setSidetoneFrequency(freq: number): Promise; setExtendedOptions(options: Record): Promise; }