Skip to content

capacitor-usb-scale 0.1.1

Install from the command line:
Learn more about npm packages
$ npm install @kduma-autoid/capacitor-usb-scale@0.1.1
Install via package.json:
"@kduma-autoid/capacitor-usb-scale": "0.1.1"

About this version

@kduma-autoid/capacitor-usb-scale

Capacitor adapter for cheap USB scales like Dymo M10

Install

npm install @kduma-autoid/capacitor-usb-scale
npx cap sync

API

enumerateDevices()

enumerateDevices() => Promise<{ devices: USBDevice[]; }>

Get a list of all connected compatible USB scale devices

Returns: Promise<{ devices: USBDevice[]; }>


requestPermission(...)

requestPermission(device?: string | undefined) => Promise<{ status: boolean; }>

Request permission to access the USB scale device

Param Type Description
device string The device to request permission for. If not specified, the first device will be used.

Returns: Promise<{ status: boolean; }>


open(...)

open(device?: string | undefined) => Promise<void>

Open the USB scale device for data reading

Param Type Description
device string The device to open. If not specified, the first device will be used.

stop()

stop() => Promise<void>

Close the USB scale device


setIncomingWeightDataCallback(...)

setIncomingWeightDataCallback(callback: (data: ScaleRead) => void) => Promise<CallbackID>

Sets a callback to be called when the scale sends data. If callback is not set, there will bi raised an usb_scale_read event.

Param Type Description
callback (data: ScaleRead) => void The callback to be called when the scale sends data.

Returns: Promise<string>


clearIncomingWeightDataCallback()

clearIncomingWeightDataCallback() => Promise<void>

Clears the callback set by setIncomingWeightDataCallback.


Type Aliases

USBDevice

{ id: string, vid: number, pid: number, serial?: string, product: { manufacturer: string, name: string } }

ScaleRead

{ data: number[], weight: number, status: ScaleStatus }

ScaleStatus

"Fault" | "Zero" | "InMotion" | "Stable" | "UnderZero" | "OverWeight" | "NeedCalibration" | "NeedZeroing" | "Unknown"

CallbackID

string

Events

usb_scale_read

addEventListener(type: "usb_scale_read", listener: (ev: ScaleRead) => any, useCapture?: boolean): void;

Emitted when the scale sends data, and there is no callback set by setIncomingWeightDataCallback.

usb_scale_connected

addEventListener(type: "usb_scale_connected", listener: (ev: { device: USBDevice }) => any, useCapture?: boolean): void;

Emitted when a compatible USB scale device is connected.

usb_scale_disconnected

addEventListener(type: "usb_scale_disconnected", listener: (ev: { device: USBDevice }) => any, useCapture?: boolean): void;

Emitted when a compatible USB scale device is disconnected.

Details


Assets

  • capacitor-usb-scale-0.1.1.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0