forked from laftho/node-nfc-nci
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
28 lines (22 loc) · 772 Bytes
/
test.js
File metadata and controls
28 lines (22 loc) · 772 Bytes
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
const nci = require("./index");
nci.listen((context) => {
context.on("error", (msg) => console.log(msg));
context.on("arrived", (tag) => {
console.log(`ARRIVED: ${JSON.stringify(tag)}`);
if (!context.hasNextWrite()) {
if (tag.uid.id === "04:e1:5f:d2:9c:39:80") {
tag.write("Text", "hello world");
}
}
});
context.on("written", (tag, previous) => {
console.log(`PREVIOUS: ${JSON.stringify(previous)}`);
console.log(`UPDATED: ${JSON.stringify(tag)}`);
});
context.on("departed", (tag) => {
console.log(`DEPARTED: ${JSON.stringify(tag)}`);
if (tag.ndef.content !== "blarg") {
context.setNextWrite("Text", "blarg");
}
});
});