Movatterモバイル変換


[0]ホーム

URL:


Getting Started

SeeREADME.md for getting started tutorial.

Core

Core
Static Members
new Pn532()

The Core library of PN532. A Pn532 instance must register exactly one adapter plugin to communication to PN532 hardware.

new Pn532()
Example
// setupconst {  _,// lodash: https://cdn.jsdelivr.net/npm/lodash@4/lodash.min.jsPn532: {Pn532,Packet,utils:Pn532utils },Crypto1,Pn532Hf14a,Pn532WebbleAdapter,Pn532WebserialAdapter,} =windowconst pn532usb =newPn532()pn532usb.use(newPn532WebserialAdapter())
Instance Members
parameters

Internal parameters of the PN532 to configure its behavior regarding different cases.

parameters

Type:number

middlewares

Stores registered middlewares to be compose. Middleware is similar to hooks.middleware will be compose and execute in order at specifickey hook.

middlewares

Type:object

Related
https://github.com/koajs/compose
plugins

Stores registered plugins

plugins

Type:Map

respBuf

Buffer of unhandled response

respBuf

Type:Array<PN532Frame>

rxBuf

Buffer of unhandled response bytes

rxBuf

Type:Packet

tx

ATransformStream to send frame to Adapter

tx

Type: TransformStream

rx

ATransformStream to read frame from Adapter

rx

Type: TransformStream

use(plugin, option)

install a plugin instance to this PN532 instance.

use(plugin:object, option:object): this
Parameters
plugin(object) A plugin instance to install
option(object ={}) option passthrough toplugin#install
Returns
this:this
Related
https://developers.line.biz/en/docs/liff/liff-plugin/
Example
// setupconst {  _,// lodash: https://cdn.jsdelivr.net/npm/lodash@4/lodash.min.jsPn532: {Pn532,Packet,utils:Pn532utils },Crypto1,Pn532Hf14a,Pn532WebbleAdapter,Pn532WebserialAdapter,} =windowconst pn532usb =newPn532()pn532usb.use(newPn532WebserialAdapter())
hasPlugin(pluginId)

Determines whetherpluginId has been installed.

hasPlugin(pluginId:string):boolean
Parameters
pluginId(string) plugin identifier
Returns
boolean: Indicating whether or not thepluginId has been installed.
addMiddleware(key, middleware)

Middleware is similar to hooks.middleware will be compose and execute in order at specifickey hook.

addMiddleware(key:string, middleware: any)
Parameters
key(string) which key to be add
middleware(any) middleware function with formatasync (ctx, next) => {}
Related
https://github.com/koajs/compose
writePacket(pack)

Write Packet to Adapter

writePacket(pack: any):Promise<null>
Parameters
pack(any) A pack to be write to adapter
Returns
Promise<null>: Resolve after finish.
sendCommandNormal(args)

Send a command to adapter via PN532 noraml frame.

sendCommandNormal(args:object):Promise<null>
Parameters
args(object)
NameDescription
args.cmdnumberPN532 command
args.dataPacket (defaultnew Packet())PN532 command data. Max size is 253 bytes.
Returns
Promise<null>: Resolve after finish.
sendCommandExtended(args)

Send a command to adapter via PN532 extended frame.

sendCommandExtended(args:object):Promise<null>
Parameters
args(object)
NameDescription
args.cmdnumberPN532 command
args.dataPacket (defaultnew Packet())PN532 command data. Max size is 65533 bytes.
Returns
Promise<null>: Resolve after finish.
sendCommandWakeup()

Send a Wakeup Command.

sendCommandWakeup():Promise<null>
Returns
Promise<null>: Resolve after finish.
resetSettings()

Reset parameters and internal registers of PN532 to default value.

resetSettings():Promise<null>
Returns
Promise<null>: Resolve after finish.
Related
PN532/C1 P.189
clearRespBuf()

Clear the buffer of unhandled response.

clearRespBuf()
readRespTimeout(args)

Read any response or specific response from adapter.

readRespTimeout(args:object):Promise<Pn532Frame>
Parameters
args(object)
NameDescription
args.cmdnumber (defaultnull)Expected cmd of response. Response will be skipped whencmd is notnull and cmd of response is not equals tocmd.
args.timeoutnumber (default5e3)The maxinum timeout for waiting response.
args.respValidatorfunction (defaultnull)Custom validator of resp.
Returns
Promise<Pn532Frame>: Resolve with raw response need to be parsed.
diagnose(args)

This command is designed for self-diagnosis.

diagnose(args:object):Promise<Pn532Frame>
Parameters
args(object ={})
NameDescription
args.testnumber (default0x00)Test number to be executed by the PN532 (1 byte),
args.dataPacket (defaultnew Packet())diagnosis command data.
args.timeoutnumberThe maxinum timeout for waiting response.
Returns
Promise<Pn532Frame>: Resolve with raw response (contains from 1 to 262 bytes data) need to be parsed.
testCommunication(utf8)

This test is for communication test between host controller and the PN532. "Parameter Length" and "Parameters" in response packet are same as "Parameter Length" and "Parameter" in command packet.

testCommunication(utf8:string):Promise<boolean>
Parameters
utf8(string ='ping') A utf8 string to test
Returns
Promise<boolean>: Resolve with test result.
testRom()

This test is for checking ROM data by 8 bits checksum.

testRom():Promise<boolean>
Returns
Promise<boolean>: Resolve with test result.
testRam()

This test is for checking RAM; 768 bytes of XRAM and 128 bytes of IDATA. The test method used consists of saving original content, writing test data, checking test data and finally restore original data. So, this test is non destructive.

testRam():Promise<boolean>
Returns
Promise<boolean>: Resolve with test result.
testTargetPolling(baudrate)

This test is for checking the percentage of failure regarding response packet receiving after polling command transmission. In this test, the PN532 sends a FeliCa polling command packet 128 times to target. The PN532 counts the number of fails and returns the failed number to host controller. This test doesn’t require specific system code for target.

Polling is done with system code (0xFF, 0xFF). The baud rate used is either 212 kbps or 424 kbps.

One polling is considered as defective after no correct polling response within 4 ms. During this test, the analog settings used are those defined in command RFConfiguration within the item n°7 (§7.3.1, p: 101).

testTargetPolling(baudrate: integer):Promise<number>
Parameters
baudrate(integer =0x01) 0x01: 212 kbps, 0x02: 424 kbps
Returns
Promise<number>: Resolve with Number of fails (Maximum 128).
testTargetPresent()

This test can be used by an initiator to ensure that a target/card is still in the field:

  • In case of DEP target, an Attention Request command is sent to the target, and it is expected to receive the same answer from the target. In that case, the test is declared as successful;
  • In case of ISO/IEC14443-4 card, a R(NACK) block is sent to the card and it is expected to receive either a R(ACK) block or the last I-Block. In that case, the test is declared as successful (ISO/IEC14443-4 card is still in the RF field).
testTargetPresent():Promise<boolean>
Returns
Promise<boolean>: Resolve with a boolean indicating whether or not the target is present.
testSelfAntenna()

This test is used to check the continuity of the transmission paths of the antenna.

testSelfAntenna():Promise<number>
Returns
Promise<number>: Resolve with test result. 0x00: OK, others: Not OK (no antenna is detected)
getFirmwareVersion()

The PN532 sends back the version of the embedded firmware.

getFirmwareVersion():Promise<object>
Returns
Promise<object>: Resolve with objectres:
  • res.firmware (string): Version and revision of the firmware.
  • res.ic (string): Version of the IC. For PN532, the value isPN532.
  • res.iso14443a (boolean): Indicating whether or not support ISO/IEC 14443 TypeA
  • res.iso14443b (boolean): Indicating whether or not support ISO/IEC 14443 TypeB
  • res.iso18092 (boolean): Indicating whether or not support ISO18092
readRegisters(adrs)

This command is used to read the content of one or several internal registers of the PN532 (located either in the SFR area or in the XRAM memory space).

readRegisters(adrs:Array<number>):Promise<object>
Parameters
adrs(Array<number> =[]) One or several internal registers of the PN532 to read. The High Byte of the address of the SFR registers should be set to0xFF.
Returns
Promise<object>: Resolve with an object which key is register address and value is register value.
writeRegisters(regs)

This command is used to overwrite the content of one or several internal registers of the PN532 (located either in the SFR area or in the XRAM memory space).

writeRegisters(regs:object):Promise<null>
Parameters
regs(object) key is register address and value is register value.
Returns
Promise<null>: Resolve after finish.
updateRegistersWithMask(rows)

This command is used to update the masked value of several internal registers of the PN532 (located either in the SFR area or in the XRAM memory space).

updateRegistersWithMask(rows:Array<{adr:number, mask:number, value:number}>):Promise<null>
Parameters
rows(Array<{adr:number, mask:number, value:number}> =[]) An array of register address and masked value to be update.
Returns
Promise<null>: Resolve after finish.
Related
PN532/C1 P.189
readGpio()

The PN532 reads the value for each port and returns the information to the host controller.

readGpio():Promise<Pn532~Gpio>
Returns
Promise<Pn532~Gpio>: SeePn532~Gpio for more description.
writeGpio(gpio)

