-
Notifications
You must be signed in to change notification settings - Fork 80
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
Support Objects in octet-stream codec #1099
Comments
I hope I understand your proposal correctly. At the moment the default encoding is JSON and as such see https://github.com/eclipse-thingweb/node-wot#mediatype-support |
I was thinking about the opposite way, where my device sends an octet stream and the JSON above is a possible description of the payload data in the device's TD. More precisely, I would like to extend the octet stream to not throw an Error at https://github.com/eclipse-thingweb/node-wot/blob/master/packages/core/src/codecs/octetstream-codec.ts#L108, but call a new funtion If that makes sense, I could try and provide a PR |
I think in any case it needs to be balanced. Having said that, you would need a solution for |
I thought, that with the data type, bit length, and bit offset defined in the TD, one could re-use the de/encoding method for the respective data type. Thus, shouldn't it be as generalizable as the To extend the example from above "properties": {
"measurements": {
// ...
"type": "object",
"properties": {
"flag1": {
"type": "boolean",
"offset": 0,
"bitLength": 1,
// ...
},
"flag2": {
"type": "boolean",
"offset": 1,
"bitLength": 1,
// ...
},
"temperature": {
"type": "number",
"offset": 2,
"bitLength": 14
"scale": 2, // number of digits to the right of the decimal point
// ...
},
"unit": {
"type": "string",
"offset": 16,
"bitLength": 24,
// ...
},
}
}
} Now sending Alternatively, if there are issues with supporting https://www.w3.org/TR/wot-thing-description11/#dfn-object that I did not see, maybe bit-offset and -length could be introduced anyway? With these parameters, I could model the above as separate properties. |
In general, I think the idea makes a lot of sense for resource-constrained environments! I am wondering, though, if there are any pre-existing standards or serialization formats to build upon? (Because I haven't found any so far that go in the same direction). Two more questions:
|
The Bluetooth standard defines a set of services describing the data sent from devices. Like for example the Heart Rate Service, where bit
Since this codec fails with fully opaque data (no type defined), and it already provides a set of parameters, like
I guess they should be |
* feat(core) add bit length and offset to octetstream-codec * fix: remove `console.log` * feat(core) add `object` support to octet-stream codec * fix: statisfy linter * fix: run prettier * fix: statisfy linter * fix: statisfy prettier and linter * chore: add more tests * fix re-vert moving contentType parameters to schema, sort properties before iterating over them * fix: statisfy linter * fix: remove console.debug * fix: use `getOwnPropertyNames` instead of `sort` * fix: simplify `writeBits` * fix: return correct Buffer in `valueToString`, fix: re-add contentType parameter `length`
@danielpeintner @derwehr do we consider this issue fixed by #1125 ? |
I do :) |
I'd like to propose supporting objects in octet streams, for example, for describing a device's payload data that sends packets with bit sequences containing measurements starting at different offsets.
i.e., a device sends 2 bytes, where bit 1 & 2 are different flags and bit 3-16 are a temperature measurement.
Similiar to this:
The text was updated successfully, but these errors were encountered: