https://github.com/don/mifare-classic-js
Read and write NDEF bytes to Mifare Classic Tags
https://github.com/don/mifare-classic-js
Last synced: about 1 year ago
JSON representation
Read and write NDEF bytes to Mifare Classic Tags
- Host: GitHub
- URL: https://github.com/don/mifare-classic-js
- Owner: don
- License: other
- Created: 2013-07-16T02:52:29.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2018-05-11T23:16:39.000Z (about 8 years ago)
- Last Synced: 2025-03-18T18:06:40.988Z (about 1 year ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 23
- Watchers: 4
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.txt
- License: LICENSE.txt
Awesome Lists containing this project
README
## NDEF Mifare Classic
This module reads and writes NDEF bytes to Mifare Classic NFC tags. The module is a wrapper around [libfreefare](https://code.google.com/p/libfreefare/) command line tools.
## API
### mifare.read(callback)
* callback - function
Example
mifare.read(function (err, data, uid) {
if (err) throw err;
console.log('The NFC tag UID is', uid);
var message = ndef.decodeMessage(data.toJSON());
console.log(ndef.stringify(message));
});
The callback is passed two arguments (err, data), where data is the contents of the file
### mifare.write(data, callback)
* bytes - byte array of ndef data
* callback - function
Example
mifare.write(bytes, function (err) {
if (err) throw err;
console.log("OK");
});
### mifare.format(callback)
* callback - function
Example
mifare.format(function (err) {
if (err) throw err;
console.log("OK");
});
## Requires
* [libfreefare](https://code.google.com/p/libfreefare/) 14219ab1451f7c4e4da51acb6f8524924ec039e6 or newer
* [libnfc](https://code.google.com/p/libnfc/) 1.7.0-rc7 or greater
### Linux (Debian)
sudo apt-get install libfreefare* libnfc* -y
### macOS
Use [Homebrew](https://brew.sh)
brew install libfreefare libnfc