The PN532 applies the value for each port that is validated by the host controller.

writeGpio(gpio:Pn532~Gpio):Promise<null>
Parameters
gpio(Pn532~Gpio ={}) SeePn532~Gpio for more description.
Returns
Promise<null>: Resolve after finish.
setParameters(flags)

This command is used to set internal parameters of the PN532, and then to configure its behavior regarding different cases.

setParameters(flags:number):Promise<null>
Parameters
flags(number) A 8-bit unsigned integer indicates new internal parameters of PN532.flags is a bit-field byte which individual definition is the following:
BitValueNameDefinition
00x01PARAM_NAD_USEDUse of the NAD information in case of initiator configuration (DEP and ISO/IEC14443-4 PCD).
10x02PARAM_DID_USEDUse of the DID information in case of initiator configuration (or CID in case of ISO/IEC14443-4 PCD configuration).
20x04PARAM_AUTO_ATR_RESAutomatic generation of the ATR_RES in case of target configuration.
30x08RFUMust be set to 0.
40x10PARAM_AUTO_RATSAutomatic generation of the RATS in case of ISO/IEC14443-4 PCD mode.
50x20PARAM_14443_4_PICCThe emulation of a ISO/IEC14443-4 PICC is enabled.
60x40PARAM_NO_AMBLEThe PN532 does not send Preamble and Postamble.
70x80RFUMust be set to 0.
Returns
Promise<null>: Resolve after finish.
Related
PN532 User Manual P.85
samConfiguration(args)

This command is used to select the data flow path by configuring the internal serial data switch.

