DEV Community

Vlladie Condeno
Vlladie Condeno

Posted on

Read Mifare Classic card using NFC-PCSC library - NodeJS & Socket IO

OBJECTIVE

Apply the tap and go so that the user doesn't need to interact with the person in charge on the station.

The challenge is to get the value stored in the smartcard and pass the data to the front end and then the front end will request the full information from the server.

The image below will be the setup.
Setup

Tools

I tried searching for a library that I can use to help me read the the smartcard sector using NodeJS. the client is using a MIFARE Classic card and I found this library pokusew/nfc-pcsc which uses a javascript/NodeJS language.

The nfc-pcsc have it's own example for mifare-classic, the only needs to do is to apply the socketIO.

Implementation

Image description
This is the structure. The NodeJS App needs to be in the same station where the smartcard reader is connected.
The client card contains a unique data as an identifier

Process:

  1. Front end will establish a websocket to the NodeJS App
  2. NodeJS App will start listening to any card that been tap.
  3. If NodeJS Receive a card tapped, it will start reading the card Sector 2, after that, NodeJS App will emit to the front end what's the information it gets from the card.
  4. If Front end get the data, it will send the data it gets to the backend to fetch the full information.

You can check the whole code in my GitHub repo below.
https://github.com/VLDCNDN/smartcard-reader

GitHub logo VLDCNDN / smartcard-reader

read smartcard Mifare Classic using NodeJS and SocketIO

Requirements

  • nodeJS 8 above

For other Requirements please refer here nfc-pcsc installation

Installation

Run npm install




Top comments (0)