Skip to content

Proposal: Move Forms out of the TD (TD2.0) #2087

@hspaay

Description

@hspaay

24-Mar-2025 Update 1: Changed title and intro based on comments.

This is an outline of the proposal to solve problems that Forms bring by moving them out of TD2.0.

Why move Forms out of the TD

Forms are overkill, complex, unnecessary, and very very annoying.

All protocols bindings need to exchange the same information: operation, thingID, affordance name, correlationID, messageID, message type (request, response, notification), action status, and input or output data.

Thats it. It always boils down to this set of information. Describing the miriad ways of how protocols can do this using forms in every single affordance is unnecessary. There is no need to spread this out over the TD, especially since it depends on the protool used. Right now forms pretty much let you build a separate protocol binding for every single affordance. This makes the words 'utter overkill' look inadequate.

Having to specify a form in every single affordance can double the TD size, cost extra processing power and resources to handle, without any benefit. It adds unnecessary complexity, increases the risk of bugs, makes testing more difficult and hinders adoption. It is the wrong solution for a simple problem. Lets get past it in TD2.0 while we can.

What is described in forms can be moved to the protocol binding. The TD only needs to reference which protocol bindings are supported and what endpoint to use.

This is IoT, not a multi-media server chat, telephony, broadcasting system that interfaces with every known system known to mankind in the past and future.

Proposal

Leverage operations and let the protocol binding define how to transfer the information for an operation.

The TD only needs to specify the protocol binding used and how to establish a secure connection. A Thing level protocols section in the TD is all that is needed. For example:

{
  protocols: {
      "websocket": {
         "endpoint": "wss://address:port/path",
         "security": "stuff goes here",
         "encoding": "json",
      }
      "mqtt": {
         "endpoint": "mqtts://address:port/"
         "security": "stuff goes here",
         ...
      }
  }
}

The TD defines how to connect. The protocol defines how to exchange messages for operations.

All protocols exchange the same information: operation, thingID, affordance name, correlationID, messageID, message type (request, response, notification) and input or output data. Let the protocol specify how to exchange this information.

The latest websocket proposal (not strawman) is a good example. It works.

... but what about ... Yep, leave them in the comments. I'm sure there are valid concerns so lets take a look. The benefits are too great to ignore this.

Bonus oppertunity

As a bonus this is an oppertunity to standardize the messaging envelopes used to send requests, receive responses and notifications, instead of reinventing this wheel for each protocol binding that needs a message envelope. This would reduce SDK development time, simplify a standard test suite to validate interoperability, and also encourage adoption especially for consumers that need to support multiple protocols. A good candidate for standardized message envelopes are the ones defined in the latest websocket protocol currently in draft.

Of course, if a protocol doesn't benefit from using an envelope, for example because addressing and headers can carry this information, then don't use one.

An example:
The http-basic protocol v2 could specify the path to use. GET "/readproperty/{name}" for the operation to read a property. This is in the protocol specification instead of the forms. BaseURI can still be used as currently specified in the TD giving sufficient flexibility to different server environments.

Edge cases

Yes there are always edge cases why this (might) not work. Please leave these in the comments.

In case it is really necessary to change the encoding for a specific affordance then specify the different encoding in the data schema of that affordance.

What is lost with this change is the ability to use different protocols for different affordances of the same Thing. I have yet to see a valid use-case for this that can't be addressed with the proposed solution. But maybe you have a few to share?

ps: I reserve the right to modify this proposal to address some of the concerns raised and fix dyslexia issues. Thank you for reading this far.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Propose closingProblem will be closed shortly if there is no veto.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions