Closed mikeygcooper closed 9 years ago
Reading and writing is currently not developed yet, but shouldn't be too difficult to implement as all the plumbing is there. I doubt I will get to this for at least another month (sorry, my priorities have recently changed, and I just need UID scanning for my current project).
It should be just a simple as sending the correct frame payloads with the existing APIs in place (ex. getFirmwareVersion). I always welcome pull requests, and if you decide to take a stab at it, these resource should help
Out of curiousity, are you using/planing to use serialport/uart or i2c. Fyi, I've only tested using the serial port so far.
I am using serialport/uart with the raspberry pi, I've got it all working now, just need to implement the data read (and perhaps write) so that I can pull urls stored on the cards. I will have a look into this at the weekend, can't promise anything though as although I'm pretty good with nodejs and javascript i've not done anything like this before :) Cheers for the info though gives me somewhere to start :)
FYI, I'm creating a Spotify jukebox, using the NFC board as the input to choose playlists, albums etc. http://www.mikeyalder.co.uk/tag/mini-jukebox-project/ <-- tracking progress here, so will give you a mention :)
Sounds great.
I've made some good progress on this and should hopefully have something pushed upstream later this week. I'm currently reading NDEF records from some NTAG203 tags. I'm still trying to fully understand the full memory format on the tags (there is 5 bytes before the NDEF data I don't understand yet) and if there are differences in other tag types (ex. Mifare Classic 1K).
I'm also debating on the API to expose (it seems handling NDEF records would be the most common case and would like to make it as painless as possible). Currently I have the following example working:
var pn532 = require('pn532');
var SerialPort = require('serialport').SerialPort;
var ndef = require('ndef');
var serialPort = new SerialPort('/dev/tty.usbserial-AFWR836M', { baudrate: 115200 });
var rfid = new pn532.PN532(serialPort);
rfid.on('ready', function() {
rfid.on('card', function(tag) {
rfid.readData().then(function(data) {
var records = ndef.decodeMessage(data.toJSON());
console.log(records);
});
});
});
I'm also debating on changing the card
event to tag
.
Once I get the read case complete, I plan to get writing (which shouldn't be to difficult as it will be similar to the read case) and then support emulating tags (allow the PN532 to be a target instead of an initiator). I'll update/tag this issue after I do a push to Github.
That sounds awesome ... I did have a look but haven't got very far ... When you push the code I will look into helping implementing different tag types. There are apparently differences between them regarding lock bytes and keys etc.
I figured out the 5 bytes at the head of the data pages (they are for lock information). I found the NFC Forum Type 2 technical specification which gave me great information on the format (straight from the source, instead of culminated from a few different internet resources). You can grab the specification documents after signing a license agreement.
I just pushed my changes that implement tag reading and writing. I also updated some method and event names, so you'll want to take a look at the README (card
event -> tag
event, readPassiveTargetId()
-> scanTag()
, etc). Currently the reading and writing for tag data working on my NTAG203, but it should work on any card type with 4 byte pages (other NTAG* tags, Mifare Ultralight). It definitely doesn't work on Mifare Classic tags, as they use 16-byte blocks, and require authentication that I've looked into, but haven't resolved yet. I've closed this issue but will open one for Mifare Classic support. I also plan to implement tag emulation soon for a project I'm working on (have the PN532 act as a tag / scanned by another device, instead of as a scanner).
Let me know how it works for you. You'll need to pull from source as I haven't pushed an update to NPM yet, but hopefully will do so in a few days.
I've tagged v0.0.5 if you want to give it a try
How do you read card data? or is this not developed yet :-/