forked from camme/node-nfc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
31 lines (24 loc) · 823 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
27
28
29
30
31
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 }));
function read(deviceID) {
console.log('');
var nfcdev = new nfc.NFC();
nfcdev.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 }));
nfcdev.stop();
});
nfcdev.on('error', function(err) {
console.log(util.inspect(err, { depth: null }));
});
nfcdev.on('stopped', function() {
console.log('stopped');
});
console.log(nfcdev.start(deviceID));
}
for (var deviceID in devices) read(deviceID);