WebThingsIO / webthing-rust

Rust implementation of a Web Thing server
Mozilla Public License 2.0
211 stars 25 forks source link

Support the current WebOfThings specification #61

Open lu-zero opened 2 years ago

lu-zero commented 2 years ago

At @sifis-home we are experimenting with augmenting the ThingDescription with additional semantic components and we are using webthings-rust (and webthings-arduino) as base.

We'd like to contribute an update to this crate to support the current specification.

Do you have preferences on how to do that?

benfrancis commented 2 years ago

Hi @lu-zero, great to hear from you and thank you for the offer of contributions.

I'm currently leading a project to make WebThings compliant with W3C WoT standards for version 2.0, including

You can read an overview of the project in https://github.com/WebThingsIO/gateway/issues/2802 and the work on WebThings Gateway is tracked by the w3c-compliance label.

The three high level phases of this project are:

  1. WebThings Gateway producer - Make the Thing Descriptions and API exposed by the gateway W3C compliant
  2. WebThings Gateway consumer - Enable the gateway to consume W3C compliant Things using wot-adapter
  3. WebThings Framework - Make all the libraries (including webthing-rust) W3C compliant

Work has started on all three, but I am currently focused on the first phase. Your contributions to the third phase would be very welcome.

It is important that the W3C specifications are implemented consistently between WebThings Gateway and all the libraries that make up WebThings Framework, so that they are all guaranteed to work together out of the box.

The first thing to note is that it is not possible to be compliant with WoT Thing Description 1.0 without removing features of the current Web Thing API, because not all of the existing features can be described in 1.0. This is why I've been working closely with the WoT Working Group to add features to 1.1 to such as new operation types.

The second thing to note is that in order to guarantee out-of-the-box interoperability we are implementing a standardised HTTP+JSON protocol binding from the Core Profile, which will replace the current Web Thing REST API (the Web Thing WebSocket API is also being standardised under the Web Thing Protocol Community Group). The WoT Profile specification is still in a lot of flux, so implementation is taking time.

In terms of making webthing-rust W3C compliant, some good first steps might be:

  1. Change links to forms (like https://github.com/WebThingsIO/gateway/issues/2806)
  2. Remove object wrappers from API payloads (like https://github.com/WebThingsIO/gateway/issues/2807)
  3. Add support for Server-Sent Events (like https://github.com/WebThingsIO/gateway/issues/2830)
  4. Change mediaType to type in links (like https://github.com/WebThingsIO/gateway/issues/2808)

This will go a long way to making the Thing Descriptions themselves W3C compliant, and make the payloads of basic API calls match what a W3C compliant WoT consumer would expect.

We could then discuss further about tidying up some remaining incompatibilities which we also still have in the gateway, and an approach for implementing the rest of WoT Profile and WoT Discovery to bring everything fully in line.

I'd be happy to set up a call to discuss a co-ordinated plan for W3C compliance, including looping in @tim-hellhake who is the current module owner of webthing-rust.