npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rfid-pn532

v0.1.9

Published

Library to run the PN532 RFID Reader

Downloads

14

Readme

#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