export enum EventType {
SUCCESS = 0,
NOTIFY = 1,
FAILED = 2
};
EventType: used in the response to the client to determine the type of event expected.
export enum PrinterLibraryActionType {
NONE = 0,
INITIALIZE = 1,
BLUETOOTH_INITIALIZE = 2,
BLUETOOTH_ENABLE = 3,
BLUETOOTH_DISABLE = 4,
DISCOVER_START = 5,
DISCOVER_DETECT = 6,
DISCOVER_FINISH = 7,
CONNECT = 8,
DISCONNECT = 9,
PRINT = 10,
STATUS = 11,
CONFIGURE = 12,
BLUETOOTH_TURNED_OFF = 13,
BLUETOOTH_TURNED_ON = 14
};
PrinterLibraryActionType: used to distinguish the response to certain requests.
- None: general response from the library that does not belong to a specific request.
- Initialize: the event belongs to the initialization process.
- Bluetooth_Initialize: the event belongs to the bluetooth component of the device.
- Bluetooth_enable: the event belongs to  the enable bluetooth request.
- Bluetooth_disable: the event belongs to the disable bluetooth request.
- Bluetooth_turned_on: this event is fired when the bluetooth adapter of the device is turned on. (not in response to the request form the app)
- Bluetooth_turned_off:Â this event is fired when the bluetooth adapter of the device is turned off. (not in response to the request form the app)
- Discover_start: response to the discover request.
- Discover_Detect: a single bluetooth device is detected. (only printers are discovered)
- Discover_Finish: discover process has finished and a list of discoverd devices is submitted. (only printers are discovered)
- Connect: the event belongs to the connection process to a particular printer.
- Disconnect: the event belongs to the disconnection process from a printer.
- Print: the event belongs to the printing process.
- Status: the event contains the response to a status request.
- Configure: response to a printer configuration request.
export enum PrinterStatusType {
OK = 0,
OK_WAITING_TO_DISPENSE = 1,
OK_STILL_PRINTING = 2,
COVER_OPEN = 4,
PAPER_OUT_BEFORE_PRINT = 5,
PAPER_OUT = 6,
RESET = 7,
ISONLINE = 8,
BATTERY_NOT_OK = 9,
PRINTER_OK = 10,
ERROR = 11,
NO_CONNECTION = 12,
NOT_REGISTERED = 13,
COMMAND_FAILED = 14,
PRINT_HALT = 15,
NO_RESPONSE = 16,
MEDIA_ERROR = 17,
STATUS_UNKNOWN = 99
};
PrinterStatusType: errors and notifications sent by the printer.
- OK: all is ok. printer is ready to print.
- OK_WAITING_TO_DISPENSE:Â the printer is in ok state but the label taken sensor detects a label in front of it. The label has to be removed before continue.
- OK_STILL_PRINTING: the printer is in ok state but label printing process is not yet completed.
- COVER_OPEN: the printer cover is open.
- PAPER_OUT_BEFORE_PRINT: the printer is out of paper.
- PAPER_OUT: the printer is out of paper.
- RESET: the printer is in reset state.
- ISONLINE: the printer is in online state.
- BATTERY_NOT_OK: printers battery has been discharged or is damaged.
- PRINTER_OK: printer is ready to print.
- ERROR: an error has occurred.
- NO_CONNECTION: no connection to the printer is established.
- NOT_REGISTERED: the printer or bluetooth device registration failed.
- COMMAND_FAILED: the printer does not recognize the specified command.
- PRINT_HALT: on error has occurred and the printer has halted.
- NO_REPONSE: no response from printer.
- MEDIA_ERROR: printer reported a problem with the media.
- STATUS_UNKNOWN: unspecified error has been received.
Not all messages are available on each printer.
export interface Device {
address: string;
name: string;
bluetoothclass: number;
type: number;
}
export declare class Device implements Device {
constructor(name: string, address: string, bluetoothclass: number, type: number);
}
Device Class fields and methods
- address: the bluetoooth mac address of a particular printer.
- name: the name of the printer (this is not the network hostname)
- bluetoothclass: bluetooth classification number of the device
- type: bluetooth type number of the device.
export interface ResultClass {}
Base class for the result
export class DeviceResult implements ResultClass {
}
DeviceResult class is currently not used.
export interface InitResult {
permissions: string[];
}
export declare class InitResult implements ResultClass, InitResult {
constructor(permissions: string[]);
}
InitResult class fields and methods
- permissions:Â contains a string list of permissions requested or required by the library.Â
export interface PrinterResult {
statusmsg: string;
status: PrinterStatusType;
}
export declare class PrinterResult implements ResultClass, PrinterResult {
constructor(status: PrinterStatusType, statusmsg: string);
}
PrinterResult class fields and methods
- statusmsg: the printer status message.
- status: the printer status type.
export interface BluetoothResult {
adapteradress: string;
adaptername: string;
paireddevices?: Device[];
connecteddevice?: Device;
discovereddevices?: Device[];
discovereddevice?: Device;
setBondedDevices(devices: Device[]): void;
}
export class BluetoothResult implements BluetoothResult {
constructor(adapteraddress: string, adaptername: string) {
this.adapteradress = adapteraddress;
this.adaptername = adaptername;
}
setBondedDevices(devices: Device[]) {
this.paireddevices = devices;
}
}
BluetoothResult class fields and methods
- adapteraddress: bluetooth mac address from the device.
- adaptername: name of the device bluetooth adapter.
- paireddevices(optional): list of bluetooth devices paired with the device bluetooth adapter.
- connecteddevices(optional): list of bluetooth devices connected to the device bluetooth.
- discovereddevices(optional): list of discovered bluetooth devices (DISCOVER_FINISH)
- discovereddevice(optional): the currently detected device in the DEVICE_DETECTED response.
export interface PrinterLibraryEvent {
type: EventType;
message: string;
error: number;
data?: ResultClass;
action: PrinterLibraryActionType;
}
export declare class PrinterLibraryEvent implements PrinterLibraryEvent {
constructor(type: EventType, meaasge: string, error: number, data: ResultClass, action: PrinterLibraryActionType);
}
PrinterLibraryEvent class fileds and methods
- type: one of the values form EventType enumeration.
- message: additional message in human readable format.
- error: errorcode.
- data(optional): one of the above Result Classes depends on the type of request/response.
- action: one of the values from the PrinterLibraryActionType enumeration.
export enum CIDPrinterListenerTypes {
PRINTER_LIBRARY = 'printerLibraryEvent'
};
enumeration that can be used in the eventlistener registration process in the Capacitor app.