@mmote/niimbluelib
Version:
Library for the communication with NIIMBOT printers
197 lines (196 loc) • 12.5 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.firmwareExchangePackets = exports.commandsMap = exports.ResponseCommandId = exports.RequestCommandId = void 0;
/**
* Commands IDs from client to printer
*
* @category Packets
**/
var RequestCommandId;
(function (RequestCommandId) {
RequestCommandId[RequestCommandId["Invalid"] = -1] = "Invalid";
/** Entire packet should be prefixed with 0x03 */
RequestCommandId[RequestCommandId["Connect"] = 193] = "Connect";
RequestCommandId[RequestCommandId["CancelPrint"] = 218] = "CancelPrint";
RequestCommandId[RequestCommandId["CalibrateHeight"] = 89] = "CalibrateHeight";
RequestCommandId[RequestCommandId["Heartbeat"] = 220] = "Heartbeat";
RequestCommandId[RequestCommandId["LabelPositioningCalibration"] = 142] = "LabelPositioningCalibration";
RequestCommandId[RequestCommandId["PageEnd"] = 227] = "PageEnd";
RequestCommandId[RequestCommandId["PrinterLog"] = 5] = "PrinterLog";
RequestCommandId[RequestCommandId["PageStart"] = 3] = "PageStart";
RequestCommandId[RequestCommandId["PrintBitmapRow"] = 133] = "PrintBitmapRow";
/** Sent if black pixels < 6 */
RequestCommandId[RequestCommandId["PrintBitmapRowIndexed"] = 131] = "PrintBitmapRowIndexed";
RequestCommandId[RequestCommandId["PrintClear"] = 32] = "PrintClear";
RequestCommandId[RequestCommandId["PrintEmptyRow"] = 132] = "PrintEmptyRow";
RequestCommandId[RequestCommandId["PrintEnd"] = 243] = "PrintEnd";
RequestCommandId[RequestCommandId["PrinterInfo"] = 64] = "PrinterInfo";
RequestCommandId[RequestCommandId["PrinterConfig"] = 175] = "PrinterConfig";
RequestCommandId[RequestCommandId["PrinterStatusData"] = 165] = "PrinterStatusData";
RequestCommandId[RequestCommandId["PrinterReset"] = 40] = "PrinterReset";
RequestCommandId[RequestCommandId["PrintQuantity"] = 21] = "PrintQuantity";
RequestCommandId[RequestCommandId["PrintStart"] = 1] = "PrintStart";
RequestCommandId[RequestCommandId["PrintStatus"] = 163] = "PrintStatus";
RequestCommandId[RequestCommandId["RfidInfo"] = 26] = "RfidInfo";
RequestCommandId[RequestCommandId["RfidInfo2"] = 28] = "RfidInfo2";
RequestCommandId[RequestCommandId["RfidSuccessTimes"] = 84] = "RfidSuccessTimes";
RequestCommandId[RequestCommandId["SetAutoShutdownTime"] = 39] = "SetAutoShutdownTime";
RequestCommandId[RequestCommandId["SetDensity"] = 33] = "SetDensity";
RequestCommandId[RequestCommandId["SetLabelType"] = 35] = "SetLabelType";
/** 2, 4 or 6 bytes */
RequestCommandId[RequestCommandId["SetPageSize"] = 19] = "SetPageSize";
RequestCommandId[RequestCommandId["SoundSettings"] = 88] = "SoundSettings";
/** some info request (niimbot app), 01 long 02 short */
RequestCommandId[RequestCommandId["AntiFake"] = 11] = "AntiFake";
/** same as GetVolumeLevel??? */
RequestCommandId[RequestCommandId["WriteRFID"] = 112] = "WriteRFID";
RequestCommandId[RequestCommandId["PrintTestPage"] = 90] = "PrintTestPage";
RequestCommandId[RequestCommandId["StartFirmwareUpgrade"] = 245] = "StartFirmwareUpgrade";
RequestCommandId[RequestCommandId["FirmwareCrc"] = 145] = "FirmwareCrc";
RequestCommandId[RequestCommandId["FirmwareCommit"] = 146] = "FirmwareCommit";
RequestCommandId[RequestCommandId["FirmwareChunk"] = 155] = "FirmwareChunk";
RequestCommandId[RequestCommandId["FirmwareNoMoreChunks"] = 156] = "FirmwareNoMoreChunks";
RequestCommandId[RequestCommandId["PrinterCheckLine"] = 134] = "PrinterCheckLine";
RequestCommandId[RequestCommandId["GetCurrentTimeFormat"] = 18] = "GetCurrentTimeFormat";
/**
* setPrinterTime: 85, 85, 7, 2, 2, 1, 6, -86, -86
* sendCompressMode: 85, 85, 7, 4, b, b2, b3, b4
* setPrinterTime: 85, 85, 7, 8, 1, b, b2, b3, b4, b5, b6, b7, b10, -86, -86
*/
RequestCommandId[RequestCommandId["PrinterConfig2"] = 7] = "PrinterConfig2";
RequestCommandId[RequestCommandId["GetKeyFunction"] = 9] = "GetKeyFunction";
})(RequestCommandId || (exports.RequestCommandId = RequestCommandId = {}));
/**
* Commands IDs from printer to client
*
* @category Packets
**/
var ResponseCommandId;
(function (ResponseCommandId) {
ResponseCommandId[ResponseCommandId["In_Invalid"] = -1] = "In_Invalid";
ResponseCommandId[ResponseCommandId["In_NotSupported"] = 0] = "In_NotSupported";
ResponseCommandId[ResponseCommandId["In_Connect"] = 194] = "In_Connect";
ResponseCommandId[ResponseCommandId["In_CalibrateHeight"] = 105] = "In_CalibrateHeight";
ResponseCommandId[ResponseCommandId["In_CancelPrint"] = 208] = "In_CancelPrint";
ResponseCommandId[ResponseCommandId["In_AntiFake"] = 12] = "In_AntiFake";
ResponseCommandId[ResponseCommandId["In_HeartbeatAdvanced1"] = 221] = "In_HeartbeatAdvanced1";
ResponseCommandId[ResponseCommandId["In_HeartbeatBasic"] = 222] = "In_HeartbeatBasic";
ResponseCommandId[ResponseCommandId["In_HeartbeatUnknown"] = 223] = "In_HeartbeatUnknown";
ResponseCommandId[ResponseCommandId["In_HeartbeatAdvanced2"] = 217] = "In_HeartbeatAdvanced2";
ResponseCommandId[ResponseCommandId["In_LabelPositioningCalibration"] = 143] = "In_LabelPositioningCalibration";
ResponseCommandId[ResponseCommandId["In_PageStart"] = 4] = "In_PageStart";
ResponseCommandId[ResponseCommandId["In_PrintClear"] = 48] = "In_PrintClear";
/** Sent by some printers after {@link RequestCommandId.PageEnd} along with {@link ResponseCommandId.In_PageEnd} */
ResponseCommandId[ResponseCommandId["In_PrinterCheckLine"] = 211] = "In_PrinterCheckLine";
ResponseCommandId[ResponseCommandId["In_PrintEnd"] = 244] = "In_PrintEnd";
ResponseCommandId[ResponseCommandId["In_PrinterConfig"] = 191] = "In_PrinterConfig";
ResponseCommandId[ResponseCommandId["In_PrinterLog"] = 6] = "In_PrinterLog";
ResponseCommandId[ResponseCommandId["In_PrinterInfoAutoShutDownTime"] = 71] = "In_PrinterInfoAutoShutDownTime";
ResponseCommandId[ResponseCommandId["In_PrinterInfoBluetoothAddress"] = 77] = "In_PrinterInfoBluetoothAddress";
ResponseCommandId[ResponseCommandId["In_PrinterInfoSpeed"] = 66] = "In_PrinterInfoSpeed";
ResponseCommandId[ResponseCommandId["In_PrinterInfoDensity"] = 65] = "In_PrinterInfoDensity";
ResponseCommandId[ResponseCommandId["In_PrinterInfoLanguage"] = 70] = "In_PrinterInfoLanguage";
ResponseCommandId[ResponseCommandId["In_PrinterInfoChargeLevel"] = 74] = "In_PrinterInfoChargeLevel";
ResponseCommandId[ResponseCommandId["In_PrinterInfoHardWareVersion"] = 76] = "In_PrinterInfoHardWareVersion";
ResponseCommandId[ResponseCommandId["In_PrinterInfoLabelType"] = 67] = "In_PrinterInfoLabelType";
ResponseCommandId[ResponseCommandId["In_PrinterInfoPrinterCode"] = 72] = "In_PrinterInfoPrinterCode";
ResponseCommandId[ResponseCommandId["In_PrinterInfoSerialNumber"] = 75] = "In_PrinterInfoSerialNumber";
ResponseCommandId[ResponseCommandId["In_PrinterInfoSoftWareVersion"] = 73] = "In_PrinterInfoSoftWareVersion";
ResponseCommandId[ResponseCommandId["In_PrinterInfoArea"] = 79] = "In_PrinterInfoArea";
ResponseCommandId[ResponseCommandId["In_PrinterStatusData"] = 181] = "In_PrinterStatusData";
ResponseCommandId[ResponseCommandId["In_PrinterReset"] = 56] = "In_PrinterReset";
ResponseCommandId[ResponseCommandId["In_PrintStatus"] = 179] = "In_PrintStatus";
/** For example, received after {@link RequestCommandId.SetPageSize} when page print is not started. */
ResponseCommandId[ResponseCommandId["In_PrintError"] = 219] = "In_PrintError";
ResponseCommandId[ResponseCommandId["In_PrintQuantity"] = 22] = "In_PrintQuantity";
ResponseCommandId[ResponseCommandId["In_PrintStart"] = 2] = "In_PrintStart";
ResponseCommandId[ResponseCommandId["In_RfidInfo"] = 27] = "In_RfidInfo";
ResponseCommandId[ResponseCommandId["In_RfidInfo2"] = 29] = "In_RfidInfo2";
ResponseCommandId[ResponseCommandId["In_RfidSuccessTimes"] = 100] = "In_RfidSuccessTimes";
ResponseCommandId[ResponseCommandId["In_SetAutoShutdownTime"] = 55] = "In_SetAutoShutdownTime";
ResponseCommandId[ResponseCommandId["In_SetDensity"] = 49] = "In_SetDensity";
ResponseCommandId[ResponseCommandId["In_SetLabelType"] = 51] = "In_SetLabelType";
ResponseCommandId[ResponseCommandId["In_SetPageSize"] = 20] = "In_SetPageSize";
ResponseCommandId[ResponseCommandId["In_SoundSettings"] = 104] = "In_SoundSettings";
ResponseCommandId[ResponseCommandId["In_PageEnd"] = 228] = "In_PageEnd";
ResponseCommandId[ResponseCommandId["In_PrinterPageIndex"] = 224] = "In_PrinterPageIndex";
ResponseCommandId[ResponseCommandId["In_PrintTestPage"] = 106] = "In_PrintTestPage";
ResponseCommandId[ResponseCommandId["In_WriteRFID"] = 113] = "In_WriteRFID";
ResponseCommandId[ResponseCommandId["In_StartFirmwareUpgrade"] = 246] = "In_StartFirmwareUpgrade";
ResponseCommandId[ResponseCommandId["In_RequestFirmwareCrc"] = 144] = "In_RequestFirmwareCrc";
ResponseCommandId[ResponseCommandId["In_RequestFirmwareChunk"] = 154] = "In_RequestFirmwareChunk";
ResponseCommandId[ResponseCommandId["In_FirmwareCheckResult"] = 157] = "In_FirmwareCheckResult";
ResponseCommandId[ResponseCommandId["In_FirmwareResult"] = 158] = "In_FirmwareResult";
/** Sent before {@link ResponseCommandId.In_PrinterCheckLine } */
ResponseCommandId[ResponseCommandId["In_ResetTimeout"] = 198] = "In_ResetTimeout";
ResponseCommandId[ResponseCommandId["In_GetCurrentTimeFormat"] = 17] = "In_GetCurrentTimeFormat";
ResponseCommandId[ResponseCommandId["In_PrinterConfig2"] = 8] = "In_PrinterConfig2";
ResponseCommandId[ResponseCommandId["In_GetKeyFunction"] = 10] = "In_GetKeyFunction";
})(ResponseCommandId || (exports.ResponseCommandId = ResponseCommandId = {}));
var TX = RequestCommandId;
var RX = ResponseCommandId;
/**
* Map request id to response id. null meant no response expected (one way).
*
* @category Packets
**/
exports.commandsMap = {
[]: null,
[]: null,
[]: null,
[]: null,
[]: [RX.In_Connect],
[]: [RX.In_CancelPrint],
[]: [RX.In_CalibrateHeight],
[]: [RX.In_HeartbeatBasic, RX.In_HeartbeatUnknown, RX.In_HeartbeatAdvanced1, RX.In_HeartbeatAdvanced2],
[]: [RX.In_LabelPositioningCalibration],
[]: [RX.In_PageEnd],
[]: [RX.In_PrinterLog],
[]: [RX.In_PageStart],
[]: [RX.In_PrintClear],
[]: [RX.In_PrintEnd],
[]: [
RX.In_PrinterInfoArea,
RX.In_PrinterInfoAutoShutDownTime,
RX.In_PrinterInfoBluetoothAddress,
RX.In_PrinterInfoChargeLevel,
RX.In_PrinterInfoDensity,
RX.In_PrinterInfoHardWareVersion,
RX.In_PrinterInfoLabelType,
RX.In_PrinterInfoLanguage,
RX.In_PrinterInfoPrinterCode,
RX.In_PrinterInfoSerialNumber,
RX.In_PrinterInfoSoftWareVersion,
RX.In_PrinterInfoSpeed,
],
[]: [RX.In_PrinterConfig],
[]: [RX.In_PrinterStatusData],
[]: [RX.In_PrinterReset],
[]: [RX.In_PrintQuantity],
[]: [RX.In_PrintStart],
[]: [RX.In_PrintStatus],
[]: [RX.In_RfidInfo],
[]: [RX.In_RfidInfo2],
[]: [RX.In_RfidSuccessTimes],
[]: [RX.In_SetAutoShutdownTime],
[]: [RX.In_SetDensity],
[]: [RX.In_SetLabelType],
[]: [RX.In_SetPageSize],
[]: [RX.In_SoundSettings],
[]: [RX.In_AntiFake],
[]: [RX.In_WriteRFID],
[]: [RX.In_PrintTestPage],
[]: [RX.In_StartFirmwareUpgrade],
[]: null,
[]: null,
[]: null,
[]: null,
[]: [RX.In_PrinterCheckLine],
[]: [RX.In_GetCurrentTimeFormat],
[]: [RX.In_PrinterConfig2],
[]: [RX.In_GetKeyFunction]
};
exports.firmwareExchangePackets = {
tx: [TX.FirmwareChunk, TX.FirmwareCrc, TX.FirmwareNoMoreChunks, TX.FirmwareCommit],
rx: [RX.In_RequestFirmwareCrc, RX.In_RequestFirmwareChunk, RX.In_FirmwareCheckResult, RX.In_FirmwareResult],
};