samConfiguration(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.modenumber (default1)defines the way of using the SAM (Security Access Module):
  • 0x01:Normal mode, the SAM is not used; this is the default mode
  • 0x02:Virtual Card, the couple PN532+SAM is seen as only one contactless SAM card from the external world
  • 0x03:Wired Card, the host controller can access to the SAM with standard PCD commands (InListPassiveTarget,InDataExchange, ...)
  • 0x04:Dual Card, both the PN532 and the SAM are visible from the external world as two separated targets.

Virtual, Wired and Dual Card mode are only valid with 106kbps ISO14443-3 and 4 type A and Mifare.

args.timeoutnumber (default0x14)Defines the timeout only in Virtual card configuration (Mode =0x02). In Virtual Card mode, this field is required; whereas in the other mode, it is optional. This parameter indicates the timeout value with a LSB of 50ms. There is no timeout control if the value isnull (Timeout = 0). The maximum value for the timeout is 12.75 sec (Timeout =0xFF).
args.irqnumber (defaultnull)Specifies if the PN532 takes care of theP70_IRQ pin or not.
  • 0x00: theP70_IRQ pin remains at high level
  • 0x01: theP70_IRQ pin is driven by the PN532.
  • null: The default value is0x01.
Returns
Promise<null>: Resolve after finish.
rfConfiguration(args)

This command is used to configure the different settings of the PN532 as described in the input section of this command.

rfConfiguration(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.itemnumberItem of the configuration.
args.dataPacket (defaultnew Packet())Data of the configuration.
Returns
Promise<null>: Resolve after finish.
rfSetField(args)

Switching on or off the RF field immediately.

When the bit AutoRFCA is off, the PN532 does not need to take care of external field before switching on its own field. In other words, if the bit AutoRFCA is off and RFon/off is on, the PN532 will generate RF field whatever external field is (present or not).

rfSetField(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.autoRfcaboolean (default1)
args.rfOnOffboolean (default0)
Returns
Promise<null>: Resolve after finish.
rfSetTimeouts(args)

Set timeouts of PN532.

Byte ValueTimeout Value
0x00no timeout
0x01100 μs
0x02200 μs
0x03400 μs
0x04800 μs
0x051.6 ms
0x063.2 ms
0x076.4 ms
0x0812.8 ms
0x0925.6 ms
0x0A51.2 ms
0x0B102.4 ms
0x0C204.8 ms
0x0D409.6 ms
0x0E819.2 ms
0x0F1.64 sec
0x0A3.28 sec
rfSetTimeouts(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.atrresnumber (default0x0B)defines the timeout betweenATR_REQ andATR_RES
args.retrynumber (default0x0A)defines the timeout value that the PN532 uses in theInCommunicateThru andInDataExchange
Returns
Promise<null>: Resolve after finish.
rfSetMaxRetries(args)

Define the number of retries that the PN532 will use in case of the following processes.

rfSetMaxRetries(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.atrobject (default0xFF)A byte containing the number of times that the PN532 will retry to send theATR_REQ in case of incorrect reception of theATR_RES (or no reception at all - timeout).
  • Foractive mode, value0xFF means to try eternally,0x00 means only once (no retry, only one try). The default value of this parameter is0xFF (infinitely).
  • Forpassive mode, the value is always overruled with0x02 (two retries).
args.pslobject (default0x01)A byte containing the number of times. Value0xFF means to try eternally,0x00 means only once (no retry, only one try). The default value of this parameter is0x01 (thePSL_REQ/PPS request is sent twice in case of need).
  • The PN532 will retry to send thePSL_REQ in case of incorrect reception of thePSL_RES (or no reception at all) for the NFC IP1 protocol
  • The PN532 will retry to send thePPS request in case of incorrect reception of the PPS response (or no reception at all) for the ISO/IEC14443-4protocol.
args.passiveActivationobject (default0xFF)A byte containing the number of times that the PN532 will retry to activate a target inInListPassiveTarget command (§7.3.5, p: 115). Value0xFF means to try eternally,0x00 means only once (no retry, only one try). The default value of this parameter is0xFF (infinitely).
Returns
Promise<null>: Resolve after finish.
inListPassiveTarget(args)

This command is used to detect as many targets (maximumMaxTg) as possible in passive mode.

inListPassiveTarget(args:object):Promise<Pn532Frame>
Parameters
args(object ={})
NameDescription
args.maxTgnumber (default1)The maximum number of targets to be initialized by the PN532. The PN532 is capable of handling 2 targets maximum at once, so this field should not exceed0x02. For Jewel card, only one target can be initialized.
args.brTynumber (default0)The baud rate and the modulation type to be used during the initialization.
  • 0x00: 106 kbps type A (ISO/IEC14443 Type A)
  • 0x01: 212 kbps (FeliCa polling)
  • 0x02: 424 kbps (FeliCa polling)
  • 0x03: 106 kbps type B (ISO/IEC14443-3B)
  • 0x04: 106 kbps Innovision Jewel tag
args.dataPacket (defaultnew Packet())InitiatorData to be used during the initialization of the target(s). Depending on the Baud Rate specified, the content of this field is different:
  • 106 kbps type A: The field is optional and is present only when the host controller wants to initialize a target with a known UID. In that case, InitiatorData contains the UID of the card (or part of it). The UID must include the cascade tag CT if it is cascaded level 2 or 3.

  • 106 kbps type B: data is consisted as following:
    • AFI (1 byte): This field is required. The AFI (Application Family Identifier) parameter represents the type of application targeted by the PN532 and is used to pre-select the PICCs before the ATQB.
    • Polling Method: This field is optional. It indicates the approach to be used in the ISO/IEC14443- 3B initialization:
      • If bit 0 = 1: Probabilistic approach (option 1) in the ISO/IEC14443-3B initialization
      • If bit 0 = 0: Timeslot approach (option 2) in the ISO/IEC14443-3B initialization
      • If this field is absent, the timeslot approach will be used.
  • 212/424 kbps: In that case, this field is required and contains the complete payload information that should be used in the polling request command (5 bytes, length byte is excluded) as defined in Error! Reference source not found. §11.2.2.5.
  • 106 kbps Innovision Jewel tag: This field is not used.
args.timeoutnumber (default3e4)The maxinum timeout for waiting response.
Returns
Promise<Pn532Frame>: Resolve with raw response need to be parsed.
Related
PN532 User Manual P.116
inDataExchange(args)

This command is used to support protocol data exchanges between the PN532 as initiator and a target.

inDataExchange(args:object):Promise<Pn532Frame>
Parameters
args(object ={})
NameDescription
args.tgnumber (default1)A byte containing the logical number of the relevant target. This byte contains also a More Information (MI) bit (bit 6) indicating, when set to 1, that the host controller wants to send more data that all the data contained in the DataOut array (see Chaining mechanism §7.4.5, p: 178). This bit is only valid for a TPE target.
args.dataPacket (defaultnew Packet())An array of raw data to be sent to the target by the PN532 (max. 263 bytes, see §7.4.7, p:186).
args.timeoutnumberThe maxinum timeout for waiting response.
args.respValidatorfunctionCustom validator of resp.
Returns
Promise<Pn532Frame>: Resolve with raw response need to be parsed.
Related
PN532 User Manual P.127
inCommunicateThru(args)

This command is used to support basic data exchanges between the PN532 and a target.

inCommunicateThru(args:object):Promise<Pn532Frame>
Parameters
args(object ={})
NameDescription
args.dataPacket (defaultnew Packet())An array of raw data to be sent to the target by the PN532 (max. 264 bytes, see §7.4.7, p:186).
args.timeoutnumberThe maxinum timeout for waiting response.
args.respValidatorfunctionCustom validator of resp.
Returns
Promise<Pn532Frame>: Resolve with raw response need to be parsed.
inDeselect(args)

This command is used to deselect the target(s) Tg. The PN532 keeps all the information relative to this target.

inDeselect(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.tgnumber (default0)A byte containing the logical number of the relevant target (0x00 is a specific value indicating all targets).
Returns
Promise<null>: Resolve after finish.
inRelease(args)

This command is used to release the target(s) Tg.

inRelease(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.tgnumber (default0)A byte containing the logical number of the relevant target (0x00 is a specific value indicating all targets).
Returns
Promise<null>: Resolve after finish.
inSelect(args)

This command is used to select the target Tg.

inSelect(args:object):Promise<null>
Parameters
args(object)
NameDescription
args.tgnumberA byte containing the logical number of the relevant target.
Returns
Promise<null>: Resolve after finish.
inAutoPoll(args)

This command is used to poll card(s) / target(s) of specified Type present in the RF field.

inAutoPoll(args:object):Promise<Pn532Frame>
Parameters
args(object ={})
NameDescription
args.pollNrnumberspecifies the number of polling (one polling is a polling for each Type).
  • 0x01 ~0xFE: polling upto 1 ~ 254 times.
  • 0xFF: Endless polling.
args.periodnumber(0x01 ~0x0F) Indicates the polling period in units of150 ms.
args.typesArray<number> (default[])Indicates the target types to be polled. Format for each type as following:

  • bit 0-2: Baudrate and modulation
    • 0x0: 106 kbps ISO/IEC14443 type A
    • 0x1: 212 kbps
    • 0x2: 424 kbps
    • 0x3: 106 kbps ISO/IEC14443 type B
    • 0x4: Innovision Jewel tag
  • bit 3: RFU, set to0.
  • bit 4: set to1 if target is Mifare or FeliCa card.
  • bit 5: set to1 if target is ISO/IEC14443-4 compliant.
  • bit 6: set to1 if target is DEP.
  • bit 7: set to0 if target is passive mode, set to1 if target is active mode.

The possible types are listed below:

  • 0x00: Generic passive 106 kbps (ISO/IEC14443-4A, Mifare and DEP)
  • 0x01: Generic passive 212 kbps (FeliCa and DEP)
  • 0x02: Generic passive 424 kbps (FeliCa and DEP)
  • 0x03: Passive 106 kbps ISO/IEC14443-4B
  • 0x04: Innovision Jewel tag
  • 0x10: Mifare card
  • 0x11: FeliCa 212 kbps card
  • 0x12: FeliCa 424 kbps card
  • 0x20: Passive 106 kbps ISO/IEC14443-4A
  • 0x23: Passive 106 kbps ISO/IEC14443-4B
  • 0x40: DEP passive 106 kbps
  • 0x41: DEP passive 212 kbps
  • 0x42: DEP passive 424 kbps
  • 0x80: DEP active 106 kbps
  • 0x81: DEP active 212 kbps
  • 0x82: DEP active 424 kbps
args.timeoutnumberThe maxinum timeout for waiting response.
Returns
Promise<Pn532Frame>: Resolve with raw response need to be parsed.
new Packet(args)

The Packet class extends Uint8Array, contains some member function of DataView and add some helper function.

new Packet(args: ...any)

ExtendsUint8Array

Parameters
args(...any)
Example
// new Packet()const pack =newPacket()
// new Packet(length)// @param {!number} length When called with a `length` argument, an internal array buffer is created in memory, of size `length` multiplied by  `BYTES_PER_ELEMENT` bytes, containing zeros.const pack =newPacket(1)
// new Packet(typedArray)// @param {!TypedArray} typedArray When called with a `typedArray` argument, which can be an object of any of the non-bigint typed-array types (such as `Int32Array`), the `typedArray` get copied into a new typed array. Each value in `typedArray` is converted to the corresponding type of the constructor before being copied into the new array. The length of the new typed array will be same as the length of the `typedArray` argument.const pack =newPacket(newUint8Array([1]))
// new Packet(buffer, byteOffset=, length=)// @param {!ArrayBuffer} buffer When called with a `buffer`, and optionally a `byteOffset` and a `length` argument, a new typed array view is created that views the specified [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer). The `byteOffset` and `length` parameters specify the memory range that will be exposed by the typed array view. If both are omitted, all of `buffer` is viewed; if only `length` is omitted, the remainder of `buffer` is viewed.// @param {number} [byteOffset=0] must be a integer, default to 0// @param {number} [length=buffer.byteLength] must be a integer, default to `buffer.byteLength`const pack =newPacket((newUint8Array([1])).buffer)
Static Members
fromView(view)

Returns a new Packet object initialized from one of theArrayBuffer views

fromView(view: (TypedArray |DataView)):Packet
Parameters
view((TypedArray |DataView)) one of theArrayBuffer views, such astyped array objects or aDataView.
Returns
Packet: a new Packet object initialized from one of theArrayBuffer views
Example
const pack =Packet.fromView(newUint8Array([1]))
fromHex(hex, reverse)

Returns a new Packet object initialized from a string of hex numbers.

fromHex(hex: !string, reverse:boolean):Packet
Parameters
hex(!string) String containing hex numbers.
reverse(boolean =false)true if the string of hex numbers is little endian.
Returns
Packet: a new Packet object initialized from a string of hex numbers.
Example
console.log(Packet.fromHex('01020304').hex)// 01020304console.log(Packet.fromHex('01020304',true).hex)// 04030201
fromBase64(base64)

Returns a new Packet object initialized from a base64 or base64url string.

fromBase64(base64: !string):Packet
Parameters
base64(!string) String with base64 or base64url encoding.
Returns
Packet: a new Packet object initialized from a base64 or base64url string.
Example
console.log(Packet.fromBase64('AA==').base64url)// AA
fromUtf8(utf8)

Returns a new Packet object initialized from a utf8 string.

fromUtf8(utf8: !string):Packet
Parameters
utf8(!string) String with utf8 encoding.
Returns
Packet: a new Packet object initialized from a utf8 string.
Example
const pack =Packet.fromUtf8('Hello world.')
merge(packs)

Returns a newPacket which is the result of concatenating all thePacket instances in thepacks together.

If thepacks has no items, then a new zero-lengthPacket is returned.

merge(packs: ...Packet):Packet
Parameters
packs(...Packet) List ofPacket orUint8Array instances to concatenate.
Returns
Packet: a new Packet object merge from two or more Packets
Example
const pack =Packet.merge(Packet.fromUtf8('Hello '),Packet.fromUtf8('world.'))
isLen(pack, len)

Determines whetherpack is instance ofPacket andpack.length is equal tolen.pack.length will not be validated iflen isnull.

isLen(pack: any, len:number):boolean
Parameters
pack(any) a data to be validate
len(number =null)pack.length should be integer ornull.pack.length will not be validated iflen isnull.
Returns
boolean: Indicating whether or notpack is an instance ofPacket and thepack.length equals tolen.
Example
if (!Packet.isLen(key,6))thrownewTypeError('invalid key')
Instance Members
isEqual(other)

Determines whether the two Packet has the same data.

isEqual(other: any):boolean
Parameters
other(any) The other value to compare.
Returns
boolean: Indicating whether or not the other value has the same data.
Example
const pack1 =newPacket([1,2])const pack2 =newPacket([3,4])if (!pack1.isEqual(pack2))thrownewError('not equal')
chunk(bytesPerChunk)

Creates a new array of Packet with length ofbytesPerChunk. The final chunk will be the remaining data iflength isn't multiple ofbytesPerChunk.

chunk(bytesPerChunk:number):Array<Packet>
Parameters
bytesPerChunk(number) must be a integer.
Returns
Array<Packet>: A new array of Packet
Example
console.log(JSON.stringify(Packet.fromHex('00010203040506').chunk(3)))// ["Packet(3): 000102","Packet(3): 030405","Packet(1): 06"]
xor

The xor value of every byte in the Packet.

xor

Type:number

Example
console.log(Packet.fromHex('01020304').xor)// 4
hex

hex string of the Packet

hex

Type:string

Example
console.log(Packet.fromHex('123456').hex)// 123456
rhex

reversed hex string of the Packet

rhex

Type:string

Example
console.log(Packet.fromHex('123456').rhex)// 563412
inspect

A string with formatPacket(length): hex

inspect

Type:string

Example
console.log(Packet.fromHex('123456').inspect)// Packet(3): 12 34 56
utf8

utf8 string of the Packet

utf8

Type:string

Example
console.log(Packet.fromHex('616263').utf8)// abc
base64

base64 string of the Packet

base64

Type:string

Example
console.log(Packet.fromHex('616263').base64)// YWJj
base64url

base64url string of the Packet

base64url

Type:string

Example
console.log(Packet.fromHex('616263').base64url)// YWJj
offset

ThebyteOffset of thePackets underlyingArrayBuffer object.

offset

Type:number

Example
console.log(Packet.fromHex('616263').offset)// 0
toJSON()

the member function will be invoked when usingJSON.stringify

toJSON():string
Returns
string: A string with formatPacket(length): hex
toString()

the member function will be invoked when convert Packet to string.

toString():string
Returns
string: A string with formatPacket(length): hex
getBigInt64(byteOffset, littleEndian)

Get a signed 64-bit integer (long long) at the specified byte offset from the start of the Packet.

getBigInt64(byteOffset:number, littleEndian:boolean): BigInt
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to read the data from.
littleEndian(boolean =true) Indicates whether the 64-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is read.
Returns
BigInt: A BigInt.
getBigUint64(byteOffset, littleEndian)

Get an unsigned 64-bit integer (unsigned long long) at the specified byte offset from the start of the Packet.

getBigUint64(byteOffset:number, littleEndian:boolean): BigInt
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to read the data from.
littleEndian(boolean =true) Indicates whether the 64-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is read.
Returns
BigInt: A BigInt.
getFloat32(byteOffset, littleEndian)

Get a signed 32-bit float (float) at the specified byte offset from the start of the Packet.

getFloat32(byteOffset:number, littleEndian:boolean):number
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to read the data from.
littleEndian(boolean =true) Indicates whether the 32-bit float is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is read.
Returns
number: A signed 32-bit float number.
getFloat64(byteOffset, littleEndian)

Get a signed 64-bit float (double) at the specified byte offset from the start of the Packet.

getFloat64(byteOffset:number, littleEndian:boolean):number
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to read the data from.
littleEndian(boolean =true) Indicates whether the 64-bit float is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is read.
Returns
number: A signed 64-bit float number.
getInt16(byteOffset, littleEndian)

Get a signed 16-bit integer (short) at the specified byte offset from the start of the Packet.

getInt16(byteOffset:number, littleEndian:boolean):number
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to read the data from.
littleEndian(boolean =true) Indicates whether the 16-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is read.
Returns
number: A signed 16-bit integer number.
getInt32(byteOffset, littleEndian)

Get a signed 32-bit integer (long) at the specified byte offset from the start of the Packet.

getInt32(byteOffset:number, littleEndian:boolean):number
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to read the data from.
littleEndian(boolean =true) Indicates whether the 32-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is read.
Returns
number: A signed 32-bit integer number.
getInt8(byteOffset)

Get a signed 8-bit integer (byte) at the specified byte offset from the start of the Packet.

getInt8(byteOffset:number):number
Parameters
byteOffset(number) The offset, in byte, from the start of the Packet where to read the data.
Returns
number: An unsigned 8-bit integer number.
getUint16(byteOffset, littleEndian)

Get an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the Packet.

getUint16(byteOffset:number, littleEndian:boolean):number
Parameters
byteOffset(number) The offset, in byte, from the start of the Packet where to read the data.
littleEndian(boolean =true) Indicates whether the 16-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is read.
Returns
number: An unsigned 16-bit integer number.
getUint32(byteOffset, littleEndian)

Get an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the Packet.

getUint32(byteOffset:number, littleEndian:boolean):number
Parameters
byteOffset(number) The offset, in byte, from the start of the Packet where to read the data.
littleEndian(boolean =true) Indicates whether the 32-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is read.
Returns
number: An unsigned 32-bit integer number.
getUint8(byteOffset)

Get an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the Packet.

getUint8(byteOffset:number):number
Parameters
byteOffset(number) The offset, in byte, from the start of the Packet where to read the data.
Returns
number: An unsigned 8-bit integer number.
setBigInt64(byteOffset, value, littleEndian)

Store a signed 64-bit integer (long long) value at the specified byte offset from the start of the Packet.

setBigInt64(byteOffset:number, value: BigInt, littleEndian:boolean)
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to store the data from.
value(BigInt) The value to set as aBigInt. The highest possible value that fits in a signed 64-bit integer is2n ** (64n -1n) - 1n (9223372036854775807n). Upon overflow, it will be negative (-9223372036854775808n).
littleEndian(boolean =true) Indicates whether the 64-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is written.
setBigUint64(byteOffset, value, littleEndian)

Store an unsigned 64-bit integer (unsigned long long) value at the specified byte offset from the start of the Packet.

setBigUint64(byteOffset:number, value: BigInt, littleEndian:boolean)
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to store the data from.
value(BigInt) The highest possible value that fits in an unsigned 64-bit integer is2n ** 64n - 1n (18446744073709551615n). Upon overflow, it will be zero (0n).
littleEndian(boolean =true) Indicates whether the 64-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is written.
setFloat32(byteOffset, value, littleEndian)

Store a signed 32-bit float (float) value at the specified byte offset from the start of the Packet.

setFloat32(byteOffset:number, value:number, littleEndian:boolean)
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to store the data from.
value(number) The value to set.
littleEndian(boolean =true) Indicates whether the 32-bit float is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is written.
setFloat64(byteOffset, value, littleEndian)

Store a signed 64-bit float (double) value at the specified byte offset from the start of the Packet.

setFloat64(byteOffset:number, value:number, littleEndian:boolean)
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to store the data from.
value(number) The value to set.
littleEndian(boolean =true) Indicates whether the 64-bit float is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is written.
setInt16(byteOffset, value, littleEndian)

Store a signed 16-bit integer (short) value at the specified byte offset from the start of the Packet.

setInt16(byteOffset:number, value:number, littleEndian:boolean)
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to store the data from.
value(number) The value to set.
littleEndian(boolean =true) Indicates whether the 16-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is written.
setInt32(byteOffset, value, littleEndian)

Store a signed 32-bit integer (long) value at the specified byte offset from the start of the Packet.

setInt32(byteOffset:number, value:number, littleEndian:boolean)
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to store the data from.
value(number) The value to set.
littleEndian(boolean =true) Indicates whether the 32-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is written.
setInt8(byteOffset, value)

Store a signed 8-bit integer (byte) value at the specified byte offset from the start of the Packet.

setInt8(byteOffset:number, value:number)
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to store the data from.
value(number) The value to set.
setUint16(byteOffset, value, littleEndian)

Store an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the Packet.

setUint16(byteOffset:number, value:number, littleEndian:boolean)
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to store the data from.
value(number) The value to set.
littleEndian(boolean =true) Indicates whether the 16-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is written.
setUint32(byteOffset, value, littleEndian)

Store an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the Packet.

setUint32(byteOffset:number, value:number, littleEndian:boolean)
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to store the data from.
value(number) The value to set.
littleEndian(boolean =true) Indicates whether the 32-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is written.
setUint8(byteOffset, value)

Store an unsigned 8-bit integer (unsigned byte) value at the specified byte offset from the start of the Packet.

setUint8(byteOffset:number, value:number)
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to store the data from.
value(number) The value to set.
getUint24(byteOffset, littleEndian)

Get an unsigned 24-bit integer at the specified byte offset from the start of the Packet.

getUint24(byteOffset:number, littleEndian:boolean):number
Parameters
byteOffset(number) The offset, in byte, from the start of the Packet where to read the data.
littleEndian(boolean =true) Indicates whether the 24-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is written.
Returns
number: An unsigned 24-bit integer number.
setUint24(byteOffset, value, littleEndian)

Store an unsigned 24-bit integer value at the specified byte offset from the start of the Packet.

setUint24(byteOffset:number, value:number, littleEndian:boolean)
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to store the data from.
value(number) The value to set.
littleEndian(boolean =true) Indicates whether the 24-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is written.
getInt24(byteOffset, littleEndian)

Get a signed 24-bit integer at the specified byte offset from the start of the Packet.

getInt24(byteOffset:number, littleEndian:boolean):number
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to read the data from.
littleEndian(boolean =true) Indicates whether the 24-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is read.
Returns
number: A signed 24-bit integer number.
setInt24(byteOffset, value, littleEndian)

Store a signed 24-bit integer value at the specified byte offset from the start of the Packet.

setInt24(byteOffset:number, value:number, littleEndian:boolean)
Parameters
byteOffset(number) The offset, in bytes, from the start of the Packet to store the data from.
value(number) The value to set.
littleEndian(boolean =true) Indicates whether the 24-bit int is stored inlittle- or big-endian format. Iffalse orundefined, a big-endian value is written.
getBit(bitOffset, lsb)

Get a bit value at the specified bit offset from the Packet.

getBit(bitOffset:number, lsb:number):number
Parameters
bitOffset(number) The offset, in bits, from the Packet to read the data from.
lsb(number =false) Indicates whether the bit value is stored in LSB (Least Significant Bit) format. Iffalse a MSB (Most Significant Bit) format is used.
Returns
number: A bit value.
setBit(bitOffset, value, lsb)

Store a bit value at the specified bit offset from the Packet.

setBit(bitOffset:number, value:number, lsb:number)
Parameters
bitOffset(number) The offset, in bits, from the Packet to store the data from.
value(number) The value to be set.
lsb(number =false) Indicates whether the bit value is stored in LSB (Least Significant Bit) format. Iffalse a MSB (Most Significant Bit) format is used.
new Crypto1(args)

JavaScript implementation of the Crypto1 cipher. This script should be load after the PN532 Core script.

new Crypto1(args:object)
Parameters
args(object ={}) args
NameDescription
args.evennumberThe even bits of lfsr.
args.oddnumberThe odd bits of lfsr.
Related
mfkey source code from RfidResearchGroup/proxmark3
Example
const {Crypto1 } =windowconst state1 =newCrypto1()const state2 =newCrypto1({even:0,odd:0 })
Static Members
beBit(x, n)

Get bit of the unsigned reversed endian 32-bit integerx at positionn.

beBit(x:number, n:number):number
Parameters
x(number) The reversed endian unsigned 32-bit integer.
n(number) The bit position.
Returns
number: The bit at positionn.
Example
const {Crypto1 } =windowconsole.log(Crypto1.beBit(0x01000000,0))// 1
bit(x, n)

Get bit of the unsigned 32-bit integerx at positionn.

bit(x:number, n:number):number
Parameters
x(number) The unsigned 32-bit integer.
n(number) The bit position.
Returns
number: The bit at positionn.
Example
const {Crypto1 } =windowconsole.log(Crypto1.bit(0x1,0))// 1
toBit(x)

Cast the numberx to bit.

toBit(x:number):number
Parameters
x(number) The number.
Returns
number: The casted bit.
Example
const {Crypto1 } =windowconsole.log(Crypto1.toBit(1))// 1console.log(Crypto1.toBit(2))// 0
toBool(x)

Indicates whether the number is truly or not.

toBool(x:number):number
Parameters
x(number) The number.
Returns
number: Return1 if the number is not falsey, otherwise return0.
Example
const {Crypto1 } =windowconsole.log(Crypto1.toBool(1))// 1console.log(Crypto1.toBool(2))// 1
toUint24(x)

Cast the numberx to unsigned 24-bit integer.

toUint24(x:number):number
Parameters
x(number) The number.
Returns
number: The casted unsigned 24-bit integer.
Example
const {Crypto1 } =windowconsole.log(Crypto1.toUint24(-1).toString(16))// 'ffffff'
toUint32(x)

Cast the numberx to unsigned 32-bit integer.

toUint32(x:number):number
Parameters
x(number) The number.
Returns
number: The casted unsigned 32-bit integer.
Example
const {Crypto1 } =windowconsole.log(Crypto1.toUint32(-1).toString(16))// 'ffffffff'
toUint8(x)

Cast the numberx to unsigned 8-bit integer.

toUint8(x:number):number
Parameters
x(number) The number.
Returns
number: The casted unsigned 8-bit integer.
Example
const {Crypto1 } =windowconsole.log(Crypto1.toUint8(-1).toString(16))// 'ff'
filter(x)

The filter function of Crypto1.

filter(x:number):number
Parameters
x(number) The unsigned 32-bit integer.
Returns
number: The filtered bit.
evenParity8(x)

Return the even parity of the unsigned 8-bit integerx.

evenParity8(x:number):number
Parameters
x(number) The unsigned 8-bit integer.
Returns
number: The even parity ofx.
evenParity32(x)

Return the even parity of the unsigned 32-bit integerx.

evenParity32(x:number):number
Parameters
x(number) The unsigned 32-bit integer.
Returns
number: The even parity ofx.
swapEndian(x)

Swap endian of the unsigned 32-bit integerx.

swapEndian(x:number):number
Parameters
x(number) The unsigned 32-bit integer.
Returns
number: The unsigned 32-bit integer after swap endian.
Example
const {Crypto1 } =windowconsole.log(Crypto1.swapEndian(0x12345678).toString(16))// '78563412'
prngSuccessor(x, n)

Generate the new prng state from the current prng statex byn times.

prngSuccessor(x:number, n:number):number
Parameters
x(number) The current prng state.
n(number) The number of times to generate the new prng state.
Returns
number: The new prng state.
updateContribution(item, mask1, mask2)

A helper function to calculates the partial linear feedback contributions and puts in MSB (Most Significant Bit).

updateContribution(item:number, mask1:number, mask2:number)
Parameters
item(number) The input number.
mask1(number)
mask2(number)
extendTable(tbl, size, bit, m1, m2, input)

Using a bit of the keystream extend the table of possible lfsr states. (complex version)

extendTable(tbl:number, size:number, bit:number, m1:number, m2:number, input:number):number
Parameters
tbl(number) An array of the even/odd bits of lfsr.
size(number) Size of array.
bit(number) The bit of the keystream.
m1(number) mask1
m2(number) mask2
input(number) The value that was fed into the lfsr at the time the keystream was generated.
Returns
number: The new size of array.
extendTableSimple(tbl, size, bit)

Using a bit of the keystream extend the table of possible lfsr states. (simple version)

extendTableSimple(tbl:number, size:number, bit:number):number
Parameters
tbl(number) An array of the even/odd bits of lfsr.
size(number) Size of array.
bit(number) The bit of the keystream.
Returns
number: The new size of array.
recover(ctx)

Recursively narrow down the search space, 4 bits of keystream at a time.

recover(ctx:object)
Parameters
ctx(object)
NameDescription
ctx.evensobjectThe array of even bits of possible lfsr states.
ctx.oddsobjectThe array of odd bits of possible lfsr states.
ctx.statesArray<Crypto1>The array of recovered lfsr states.
lfsrRecovery32(ks2, input)

Recover the state of the lfsr given 32 bits of the keystream.Additionally you can use the in parameter to specify the value that was fed into the lfsr at the time the keystream was generated

lfsrRecovery32(ks2:number, input:number):Array<Crypto1>
Parameters
ks2(number)
input(number)
Returns
Array<Crypto1>: The array of recovered lfsr states.
lfsrRecovery64(ks2, ks3)

Reverse 64 bits of keystream into possible lfsr states.Variation mentioned in the paper. Somewhat optimized version

lfsrRecovery64(ks2:number, ks3:number):Crypto1
Parameters
ks2(number) keystream 2
ks3(number) keystream 3
Returns
Crypto1: The recovered lfsr state.
mfkey32v2(args)

Recover the key with the two authentication attempts from reader.

mfkey32v2(args:object):Packet
Parameters
args(object)
NameDescription
args.uid(number |Packet |string)The 4-bytes uid in the authentication attempt.
args.nt0(number |Packet |string)The nonce from tag in the first authentication attempt.
args.nr0(number |Packet |string)The calculated nonce response from reader in the first authentication attempt.
args.ar0(number |Packet |string)The random challenge from reader in the first authentication attempt.
args.nt1(number |Packet |string)The nonce from tag in the second authentication attempt.
args.nr1(number |Packet |string)The calculated nonce response from reader in the second authentication attempt.
args.ar1(number |Packet |string)The random challenge from reader in the second authentication attempt.
Returns
Packet: The recovered key.
Example
const {Crypto1,Pn532: {Packet } } =windowconsole.log(Crypto1.mfkey32v2({uid:0x65535D33,nt0:0xCB7B9ED9,nr0:0x5A8FFEC6,ar0:0x5C7C6F89,nt1:0x1E6D9228,nr1:0x6FB8B4A8,ar1:0xEF4039FB,}).hex)// A9AC67832330console.log(Crypto1.mfkey32v2({uid:Packet.fromHex('65535D33'),nt0:Packet.fromHex('CB7B9ED9'),nr0:Packet.fromHex('5A8FFEC6'),ar0:Packet.fromHex('5C7C6F89'),nt1:Packet.fromHex('1E6D9228'),nr1:Packet.fromHex('6FB8B4A8'),ar1:Packet.fromHex('EF4039FB'),}).hex)// A9AC67832330console.log(Crypto1.mfkey32v2({uid:'65535D33',nt0:'CB7B9ED9',nr0:'5A8FFEC6',ar0:'5C7C6F89',nt1:'1E6D9228',nr1:'6FB8B4A8',ar1:'EF4039FB',}).hex)// A9AC67832330
mfkey64(args)

Recover the key with the successfully authentication between the reader and the tag.

mfkey64(args:object):Packet
Parameters
args(object)
NameDescription
args.uid(number |Packet |string)The 4-bytes uid in the authentication.
args.nt(number |Packet |string)The nonce from tag in the authentication.
args.nr(number |Packet |string)The calculated response ofargs.nt from reader in the authentication.
args.ar(number |Packet |string)The random challenge from reader in the authentication.
args.at(number |Packet |string)The calculated response ofargs.ar from tag in the authentication.
Returns
Packet: The recovered key.
Example
const {Crypto1,Pn532: {Packet } } =windowconsole.log(Crypto1.mfkey32v2({uid:0x65535D33,nt:0x2C198BE4,nr:0xFEDAC6D2,ar:0xCF0A3C7E,at:0xF4A81AF8,}).hex)// A9AC67832330console.log(Crypto1.mfkey32v2({uid:Packet.fromHex('65535D33'),nt:Packet.fromHex('2C198BE4'),nr:Packet.fromHex('FEDAC6D2'),ar:Packet.fromHex('CF0A3C7E'),at:Packet.fromHex('F4A81AF8'),}).hex)// A9AC67832330console.log(Crypto1.mfkey32v2({uid:'65535D33',nt:'2C198BE4',nr:'FEDAC6D2',ar:'CF0A3C7E',at:'F4A81AF8',}).hex)// A9AC67832330
decrypt(args)

Decrypt the data.

decrypt(args:object):Packet
Parameters
args(object)
NameDescription
args.nr(number |Packet |string)The calculated response ofargs.nt from reader in the authentication.
args.nt(number |Packet |string)The nonce from tag in the authentication.
args.uid(number |Packet |string)The 4-bytes uid in the authentication.
args.dataPacketThe encrypted data.
args.keyPacketThe 6-bytes key to decrypt the data.
Returns
Packet: The decrypted data.
Instance Members
reset()

Reset the internal lfsr.

reset(): this
Returns
this:this
Example
const {Crypto1 } =windowconst state1 =newCrypto1({even:1,odd:1 })state1.reset()
setLfsr(key)

Set the internal lfsr with the key.

setLfsr(key:Packet): this
Parameters
key(Packet) The key to set the internal lfsr.
Returns
this:this
Example
const {Crypto1,Pn532: {Packet } } =windowconst state1 =newCrypto1()state1.setLfsr(newPacket('FFFFFFFFFFFF'))
getLfsr()

Get the internal lfsr.

getLfsr():Packet
Returns
Packet: The internal lfsr.
Example
const {Crypto1,Pn532: {Packet } } =windowconst state1 =newCrypto1()console.log(state1.setLfsr(newPacket('FFFFFFFFFFFF')).getLfsr().hex)// 'FFFFFFFFFFFF'
lfsrBit(input, isEncrypted)

Get the lfsr output bit and update lfsr by input bit.

lfsrBit(input:number, isEncrypted:number):number
Parameters
input(number) The input bit.
isEncrypted(number) Indicates whether the input bit is encrypted or not.
Returns
number: The lfsr output bit.
lfsrByte(input, isEncrypted)

Get the lfsr output byte and update lfsr by input byte.

lfsrByte(input:number, isEncrypted:number):number
Parameters
input(number) The input byte.
isEncrypted(number) Indicates whether the input byte is encrypted or not.
Returns
number: The lfsr output byte.
lfsrWord(input, isEncrypted)

Get the lfsr 32-bit output word and update lfsr by 32-bit input word.

lfsrWord(input:number, isEncrypted:number):number
Parameters
input(number) The 32-bit input word.
isEncrypted(number) Indicates whether the 32-bit input word is encrypted or not.
Returns
number: The lfsr 32-bit output word.
lfsrRollbackBit(input, isEncrypted)

Rollback the lfsr in order to get previous states

lfsrRollbackBit(input:number, isEncrypted:number):number
Parameters
input(number) The input bit.
isEncrypted(number) Indicates whether the input bit is encrypted or not.
Returns
number: The lfsr output bit.
lfsrRollbackByte(input, isEncrypted)

Rollback the lfsr in order to get previous states

lfsrRollbackByte(input:number, isEncrypted:number):number
Parameters
input(number) The input byte.
isEncrypted(number) Indicates whether the input byte is encrypted or not.
Returns
number: The lfsr output byte.
lfsrRollbackWord(input, isEncrypted)

Rollback the lfsr in order to get previous states

lfsrRollbackWord(input:number, isEncrypted:number):number
Parameters
input(number) The 32-bit input word.
isEncrypted(number) Indicates whether the 32-bit input word is encrypted or not.
Returns
number: The lfsr 32-bit output word.

Plugin

Plugin
Static Members
new Pn532Hf14a()

The Hf14a plugin for PN532. After register to PN532 instance, this plugin will expose plugin functions underpn532.$hf14a.

new Pn532Hf14a()
Example
const pn532 =newPn532()pn532.use(newPn532WebserialAdapter())// A pn532 instance must register exactly one adapter pluginpn532.use(newPn532Hf14a())
Instance Members
inListPassiveTarget(args)

This command is used to detect as many mifare targets (maximumMaxTg) as possible in passive mode.

inListPassiveTarget(args:object):Promise<Array<Pn532Hf14a~MifareTarget>>
Parameters
args(object ={})
NameDescription
args.maxTgnumber (default1)The maximum number of mifare targets to be initialized by the PN532. The PN532 is capable of handling 2 targets maximum at once, so this field should not exceed0x02.
args.uidPacket (defaultnew Packet())Set to UID of card if wants to initialize a target with a known UID.
args.timeoutany
Returns
Promise<Array<Pn532Hf14a~MifareTarget>>: Resolve with an array of detected mifare targets.
testIso14443Part4Present()

BecausePn532#testTargetPresent failed to detect JCOP31 target so we need to do it manually.

testIso14443Part4Present():Promise<boolean>
Returns
Promise<boolean>: Resolve with a boolean indicating whether or not the ISO/IEC14443-4 card is present.
Related
https://github.com/nfc-tools/libnfc/blob/3df7f25f11499fa788e40c41ee7b45582262c566/libnfc/chips/pn53x.c#L1999
mfSelectCard(args)

This function is used to detect one mifare target in passive mode. It will release the target if reader connection is opened.

Parameters
args(object ={})
NameDescription
args.timeoutany
Returns
Promise<Pn532Hf14a~MifareTarget>: Resolve with detected mifare target.
mfAuthBlock(args)

This function is used to authenticate block with a specific key type and key.

mfAuthBlock(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.blocknumber (default0)Which block to be authenticated.
args.isKbboolean (default0)Type of the key.0: key A,1: key B.
args.keyPacket6 bytes key to authenticate the block.
args.tgnumber (default1)A byte containing the logical number of the relevant target.
args.uidPacketUid of the target to be authenticated. Currently only accepted 4 bytes uid.
args.blocksPerSectornumber (default4)A integer represent how many blocks per sector.
Returns
Promise<null>: Resolve after finish.
mfIsValidAcl(acl)

This function is used to validate the Access Control Bits of the sector.

mfIsValidAcl(acl:Packet):boolean
Parameters
acl(Packet) 3 bytes containing the Access Control Bits of the sector.
Returns
boolean: Indicating whether or not theacl is valid.
mfKeysUniq(keys)

This function is used to remove key that is invalid or duplicated in array.

mfKeysUniq(keys:Array<Packet>):Array<Packet>
Parameters
keys(Array<Packet>) Array of 6 bytes key.
Returns
Array<Packet>: Result.
mfReadBlock(args)

Read block data from target by specific key type and key.

mfReadBlock(args:object):Promise<Packet>
Parameters
args(object ={})
NameDescription
args.blocknumber (default0)Which block to be authenticated and read.
args.isKbboolean (default0)Type of the key.0: key A,1: key B.
args.keyPacket6 bytes key to authenticate the block.
Returns
Promise<Packet>: Resolve with 16 bytes block data.
mfReadBlockKeyBA(args)

Read block data from target by key B and key A.

mfReadBlockKeyBA(args:object):Promise<Packet>
Parameters
args(object ={})
NameDescription
args.blocknumber (default0)Which block to be authenticated and read.
args.kaPacket6 bytes Key A of the block.
args.kbPacket6 bytes Key B of the block.
Returns
Promise<Packet>: Resolve with 16 bytes block data.
mfReadSector(args)

Read sector data from target by specific key type and key.

mfReadSector(args:object):Promise<Packet>
Parameters
args(object ={})
NameDescription
args.sectornumber (default0)Which sector to be authenticated and read.
args.isKbboolean (default0)Type of the key.0: key A,1: key B.
args.keyPacket6 bytes key to authenticate the sector.
Returns
Promise<Packet>: Resolve with 64 bytes sector data.
Returns
Promise<object>: Resolve withres:
  • res.data (Packet): 64 bytes sector data. Block data that failed to read will be filled with0x00.
  • res.success (Array<boolean>): Indicating whether or not the block read successfully. There are 4 blocks in sector.
mfReadSectorKeyBA(args)

Read sector data from target by key B and key A.

mfReadSectorKeyBA(args:object):Promise<object>
Parameters
args(object ={})
NameDescription
args.sectornumber (default0)Which sector to be authenticated and read.
args.kaPacket6 bytes Key A of the sector.
args.kbPacket6 bytes Key B of the sector.
Returns
Promise<object>: Resolve withres:
  • res.data (Packet): 64 bytes sector data. Block data that failed to read will be filled with0x00.
  • res.success.read (Array<boolean>): Indicating whether or not the block read successfully. There are 4 blocks in sector.
  • res.success.key (Array<boolean>): Indicating whether or not the key has authenticated successfully.
mfCheckKeys(args)

Check sector key of Mifare card.

mfCheckKeys(args:object):Promise<Array<Packet>>
Parameters
args(object ={})
NameDescription
args.sectorMaxnumber (default16)How many sectors to read from target.
args.keysArray<Packet>Array of 6 bytes keys to be check.
Returns
Promise<Array<Packet>>: Resolve with array of sector key As and key Bs. Odd Index (0,2,4...) are Key A, even index (1,3,5...) are Key B. If the sector key is not found, the value will benull.
mfReadCardByKeys(args)

Read all sector data from target. This function will try to auth sector bykeys.

mfReadCardByKeys(args:object):Promise<object>
Parameters
args(object ={})
NameDescription
args.sectorMaxnumber (default16)How many sectors to read from target.
args.keysArray<Packet>Array of 6 bytes keys.
Returns
Promise<object>: Resolve withres:
  • res.data (Packet): All sector data. Block data that failed to read will be filled with0x00.
  • res.success.read (Array<boolean>): Indicating whether or not the block read successfully. There are 4 blocks in sector.
  • res.success.key (Array<Packet, null>): Key A and Key B of all sector. Array may containsnull if sector key not found.
mfWriteBlock(args)

Write block data to target by specific key type and key.

mfWriteBlock(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.blocknumber (default0)Which block to be authenticated and write.
args.isKbboolean (default0)Type of the key.0: key A,1: key B.
args.keyPacket6 bytes key to authenticate the block.
args.dataPacket16 bytes block data to write.
Returns
Promise<null>: Resolve after finished.
mfWriteBlockKeyBA(args)

Write block data from target by key B and key A.

mfWriteBlockKeyBA(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.blocknumber (default0)Which block to be authenticated and write.
args.kaPacket6 bytes Key A of the block.
args.kbPacket6 bytes Key B of the block.
args.dataPacket16 bytes block data to write.
Returns
Promise<null>: Resolve after finished.
mfSetUidGen2(args)

Setuid of chinese magic card gen2 (aka CUID).

mfSetUidGen2(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.atqaPacket (defaultnull)2 bytes ATQA of target (akaSENS_RES).
args.sakPacket (defaultnull)1 byte SAK of target (akaSEL_RES).
args.uidPacket4 bytes uid of target.
args.keysArray<Packet>Array of 6 bytes keys.
Returns
Promise<null>: Resolve after finished.
mfWriteSector(args)

Write sector data to target by specific key type and key.

mfWriteSector(args:object):Promise<object>
Parameters
args(object ={})
NameDescription
args.sectornumber (default0)Which sector to be authenticated and write.
args.isKbboolean (default0)Type of the key.0: key A,1: key B.
args.keyPacket6 bytes key to authenticate the sector.
args.dataPacket64 bytes sector data to write.
Returns
Promise<object>: Resolve withres:
  • res.success (Array<boolean>): Indicating whether or not the block write successfully. There are 4 blocks in sector.
mfWriteSectorKeyBA(args)

Write sector data to target by key B and key A.

mfWriteSectorKeyBA(args:object):Promise<object>
Parameters
args(object ={})
NameDescription
args.sectornumber (default0)Which sector to be authenticated and write.
args.kaPacket6 bytes Key A of the sector.
args.kbPacket6 bytes Key B of the sector.
args.dataPacket64 bytes sector data to write.
Returns
Promise<object>: Resolve withres:
  • res.success (Array<boolean>): Indicating whether or not the block write successfully. There are 4 blocks in sector.
mfWriteCardByKeys(args)

Write all sector data to target. This function will try to auth sector bykeys.

mfWriteCardByKeys(args:object):Promise<object>
Parameters
args(object ={})
NameDescription
args.sectorMaxnumber (default16)How many sectors to write to target.
args.keysArray<Packet>Array of 6 bytes keys.
args.dataPacketAll sector data to write.
Returns
Promise<object>: Resolve withres:
  • res.success (Array<boolean>): Indicating whether or not the block write successfully. There are 4 blocks in sector.
mfIncrementBlock(args)

Increment from value blocksrc byint32 and transfer todist block.

mfIncrementBlock(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.src{block:number, isKb:boolean, key:Packet}Which value block to increment from.
args.dist{block:number, isKb:boolean, key:Packet}Which block to transfer to.
args.int32number (default0)A signed 32-bit integer to increment by.
Returns
Promise<null>: Resolve after finished.
Related
MF1S50YYX_V1 P.9
mfDecrementBlock(args)

Decrement from value blocksrc byint32 and transfer todist block.

mfDecrementBlock(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.src{block:number, isKb:boolean, key:Packet}Which value block to decrement from.
args.dist{block:number, isKb:boolean, key:Packet}Which block to transfer to.
args.int32number (default0)A signed 32-bit integer to decrement by.
Returns
Promise<null>: Resolve after finished.
Related
MF1S50YYX_V1 P.9
mfRestoreBlock(args)

Copy from value blocksrc and transfer todist block.

mfRestoreBlock(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.src{block:number, isKb:boolean, key:Packet}Which value block to copy from.
args.dist{block:number, isKb:boolean, key:Packet}Which block to transfer to.
Returns
Promise<null>: Resolve after finished.
Related
MF1S50YYX_V1 P.9
mfBackdoorGen1a()

Send backdoor command of chinese magic card gen1a (aka UID).

mfBackdoorGen1a():Promise<null>
Returns
Promise<null>: Resolve after finished.
mfReadBlockGen1a(args)

Read block data from chinese magic card gen1a (aka UID).

mfReadBlockGen1a(args:object):Promise<Packet>
Parameters
args(object ={})
NameDescription
args.blocknumber (default0)Which block to be read.
Returns
Promise<Packet>: Resolve with 16 bytes block data.
mfReadSectorGen1a(args)

Read sector data from chinese magic card gen1a (aka UID).

mfReadSectorGen1a(args:object):Promise<object>
Parameters
args(object ={})
NameDescription
args.sectornumber (default0)Which sector to be read.
Returns
Promise<object>: Resolve withres:
  • res.data (Packet): 64 bytes sector data. Block data that failed to read will be filled with0x00.
  • res.success (Array<boolean>): Indicating whether or not the block read successfully. There are 4 blocks in sector.
mfReadCardGen1a(args)

Read all sector data from chinese magic card gen1a (aka UID).

mfReadCardGen1a(args:object):Promise<object>
Parameters
args(object ={})
NameDescription
args.sectorMaxnumber (default16)How many sectors to read from target.
Returns
Promise<object>: Resolve withres:
  • res.data (Packet): All sector data. Block data that failed to read will be filled with0x00.
  • res.success (Array<boolean>): Indicating whether or not the block read successfully. There are 4 blocks in sector.
mfWriteBlockGen1a(args)

Write block data to chinese magic card gen1a (aka UID).

mfWriteBlockGen1a(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.blocknumber (default0)Which block to be write.
args.dataPacket16 bytes block data to write.
Returns
Promise<null>: Resolve after finished.
mfWriteSectorGen1a(args)

Write sector data to chinese magic card gen1a (aka UID).

mfWriteSectorGen1a(args:object):Promise<object>
Parameters
args(object ={})
NameDescription
args.sectornumber (default0)Which sector to be read.
args.dataPacket64 bytes sector data to write.
Returns
Promise<object>: Resolve withres:
  • res.success (Array<boolean>): Indicating whether or not the block write successfully. There are 4 blocks in sector.
mfWriteCardGen1a(args)

Write all sector data to chinese magic card gen1a (aka UID).

mfWriteCardGen1a(args:object):Promise<object>
Parameters
args(object ={})
NameDescription
args.sectorMaxnumber (default16)How many sectors to write to target.
args.dataany
Returns
Promise<object>: Resolve withres:
  • res.success (Array<boolean>): Indicating whether or not the block write successfully. There are 4 blocks in sector.
mfSetUidGen1a(args)

Setuid of chinese magic card gen1a (aka UID).

mfSetUidGen1a(args:object):Promise<null>
Parameters
args(object ={})
NameDescription
args.atqaPacket (defaultnull)2 bytes ATQA of target (akaSENS_RES).
args.sakPacket (defaultnull)1 byte SAK of target (akaSEL_RES).
args.uidPacket4 bytes uid of target.
Returns
Promise<null>: Resolve after finished.
mfWipeGen1a(args)

Wipe all sector data of chinese magic card gen1a (aka UID).

mfWipeGen1a(args:object):Promise<object>
Parameters
args(object ={})
NameDescription
args.atqaPacket (defaultnull)2 bytes ATQA of target (akaSENS_RES).
args.sakPacket (defaultnull)1 byte SAK of target (akaSEL_RES).
args.uidPacket4 bytes uid of target.
args.sectorMaxany (default16)
Returns
Promise<object>: Resolve withres:
  • res.success (Array<boolean>): Indicating whether or not the block wipe successfully. There are 4 blocks in sector.
new Pn532LoggerRxTx()

This plugin is used to debug adapter commucation.

new Pn532LoggerRxTx()
Example
const pn532 =newPn532()pn532.use(newPn532LoggerRxTx())
new Pn532WebbleAdapter()

This is a web bluetooth adapter ofPn532. A pn532 instance must register exactly one adapter plugin. After register to PN532 instance, this plugin will expose plugin functions underpn532.$adapter.

new Pn532WebbleAdapter()
Example
const pn532ble =newPn532()pn532ble.use(newPn532WebbleAdapter())console.log(JSON.stringify(await pn532ble.getFirmwareVersion()))// {"firmware":"1.6","ic":"PN532","iso14443a":true,"iso14443b":true,"iso18092":true}
Instance Members
isSupported()

Determines whether Web Bluetooth API is supported.

isSupported():Promise<boolean>
Returns
Promise<boolean>: Resolve with a boolean indicating whether or not Web Bluetooth API is supported.
isOpen()

Determines whether the adapter is open.

isOpen():boolean
Returns
boolean: A boolean indicating whether or not the adapter is open.
disconnect()

Disconnect the connection of adapter.

disconnect():Promise<null>
Returns
Promise<null>: Resolve after finished.
connect()

Open the connection of adapter.

connect():Promise<null>
Returns
Promise<null>: Resolve after finished.
new Pn532WebserialAdapter()

This is a web serial adapter ofPn532. A pn532 instance must register exactly one adapter plugin. After register to PN532 instance, this plugin will expose plugin functions underpn532.$adapter.

new Pn532WebserialAdapter()
Example
const pn532ble =newPn532()pn532ble.use(newPn532WebserialAdapter())console.log(JSON.stringify(await pn532ble.getFirmwareVersion()))// {"firmware":"1.6","ic":"PN532","iso14443a":true,"iso14443b":true,"iso18092":true}
Instance Members
isSupported()

Determines whether SerialPort is supported.

isSupported():Promise<boolean>
Returns
Promise<boolean>: Resolve with a boolean indicating whether or not SerialPort is supported.
isSupported()

Determines whether Web Serial API is supported.

isSupported():Promise<boolean>
Returns
Promise<boolean>: Resolve with a boolean indicating whether or not Web Serial API is supported.
isOpen()

Determines whether the connection of adapter is open.

isOpen():boolean
Returns
boolean: A boolean indicating whether or not the connection of adapter is open.
isOpen()

Determines whether the connection of adapter is open.

isOpen():boolean
Returns
boolean: A boolean indicating whether or not the connection of adapter is open.
disconnect()

Disconnect the connection of adapter.

disconnect():Promise<null>
Returns
Promise<null>: Resolve after finished.
disconnect()

Disconnect the connection of adapter.

disconnect():Promise<null>
Returns
Promise<null>: Resolve after finished.
connect()

Open the connection of adapter.

connect():Promise<null>
Returns
Promise<null>: Resolve after finished.
connect()

Open the connection of adapter.

connect():Promise<null>
Returns
Promise<null>: Resolve after finished.

Example

Example
Static Members
M1 UID4B Writer

URL:http://taichunmin.idv.tw/pn532.js/m1-uid4b-writer.html

This tools can write 4 bytes UID to Chinese Magic Card (support UID and CUID) via Web Bluetooth or Web Serial.

M1 UID4B Writer
M1 EML Toolkit

URL:http://taichunmin.idv.tw/pn532.js/m1-eml-toolkit.html

This tools can read or write data from Mifare Classic 1k (support UID and CUID) via Web Bluetooth or Web Serial.

M1 EML Toolkit
M1 UID Scanner

URL:http://taichunmin.idv.tw/pn532.js/m1-uid-scanner.html

This tools can scan UID of NFC Type A Tags via Web Bluetooth or Web Serial.

M1 UID Scanner
mfkey32v2 and mfkey64

URL:http://taichunmin.idv.tw/pn532.js/mfkey.html

An online tool for mfkey32v2 and mfkey64 that recover mifare key from encrypted data obtained from reader-only attack or sniff communications between reader and card.

mfkey32v2 and mfkey64
Key Detector for 北方智能卡

URL:http://taichunmin.idv.tw/pn532.js/detector-shop143630998.html

This tools is only support supercard單卡嗅探王. It can change uid and type of supercard, or do reader-only attack to recover key.

Key Detector for 北方智能卡
Key Detector for 福睿

URL:http://taichunmin.idv.tw/pn532.js/detector-furui.html

This tools is only support supercard福睿偵測卡. It can change uid and type of supercard, or do reader-only attack to recover key.

Key Detector for 福睿

other

other
Static Members
new Pn532Frame(pack)

Interface of PN532 Frame. Please usePn532Frame.create to create a new instance.

new Pn532Frame(pack:Packet)
Parameters
pack(Packet) A PN532 Frame Data.
Static Members
create(pack)

Create a newPn532FrameNormal orPn532FrameExtended instance depends on data inpack.

Parameters
pack(Packet) A PN532 Frame Packet.
Returns
(Pn532FrameNormal |Pn532FrameExtended): APn532Frame initialized frompack
bufFindOffsetLen(buf)

Findoffset andlength of a PN532 Frame inbuf

bufFindOffsetLen(buf:Packet):Array<number>
Parameters
buf(Packet) A buffer
Returns
Array<number>:[offset, length] of a PN532 Frame inbuf. returns[offset, 0] if PN532 Frame not found inbuf.
Instance Members
pack
cmd

Getcmd of this PN532 Frame

cmd

Type:number

isAck

Indicating whether or not this Frame is PN532 ACK Frame.

isAck

Type:boolean

tfi

Gettfi of this PN532 Frame

tfi

Type:number

getFrameErr()

Get format error in frame data.

getFrameErr():Error?
Returns
Error?: ReturnsError if a format error found in frame data. Otherwise returnsnull.
getAppErr()

Get application error in frame data.

getAppErr():Error?
Returns
Error?: ReturnsError if an application error found in frame data. Otherwise returnsnull.
new Pn532FrameAck(pack)

Class of PN532 ACK/NACK Frame

new Pn532FrameAck(pack:Packet)

ExtendsPn532Frame

Parameters
pack(Packet) A PN532 Frame Data.
new Pn532FrameNormal(pack)

Class of PN532 Normal Frame

new Pn532FrameNormal(pack: any)

ExtendsPn532Frame

Parameters
pack(any)
new Pn532FrameExtended(pack)

Class of PN532 Extended Frame

new Pn532FrameExtended(pack: any)

ExtendsPn532Frame

Parameters
pack(any)

modules

modules
Static Members
pn532.js/Packet
pn532.js/Packet
Example
importPacketfrom'pn532.js/Packet'
pn532.js/plugin/Hf14a
pn532.js/plugin/Hf14a
Example
importPn532Hf14afrom'pn532.js/plugin/Hf14a'
pn532.js/plugin/LoggerRxTx
pn532.js/plugin/LoggerRxTx
Example
importPn532LoggerRxTxfrom'pn532.js/plugin/LoggerRxTx'
pn532.js/plugin/WebbleAdapter
pn532.js/plugin/WebbleAdapter
Example
importPn532WebbleAdapterfrom'pn532.js/plugin/WebbleAdapter'
pn532.js/plugin/WebserialAdapter
pn532.js/plugin/WebserialAdapter
Example
importPn532WebserialAdapterfrom'pn532.js/plugin/WebserialAdapter'
pn532.js/pn532
pn532.js/pn532
Example
importPn532from'pn532.js/pn532'
pn532.js/utils
pn532.js/utils
Example
import *asPn532Utilsfrom'pn532.js/utils'

typedef

typedef
Static Members
Pn532Hf14a~MifareTarget
Pn532Hf14a~MifareTarget

Type:object

Properties
atqa(Packet) : 2 bytes ATQA of target (akaSENS_RES).
pack(Packet) : raw data of response
rats(Packet) : Request for answer to select
sak(Packet) : 1 byte SAK of target (akaSEL_RES).
uid(Packet) : 4, 7 or 10 bytes uid of target.
Pn532~Gpio
Pn532~Gpio

Type:object

Properties
p32(number) : Representing the pin P32_INT0. P32 can be used as standard GPIO and is therefore not used as external interrupt trigger. Nevertheless, for the PowerDown command (§7.2.11, p:98), this pin can be used for the waking up. Moreover, when configured to use the handshake mechanism (§6.3, p:48), this pin may be used for the H_REQ line.
p33(number) : Representing the pin P33_INT1. P33 can be used as standard GPIO and is therefore not used as external interrupt trigger. Nevertheless, for the PowerDown command (§7.2.11, p:98), this pin can be used for the waking up.
p34(number) : Representing the pin P34/SIC_CLK. When configured to use the SAM companion chip (seeSAMConfiguration command (§7.2.10 p:89)), P34 is used for the CLAD line.
p71(number) : Representing the pins MISO/P71 of the SPI bus. P71 and P72 can be used as GPIO when the PN532 is not configured to use the SPI interface to communicate with the host controller.
p72(number) : Representing the pin SCK/P72 of the SPI bus. P71 and P72 can be used as GPIO when the PN532 is not configured to use the SPI interface to communicate with the host controller.
i0(number) : I0 and I1 (see § 6.1.1, p:24) are used to select the host controller interface. Once the selection has been done by the firmware, these two pins can be used as GPIOs.
i1(number) : I0 and I1 (see § 6.1.1, p:24) are used to select the host controller interface. Once the selection has been done by the firmware, these two pins can be used as GPIOs.

pn532.js/Crypto1

src/Crypto1.js
pn532.js/Crypto1
Example
importCrypto1from'pn532.js/Crypto1'

pn532.js/plugin/SerialPortAdapter

src/plugin/SerialPortAdapter.js
pn532.js/plugin/SerialPortAdapter
Example
importPn532SerialPortAdapterfrom'pn532.js/plugin/SerialPortAdapter'// Run serialport-list to list port, see https://serialport.io/docs/bin-listpn532.use(newPn532SerialPortAdapter(), {path:'/dev/tty.usbserial-120' })

[8]ページ先頭

©2009-2025 Movatter.jp