chore(binding-opcua) fix application/octet-stream encoding/decoding #…#1449
chore(binding-opcua) fix application/octet-stream encoding/decoding #…#1449erossignon wants to merge 1 commit intoeclipse-thingweb:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1449 +/- ##
==========================================
- Coverage 77.58% 77.41% -0.17%
==========================================
Files 79 84 +5
Lines 15331 15989 +658
Branches 1445 1519 +74
==========================================
+ Hits 11894 12378 +484
- Misses 3414 3585 +171
- Partials 23 26 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| const variantInJson = opcuaJsonEncodeVariant(dataValue.value, false); | ||
| const content = contentSerDes.valueToContent(variantInJson, schemaDataValue, contentType); | ||
| return content; | ||
| } else if (contentType === "application/octet-stream") { |
There was a problem hiding this comment.
I think the general problem with the current code is that it right away decodes the data on the wire. It should first get the data raw and afterwards the ContentSerdes decodes the data.
There was a problem hiding this comment.
Take a look at CoAP for example where the readResource call returns the raw data
node-wot/packages/binding-coap/src/coap-client.ts
Lines 59 to 75 in 8dc6ed8
Afterwards the configured ContentSerdes deals with the actual content and whether the "byte stream" is JSON, CBOR or anything else..
The same should happen with OPC UA....
There was a problem hiding this comment.
the current code is that it right away decodes the data
In fact this code is where the encoding takes palce;( not decoding)
|
I tried to test the PR with a simple example and I think it does not work as expected. Maybe I am just not understanding it properly. As mentioned in #1400 OPC-UA seems to work fine until I add Note: FYI, not adding any contentType at all would mean JSON which is not the case for OPC UA I believe. If I add Also, it seems that the according code hasn't changed in that regard. Try to add |
Could you provide an example of things that reproduce what you're doing. That would be easier to grasp . My understanding should be clearly available in the new unit test added. May be I missed your specific case. |
…1400