Skip to content

Commit

Permalink
Unify card naming (replace Mifare by MIFARE in comments to unify and …
Browse files Browse the repository at this point in the history
…follow the card family brand usage)
  • Loading branch information
pokusew committed Dec 31, 2018
1 parent 38b4bdb commit 4a76a2b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .idea/dictionaries/pokusew.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ This library uses pcsclite native bindings [pokusew/node-pcsclite](https://githu
- [Frequent errors](#frequent-errors)
- [TypeError: NFC is not a constructor](#typeerror-nfc-is-not-a-constructor)
- [Transaction failed error when using `CONNECT_MODE_DIRECT`](#transaction-failed-error-when-using-connect_mode_direct)
- [Mifare Classic: Authentication Error after Multiple Writes](#mifare-classic-authentication-error-after-multiple-writes)
- [MIFARE Classic: Authentication Error after Multiple Writes](#mifare-classic-authentication-error-after-multiple-writes)
- [Reading data from a type 4 tags inside a Elsys.se sensors](#reading-data-from-a-type-4-tags-inside-a-elsysse-sensors)
- [License](#license)

Expand Down Expand Up @@ -81,7 +81,7 @@ When a NFC tag (card) is attached to the reader, the following is done:

- when `autoProcessing` is true (default value) it will handle card by the standard:
`TAG_ISO_14443_3` *(Mifare Ultralight, 1K ...)*: sends GET_DATA command to retrieve **card UID**
`TAG_ISO_14443_3` *(MIFARE Ultralight, 1K ...)*: sends GET_DATA command to retrieve **card UID**
`TAG_ISO_14443_4` *(e.g.: Andorid HCE)*: sends SELECT_APDU command to retrive data by file
**then `card` event is fired, for which you can listen and then you can read or write data on the card**
Expand Down Expand Up @@ -130,7 +130,7 @@ nfc.on('reader', reader => {
reader.on('card', card => {
// card is object containing following data
// [always] String type: TAG_ISO_14443_3 (standard nfc tags like Mifare) or TAG_ISO_14443_4 (Android HCE and others)
// [always] String type: TAG_ISO_14443_3 (standard nfc tags like MIFARE) or TAG_ISO_14443_4 (Android HCE and others)
// [always] String standard: same as type
// [only TAG_ISO_14443_3] String uid: tag uid
// [only TAG_ISO_14443_4] Buffer data: raw data from select APDU response
Expand Down Expand Up @@ -183,7 +183,7 @@ nfc.on('reader', reader => {
reader.on('card', card => {
// card is object containing following data
// String standard: TAG_ISO_14443_3 (standard nfc tags like Mifare) or TAG_ISO_14443_4 (Android HCE and others)
// String standard: TAG_ISO_14443_3 (standard nfc tags like MIFARE Ultralight) or TAG_ISO_14443_4 (Android HCE and others)
// String type: same as standard
// Buffer atr
Expand Down Expand Up @@ -216,11 +216,11 @@ nfc.on('error', err => {
## Reading and writing data
You can read from and write to numerous NFC tags including Mifare Ultralight (tested), Mifare Classic, Mifare DESFire, ...
You can read from and write to numerous NFC tags including MIFARE Ultralight (tested), MIFARE Classic, MIFARE DESFire, ...
> Actually, you can even read/write any possible non-standard NFC tag and card, via sending APDU commands according card's technical documentation via `reader.transmit`.
Here is **a simple example** showing reading and writing data to simple card **without authenticating** (e.g. Mifare Ultralight):
Here is **a simple example** showing reading and writing data to simple card **without authenticating** (e.g. MIFARE Ultralight):
_See [Basic usage](#basic-usage) how to set up reader or [look here for full code](/examples/from-readme-3.js)_
```javascript
Expand Down Expand Up @@ -264,9 +264,9 @@ reader.on('card', async card => {
📦📦📦 You can find more examples in [examples folder](/examples), including:
* [read-write.js](/examples/read-write.js) – detecting, reading and writing cards
* [mifare-classic.js](/examples/mifare-classic.js) – authenticating, reading and writing Mifare Classic cards
* [mifare-desfire.js](/examples/mifare-desfire.js) – authenticating and accessing data on Mifare DESFire cards
* [read-write.js](/examples/read-write.js) – detecting, reading and writing cards standard ISO/IEC 14443-3 cards (NTAG, MIFARE Ultralight, ...)
* [mifare-classic.js](/examples/mifare-classic.js) – authenticating, reading and writing MIFARE Classic cards
* [mifare-desfire.js](/examples/mifare-desfire.js) – authenticating and accessing data on MIFARE DESFire cards
* [basic.js](/examples/basic.js) – reader events explanation
* [led.js](/examples/led.js) – controlling LED and buzzer of ACR122U reader
* [uid-logger.js](/examples/uid-logger.js) – logs uid when a card is detected
Expand Down Expand Up @@ -370,7 +370,7 @@ It was removed for non-standard behaviour of ES6 modules in ES5 env (see [#12](h
No worry, just needs a proper configuration, see [explanation and instructions here](https://github.com/pokusew/nfc-pcsc/issues/13#issuecomment-302482621).
### Mifare Classic: Authentication Error after Multiple Writes
### MIFARE Classic: Authentication Error after Multiple Writes
No worry, you have probably modified a sector trailer instead of a data block, see [explanation and instructions here](https://github.com/pokusew/nfc-pcsc/issues/16#issuecomment-304989178).
Expand Down
2 changes: 1 addition & 1 deletion examples/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ nfc.on('reader', reader => {
reader.on('card', card => {

// card is object containing following data
// [always] String type: TAG_ISO_14443_3 (standard nfc tags like Mifare) or TAG_ISO_14443_4 (Android HCE and others)
// [always] String type: TAG_ISO_14443_3 (standard nfc tags like MIFARE) or TAG_ISO_14443_4 (Android HCE and others)
// [always] String standard: same as type
// [only TAG_ISO_14443_3] String uid: tag uid
// [only TAG_ISO_14443_4] Buffer data: raw data from select APDU response
Expand Down
4 changes: 2 additions & 2 deletions examples/led.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ nfc.on('reader', async reader => {
reader.on('card', async card => {


// standard nfc tags like Mifare
// standard nfc tags like MIFARE
if (card.type === TAG_ISO_14443_3) {
// const uid = card.uid;
pretty.info(`card detected`, { reader: reader.name, card });
Expand All @@ -52,7 +52,7 @@ nfc.on('reader', async reader => {
pretty.info(`card detected`, { reader: reader.name, card });
}

// Notice: reading data from Mifare Classic cards (e.g. Mifare 1K) requires,
// Notice: reading data from MIFARE Classic cards (e.g. MIFARE 1K) requires,
// that the data block must be authenticated first
// don't forget to fill your keys and types
// reader.authenticate(blockNumber, keyType, key, obsolete = false)
Expand Down
22 changes: 11 additions & 11 deletions examples/mifare-classic.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

// #############
// Example: Mifare Classic
// Example: MIFARE Classic
// - should work well with any compatible PC/SC card reader
// - what is covered:
// - authentication
Expand All @@ -13,12 +13,12 @@

// ## Note about the card's data structure
//
// ### Mifare Classic EV1 1K
// ### MIFARE Classic EV1 1K
// – 1024 × 8 bit EEPROM memory
// – 16 sectors of 4 blocks
// – see https://www.nxp.com/docs/en/data-sheet/MF1S50YYX_V1.pdf
//
// ### Mifare Classic EV1 4K
// ### MIFARE Classic EV1 4K
// – 4096 × 8 bit EEPROM memory
// – 32 sectors of 4 blocks and 8 sectors of 16 blocks
// – see https://www.nxp.com/docs/en/data-sheet/MF1S70YYX_V1.pdf
Expand Down Expand Up @@ -62,15 +62,15 @@ nfc.on('reader', async reader => {
reader.on('card', async card => {


// Mifare Classic is ISO/IEC 14443-3 tag
// MIFARE Classic is ISO/IEC 14443-3 tag
// skip other standards
if (card.type !== TAG_ISO_14443_3) {
return;
}

pretty.info(`card detected`, reader, card);

// Reading and writing data from/to Mifare Classic cards (e.g. Mifare 1K) requires,
// Reading and writing data from/to MIFARE Classic cards (e.g. MIFARE 1K) requires,
// that the accessed data blocks must be authenticated first
// Don't forget to fill YOUR keys and types! (default ones are stated below)
// reader.authenticate(blockNumber, keyType, key, obsolete = false)
Expand Down Expand Up @@ -106,14 +106,14 @@ nfc.on('reader', async reader => {
// reader.read(blockNumber, length, blockSize = 4, packetSize = 16)
// - blockNumber - memory block number where to start reading
// - length - how many bytes to read
// - blockSize - 4 for Mifare Ultralight, 16 for Mifare Classic
// - blockSize - 4 for MIFARE Ultralight, 16 for MIFARE Classic
// ! Caution! length must be divisible by blockSize
// ! Caution! Mifare Classic cards have sector trailers
// ! Caution! MIFARE Classic cards have sector trailers
// containing access bits instead of data, each last block in sector is sector trailer
// (e.g. block 3, 7, 11, 14)
// see for more info https://github.com/pokusew/nfc-pcsc/issues/16#issuecomment-304989178

const data = await reader.read(4, 16, 16); // blockSize=16 must specified for Mifare Classic cards
const data = await reader.read(4, 16, 16); // blockSize=16 must specified for MIFARE Classic cards

pretty.info(`data read`, reader, data);

Expand All @@ -133,9 +133,9 @@ nfc.on('reader', async reader => {
// reader.write(blockNumber, data, blockSize = 4, packetSize = 16)
// - blockNumber - memory block number where to start writing
// - data - what to write
// - blockSize - 4 for Mifare Ultralight, 16 for Mifare Classic
// - blockSize - 4 for MIFARE Ultralight, 16 for MIFARE Classic
// ! Caution! data.length must be divisible by blockSize
// ! Caution! Mifare Classic cards have sector trailers
// ! Caution! MIFARE Classic cards have sector trailers
// containing access bits instead of data, each last block in sector is sector trailer
// (e.g. block 3, 7, 11, 14)
// see for more info https://github.com/pokusew/nfc-pcsc/issues/16#issuecomment-304989178
Expand All @@ -145,7 +145,7 @@ nfc.on('reader', async reader => {
const randomNumber = Math.round(Math.random() * 1000);
data.writeInt16BE(randomNumber, 0);

await reader.write(4, data, 16); // blockSize=16 must specified for Mifare Classic cards
await reader.write(4, data, 16); // blockSize=16 must specified for MIFARE Classic cards

pretty.info(`data written`, reader, data);

Expand Down
4 changes: 2 additions & 2 deletions examples/mifare-desfire.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

// #############
// Example: Mifare DESFire
// Example: MIFARE DESFire
// - what is covered:
// - 3DES authentication
// - reading data files
Expand Down Expand Up @@ -54,7 +54,7 @@ nfc.on('reader', async reader => {

pretty.info(`device attached`, reader);

// we have to handle Mifare DESFIRE
// we have to handle MIFARE DESFire
reader.autoProcessing = false;

// just handy shortcut to send data
Expand Down
8 changes: 4 additions & 4 deletions examples/read-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// #############
// Example: Reading and writing data
// - should work well with any compatible PC/SC card reader
// - tested with Mifare Ultralight cards but should work with many others (e.g. NTAG)
// - tested with MIFARE Ultralight cards but should work with many others (e.g. NTAG)
// - what is covered:
// - example reading and writing data on from/to card
// - NOTE! for reading and writing data from/to Mifare Classic please see examples/mifare-classic.js which explains Mifare Classic specifics
// - NOTE! for reading and writing data from/to MIFARE Classic please see examples/mifare-classic.js which explains MIFARE Classic specifics
// #############

import { NFC, TAG_ISO_14443_3, TAG_ISO_14443_4, KEY_TYPE_A, KEY_TYPE_B } from '../src/index';
Expand Down Expand Up @@ -46,7 +46,7 @@ nfc.on('reader', async reader => {
// reader.read(blockNumber, length, blockSize = 4, packetSize = 16)
// - blockNumber - memory block number where to start reading
// - length - how many bytes to read
// - blockSize - 4 for Mifare Ultralight, 16 for Mifare Classic
// - blockSize - 4 for MIFARE Ultralight, 16 for MIFARE Classic
// ! Caution! length must be divisible by blockSize (we have to read the whole block(s))

const data = await reader.read(4, 4);
Expand All @@ -69,7 +69,7 @@ nfc.on('reader', async reader => {
// reader.write(blockNumber, data, blockSize = 4, packetSize = 16)
// - blockNumber - memory block number where to start writing
// - data - what to write
// - blockSize - 4 for Mifare Ultralight, 16 for Mifare Classic
// - blockSize - 4 for MIFARE Ultralight, 16 for MIFARE Classic
// ! Caution! data.length must be divisible by blockSize (we have to write the whole block(s))

const data = Buffer.allocUnsafe(4).fill(0);
Expand Down
2 changes: 1 addition & 1 deletion examples/without-auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ nfc.on('reader', reader => {
reader.on('card', card => {

// card is object containing following data
// String standard: TAG_ISO_14443_3 (standard nfc tags like Mifare) or TAG_ISO_14443_4 (Android HCE and others)
// String standard: TAG_ISO_14443_3 (standard nfc tags like MIFARE) or TAG_ISO_14443_4 (Android HCE and others)
// String type: same as standard
// Buffer atr

Expand Down

0 comments on commit 4a76a2b

Please sign in to comment.