capacitor-usb-scale 0.1.4
Install from the command line:
Learn more about npm packages
$ npm install @kduma-autoid/capacitor-usb-scale@0.1.4
Install via package.json:
"@kduma-autoid/capacitor-usb-scale": "0.1.4"
About this version
Capacitor adapter for cheap USB scales like Dymo M10
npm install @kduma-autoid/capacitor-usb-scale
npx cap sync
enumerateDevices()
requestPermission(...)
open(...)
stop()
setIncomingWeightDataCallback(...)
clearIncomingWeightDataCallback()
- Type Aliases
enumerateDevices() => Promise<{ devices: USBDevice[]; }>
Get a list of all connected compatible USB scale devices
Returns: Promise<{ devices: USBDevice[]; }>
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(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() => Promise<void>
Close the USB scale device
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() => Promise<void>
Clears the callback set by setIncomingWeightDataCallback
.
{ id: string, vid: number, pid: number, serial?: string, product: { manufacturer: string, name: string } }
{ data: number[], weight: number, status: ScaleStatus }
"Fault" | "Zero" | "InMotion" | "Stable" | "UnderZero" | "OverWeight" | "NeedCalibration" | "NeedZeroing" | "Unknown"
string
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
.
addEventListener(type: "usb_scale_connected", listener: (ev: { device: USBDevice }) => any, useCapture?: boolean): void;
Emitted when a compatible USB scale device is connected.
addEventListener(type: "usb_scale_disconnected", listener: (ev: { device: USBDevice }) => any, useCapture?: boolean): void;
Emitted when a compatible USB scale device is disconnected.