Class: RFID

RFID()

Functions for reading RFID cards

Constructor

new RFID()

Source:

Methods

(static) this.mfAuthByKey(cardIndex, address, key, onSuccessFunction, onErrorFunction)

Authenticate mifare card block with direct key data. This is less secure method, as it requires the key to be present in the program, the prefered way is to store a key once in a secure environment and then authenticate using the stored key.
Parameters:
Name Type Description
cardIndex number Index of the card as sent by onRFCardDetected delegate call
address number Address of the block to authenticate
key string 6 byte key
onSuccessFunction function JavaScript function called if successful
onErrorFunction function JavaScript function called if an error occurs
Source:

(static) this.mfAuthByStoredKey(cardIndex, type, address, keyIndex, onSuccessFunction, onErrorFunction)

Authenticate mifare card block with previously stored key. This the prefered method, as no key needs to reside in application.
Parameters:
Name Type Description
cardIndex number Index of the card as sent by onRFCardDetected delegate call
type string Key type, either 'A' or 'B'
address number Address of the block to authenticate
keyIndex number Index of the stored key, you can have up to 8 keys stored (0-7)
onSuccessFunction function JavaScript function called if successful
onErrorFunction function JavaScript function called if an error occurs
Source:

(static) this.mfRead(cardIndex, address, length, onSuccessFunction, onErrorFunction)

Reads one more more blocks of data from Mifare Classic/Ultralight cards. A single read operation gets 16 bytes of data, so you can pass 32 on length to read 2 blocks, etc.
Parameters:
Name Type Description
cardIndex number Index of the card as sent by onRFCardDetected delegate call
address number Address of the block to read
length number Number of bytes to read, this must be multiple of block size (16 bytes)
onSuccessFunction function JavaScript function called if successful
onErrorFunction function JavaScript function called if an error occurs
Source:

(static) this.mfStoreKeyIndex(keyIndex, type, key, onSuccessFunction, onErrorFunction)

Store key in the internal module memory for later use
Parameters:
Name Type Description
keyIndex number Index of the stored key, you can have up to 8 keys stored (0-7)
type string Key type, either 'A' or 'B'
key string 6 byte key
onSuccessFunction function JavaScript function called if successful
onErrorFunction function JavaScript function called if an error occurs
Source:

(static) this.mfUlcAuthByKey(cardIndex, key, onSuccessFunction, onErrorFunction)

Performs 3DES authentication of Mifare Ultralight C card using the given key
Parameters:
Name Type Description
cardIndex number Index of the card as sent by onRFCardDetected delegate call
key string 16 bytes 3DES key to authenticate with
onSuccessFunction function JavaScript function called if successful
onErrorFunction function JavaScript function called if an error occurs
Source:

(static) this.mfUlcSetKey(cardIndex, key, onSuccessFunction, onErrorFunction)

Sets the 3DES key of Mifare Ultralight C cards
Parameters:
Name Type Description
cardIndex number Index of the card as sent by onRFCardDetected delegate call
key string 16 bytes 3DES key to set
onSuccessFunction function JavaScript function called if successful
onErrorFunction function JavaScript function called if an error occurs
Source:

(static) this.mfWrite(cardIndex, address, data, onSuccessFunction, onErrorFunction)

Writes one more more blocks of data to Mifare Classic/Ultralight cards. A single write operation stores 16 bytes of data, so you can pass 32 on length to write 2 blocks, etc
Parameters:
Name Type Description
cardIndex number Index of the card as sent by onRFCardDetected delegate call
address number Address of the block to write
data string Data to write, must be multiple of the block size (16 bytes)
onSuccessFunction function JavaScript function called if successful
onErrorFunction function JavaScript function called if an error occurs
Source:

(static) this.onRFCardDetected(detectFunction)

Sets the callback function for when an RFID card is detected
Parameters:
Name Type Description
detectFunction function JavaScript function called when an RFID card is detected
Source:

(static) this.onRFCardRemoved(removeFunction)

Sets the callback function for when an RFID card is removed
Parameters:
Name Type Description
removeFunction function JavaScript function called when an RFID card is removed
Source:

(static) this.rfClose(successFunction, errorFunction)

Powers down RF card reader module. Call this function after you are done with the reader.
Parameters:
Name Type Description
successFunction function JavaScript function called if successful
errorFunction function JavaScript function called if an error occurs
Source:

(static) this.rfInit(successFunction, errorFunction)

Initializes and powers on the RF card reader module. Call this function before any other RF card functions. The module power consumption is highly optimized, so it can be left on for extended periods of time.
Parameters:
Name Type Description
successFunction function JavaScript function called if successful
errorFunction function JavaScript function called if an error occurs
Source:

(static) this.rfRemoveCard(cardIndex, onSuccessFunction, onErrorFunction)

Call this function once you are done with the card, a delegate call rfCardRemoved will be called when the card leaves the RF field and new card is ready to be detected
Parameters:
Name Type Description
cardIndex number Index of the card as sent by onRFCardDetected delegate call
onSuccessFunction function JavaScript function called if successful
onErrorFunction function JavaScript function called if an error occurs
Source: