diff --git a/index.html b/index.html index 8c5d14c2..3ac75bd3 100644 --- a/index.html +++ b/index.html @@ -173,6 +173,8 @@
  • Invoke an Action.
  • Observe Events emitted by the Thing.
  • Observe changes to the Thing Description of the Thing.
  • +
  • Get the Thing Description.
  • +
  • Get the list of linked resources based on the Thing Description.
  • @@ -306,6 +308,9 @@

    The ThingFilter dictionary

    +

    + Constraints are experimental feature, implementations are not required to support them. +

    Semantic annotations need revisiting in order to simplify their representation. In the [[WOT-TD]] specification they represent the `@type` construct. At the moment only `@context`, `@type` and `@id` constructs are used in the TD.

    @@ -471,7 +476,7 @@

    The ThingTemplate dictionary

             let subscription = wot.discover({ method: "local" }).subscribe({
    -          next: thing => { console.log("Found local Thing " + thing.name); },
    +          thing => { console.log("Found local Thing " + thing.name); },
               error: err => { console.log("Discovery error: " + err.message); },
               complete: () => { console.log("Discovery finished successfully");}
             });
    @@ -507,7 +512,6 @@ 

    The ConsumedThing interface

           interface ConsumedThing {
             readonly attribute DOMString name;
    -        void setName(DOMString name);
             ThingDescription getThingDescription();
             Promise<any> invokeAction(DOMString name, any parameters);
             Promise<void> writeProperty(DOMString name, any value);
    @@ -519,19 +523,13 @@ 

    The ConsumedThing interface

    ConsumedThing represents a local proxy object of the remote Thing. -

    -

    The setName() method

    +

    The name property

    - Takes a name parameter and sets the name of the Thing, as used in applications. Applications can provide a maximum 128 bytes long name, but implementations may reject (by throwing a `RangeError`) or truncate the provided name, depending on the capabilities of the underlying platform. Setting name throws `TypeError` on other invalid (not string) input. + The `name` property represents the name of the Thing as specified in the TD. In this version it is read only.

    -

    The getThingDescription() method

    Returns the Thing Description of the Thing. @@ -592,7 +590,8 @@

    Examples

    Below a ConsumedThing interface example is given.

    -        wot.fetch("http://mmyservice.org/mySensor").then(td => {
    +        try {
    +          let td = await wot.fetch("http://mmyservice.org/mySensor");
               let thing = wot.consume(td);
               console.log("Thing " + thing.name + " has been consumed.");
               let subscription = thing.onPropertyChange("temperature")
    @@ -605,9 +604,9 @@ 

    Examples

    console.log("Error starting measurement."); subscription.unsubscribe(); }) - }).catch(error => { + } catch(error) { console.log("Error during fetch or consume: " + error.message); - }); + };
    @@ -630,11 +629,11 @@

    The ExposedThing interface

    Promise<void> unregister(optional USVString directory); Promise<void> emitEvent(DOMString eventName, any payload); // define Thing Description modifiers - ExposedThing addProperty(ThingPropertyInit property); + ExposedThing addProperty(ThingProperty property); ExposedThing removeProperty(DOMString name); - ExposedThing addAction(ThingActionInit action); + ExposedThing addAction(ThingAction action); ExposedThing removeAction(DOMString name); - ExposedThing addEvent(ThingEventInit event); + ExposedThing addEvent(ThingEvent event); ExposedThing removeEvent(DOMString name); // define request handlers ExposedThing setActionHandler(ActionHandler action, optional DOMString actionName); @@ -682,10 +681,10 @@

    The DataSchema type

    typedef USVString DataSchema;

    - The DataSchema type represents a type name specified in the Thing Description in a serialized form, for instance JSON Schema. + The DataSchema type represents a data type specified in the Thing Description in a serialized form.

    - DataSchema is under development, currently it can denote any type supported by the Thing Description and the WoT Runtime, such as simple type like "boolean", "number", "string", or "array", or "object" that may specify value range etc. + DataSchema is under development, currently it can denote any type supported by the Thing Description and the WoT Runtime.

    @@ -693,12 +692,12 @@

    The DataSchema type

    Adds a Property defined by the argument and updates the Thing Description. Throws on error. Returns a reference to the same object for supporting chaining.

    -
    -

    The ThingPropertyInit dictionary

    +
    +

    The ThingProperty dictionary

    -          dictionary ThingPropertyInit: SemanticAnnotations {
    +          dictionary ThingProperty: SemanticAnnotations {
                 required DOMString name;
    -            required DataSchema type;
    +            required DataSchema schema;
                 any value;
                 boolean writable = true;
                 boolean observable = true;
    @@ -709,7 +708,7 @@ 

    The ThingPropertyInit dictionary

    • The name attribute represents the name of the Property.
    • - The type attribute represents the type for the Property. + The schema attribute represents the data type for the Property described by DataSchema.
    • The value attribute represents the value of the Property.
    • @@ -731,23 +730,23 @@

      The ThingPropertyInit dictionary

      The addAction() method

      - Adds an Action to the Thing object as defined by the action argument of type ThingActionInit and updates the Thing Description. Throws on error. Returns a reference to the same object for supporting chaining. + Adds an Action to the Thing object as defined by the action argument of type ThingAction and updates the Thing Description. Throws on error. Returns a reference to the same object for supporting chaining.

      -
      -

      The ThingActionInit dictionary

      +
      +

      The ThingAction dictionary

      -          dictionary ThingActionInit: SemanticAnnotations {
      +          dictionary ThingAction: SemanticAnnotations {
                   required DOMString name;
      -            DataSchema inputDataDescription;
      -            DataSchema outputDataDescription;
      +            DataSchema inputSchema;
      +            DataSchema outputSchema;
                 };
             

      - The ThingActionInit dictionary describes the arguments and the return value. + The ThingAction dictionary describes the arguments and the return value.

      • The name attribute provides the Action name.
      • -
      • The inputDataDescription attribute provides the description of the input arguments (argument list is represented by an object). If missing, it means the action does not accept arguments.
      • -
      • The outputDataDescription attribute provides the description of the returned data. If missing, it means the action does not return data.
      • +
      • The inputSchema attribute provides the description of the input arguments (argument list is represented by an object). If missing, it means the action does not accept arguments.
      • +
      • The outputSchema attribute provides the description of the returned data. If missing, it means the action does not return data.

      @@ -761,19 +760,19 @@

      The ThingActionInit dictionary

      The addEvent() method

      - Adds an event to the Thing object as defined by the event argument of type ThingEventInit and updates the Thing Description. Throws on error. Returns a reference to the same object for supporting chaining. + Adds an event to the Thing object as defined by the event argument of type ThingEvent and updates the Thing Description. Throws on error. Returns a reference to the same object for supporting chaining.

      -
      -

      The ThingEventInit dictionary

      +
      +

      The ThingEvent dictionary

      -          dictionary ThingEventInit: SemanticAnnotations {
      +          dictionary ThingEvent: SemanticAnnotations {
                   required DOMString name;
      -            DataSchema dataDescription;
      +            DataSchema schema;
                 };
               
      • The name attribute represents the event name.
      • -
      • The dataDescription attribute represents the type of the data that is attached to the event. If missing, it means the event does not carry data.
      • +
      • The schema attribute represents the type of the data that is attached to the event. If missing, it means the event does not carry data.
      @@ -854,13 +853,13 @@

      Examples

      thing.addProperty({ name: "temperature", value: "0", - type: "number", + schema: '{ \"type\": \"number\" }', writable: false // use default values for the rest }); thing.addEvent({ name: "onchange", - dataDescription: "number" + schema: '{ \"type\": \"number\" }' }); thing.addAction({ name: "reset", @@ -896,8 +895,7 @@

      Examples

      WoT.fetch("http://myservice.org/mySensor/description") .then(td => { let e_thing = WoT.produce(td); - // properties, actions and events are added based on the TD - console.log("created " + thing.name }); + // properties, actions and events have been added based on the TD // now add the requests handlers try { e_thing.setPropertyReadHandler(propertyName => { @@ -937,6 +935,71 @@

      Examples

      +
      +

      Experimental extensions to the ConsumedThing interface

      +

      + The ThingDescription related functionality, such as enumerating Properties, Actions, Events and links (introspection) is an API extension that is out of scope for this specification. However, the draft interfaces are defined here for informative purposes. +

      +
      +      partial interface ConsumedThing {
      +        sequence<ThingProperty> getProperties();
      +        sequence<ThingAction> getActions();
      +        sequence<ThingEvent> getEvents();
      +        sequence<TDLink> getLinks();
      +      };
      +    
      + +

      The getProperties() method

      +

      + Returns the list of Properties defined in the Thing Description of the Thing in the form of a list of ThingProperty objects. +

      +
      + +

      The getActions() method

      +

      + Returns the list of Actions defined in the Thing Description of the Thing in the form of a list of ThingAction objects. +

      +
      + +

      The getEvents() method

      +

      + Returns the list of Events defined in the Thing Description of the Thing in the form of a list of ThingEvent objects. +

      +
      + +

      The getLinks() method

      +

      + Returns the list of linked resources in Thing Description of the Thing in the form of a list of TDLink objects. +

      +
      +

      The TDLink dictionary

      +

      + Contains a hyperlink reference, a relation type and a media type. +

      +
      +          dictionary TDLink {
      +              required USVString href;
      +              USVString mediaType;
      +              DOMString rel;
      +          };
      +        
      +

      The TDLink dictionary contains the following properties: +

        +
      • + The href attribute represents a hyperlink reference. +
      • +
      • + The rel attribute represents a relation type. +
      • +
      • + The mediaType attribute represents a IANA media type. For TDs there will be registered media types, so applications will be able to check whether an `href` link points to a TD, i.e. whether the link is fetcheable with this API. +
      • +
      +

      +
      +
      +
      +

      Observables

      @@ -1125,6 +1188,9 @@

      The Observable interface

      IANA media types (formerly known as MIME types) are defined in RFC2046.

      +

      + The terms hyperlink reference and relation type are defined in [[!HTML5]] and RFC8288. +