物联网系统设计
This project is maintained by phodal
这是一个开源的最小物联网系统的CoAP版,如果你还是一个初学者建议用HTTP版 https://github.com/phodal/iot
npm install iot-coap
新建一个index.js
const iotcoap = require('iot-coap');
iotcoap.run();
iotcoap.rest.run(); //运行REST
创建iot.json
{
"db_name": "iot.db",
"table_name": "basic",
"key":[
"id",
"value",
"sensors1",
"sensors2"
],
"db_table": "id integer primary key, value text, sensors1 float, sensors2 float",
"init_table":[
"insert or replace into basic (id,value,sensors1,sensors2) VALUES (1, 'is id 1', 19, 20);",
"insert or replace into basic (id,value,sensors1,sensors2) VALUES (2, 'is id 2', 20, 21);"
],
"query_table":"select * from basic;",
"rest_url": "/id/:id",
"rest_post_url": "/",
"rest_port": 8848
}
接着运行
node index.js
node method_test/get.js
curl -H "Content-Type: application/json" -d '{"id":3, "value":"dream","sensors1":12,"sensors2":13}' http://localhost:8848
CoAP 修改url为
coap://iot-coap.phodal.com
RESTful 修改url为
构建基于CoAP SQLite Nodejs的物联网之查询数据
构建基于CoAP SQLite Nodejs的物联网之数据库
© 2014 Phodal Huang. This code is distributed under the MIT license.