/** * Winkeyer 3.1 Protocol Implementation * * Full implementation of the Winkeyer 3.1 host mode protocol for controlling * morse code keyers via serial port. Includes command builders, status parsing, * and serial transport wrapper. * * Reference: Winkeyer 3.1 Host Mode Protocol */ import type { KeyerMode, KeyerStatus, ProtocolAdapter } from "./index"; /** * Command codes sent from host to Winkeyer device */ export declare enum WinkeyerCommand { ADMIN = 0, SET_SIDETONE = 1,/* 1..10 */ SET_SPEED = 2,/* 5 .. 99 WPM */ SET_WEIGHTING = 3,/* 10 .. 90 */ PTT_LEADTAIL = 4,/* 0..250 x10 ms */ SET_SPEED_POT = 6,/* min, range, 0x00 */ SET_PAUSE = 8,/* 0 off 1 on */ GET_SPEED_POT = 7,/* returns 0x80 + 0 ... 0x1F */ BUFFER_BACKSPACE = 8, SET_PINCONFIG = 9,/* config mask */ CLEAR_BUFFER = 10, KEY_IMMEDIATE = 11, SET_HSCW = 12,/* LPM /100, i.e. 20 == 2000 LPM */ SET_FARNSWORTH = 13,/* effective WPM */ SET_MODE = 14, SET_DEFAULTS = 15,/* 15 bytes of config data */ SET_1ST_EXT = 16,/* 0 .. 250 ms */ SET_KEY_COMP = 17,/* 0 .. 250 ms */ SET_PADDLE_SWITCHPOINT = 18,/* 10 .. 90, default 50 = one dit */ NULL_CMD = 19, SWPADDLE = 20,/* software paddle bit 0 = dit, bit 1 = dah */ REQ_STATUS = 21, SET_POINTER = 22,/* 0 = reset, 1 = move to + overwrite, 2 = move to + insert, 03 = add nulls; second byte is position or count of nulls */ DITDAH_RATIO = 23,/* 33 .. 66, default 50 */ BUFFERED_PTT = 24,/* 0 = off, 1 = on */ BUFFERED_KEYDOWN = 25,/* 0 .. 99 seconds */ BUFFERED_WAIT = 26,/* 0 .. 99 seconds */ MERGE_LETTERS = 27,/* char1, char2 */ BUFFERED_SPEED = 28,/* 5 .. 99 WPM */ BUFFERED_HSCW = 29,/* LPM /100 */ BUFFERED_SPEED_OFF = 30, BUFFERED_NOP = 31, LOAD_BUFFER = 21 } /** * Admin sub-commands (used with ADMIN command) */ export declare enum AdminCommand { COLD_RESET = 1, HOST_OPEN = 2, HOST_CLOSE = 3, GET_FIRMWARE_VERSION = 9, SET_WK2_MODE = 11 } /** * Decoded Winkeyer status byte. * Format: 110x0xxx */ export interface WinkeyerStatusByte { kind: "winkeyer-status"; raw: number; waiting: boolean; keydown: boolean; busy: boolean; paddleBreakIn: boolean; xoff: boolean; } /** * Winkeyer device mode configuration */ export interface WinkeyerMode extends KeyerMode { disableWatchdog?: boolean; paddleSwap?: boolean; autospace?: boolean; contestSpacing?: boolean; paddleBreak?: boolean; } /** * Speed potentiometer configuration */ export interface SpeedPotParameters { minWpm: number; maxWpm: number; } /** * Message slot identifiers */ export declare enum MessageSlot { MESSAGE_1 = 0, MESSAGE_2 = 1, MESSAGE_3 = 2, MESSAGE_4 = 3, MESSAGE_5 = 4, MESSAGE_6 = 5 } /** * Convert plain text to ASCII bytes for Winkeyer transmission * Winkeyer receives and transmits plain ASCII text */ export declare function textToBytes(text: string): Uint8Array; export interface WinkeyerAdapterHooks { setStatus: (status: KeyerStatus) => void; echoAscii: (ascii: string) => void; sendBytes: (data: Uint8Array) => Promise; } /** * ProtocolAdapter implementation for Winkeyer over an existing SerialSession. */ export declare class WinkeyerProtocolAdapter implements ProtocolAdapter { private readonly hooks; private pendingResolve; private pendingReject; private speedPotMinWpm; private status; private expectVersion; private keyingMode; private sidetoneFreq; private weight; private dahDitRatio; private defaultsBuffer; private pendingDefaultsResolve; private pendingDefaultsReject; constructor(hooks: WinkeyerAdapterHooks); /** * @param weighting 1 = weighting 1:1, >1 is more key down time, <1 means more space time * It is converted to winkeyer parameter, clamped and applied */ setWeighting(weighting: number): Promise; /** * * @param ratio dash to dit ratio, default 3.0. It is converted to winkeyer parameter, clamped and applied. Winkeyer default is 3.0, and it accepts 33..66 (i.e. 3.0 .. 6.0) with 50 (3.0) as the default. Note that this is a different parameter from the weighting; changing this does not change the overall speed, only the relative length of dahs to dits. * @returns */ setDashRatio(ratio: number): Promise; /** * * @returns */ private getKeyingModeByte; /** * * @param mode : standard set of keying options used for computer-driven keying * @returns Promise resolving after data had been transferred to the keyer serial port */ setKeyerMode(mode: KeyerMode): Promise; /** * @param options : other non-essential keying options, Winkeyer-specific. Tolerates any options not defined in WinkeyerMode, but only the defined ones will be applied. This is to allow future expansion without changing the method signature. * @returns Promise resolving after data had been transferred to the keyer serial port */ setExtendedOptions(options: Record): Promise; getWpm(): number | undefined; getWeighting(): number; getKeyerMode(): KeyerMode; getDashRatio(): number; getSidetoneFrequency(): number; handleIncomingData(data: Uint8Array): void; /** * Sends HOST OPEN and waits for the firmware version byte response. * If the keyer responds with 0xFF the keyer is permanently locked; throws immediately. */ open(): Promise; getVersion(): Promise; init(): Promise; /** * Resets buffer and stops all transmission immediately. */ break(): Promise; sendCw(text: string): Promise; setWpm(wpm: number): Promise; setSidetoneFrequency(freq: number): Promise; private decodeDefaults; private getDefaults; close(): Promise; }