import IPostMessage from '../../IPostMessage'; import IBarcodeScannerDataMessage from './IBarcodeScannerDataMessage'; import IBarcodeScanner, { IBarcodeScannerOptions, IBarcodeScannerResponse } from './IBarcodeScanner'; export declare const DEFAULT_SCANNER_ID = 0; /** * The `sos.hardware.barcodeScanner` API provides methods for working with barcode scanners. * It allows starting and stopping the scanner, as well as listening for scanned data and errors. * * :::note * This API is experimental and may change in the future. * ::: * *
* Device Barcode Scanner Capabilities * | Capability | Description | * |:------------|:-------------| * | `BARCODE_SCANNER` | If device supports serial communication for Barcode Scanners | * * If you want to check if the device supports this capability, use [`sos.display.supports()`](https://developers.signageos.io/sdk/sos/display#supports). *
*/ export default class BarcodeScanner implements IBarcodeScanner { private messagePrefix; private postMessage; static MESSAGE_PREFIX: "barcode_scanner"; private eventEmitter; /** @internal */ constructor(messagePrefix: string, postMessage: IPostMessage); /** * The `getVersion()` method returns the version of the barcode scanner. * * @returns {Promise} Returns a promise that resolves to the version of the barcode scanner. * @throws {Error} If the version cannot be retrieved. * @since 3.0.0 */ getVersion(): Promise; /** * The `start()` starts the barcode scanner and starts listening for scanned data. * @param userOptions User options to configure the scanner. * @param userOptions.timeout The maximum time to wait for a scan before timing out. * @param userOptions.cancelPrevious If set to `true`, it will cancel any previous scanner instance with the same `scannerId`. * @returns Returns a promise that resolves to an object with methods to stop the scanner and listen for scanned data and errors. * @throws {Error} If the scanner cannot be started. * @throws {Error} If the scanner is already running and `cancelPrevious` option is not set to `true`. * @throws {Error} If any other error occurs while starting the scanner. * @since 3.0.0 * * @example * // Start the barcode scanner with default options * const scanner = await sos.hardware.barcodeScanner.start(); * // Listen for scanned data * scanner.onData((data) => { * console.log(`Scanned data: ${data}`); * }); * // Listen for errors * scanner.onError((error) => { * console.error(`Scanner error: ${error.message}`); * }); */ start(userOptions?: Omit): Promise; /** @internal */ handleMessageData(msg: IBarcodeScannerDataMessage): void; private getMessage; }