Raspi+EXPLORE-NFC Node.js 제어를 통해 웹에 연결
Node.js제어여기 라이브러리를 통해 제대로 작동하지 못해 내용을 만들어 보았습니다.
여기 있습니다.
node_modules/explorenfc/index.js
//省略
read: function(cb){
// exec: spawns a shell.
child_process.exec(binary, function(error, stdout, stderr){
// TODO, parse the output from the board
// If it looks like this could be what we want
var result = processLines(stdout);
if(result){
cb(result);
}else{
cb(stdout);
}
});
},
//省略
stdout의 내용을 직접 출력합니다.샘플 코드를 편집하여 다음과 같은 샘플을 만들었습니다.
nfc.js
'use strict'
const nfc = require("explorenfc");
nfc.init("/usr/bin/explorenfc-basic");
nfc.read((nfcEvent) => {
if(nfcEvent){
let tmp = nfcEvent.split('\r\n');
let nfcdata = {};
nfcdata.Manufacturer = tmp[2].split(':')[1];
nfcdata.CID = tmp[3].split(':')[1];
nfcdata.IC = tmp[4].split(':')[1];
console.log(nfcdata);
}else{
console.log("no NFC Event");
}
});
실행$ node nfc.js
{ Manufacturer: ' \t0114',
CID: ' \t01149615C010',
IC: ' \t0401' }
이런 느낌으로 nfc의 정보가 들어오고 있다nfcdata
.또한 Milkcoa로 네트워크 연결
밀카오 사용법에 대해 알아봐 주세요.
nfc.js
'use strict'
const nfc = require("explorenfc");
const MilkCocoa = require('milkcocoa');
const milkcocoa = new MilkCocoa('<id>.mlkcca.com');
const ds = milkcocoa.dataStore('mydatastore');
nfc.init("/usr/bin/explorenfc-basic");
nfc.read((nfcEvent) => {
if(nfcEvent){
let tmp = nfcEvent.split('\r\n');
let nfcdata = {};
nfcdata.Manufacturer = tmp[2].split(':')[1];
nfcdata.CID = tmp[3].split(':')[1];
nfcdata.IC = tmp[4].split(':')[1];
console.log(nfcdata);
ds.push(nfcdata); //Milkcocoaに情報を保存
ds.send({flag:1}); //Milkcocoaに情報を送信
}else{
console.log("no NFC Event");
}
});
Reference
이 문제에 관하여(Raspi+EXPLORE-NFC Node.js 제어를 통해 웹에 연결), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/n0bisuke/items/2268cd88a6fca9b9f1e7텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)