Web of things introduction
Transcript of Web of things introduction
Web of Things
Roger
既生 IoT 何生 WoT❖ WoT 是 IoT 的 Application
Layer ,使用 Web 技術來打造 application 。
❖ 以 URL 來表示 IoT 裝置,為 IoT 加入 URL 的觀念,就是 Google 提出的 Physical Web 計畫。
❖ 在物聯網之後,各種異質網路之間的通訊與融合成為一種趨勢,從而增加現實世界事物與其網路相應事物之間的協同互動。
WoT vs IoT
Future
WoT Architecture
Layer 1 - Access❖ Based on REST and
Resource Oriented Architecture
❖ Extend with Pub/Sub
➢ MQTT,
➢ XMPP
➢ CoAP
Layer 2 - Find❖ How do we enable users to find the
right service for their application?
❖ Enabling Smart Things to be indexed by search engines.
➢ microdata
➢ schema.org
➢ Swagger
➢ JSON-LD
Layer 3 - Share
❖ How do we share smart things with friends?
❖ Social Access Controller (SAC) as proxy between clients and smart things.
Layer 4 - Compose❖ How do we enable their easy
composition by non-specialists into new applications?
❖ Physical Mashups
❖ Tools
➢ IFTTT
➢ Node-RED
➢ WoT-a-Mashup
Web Things integration patterns (1)❖直接連接
➢ 每個裝置都有專屬的 URL ,直接與裝置連結
Web Things integration patterns (2)❖基於 Gateway 連接
➢ 當裝置無法提供 internet protocol 時,只能先透過其他協定例如 CoAP 與 Router 連結後,再把資料由 Router 回傳給 Client 端。
Web Things integration patterns (3)❖基於雲端服務連接
➢ 與第 2 種類似,把 Router 替換成雲端服務,再透過雲端 server 與各個 WoT 連結。
Web Things requirements - Must Should May❖A Web Thing must at least be an HTTP/1.1 server.
❖A Web Thing must have a root resource accessible via an HTTP URL.
❖A Web Thing must support GET, POST, PUT and DELETE HTTP verbs.
❖A Web Thing must implement HTTP status codes 200, 400, 500.➢ 2XX Success. 4XX Client Error. 5XX Server Error.
❖A Web Thing must support JSON as default representation.➢ include error message
❖A Web Thing must support GET on its root URL.
EXAMPLE : Valid root URLs
http://gateway.api.com/devices/TVhttp://kitchen-raspberry.device-lab.co.ukhttps://192.168.10.10:9002https://kitchen:3000/fridge/root
Web Things requirements - Must Should May
❖A Web Thing should use secure HTTP connections (HTTPS).
❖A Web Thing should implement the WebSocket Protocol.
❖A Web Thing should support the Web Things model.
❖A Web Thing should return a 204 for all write operations.
➢ By default, all PUT, POST, and DELETE requests to a Web Thing should return a 204 NO CONTENT response and no response body.
❖A Web Thing should provide a default human-readable documentation.
Web Things requirements - Must Should May
❖A Web Thing may support the HTTP OPTIONS verb for each of its resources.
❖A Web Thing may provide additional representation mechanisms (RDF, XML, JSON-LD).
❖A Web Thing may offer a HTML-based user interface.
❖A Web Thing may provide precise information about the intended meaning of individual parts of the model.
Web Thing Model❖The Web Thing follows the Web Things Requirements.
❖The Web Things model is a contract between clients and Things in the IoT.
URL Description
{wt} The root resource URL
{wt}/model/ The model of a Web Thing
{wt}/properties/ The list of properties
{wt}/properties/{id} A specific property
{wt}/actions/ The list of actions
{wt}/actions/{id} A specific action
{wt}/actions/{id}/{actionId} A specific execution of an action
{wt}/.../ ...
end-points exaples
Web Thing Model - Common ConstructsEXAMPLE 2: Basic JSON payload
{ "id": "myCar", // required "name": "My great car", // A short human-readable name for the resource. "description": "This is such a great car.", // A human-readable description of the resource. "createdAt": "2012-08-24T17:29:11.683Z", // Timestamp when this resource was created "updatedAt": "2012-08-24T17:29:11.683Z", // Timestamp when this resource was last updated. "tags": [ // An array of tags. "cart", "device", "test" ], "customFields": { // A JSON object with key-value pairs to store custom information about this resource. "size": "20", "color": "blue" }, "links": { // A JSON object that lists the sub-resources that this resource links to. "model": { "link": "model/", "title": "Model this Web Thing." }, "properties": { "link": "properties/", "title": "Properties of this Web Thing." }, "actions": { "link": "actions/", "title": "Actions of this Web Thing." }, ... }}
Example - Retrieve a Web ThingEXAMPLE 8: Get the Root Resource of a Web Thing--> REQUESTGET {wt} <-- RESPONSE200 OKLink: <model/>; rel="model"Link: <properties/>; rel="properties"Link: <actions/>; rel="actions"Link: <product/>; rel="product"Link: <type/>; rel="type"Link: <help/>; rel="help"Link: <ui/>; rel="ui"Link: <_myCustomLinkRelType/>; rel="_myCustomLinkRelType"
{ "id": "myCar", "name": "My super great car", "description": "This is such a great car.", "createdAd": "2012-08-24T17:29:11.683Z", "updatedAd": "2012-08-24T17:29:11.683Z", "tags":["cart", "device", "test"], "customFields":{ "size": "20", "color":"blue" }}
Example - Update a Web ThingEXAMPLE 9: Update my super great car--> REQUESTPUT {wt} { "name":"My really super great car"}
<-- RESPONSE204 NO CONTENT
Example - Retrieve a list of actionsEXAMPLE 15: List of actions--> REQUESTGET {wt}/actions
<-- RESPONSE200 OKLink: <http://webofthings.org/actions/upgradefirmware>; rel="type"
[ { "id":"upgradeFirmware", "name":"Upgrade Device Firmware" }, { "id":"reboot", "name":"Reboot" }]
Example - Execute an actionEXAMPLE 17: Schedule a reboot--> REQUESTPOST {wt}/actions/reboot
{ "delay":50, "mode":"debug"}
<-- RESPONSE204 NO RESPONSELocation: {wt}/actions/reboot/233