1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #3562 from Steve-Mcl/mqttv5-userprops

MQTT Node - save and restore v5 config user props
This commit is contained in:
Stephen McLaughlin 2022-04-29 12:09:38 +01:00 committed by GitHub
commit 3a7a606f6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -480,6 +480,7 @@
willRetain: {value:false},
willPayload: {value:""},
willMsg: { value: {}},
userProps: { value: ""},
sessionExpiry: {value:0}
},
credentials: {
@ -609,6 +610,7 @@
default: !this.userProps ? 'none':'json',
types: [typedInputNoneOpt, 'json']
});
$("#node-config-input-userProps").typedInput('value',this.userProps);
if (typeof this.keepalive === 'undefined') {
this.keepalive = 15;
$("#node-config-input-keepalive").val(this.keepalive);
@ -718,6 +720,14 @@
}
if (v5) {
this.userProps = "";
const userPropsType = $("#node-config-input-userProps").typedInput("type");
if(userPropsType == "json") {
const userProps = $("#node-config-input-userProps").val();
if (userProps && typeof userProps === "string") {
this.userProps = userProps.trim();
}
}
this.birthMsg = saveV5Message("birth");
this.closeMsg = saveV5Message("close");
this.willMsg = saveV5Message("will");

View File

@ -415,8 +415,12 @@ module.exports = function(RED) {
setIfHasProperty(opts, node, "topicAliasMaximum", init);
setIfHasProperty(opts, node, "maximumPacketSize", init);
setIfHasProperty(opts, node, "receiveMaximum", init);
setIfHasProperty(opts, node, "userProperties", init);//https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116
setIfHasProperty(opts, node, "userPropertiesType", init);
//https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901116
if (hasProperty(opts, "userProperties")) {
node.userProperties = opts.userProperties;
} else if (hasProperty(opts, "userProps")) {
node.userProperties = opts.userProps;
}
function createLWT(topic, payload, qos, retain, v5opts, v5SubPropName) {
let message = undefined;