mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
673a6bbe2c
commit
84a6a5235e
@ -28,6 +28,13 @@
|
|||||||
<option value="2">2</option>
|
<option value="2">2</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-datatype"><i class="fa fa-sign-out"></i> <span data-i18n="mqtt.label.output"></span></label>
|
||||||
|
<select id="node-input-datatype" style="width:70%;">
|
||||||
|
<option value="buffer" data-i18n="mqtt.output.buffer"></option>
|
||||||
|
<option value="utf8" data-i18n="mqtt.output.string"></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
||||||
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
||||||
@ -61,6 +68,7 @@
|
|||||||
name: {value:""},
|
name: {value:""},
|
||||||
topic: {value:"",required:true,validate: RED.validators.regex(/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/)},
|
topic: {value:"",required:true,validate: RED.validators.regex(/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/)},
|
||||||
qos: {value: "2"},
|
qos: {value: "2"},
|
||||||
|
datatype: {value:"utf8",required:true},
|
||||||
broker: {type:"mqtt-broker", required:true}
|
broker: {type:"mqtt-broker", required:true}
|
||||||
},
|
},
|
||||||
color:"#d8bfd8",
|
color:"#d8bfd8",
|
||||||
@ -77,6 +85,9 @@
|
|||||||
if (this.qos === undefined) {
|
if (this.qos === undefined) {
|
||||||
$("#node-input-qos").val("2");
|
$("#node-input-qos").val("2");
|
||||||
}
|
}
|
||||||
|
if (this.datatype === undefined) {
|
||||||
|
$("#node-input-datatype").val("utf8");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -392,13 +392,14 @@ module.exports = function(RED) {
|
|||||||
if (!/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/.test(this.topic)) {
|
if (!/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/.test(this.topic)) {
|
||||||
return this.warn(RED._("mqtt.errors.invalid-topic"));
|
return this.warn(RED._("mqtt.errors.invalid-topic"));
|
||||||
}
|
}
|
||||||
|
this.datatype = n.datatype || "utf8";
|
||||||
var node = this;
|
var node = this;
|
||||||
if (this.brokerConn) {
|
if (this.brokerConn) {
|
||||||
this.status({fill:"red",shape:"ring",text:"node-red:common.status.disconnected"});
|
this.status({fill:"red",shape:"ring",text:"node-red:common.status.disconnected"});
|
||||||
if (this.topic) {
|
if (this.topic) {
|
||||||
node.brokerConn.register(this);
|
node.brokerConn.register(this);
|
||||||
this.brokerConn.subscribe(this.topic,this.qos,function(topic,payload,packet) {
|
this.brokerConn.subscribe(this.topic,this.qos,function(topic,payload,packet) {
|
||||||
if (isUtf8(payload)) { payload = payload.toString(); }
|
if (this.datatype == "utf8" && isUtf8(payload)) { payload = payload.toString(); }
|
||||||
var msg = {topic:topic,payload:payload, qos: packet.qos, retain: packet.retain};
|
var msg = {topic:topic,payload:payload, qos: packet.qos, retain: packet.retain};
|
||||||
if ((node.brokerConn.broker === "localhost")||(node.brokerConn.broker === "127.0.0.1")) {
|
if ((node.brokerConn.broker === "localhost")||(node.brokerConn.broker === "127.0.0.1")) {
|
||||||
msg._topic = topic;
|
msg._topic = topic;
|
||||||
|
@ -324,6 +324,7 @@
|
|||||||
"label": {
|
"label": {
|
||||||
"broker": "Server",
|
"broker": "Server",
|
||||||
"example": "e.g. localhost",
|
"example": "e.g. localhost",
|
||||||
|
"output": "Output",
|
||||||
"qos": "QoS",
|
"qos": "QoS",
|
||||||
"retain": "Retain",
|
"retain": "Retain",
|
||||||
"clientid": "Client ID",
|
"clientid": "Client ID",
|
||||||
@ -358,6 +359,10 @@
|
|||||||
"connect-failed": "Connection failed to broker: __broker__"
|
"connect-failed": "Connection failed to broker: __broker__"
|
||||||
},
|
},
|
||||||
"retain": "Retain",
|
"retain": "Retain",
|
||||||
|
"output": {
|
||||||
|
"buffer": "a Buffer",
|
||||||
|
"string": "a String"
|
||||||
|
},
|
||||||
"true": "true",
|
"true": "true",
|
||||||
"false": "false",
|
"false": "false",
|
||||||
"tip": "Tip: Leave topic, qos or retain blank if you want to set them via msg properties.",
|
"tip": "Tip: Leave topic, qos or retain blank if you want to set them via msg properties.",
|
||||||
|
@ -324,6 +324,7 @@
|
|||||||
"label": {
|
"label": {
|
||||||
"broker": "サーバ",
|
"broker": "サーバ",
|
||||||
"example": "例) localhost",
|
"example": "例) localhost",
|
||||||
|
"output": "出力",
|
||||||
"qos": "QoS",
|
"qos": "QoS",
|
||||||
"retain": "保持",
|
"retain": "保持",
|
||||||
"clientid": "クライアント",
|
"clientid": "クライアント",
|
||||||
@ -358,6 +359,10 @@
|
|||||||
"connect-failed": "ブローカへの接続に失敗しました: __broker__"
|
"connect-failed": "ブローカへの接続に失敗しました: __broker__"
|
||||||
},
|
},
|
||||||
"retain": "保持",
|
"retain": "保持",
|
||||||
|
"output": {
|
||||||
|
"buffer": "バイナリバッファ",
|
||||||
|
"string": "文字列"
|
||||||
|
},
|
||||||
"true": "する",
|
"true": "する",
|
||||||
"false": "しない",
|
"false": "しない",
|
||||||
"tip": "注釈: トピックやQoSをメッセージのプロパティを用いて設定する場合は、無記入にしてください。",
|
"tip": "注釈: トピックやQoSをメッセージのプロパティを用いて設定する場合は、無記入にしてください。",
|
||||||
|
@ -314,6 +314,7 @@
|
|||||||
"label": {
|
"label": {
|
||||||
"broker": "服务端",
|
"broker": "服务端",
|
||||||
"example": "e.g. localhost",
|
"example": "e.g. localhost",
|
||||||
|
"output": "输出",
|
||||||
"qos": "QoS",
|
"qos": "QoS",
|
||||||
"clientid": "客户端ID",
|
"clientid": "客户端ID",
|
||||||
"port": "端口",
|
"port": "端口",
|
||||||
@ -342,6 +343,10 @@
|
|||||||
"connect-failed": "与服务端 __broker__ 的连接失败"
|
"connect-failed": "与服务端 __broker__ 的连接失败"
|
||||||
},
|
},
|
||||||
"retain": "保留",
|
"retain": "保留",
|
||||||
|
"output": {
|
||||||
|
"buffer": "Buffer",
|
||||||
|
"string": "字符串"
|
||||||
|
},
|
||||||
"true": "是",
|
"true": "是",
|
||||||
"false": "否",
|
"false": "否",
|
||||||
"tip": "提示: 若希望通过msg属性对topic(信息), qos及retain(保留)进行设置, 则将上述项留白",
|
"tip": "提示: 若希望通过msg属性对topic(信息), qos及retain(保留)进行设置, 则将上述项留白",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user