WoT.js
Interface
-
general control: (type: general)
-
end user's mobile/web communicate with device
- JSON-LD
-
schema
schema: { '@type': 'general', '@context': { '門A': { “@events” : { // 聽到事件 “bell”: null, “key”: { “valid” : “boolean” } }, “@properties” : { “is_open” : “boolean” }, “@actions” : { //主動去做 “unlock” : null } } } }
宣告物體組成: Door schema js: wot.schema({}) json: { “@events” : { “bell”: null, “key”: { “valid” : “boolean” } }, “@properties” : { “is_open” : “boolean” }, “@actions” : { “unlock” : null } } 假設現在一共有門A, 則全部schema: js: wot.register('門A', 'Door'); wot.register('門B', 'Door'); json: { @context : { @base=”http://…. }, “@dependencies” : { “door” : “門A”, “light” : “switch12” } }
client: 端發出去 var 門A = wot.register('門A', 'Door'); 門A.onEvents('unlock', function() { });
json-ld send:
{ name: 'data channel id', type: 'general', 門A: { property: { is_open: true } } }
-
- JSON-LD
-
remote/upgrade firmware
-
-
develop control: (type: command)
-
dev:
- support any framework (ex. cylonjs, johnny-five...etc) 寫在 client 端
- node_modules dependency problem
- combile with MCU workflow (option)
{ type: 'command', command_line: { property: { active_cmd: true }, privilege: { name: 'root', token: 'ffef234234234' } } }
-
debug:
schema: { '@type': 'command', '@context': { 'command_line': { @property: { active_cmd: { valid: boolean, defaultValue: false } } @privilege: ['root', 'abc'] }, 'prompt': { @actions: { }, @privilege: ['root', 'abc'] }, 'restart': { @actions: { }, @privilege: ['root', 'abc'] }, 'send_file': { @actions: { }, @privilege: ['root', 'abc'] } } }
- real-time show cmdtype: 'command'data:'name': 'root''value':active_cmd: true
- prompt featuretype: 'command'model:'@actions':'prompt': 'blabla...'
- real-time show cmd
-
watch:
- restarttype: 'command'model:'@actions':'prompt': 'blabla...'
- send/get file (by websocket)type: 'command'model:'@actions':'send_file': 'binary file'
- restart
-
build file
- remove watching status
- set config in /etc/rc.local
- user only open his browser with http://localhost:8081 , it can see this device web.
- ReactJS
-
privilege
- viewer (read-only)
- root
- other ... (use cloud service token)
client 端傳送進去規格
燒進去版子的content:
var wot = require('wot');
var cylon = require('cylon');
wot.on('led', function(data) {
if ( Number(data) === 1 ) {
} else {
}
}
})