forked from camme/node-nfc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
26 lines (21 loc) · 797 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var nfc = require('./index').nfc
, util = require('util')
, version = nfc.version()
, devices = nfc.scan()
;
console.log('version: ' + util.inspect(version, { depth: null }));
console.log('devices: ' + util.inspect(devices, { depth: null }));
var read = function(deviceID) {
console.log('');
console.log(new nfc.NFC().on('read', function(tag) {
console.log(util.inspect(tag, { depth: null }));
if ((!!tag.data) && (!!tag.offset)) console.log(util.inspect(nfc.parse(tag.data.slice(tag.offset)), { depth: null }));
if (--count === 0) process.exit(0);
}).on('error', function(err) {
console.log(util.inspect(err, { depth: null }));
}).start(deviceID));
count++;
};
var count = 0;
for (var deviceID in devices) read(deviceID);
if (count === 0) process.exit(0);