node-red/packages/node_modules/@node-red/nodes/locales/zh-CN/network/10-mqtt.html

72 lines
4.4 KiB
HTML
Raw Normal View History

<!--
Copyright JS Foundation and other contributors, http://js.foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script type="text/x-red" data-help-name="mqtt in">
<p>连接到MQTT代理并订阅来自指定主题的消息。</p>
<h3>输出</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">字符串 | buffer</span></dt>
<dd>如果不是二进制buffer的话就是字符串</dd>
<dt>topic <span class="property-type">字符串</span></dt>
<dd>MQTT主题使用<code>/</code>作为层次结构分隔符。</dd>
<dt>qos <span class="property-type">数值</span> </dt>
<dd>QoS服务质量0, 最多一次; 1, 最少一次; 2, 只一次。</dd>
<dt>retain <span class="property-type">布尔值</span></dt>
<dd>值为true时表示消息已保留且可能是旧的。</dd>
</dl>
<h3>详细</h3>
<p>订阅主题可以包括MQTT通配符+:一个级别,#:多个级别)。</p>
<p>使用该节点您首先需要建立与MQTT代理的连接。通过单击铅笔图标来进行配置。</p>
<p>如有需要几个MQTT节点输入或输出可以共享相同的代理连接。</p>
</script>
<script type="text/x-red" data-help-name="mqtt out">
<p>连接到MQTT代理并发布消息。</p>
<h3>输入</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">字符串 | buffer</span></dt>
<dd>要发布的有效负载。如果未设置此属性,则不会发送任何消息。要发送空白消息,请将此属性设置为空字符串。</dd>
<dt class="optional">topic <span class="property-type">字符串</span></dt>
<dd>要发布的MQTT主题。</dd>
<dt class="optional">qos <span class="property-type">number</span></dt>
<dd>QoS服务质量0, 最多一次; 1, 最少一次; 2, 只一次。默认值为0。</dd>
<dt class="optional">retain <span class="property-type">布尔值</span></dt>
<dd>设置为<code>true</code>来将消息保留在代理上。默认值为<code>false</code></dd>
</dl>
<h3>详细</h3>
<p><code>msg.payload</code>用作已发布消息的有效载荷。如果包含Object则会在发送之前将其转换为JSON字符串。如果它包含二进制buffer则消息将按原样发布。</p>
<p>可以在节点中配置所使用的主题,或者如果留为空白,则可以通过<code>msg.topic</code>进行设置。</p>
<p>同样可以在节点中配置QoS和保留值或者如果保留空白则分别由<code>msg.qos</code><code>msg.retain</code>设置。要清除先前存储在代理中的主题,请设置保留标志并向该主题发布空消息。</p>
<p>该节点需要与要配置的MQTT代理的连接。通过单击铅笔图标进行配置。</p>
<p>如果需要几个MQTT节点输入或输出可以共享相同的代理连接。</p>
</script>
<script type="text/x-red" data-help-name="mqtt-broker">
<p>与MQTT代理的连接设置。</p>
<p>创建与代理的连接设置。可以在<code>MQTT In</code><code>MQTT Out</code>节点中重复利用这些设置。</p>
<p>如果未为该节点设置客户端ID并且设置了会话初始化则将生成一个随机客户端ID。设置客户端ID时请确保它对于连接目标处的代理是唯一的。</p>
<h4>Birth Message</h4>
<p>建立连接后发布在以配置主题中的消息。</p>
<h4>Close Message</h4>
<p>在连接正常结束之前重新部署或者关闭了节点时,发布在以配置主题中的消息。</p>
<h4>Will Message</h4>
<p>当节点意外丢失连接时由代理发布的消息</p>
<h4>WebSockets</h4>
<p>可以将节点配置成使用WebSocket连接。使用WebSocket时请在服务器字段中以完整格式描述连接目标的URI。 例如:</p>
<pre>ws://example.com:4000/mqtt</pre>
</script>