From 438e4240670a8ed0c6af0f3f4b6879fa33848b7c Mon Sep 17 00:00:00 2001 From: Mannes Brak Date: Wed, 20 May 2026 16:24:06 +0200 Subject: [PATCH] device: add optional printerCode field to DeviceEntry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In-protocol model identifier returned by a device's identity query. Used by transport-agnostic autodetect: open wire → ask printer who it is → look up by code. Single code or array of codes (some chassis report multiple IDs across firmware revisions). Niimbot is the only consumer today, mapping PrinterInfo(0x08) replies through niimbluelib's modelsLibrary. Other drivers can opt in when they grow an equivalent query; Brother / Dymo / cat-printer stay on USB VID/PID and leave the field absent. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/device.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/device.ts b/src/device.ts index 4d1555d..38456fd 100644 --- a/src/device.ts +++ b/src/device.ts @@ -415,6 +415,24 @@ export interface DeviceEntry { * falls back to legacy `support.status`. */ verifications?: DeviceVerifications; + + /** + * In-protocol model identifier(s) reported by the device itself in + * response to a driver-specific identity query. Used by transport- + * agnostic autodetect: open the wire, ask the printer who it is, + * look up by code. + * + * Niimbot today is the only consumer: chassis reply to + * `PrinterInfo(0x08)` (= `PrinterModelId`) with a 1- or 2-byte BE + * integer, matched against this field by `findDeviceByPrinterCode`. + * Codes mirror niimbluelib's `modelsLibrary`; a chassis may report + * any of several IDs (e.g. D110 → `[2304, 2305]`), so the field + * accepts a single code or an array. + * + * Brother / Dymo / cat-printer have no equivalent in-protocol query + * and leave this absent — they autodetect via USB VID/PID instead. + */ + printerCode?: number | readonly number[]; } /**