config.js測試
module.exports = { coap: { port: 5683, host: "localhost" } };
coapServer.jsui
require('coffee-script/register'); var config = require('./config'); process.stdout.write('Starting CoAP...'); var coapServer = require('./lib/coapServer')(config); console.log(' done.');
此時用Firefox的Copper,訪問coap://127.0.0.1:5683/
,進行ping測試。
(注:Copper訪問`coap://localhost:5683/,不能解析)code
coapServer
必須有config
參數,lib/coapServer.js
中的代碼有bug,沒有config
參數時會報錯ip