New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rfid-pn532

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rfid-pn532

Library to run the PN532 RFID Reader

latest
Source
npmnpm
Version
0.1.9
Version published
Maintainers
2
Created
Source

#RFID Driver for the rfid-pn532 Tessel RFID module. The hardware documentation for this module can be found here.

If you run into any issues you can ask for support on the RFID Module Forums.

###Installation

npm install rfid-pn532

###Example

/*********************************************
This basic RFID example listens for an RFID
device to come within range of the module,
then logs its UID to the console.
*********************************************/

var tessel = require('tessel');
var rfidlib = require('rfid-pn532');

var rfid = rfidlib.use(tessel.port['A']); 

rfid.on('ready', function (version) {
  console.log('Ready to read RFID card');

  rfid.on('data', function(card) {
    console.log('UID:', card.uid.toString('hex'));
  });
});

###Methods

# rfid.setPollPeriod( pollPeriod, callback(err) )
Set the time in milliseconds between each check for an RFID device. The poll period is 500ms by default.

# rfid.mifareClassicAuthenticateBlock( cardUID, blockNumber, authType, authKey, callback(err) )
Authenticate a block of memory to read or write on a MIFARE classic card. cardUID is the UID of the card to authenticate. blockNumber is the block address to authenticate. authType can be 0 for authorization type A or 1 for type B. authKey is an array containing the authorization key for the memory block, most commonly [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF].

# rfid.mifareClassicReadBlock( blockNumber, callback(err, data) )
Read a block of memory on a MIFARE classic card. blockNumber is the address of the block to read.

# rfid.mifareClassicWriteBlock( blockNumber, data, callback(err) )
Write a block of memory on a MIFARE classic card. blockNumber is the address of the block to write. data is an array containing the 16 bytes of data to write to the block.

# rfid.startListening( callback(err) )
Tell the RFID module to start listening for targets. Only necessary when configuring the module for manual target reading.

# rfid.stopListening( callback() )
Tell the RFID module to stop listening for targets. This will also disable automatic listening for targets.

##Events # rfid.on( 'data', callback(data) )
Emitted when an RFID target comes within range of the module.

# rfid.on( 'read', callback(data) )
Same as 'data' event.

# rfid.on( 'error', callback(err) )
Emitted upon error.

# rfid.on( 'ready', callback() )
Emitted upon first successful communication between the Tessel and the module.

###Further Examples

  • Mifare Classic. This example authorizes a mifare classic for read/write operations. First it will read a block of data off the card, write new data over the block, and then read back the data on the card to verify that the data on the card has changed.

###Configuration You can optionally configure how the RFID module listens for targets with an options argument in the .use() method. The supported options are listen and delay. Set listen to true to automatically listen for targets coming in range, or to false to manually control when the module should read targets. The default for this option is true. The delay option is used to set the amount of time in milliseconds to wait after reading a target to start listening again. The default for delay is 500 milliseconds. This option is ignored when listen is set to false.

var tessel = require('tessel');
var rfid = require('rfid-pn532').use(
  tessel.port['A'],
  {
    listen: true, 
    delay: 500
  }
);

##TODO Implement commands for additional NFC card/tag types

###License

FAQs

Package last updated on 04 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts