Getting Started with a W3C WoT...

Post on 21-Jul-2020

8 views 0 download

Transcript of Getting Started with a W3C WoT...

GettingStartedwithaW3CWoT ProjectRIOTSummit,Berlin,Germany,2016

WhatistheWebofThings?

InternetofThings

IEEE802.15.4 Ethernet BluetoothWi-Fi LoRa …

:Connectivity

ApplicationLayer

WhatistheWebofThings?

InternetofThings

IEEE802.15.4 Ethernet BluetoothWi-Fi LoRa …

:Connectivity

WebofThings:Applications

WhatistheWebofThings?

InternetofThings

IEEE802.15.4 Ethernet BluetoothWi-Fi LoRa …

:Connectivity

W3CWoT Mission

“interconnectingexistingInternetofThingsplatformsandcomplementingavailablestandards”

WebofThings

Nottobeyetanotherstandard

WoT INTERFACE

IoTPlatformsandProtocolBindingshttp://w3c.github.io/wot/current-practices/wot-practices.html#wot-interface

WoT Interface

• InterfaceexposedbyServients tothenetwork

WoTServient

WoTInterface

WoTServient

WoTInterface

WoTInterface

• InterfaceexposedbyServients tothenetwork

WoTServient WoTServient

Protocol

WoTInterface WoTInterface

ProtocolBindings

• Interfacecanbeboundtovariousprotocols

WoTServient WoTServient

HTTP

WoTInterface WoTInterface

ProtocolBindings

ProtocolBindings

HTTP HTTP

ProtocolBindings

• Interfacecanbeboundtovariousprotocols

WoTServient WoTServient

WoTInterface

ProtocolBindings

ProtocolBindings

CoAP

CoAPWoTInterface

CoAP

ProtocolBindings

• MultiplebindingspossibleonThings

WoTServient WoTServient

WoTInterface WoTInterface

ProtocolBindings

ProtocolBindings

WebSocket

WS WSMQTT

ResourceModel

• InteractionpointsareWebresources

WoTServient WoTServient

ProtocolBindings

ProtocolBindings

ResourceModel

ResourceModel

WoTInterface WoTInterface··· ···

ServientRole• ExposingThingsareinserverrole• ConsumingThingsareinclientrole

WoTServient WoTServient

ProtocolBindings

ProtocolBindings

InteractionResourcesWebLinks http://wot.example.com/res

ClientRole ServerRole··· ···

ServientRole

• Usuallybothrolesatthesametimeà Servient

WoTServient WoTServientWoTServient

ProtocolBindings

ProtocolBindings

WebLinks

ClientRole BothRoles

ProtocolBindings

BothRoles··· ······

InteractionResources

WebLinks

InteractionResources

WebLinks

THINGDESCRIPTION

MetadataandInteractionshttp://w3c.github.io/wot/current-practices/wot-practices.html#thing-description

WoTServient

ProtocolBindings

ResourceModel

WoTInterface···

HowtoInteractwithWoTServients?

Whoareyou?

Whatkindof functionsdoyouhave?

Whatkindofdatadoyouserve?

HowcanIaccessthedata/function?

Whatkindofprotocols/encodings doyousupport?

Aretheresomesecurityconstrains?

àW3CThingDescription

SemanticDescription

• ReachinteroperabilitythroughLinkedDatavocabularies– subject,predicate,objecttriples– rootedintheRDFmodel

• W3CThingDescription– describesWoTInterfacetointeractwithThings– extensiblewithdomain-specificvocabulary– differentserializationspossible

ThingDescription(TD)

• DescribesThingmetadataandinteractions

WoTServient WoTServient

ProtocolBindings

ProtocolBindings

ResourceModel

ResourceModel

WoTInterface WoTInterface··· ···

ThingDescription(TD)• ConsumingThingsareinclientrole• ExposedThingsareinserverrole

WoTServient WoTServient

ProtocolBindings

ProtocolBindings

ClientRole ServerRole

ThingDescription(TD)

• ExposedThingsprovideThingDescription

WoTServient WoTServient

ProtocolBindings

ProtocolBindings

ThingDescription

InteractionResources

ClientRole ServerRoleHTTPCoAP

ThingDescription(TD)

• ConsumingThingslearnWoTInterfacefromTD

WoTServient WoTServient

ProtocolBindings

ProtocolBindings

ThingDescription

InteractionResources

Metadata,WebLinks

ClientRole ServerRoleHTTP HTTPCoAP

ThingDescription(TD)

• Thing-to-thingcommunication

WoTServient WoTServient

ProtocolBindings

ProtocolBindings

ThingDescription

InteractionResources

Metadata,WebLinks

ClientRole ServerRoleHTTP HTTPCoAP

ThingDescription(TD)

• DefaultserializationisJSON-LD– basedonwellestablishedJSONformat– differentimplementationsandtoolsavailable–@contextdefinesvocabularies– SeeTDexample

TDExample{

"@context": ["http://w3c.github.io/wot/w3c-wot-td-context.jsonld",{ "actuator": "http://example.org/actuator#" }

],

"@type": "Thing","name": "MyLEDThing",

"uris": ["coap://myled.example.com:5683/","http://mything.example.com:8080/myled/"

],

"encodings": ["JSON", "EXI"],"security": {

"cat": "token:jwt","alg": "HS256","as": "https://authority-issuing.example.org"

},

"properties": [

"properties": [{"@type": "actuator:onOffStatus","name": "status","valueType": { "type": "boolean" },"writable": true,"hrefs": [ "pwr", "status" ]

}],"actions": [

{"@type": "actuator:fadeIn","name": "fadeIn","inputData": {

"valueType": { "type": "integer" },"actuator:unit": "actuator:ms"

},"hrefs": [ "in", "led/in" ]

},{"@type": "actuator:fadeOut","name": "fadeOut","inputData": {

"valueType": { "type": "integer" },"actuator:unit": "actuator:ms"

},"hrefs": [ "out", "led/out" ]

}],

Interactionresources

Property

Action

Action

Events(workinprogress)

TypeSystem

• DefaultcurrentlybasedonJSONSchemahttp://w3c.github.io/wot/current-practices/wot-practices.html#type-system

• Beststartwithsimpletypes– boolean– integer– number– string

• Othersystemscanbepluggedinunder“valueType“field

HowtoCreateaTD?

• Manuallycopy,paste,andmodify– http://w3c.github.io/wot/current-practices/wot-practices.html#td-examples

– orlookintotheTDrepositoryhttp://vs0.inf.ethz.ch:8080(developmentrepository,sometimesoffline)

• Generatefromdevelopmentframework– TDserializationbasedontheinteractionsprovided

SCRIPTINGAPI

RuntimeEnvironmentandPortableAppshttp://w3c.github.io/wot/current-practices/wot-practices.html#scripting-api

WithoutScriptingAPI

• Applicationlogicoftenimplementednatively

WoTServient

ProtocolBindings

ApplicationLogic

C/C++/Java/…

ResourceModel

WoTInterface···

ScriptingAPI

• Commonruntimeenablesportableapps

WoTServient

RuntimeEnvironment

AppScript

ProtocolBindings

ResourceModel

ClientAPI

ServerAPI

Disc.API

WoTInterface···

• Commonruntimeenablesportableapps

WoT Servient VendorB

RuntimeEnvironment

WoT Servient VendorA

RuntimeEnvironment

ScriptingAPI

ResourceModel ResourceModel

AppScript

ClientAPI

ServerAPI

Disc.API

ClientAPI

ServerAPI

Disc.API

WoTInterface···

WoTInterface···

ProtocolBindings ProtocolBindings

• Commonruntimeenablesportableapps

WoT Servient VendorB

RuntimeEnvironment

WoT Servient VendorA

RuntimeEnvironment

ScriptingAPI

ProtocolBindings

ResourceModel

ProtocolBindings

ResourceModel

AppScript

ClientAPI

ServerAPI

Disc.API

ClientAPI

ServerAPI

Disc.API

WoTInterface···

WoTInterface···

WoTRootElement(withDiscovery)interfaceWoT {

Promise<sequence<ConsumedThing>>discover(ThingFilterfilter);Promise<ConsumedThing>consumeDescription(Object td);Promise<ConsumedThing>consumeDescriptionUri(DOMStringuri);Promise<ExposedThing>createThing(DOMStringname);Promise<ExposedThing>createFromDescription(Object td);Promise<ExposedThing>createFromDescriptionUri(DOMStringuri);

};

ClientAPI:ConsumedThinginterfaceConsumedThing {

readonly attributeDOMStringname;Promise<any>getProperty(DOMStringpropertyName);Promise<any>setProperty(DOMStringpropertyName,anynewValue);Promise<any>invokeAction(DOMStringactionName,anyparameter);ConsumedThingaddListener(DOMStringeventName,

ThingEventListener listener);ConsumedThing removeListener(DOMStringeventName,

ThingEventListener listener);ConsumedThing removeAllListeners(DOMStringeventName);Object getDescription();

};

ServerAPI:ExposedThinginterface ExposedThing {

readonly attributeDOMStringname;ExposedThing addProperty(DOMStringname,object type);ExposedThing addAction(DOMStringname,Object input,Object output);ExposedThing addEvent(DOMStringname,Object output);Promise<any>getProperty(DOMStringpropertyName);Promise<any>setProperty(DOMStringpropertyName,anynewValue);Promise<any>emitEvent(DOMStringeventName,anypayload);ExposedThing onUpdateProperty(DOMStringn,PropertyChangeListener cb);ExposedThing onInvokeAction(DOMStringactionName,ActionHandler cb);Object getDescription();

};

ScriptExample(ConsumeThing)WoT.consumeDescriptionUri("http://servient.example.com/things/counter")

.then(function(counter) {counter

.invokeAction("increment", {}).then(function() {console.log("incremented");counter

.getProperty("count").then(function(count) {console.log("new count state is " + count);

});})._catch(console.error);

})._catch(function(err) {

console.error(err);});

ScriptExample(ExposeThing)WoT.newThing("counter")

.then(function(thing) {thing

.addProperty("count", {"type": "integer"})

.addAction("increment")

.onInvokeAction("increment", function() {console.log("incrementing counter");var value = thing.getProperty("count") + 1;thing.setProperty("count", value);return value;

});thing

.setProperty("count", 0)});

SUMMARYW3CWebofThings

ThingImplementation:WoT Servient

WoT Servient

Server RoleClient Role

Protocol Bindings

Resource Model

App Script

Legacy comm-

unication

Client API Server API

ThingDescription

Legacydevice

Web Server Web Client

Proprietary interface

Runtime Environment

WoT Servient WoT Servient

ApplicationLogic:CanconsumeremoteThingsthroughtheClientAPI,localhardwareandconnectedlegacydevices throughaPhysicalAPI(t.b.d.),andexposeThingsthroughtheServerAPI.Toallowportableappscripts, theServientmustpovide aruntimeenvironment.

ResourceModel:Provides acommonabstractionwithuniforminterfaceacrossthedifferentprotocols.LiketheWeb, itallowstoidentifyandaddressinteractionpointsthroughURIs.

ProtocolBinding:Converts abstractinteractionswithThingstodifferentprotocolsusing theinformationfromTD.

ThingDescription(TD):DeclaresWoT Interfaceforinteractionandprovides(semantic)metadatafortheThing.TDisusedbyWoTclientstoinstantiatelocalsoftwareobjectoftheThing.

WoT Interface

Discovery API(Physic. API)

• NativeWoTThingshostaServient directly• TDisprovidedbyThingorsupportinghostontheWeb

WoT ServientonThingItself

WoT Servient (Wot Device)

Client RoleServer Role

Protocol Bindings

Resource Model

Script

Runtime Environment

Browser

Client Role

ProtocolBindings

Resource Model

App Script

Runtime Env.

ThingDescription

• WoTServients canrunonhubs(e.g.,smartphone,gateway)• MultipleServients canbeinstantiatedthroughsandboxedapps• Appscanactasagents/proxiesforlegacydevices

WoT ServientonIntegrationHub

WoT Servient

Client RoleServer Role

Protocol Bindings

Resource Model

App Script

Legacycomm.

Legacydevice

Browser

Client Role

ProtocolBindings

Resource Model

App Script

Runtime Env. Runtime Environment

Hub Platform

ThingDescription

• Acloudmirror(deviceshadow)enablesscalableremoteaccess• IssynchronizedwithlocalServient• Canforwardinteractionsandcachedata

WoT Servient intheCloud

Browser

ClientRole

ProtocolBinding

ResourceModel

AppScript

RuntimeEnvi.

WoT Servient

ClientRoleServer Role

ProtocolBinding

ResourceModel

AppScriptWoT Servient

Client RoleServerRole

Protocol Binding

ResourceModel

AppScript

Legacycomm.

Legacydevice

Hub

Cloud

CloudPlatform

Runtime EnvironmentRuntimeEnvironment

ThingDescription

ThingDescription

LocalAnywhere

OnlineResources• InterestGroup

– https://www.w3.org/WoT/IG/– https://lists.w3.org/Archives/Public/public-wot-ig/ (subscribetomailinglist)

• Documents(forimplementers)– http://w3c.github.io/wot/architecture/wot-architecture.html– http://w3c.github.io/wot/current-practices/wot-practices.html (livingdocument)

Beijing2016Release:http://w3c.github.io/wot/current-practices/wot-practices-beijing-2016.html

• GitHub (documentsandproposals)– https://github.com/w3c/wot

• Wiki(organizationalinformation:WebConf calls,Face-to-Facemeetings,…)– https://www.w3.org/WoT/IG/wiki/Main_Page

• WoT Projects(implementingWoT CurrentPractices)– https://github.com/thingweb/– https://github.com/mkovatsc/wot-demo-devices– Pleaseaddyours!

PLUGFESTW3CWoTF2FBeijing2016

Scenario1– ‘Hello WoT‘

WoTTDinterpreterforhuman interaction

/voteTooHot /on

SetupservientinteractionbasedonTD

Scenario2– ‘Full WoT‘WoTServient providing

scriptforvotingWoTClient

consumesscript

/voteTooHot /on

TDRepositorySearch for Action@type=“tooHot“WoTServient searchs

avotingservient

Scenario3– ‘MiniAutomation‘

Consumebrightness sensortocontrolcurtain

OnlineResources• CurrentPractices(BeijingRelease)

– http://w3c.github.io/wot/current-practices/wot-practices-beijing-2016.html

• OrganizationWiki– https://www.w3.org/WoT/IG/wiki/F2F_meeting,_July_2016,_China,_Beijing#PlugFest

• TestCases– https://github.com/w3c/wot/blob/master/plugfest/2016-beijing/plugfest-test-cases-

beijing-2016.md

• ReportTemplate– https://github.com/w3c/wot/blob/master/plugfest/2016-beijing/TestCaseCoverage.xlsx

(t.b.d.)