Skip to content
This repository was archived by the owner on Mar 17, 2020. It is now read-only.

Commit d59c62b

Browse files
committed
Add experimental NFC support
1 parent d19bb82 commit d59c62b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

server/main.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,22 @@ board.on("ready", function() {
174174
led.color(colorCharacteristic._value.hexSlice());
175175
led.intensity(30);
176176
});
177+
178+
try {
179+
var nfc = require("node-webnfc");
180+
181+
nfc.init(_ => {
182+
nfc.watch(message => {
183+
var record = message.records[0];
184+
if (record) {
185+
// Expects color of css hex form, eg. "#ff00ff".
186+
var color = record.data.name;
187+
if (color) {
188+
colorCharacteristic._led.color(color);
189+
}
190+
}
191+
}, { mode: "any", recordType: "json" });
192+
});
193+
} catch (err) {
194+
console.log("NFC feature disabled.");
195+
}

0 commit comments

Comments
 (0)