@kduma-autoid/capacitor-sunmi-uhf
v4.0.0
Published
Capacitor plugin for communication with Sunmi's UHF module SDK
Downloads
17
Maintainers
Readme
@kduma-autoid/capacitor-sunmi-uhf
Capacitor plugin for communication with Sunmi's UHF module SDK
Install
npm install @kduma-autoid/capacitor-sunmi-uhf
npx cap sync
Add following entry to your android/settings.gradle
file:
include ':sunmi-scanner-sdk'
project(':sunmi-scanner-sdk').projectDir = new File('../node_modules/@kduma-autoid/capacitor-sunmi-uhf/android/libs/sunmi-scanner-sdk')
API
getScanModel()
startScanning(...)
setTagReadCallback(...)
clearTagReadCallback()
setInventoryScanCompletedCallback(...)
clearInventoryScanCompletedCallback()
stopScanning()
readTag(...)
writeTag(...)
lockTag(...)
killTag(...)
setAccessEpcMatch(...)
cancelAccessEpcMatch()
getAccessEpcMatch()
setImpinjFastTid(...)
getImpinjFastTid()
getBatteryChargeState()
getBatteryRemainingPercent()
getBatteryChargeNumTimes()
getBatteryVoltage()
getFirmwareVersion()
getReaderSN()
addListener('onReaderConnected', ...)
addListener('onReaderBoot', ...)
addListener('onReaderBootOrConnected', ...)
addListener('onReaderDisconnected', ...)
addListener('onReaderLostConnection', ...)
addListener('onReaderDisconnectedOrLostConnection', ...)
addListener('onBatteryRemainingPercent', ...)
addListener('onBatteryLowElectricity', ...)
addListener('onBatteryRemainingPercentOrLowElectricity', ...)
addListener('onBatteryChargeState', ...)
addListener('onBatteryChargeNumTimes', ...)
addListener('onBatteryVoltage', ...)
addListener('onFirmwareVersion', ...)
addListener('onReaderSN', ...)
removeAllListeners()
- Interfaces
- Type Aliases
getScanModel()
getScanModel() => Promise<{ model: "UHF_S7100" | "UHF_R2000" | "INNER" | "NONE" | "UNKNOWN"; available: boolean; }>
Get RFID type
Returns:
model
- RFID type:UHF_S7100
- UHF S7100,UHF_R2000
- UHF R2000,INNER
- Inner RFID,NONE
- No RFID module,UNKNOWN
- Unknown RFID module.available
- Whether the RFID module is available.
Returns: Promise<{ model: 'UHF_S7100' | 'UHF_R2000' | 'INNER' | 'NONE' | 'UNKNOWN'; available: boolean; }>
startScanning(...)
startScanning(options?: { repeat_times?: number | undefined; } | undefined) => Promise<void>
Starts scanning inventory operation
Parameters:
options.repeat_times
- The number of times the inventory to be repeated. If it is0xFF
, the time used in this inventory round is the shortest time. If there is only one tag in the RF area, the time used in this inventory round is 30-50mS. This parameter value is normally used when quickly polling with several antennas in a four-channel device.
Please note: When the parameter options.repeat_times
is set as 255
(0xFF
), the algorithm specially designed for reading a small amount of tags will be enabled. It is more efficient and sensitive to read a small amount of tags. However, this parameter is not suitable to be used to simultaneously read a large amount of tags.
| Param | Type |
| ------------- | --------------------------------------- |
| options
| { repeat_times?: number; } |
setTagReadCallback(...)
setTagReadCallback(callback: (data: { epc: string; pc: string; frequency: string; rrsi: string; antenna: number; last_updated: number; read_count: number; }) => void) => Promise<CallbackID>
Sets TagReadCallback
| Param | Type |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| callback
| (data: { epc: string; pc: string; frequency: string; rrsi: string; antenna: number; last_updated: number; read_count: number; }) => void |
Returns: Promise<string>
clearTagReadCallback()
clearTagReadCallback() => Promise<void>
Removes TagReadCallback
setInventoryScanCompletedCallback(...)
setInventoryScanCompletedCallback(callback: (data: { rate: number; tags_read: number; details: { start_time: number; end_time: number; }; }) => void) => Promise<CallbackID>
Sets InventoryScanCompletedCallback
| Param | Type |
| -------------- | ------------------------------------------------------------------------------------------------------------------------ |
| callback
| (data: { rate: number; tags_read: number; details: { start_time: number; end_time: number; }; }) => void |
Returns: Promise<string>
clearInventoryScanCompletedCallback()
clearInventoryScanCompletedCallback() => Promise<void>
Removes InventoryScanCompletedCallback
stopScanning()
stopScanning() => Promise<void>
Stops scanning
readTag(...)
readTag(options: { bank: "RESERVED" | "EPC" | "TID" | "USER"; address: number; length: number; password?: string; }) => Promise<{ crc: string; pc: string; epc: string; data: string; details: { data_length: number; antenna: number; tag_read_count: number; start_time: number; end_time: number; }; }>
Tag operation – read tags
Parameters:
options.bank
- Tag memory bank:RESERVED
- Reserved Memory,EPC
- EPC Memory,TID
- TID Memory,USER
- User Memory.options.address
- The first word address of the data read. For the value range, please refer to tag specs.options.length
- The data length, word length or WORD (16 bits) length of the data read; For the value range, please refer to tag specs.options.password
- Tag access password. 4 bytes. If the tag does not have a password, this parameter is not required.
Please note: setAccessEpcMatch
should be done first. Tags with the same EPC but different data read will be deemed as different tags.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------------------------------------ |
| options
| { bank: 'RESERVED' | 'EPC' | 'TID' | 'USER'; address: number; length: number; password?: string; } |
Returns: Promise<{ crc: string; pc: string; epc: string; data: string; details: { data_length: number; antenna: number; tag_read_count: number; start_time: number; end_time: number; }; }>
writeTag(...)
writeTag(options: { bank: "RESERVED" | "EPC" | "TID" | "USER"; address: number; data: string; password?: string; }) => Promise<{ crc: string; pc: string; epc: string; details: { antenna: number; tag_read_count: number; start_time: number; end_time: number; }; }>
Tag operation – write tags
Parameters:
options.bank
- Tag memory bank:RESERVED
- Reserved Memory,EPC
- EPC Memory,TID
- TID Memory,USER
- User Memory.options.address
- The first word address of the data written. For the value range, please refer to tag specs; it usually starts from 02 if it was written into EPC memory bank, and PC + CRC are stored in the first four bytes of this area.options.data
- The data written in Hex String Format.options.password
- Tag access password. 4 bytes. If the tag does not have a password, this parameter is not required.
Please note: setAccessEpcMatch
should be done first. Tags with the same EPC but different data read will be deemed as different tags.
| Param | Type |
| ------------- | ---------------------------------------------------------------------------------------------------------------- |
| options
| { bank: 'RESERVED' | 'EPC' | 'TID' | 'USER'; address: number; data: string; password?: string; } |
Returns: Promise<{ crc: string; pc: string; epc: string; details: { antenna: number; tag_read_count: number; start_time: number; end_time: number; }; }>
lockTag(...)
lockTag(options: { bank: "USER" | "TID" | "EPC" | "ACCESS_PASSWORD" | "KILL_PASSWORD"; type: "OPEN" | "LOCK" | "PERM_OPEM" | "PERM_LOCK"; password: string; }) => Promise<{ crc: string; pc: string; epc: string; details: { antenna: number; tag_read_count: number; start_time: number; end_time: number; }; }>
Tag operation – lock tags
Parameters:
options.bank
- Tag memory bank:USER
- User Memory,TID
- TID Memory,EPC
- EPC Memory,ACCESS_PASSWORD
- Access Password,KILL_PASSWORD
- Kill Password.options.type
- The types of lock operation:OPEN
- open,LOCK
- lock,PERM_OPEM
- permanently open,PERM_LOCK
- permanently locked.options.password
- Tag access password. 4 bytes.
Please note: setAccessEpcMatch
should be done first. Tags with the same EPC but different data read will be deemed as different tags.
| Param | Type |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| options
| { bank: 'EPC' | 'TID' | 'USER' | 'ACCESS_PASSWORD' | 'KILL_PASSWORD'; type: 'OPEN' | 'LOCK' | 'PERM_OPEM' | 'PERM_LOCK'; password: string; } |
Returns: Promise<{ crc: string; pc: string; epc: string; details: { antenna: number; tag_read_count: number; start_time: number; end_time: number; }; }>
killTag(...)
killTag(options: { password: string; }) => Promise<{ crc: string; pc: string; epc: string; details: { antenna: number; tag_read_count: number; start_time: number; end_time: number; }; }>
Tag operation – kill tags
Parameters:
options.password
- Tag access password. 4 bytes.
Please note: setAccessEpcMatch
should be done first. Tags with the same EPC but different data read will be deemed as different tags.
| Param | Type |
| ------------- | ---------------------------------- |
| options
| { password: string; } |
Returns: Promise<{ crc: string; pc: string; epc: string; details: { antenna: number; tag_read_count: number; start_time: number; end_time: number; }; }>
setAccessEpcMatch(...)
setAccessEpcMatch(options: { epc: string; }) => Promise<{ details: { start_time: number; end_time: number; }; }>
Tag operation – set the matched EPC to be accessed (EPC match is valid until the next refresh)
Parameters:
options.epc
- EPC number in Hex String Format.
Please note: Tags with the same EPC but different data read will be deemed as different tags.
| Param | Type |
| ------------- | ----------------------------- |
| options
| { epc: string; } |
Returns: Promise<{ details: { start_time: number; end_time: number; }; }>
cancelAccessEpcMatch()
cancelAccessEpcMatch() => Promise<{ details: { start_time: number; end_time: number; }; }>
Tag operation – clear the matched EPC to be accessed
Returns: Promise<{ details: { start_time: number; end_time: number; }; }>
getAccessEpcMatch()
getAccessEpcMatch() => Promise<{ epc_match: string; details: { start_time: number; end_time: number; }; }>
Tag operation – get EPC match
Returns: Promise<{ epc_match: string; details: { start_time: number; end_time: number; }; }>
setImpinjFastTid(...)
setImpinjFastTid(options: { enable: boolean; save?: boolean; }) => Promise<{ details: { start_time: number; end_time: number; }; }>
Tag operation – set FastTID (only valid to some models of Impinj Monza tags)
Parameters:
options.enable
- FastTID on or off status.options.save
- Save the configuration into the internal Flash, which will prevent it from being lost due to an outage. Default isfalse
.
Please note: This function is only effective to some models of Impinj Monza tags.
Please note: This function recognizes EPC and TID at the same time, thus drastically enhancing the efficiency of reading TID.
Please note: After turning on this function, tags of specific model will package TID into EPC during inventory. Therefore, the PC of a tag will be changed, and the original PC + EPC will become: the modified PC + EPC + (CRC of EPC) + TID.
Please note: If there is something goes wrong when recognizing a TID, the original PC + EPC will be uploaded. ★Please turn off this function if you do not need it to avoid unnecessary time used.
| Param | Type |
| ------------- | ------------------------------------------------- |
| options
| { enable: boolean; save?: boolean; } |
Returns: Promise<{ details: { start_time: number; end_time: number; }; }>
getImpinjFastTid()
getImpinjFastTid() => Promise<{ status: number; details: { start_time: number; end_time: number; }; }>
Tag operation – inquire FastTID
Returns: Promise<{ status: number; details: { start_time: number; end_time: number; }; }>
getBatteryChargeState()
getBatteryChargeState() => Promise<void>
Refreshes the battery charging state. The resulting battery state will be returned in onBatteryChargeState
events.
getBatteryRemainingPercent()
getBatteryRemainingPercent() => Promise<void>
Refreshes the battery remaining percent. The resulting battery remaining percent will be returned in onBatteryRemainingPercent
events.
getBatteryChargeNumTimes()
getBatteryChargeNumTimes() => Promise<void>
Refreshes the battery cycles. The resulting battery cycles will be returned in onBatteryChargeNumTimes
events.
getBatteryVoltage()
getBatteryVoltage() => Promise<void>
Refreshes the battery voltage. The resulting battery voltage will be returned in onBatteryVoltage
events.
getFirmwareVersion()
getFirmwareVersion() => Promise<void>
Refreshes the UHF firmware version. The resulting UHF firmware version will be returned in onFirmwareVersion
events.
getReaderSN()
getReaderSN() => Promise<void>
Refreshes the reader serial number version. The resulting reader serial number version will be returned in onReaderSN
events.
addListener('onReaderConnected', ...)
addListener(eventName: 'onReaderConnected', listenerFunc: () => void) => Promise<PluginListenerHandle>
Listens for reader connected events.
| Param | Type |
| ------------------ | -------------------------------- |
| eventName
| 'onReaderConnected' |
| listenerFunc
| () => void |
Returns: Promise<PluginListenerHandle>
addListener('onReaderBoot', ...)
addListener(eventName: 'onReaderBoot', listenerFunc: () => void) => Promise<PluginListenerHandle>
Listens for reader booted events.
| Param | Type |
| ------------------ | --------------------------- |
| eventName
| 'onReaderBoot' |
| listenerFunc
| () => void |
Returns: Promise<PluginListenerHandle>
addListener('onReaderBootOrConnected', ...)
addListener(eventName: 'onReaderBootOrConnected', listenerFunc: () => void) => Promise<PluginListenerHandle>
Listens for reader connected or booted events.
| Param | Type |
| ------------------ | -------------------------------------- |
| eventName
| 'onReaderBootOrConnected' |
| listenerFunc
| () => void |
Returns: Promise<PluginListenerHandle>
addListener('onReaderDisconnected', ...)
addListener(eventName: 'onReaderDisconnected', listenerFunc: () => void) => Promise<PluginListenerHandle>
Listens for reader disconnected events.
| Param | Type |
| ------------------ | ----------------------------------- |
| eventName
| 'onReaderDisconnected' |
| listenerFunc
| () => void |
Returns: Promise<PluginListenerHandle>
addListener('onReaderLostConnection', ...)
addListener(eventName: 'onReaderLostConnection', listenerFunc: () => void) => Promise<PluginListenerHandle>
Listens for reader lost connection events.
| Param | Type |
| ------------------ | ------------------------------------- |
| eventName
| 'onReaderLostConnection' |
| listenerFunc
| () => void |
Returns: Promise<PluginListenerHandle>
addListener('onReaderDisconnectedOrLostConnection', ...)
addListener(eventName: 'onReaderDisconnectedOrLostConnection', listenerFunc: () => void) => Promise<PluginListenerHandle>
Listens for reader disconnected or lost connection events.
| Param | Type |
| ------------------ | --------------------------------------------------- |
| eventName
| 'onReaderDisconnectedOrLostConnection' |
| listenerFunc
| () => void |
Returns: Promise<PluginListenerHandle>
addListener('onBatteryRemainingPercent', ...)
addListener(eventName: 'onBatteryRemainingPercent', listenerFunc: (event: { charge_level: number; }) => void) => Promise<PluginListenerHandle>
Listens for battery remaining percent events.
| Param | Type |
| ------------------ | ---------------------------------------------------------- |
| eventName
| 'onBatteryRemainingPercent' |
| listenerFunc
| (event: { charge_level: number; }) => void |
Returns: Promise<PluginListenerHandle>
addListener('onBatteryLowElectricity', ...)
addListener(eventName: 'onBatteryLowElectricity', listenerFunc: (event: { charge_level: number; }) => void) => Promise<PluginListenerHandle>
Listens for battery low electricity events.
| Param | Type |
| ------------------ | ---------------------------------------------------------- |
| eventName
| 'onBatteryLowElectricity' |
| listenerFunc
| (event: { charge_level: number; }) => void |
Returns: Promise<PluginListenerHandle>
addListener('onBatteryRemainingPercentOrLowElectricity', ...)
addListener(eventName: 'onBatteryRemainingPercentOrLowElectricity', listenerFunc: (event: { charge_level: number; }) => void) => Promise<PluginListenerHandle>
Listens for battery remaining percent or low electricity events.
| Param | Type |
| ------------------ | ---------------------------------------------------------- |
| eventName
| 'onBatteryRemainingPercentOrLowElectricity' |
| listenerFunc
| (event: { charge_level: number; }) => void |
Returns: Promise<PluginListenerHandle>
addListener('onBatteryChargeState', ...)
addListener(eventName: 'onBatteryChargeState', listenerFunc: (event: { state: "Unknown" | "NotCharging" | "PreCharging" | "QuickCharging" | "Charged"; }) => void) => Promise<PluginListenerHandle>
Listens for battery charge state events.
| Param | Type |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------ |
| eventName
| 'onBatteryChargeState' |
| listenerFunc
| (event: { state: 'Unknown' | 'NotCharging' | 'PreCharging' | 'QuickCharging' | 'Charged'; }) => void |
Returns: Promise<PluginListenerHandle>
addListener('onBatteryChargeNumTimes', ...)
addListener(eventName: 'onBatteryChargeNumTimes', listenerFunc: (event: { battery_cycles: number; }) => void) => Promise<PluginListenerHandle>
Listens for battery charge num times events.
| Param | Type |
| ------------------ | ------------------------------------------------------------ |
| eventName
| 'onBatteryChargeNumTimes' |
| listenerFunc
| (event: { battery_cycles: number; }) => void |
Returns: Promise<PluginListenerHandle>
addListener('onBatteryVoltage', ...)
addListener(eventName: 'onBatteryVoltage', listenerFunc: (event: { voltage: number; }) => void) => Promise<PluginListenerHandle>
Listens for battery voltage events.
| Param | Type |
| ------------------ | ----------------------------------------------------- |
| eventName
| 'onBatteryVoltage' |
| listenerFunc
| (event: { voltage: number; }) => void |
Returns: Promise<PluginListenerHandle>
addListener('onFirmwareVersion', ...)
addListener(eventName: 'onFirmwareVersion', listenerFunc: (event: { version: string; major: number; minor: number; }) => void) => Promise<PluginListenerHandle>
Listens for UHF firmware version events.
| Param | Type |
| ------------------ | ----------------------------------------------------------------------------------- |
| eventName
| 'onFirmwareVersion' |
| listenerFunc
| (event: { version: string; major: number; minor: number; }) => void |
Returns: Promise<PluginListenerHandle>
addListener('onReaderSN', ...)
addListener(eventName: 'onReaderSN', listenerFunc: (event: { sn: string; region: "America" | "Europe" | "China" | "Unknown"; band_low: number; band_high: number; }) => void) => Promise<PluginListenerHandle>
Listens for reader serial number events.
| Param | Type |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| eventName
| 'onReaderSN' |
| listenerFunc
| (event: { sn: string; region: 'Unknown' | 'America' | 'Europe' | 'China'; band_low: number; band_high: number; }) => void |
Returns: Promise<PluginListenerHandle>
removeAllListeners()
removeAllListeners() => Promise<void>
Removes all listeners
Interfaces
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove
| () => Promise<void> |
Type Aliases
CallbackID
string