-
Notifications
You must be signed in to change notification settings - Fork 88
chore(binding-opcua) fix application/octet-stream encoding/decoding #… #1449
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
Open
erossignon
wants to merge
1
commit into
eclipse-thingweb:master
Choose a base branch
from
node-opcua:feat/1400
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /******************************************************************************** | ||
| * Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
| * | ||
| * See the NOTICE file(s) distributed with this work for additional | ||
| * information regarding copyright ownership. | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Eclipse Public License v. 2.0 which is available at | ||
| * http://www.eclipse.org/legal/epl-2.0, or the W3C Software Notice and | ||
| * Document License (2015-05-13) which is available at | ||
| * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document. | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 OR W3C-20150513 | ||
| ********************************************************************************/ | ||
|
|
||
| import { DataSchema } from "wot-typescript-definitions"; | ||
|
|
||
| export const variantDataSchema: DataSchema = { | ||
| description: "A JSON structure representing a OPCUA Variant encoded in JSON format using 1.04 specification", | ||
| type: "object", | ||
| properties: { | ||
| Type: { | ||
| type: "number", | ||
| enum: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], | ||
| description: "The OPCUA DataType of the Variant, must be 'number'", | ||
| }, | ||
| Body: { | ||
| description: "The body can be any JSON value", | ||
| // "type": ["string", "number", "object", "array", "boolean", "null"] | ||
| }, | ||
| }, | ||
| required: ["Type", "Body"], | ||
| additionalProperties: false, | ||
| }; | ||
|
|
||
| export const opcuaVariableSchemaType: Record<string, DataSchema> = { | ||
| number: { | ||
| type: "number", | ||
| description: "A simple number", | ||
| }, | ||
| dataValue: { | ||
| description: "A JSON structure representing a OPCUA DataValue encoded in JSON format using 1.04 specification", | ||
| type: "object", | ||
| properties: { | ||
| SourceTimestamp: { | ||
| // type: "date", | ||
| description: "The sourceTimestamp of the DataValue", | ||
| }, | ||
| Value: variantDataSchema, | ||
| }, | ||
| required: ["Value"], | ||
| additionalProperties: false, | ||
| }, | ||
| variant: variantDataSchema, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
rawand afterwards the ContentSerdes decodes the data.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.