Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/binding-opcua/src/codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export const theOpcuaJSONCodec = new OpcuaJSONCodec();

export class OpcuaBinaryCodec implements ContentCodec {
getMediaType(): string {
return "application/opcua+octet-stream"; // see Ege
return "application/opcua+octet-stream";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a left-over I would like to remove

}

bytesToValue(bytes: Buffer, schema: DataSchema, parameters?: { [key: string]: string }): DataValueJSON {
Expand Down
8 changes: 8 additions & 0 deletions packages/binding-opcua/src/opcua-protocol-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,13 @@ export class OPCUAProtocolClient implements ProtocolClient {
return this._resolveNodeId2(form, fNodeId as NodeIdLike | NodeByBrowsePath);
}

// node-opcua handles the contentType internally and no further *external* processing should be done
private vanishContentType(form: OPCUAForm) {
if (!(form.contentType === "application/opcua+json" || form.contentType === "application/opcua+octet-stream")) {
form.contentType = undefined;
}
}

public async readResource(form: OPCUAForm): Promise<Content> {
debug(`readResource: reading ${form}`);

Expand All @@ -314,6 +321,7 @@ export class OPCUAProtocolClient implements ProtocolClient {
return this._dataValueToContent(form, dataValue);
});
debug(`readResource: contentType ${content.type}`);
this.vanishContentType(form);
return content;
}

Expand Down