rfid_nur
v0.0.10
Published
Small lib for Nordic RFiD reader
Downloads
12
Maintainers
Readme
Library to use Nordic ID reader with nur protocol. (only a few command implemented and some of them partially)
The program is partially tested with Nordic ID Sampo This very early library so not use it, except checking commands structure
Original documentation of the protocol: https://github.com/NordicID/nur_sdk/tree/master/Docs
Change ip.of.the.reader to the actual ip of the reader
Sample program:
var net = require('net'),
Nur = require('rfid_nur'),
nur = new Nur();
var processTag = function(data){
if (data.status === 0) {
console.log("Tag found, EPC: " + data.EPC);
var newEPC = '00000025',
password = 0x00000000,
bank = 1 //EPC bank
;
console.log("Changing EPC to " + newEPC);
// dont know why need '1000' prefix and seems to not update how much lenght will be used
client.write(nur.cmd.writeTag(procesWrite, 0x02, password, bank, 32, data.EPC.length * 4, Buffer.from(data.EPC, 'hex'), bank, 1, Buffer.from('1000' + newEPC, 'hex') ));
} else {
console.log("No tag found: 0x" + data.status.toString(16));
}
},
procesWrite = function(data){
if (data.status === 0){
console.log("Succesfull write, " + data.error + " word written.");
} else {
console.log("Failed to write: " + data.status);
}
};
var client = new net.Socket();
client.connect(4333, 'ip.of.the.reader', function() {
console.log('Connected');
client.write(nur.cmd.ping(console.log));
// client.write(nur.cmd.getReaderInformation(console.log));
client.write(nur.cmd.scanSingleTag(processTag, 1000));
// console.log("write");
//console.log(nur.cmd.writeTag(console.log, 0x02, 0x00000000, 1, 32, 96, Buffer.from('2000020101000000000006DB', 'hex'), 3, 0, Buffer.from('0101020203030404','hex') ));
//controlFlags, password, bank, bitAddress, maskBitLength, mask, bankToWrite, bitAddressWrite, data
//client.write(nur.cmd.writeTag(console.log, 0x02, 0x00000000, 1, 32, 32, Buffer.from('00080025', 'hex'), 1, 1, Buffer.from('100000000025','hex') ));
});
client.on('data', function(data) {
nur.parseStream(data);
});
client.on('close', function() {
console.log('Connection closed');
});
client.on("error", function(err) {
console.log("Caught socket error: " + err.message);
});
// nur.on('answer', console.log);
// nur.on('unsolicited', console.log);
nur.on('inventory', console.log);
nur.on('unsolicited', function(data){
// console.log(nur.parseAnswer(data));
if (data.readUInt8() === 0x81){
client.write(nur.cmd.scanSingleTag(processTag, 1000));
}
});
/*
nur.on('answer', function(data){
console.log(nur.parseAnswer(data));
});*/