-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional Semantic Information for Objects #4
Comments
This is a very interesting question and I also considered it some time ago, as it can be very useful to have information about the valid range of a value etc. But I decided that I would like to keep the implementation as simple as possible and provide just enough information for understanding the available data nodes and types. With the new revision of the spec that is more compatible with CoAP and HTTP, one simple way to provide such features without losing the simplicity of the protocol would be with a query string in the GET request. For example, I would probably not like to implement this in the quite lightweight library now, as it would require enlarging the What do you think? |
That makes total sense -- I'm a big fan of simplicity. One thing that I was thinking could work for my application while using ThingSet: have a different limb of the tree that describes specifications:
IIUC, maps are a supported value type (or at least it's supported by Tiny-TP :)), and names only need to be unique if they are meant for publication. So I could perform the following text query for the specs of Bat_V:
That's a pretty nice solution that would allow for improved UI presentations and additional client side validation (for devices that support specs on their properties). (Things would be a bit more complex in the binary query language, but I think it would still work.) |
You understood correctly that maps are supported value types in general, but they are currently not implemented in the library (yet). Arrays were recently added. It's also correct that the names only need to be unique if they are used for publication. Otherwise we couldn't have a separate "Enable" node under each publication channel. I like your approach a lot, as it doesn't require any changes. Quickly tried it out and it works almost as you suggested. As a map as the value is currently not supported, I defined "Bat_V" as an internal (path) node. Here is an example implemented in the C++ library: ThingSet/thingset-device-library@3c09bd3 The result is:
If you have a linux system with installed GCC and PlatformIO it's quite easy to play around with the protocol now. You clone that repository and run following commands in its root folder:
It gives you a shell which reads requests from the terminal and prints the response. |
(Feature request for consideration. This was based upon my reading of the previous spec, and may be out of sync with the concepts in this spec (such as the object tree))
I really like how the ThingSet protocol supports object names. But it would be nice to have other semantic information about fields, especially for input fields.
Examples of semantic information
To give some concrete examples of semantic information that could be very nice for inputs:
An an example of semantic information that could be nice for outputs:
Advantages of more semantic information
This additional semantic information could be very helpful for clients. For example, if clients know the minval and maxval for an input field, they can correctly send information within that bound. And if they know that output values will be clamped above some level, they can make more intelligent decisions based upon that.
This semantic information could also be very useful for user interface (UI) generation. For example, when displaying a UI to set the maximum allowable current for an MPPT solar converter, it would be nice to know that the minval for that field is 0A and the maxval for that field is 10A. Same with a thermostat or a lightbulb: that additional semantic information can make the UI much richer and more accurate. The UI may be able to rely entirely on the semantic information for generating a beautiful interface.
A possible implementation
With these semantic types, they could be queried as part of the "list" command for each type. For example, you could modify the list results as follows (this is Text Example 2 and Binary Example 3 on https://thingset.github.io/spec/functions):
Text Request:
Text Response:
Binary Request:
Binary Response:
There is certainly more overhead associated with the proposal above. For Example 3 in the spec, the simple map{name: value} took up 26 bytes, while this updated map{id: map{properties}} would take 34 bytes to transmit the same information (name + value). With the additional information shown above (minval/maxval/readfreq_Hz), the message would take 43 bytes.
The text was updated successfully, but these errors were encountered: