Commit 0192a616 authored by wubi's avatar wubi

init

parents
Pipeline #172 failed with stages

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

<script type="text/javascript">
"use strict";
(() => {
// src/nodes/ai-reasoning/utils/index.ts
function isCustomProgram(value) {
return value === "custom" /* Custom */;
}
// src/nodes/ai-reasoning/client/index.ts
RED.nodes.registerType("ai-reasoning", {
category: "AIoTedge" /* AIoTedge */,
color: "darksalmon",
defaults: {
name: {
value: ""
},
program: {
value: "system" /* System */,
required: true
},
programPath: {
value: ""
},
identificationSource: {
value: "Rtsp" /* Rtsp */,
required: true
},
identifyObject: {
value: "none" /* Unlimited */,
required: true
},
identificationSourcePath: {
value: "",
required: true
}
},
inputs: 1,
outputs: 3,
outputLabels: function(i) {
return [
this._("stdout"),
this._("stderr"),
this._("retcode")
][i];
},
icon: "cog.png",
paletteLabel: function() {
return this._("nodeName");
},
label() {
return this.name || this._("nodeName");
},
oneditprepare() {
const node = this;
setup();
console.log(this);
function setup() {
addEventlistenner();
}
function addEventlistenner() {
$("#node-input-program").on("change", (event) => {
const value = event.target.value;
if (isCustomProgram(value)) {
$("#node-input-programPath-item").show().val(node.programPath || "");
} else {
$("#node-input-programPath-item").hide().val("");
}
});
}
}
});
})();
</script>
<script type="text/html" data-template-name="ai-reasoning">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]name" />
</div>
<div class="form-row">
<label for="node-input-program"><i class="fa fa-file"></i> <span data-i18n="program"></span></label>
<select type="text" id="node-input-program" data-i18n="[placeholder]program" style="width: 70%;">
<option value="system" data-i18n="program.system"></option>
<option value="custom" data-i18n="program.custom"></option>
</select>
</div>
<div class="form-row" id="node-input-programPath-item" style="display: none;">
<label for="node-input-programPath"><i class="fa fa-bookmark-o"></i> <span data-i18n="program.path"></span></label>
<input type="text" id="node-input-programPath" data-i18n="[placeholder]program.path" />
</div>
<div class="form-row">
<label for="node-input-identificationSource"><i class="fa fa-windows"></i> <span data-i18n="identificationSource"></span></label>
<select type="text" id="node-input-identificationSource" data-i18n="[placeholder]identificationSource" style="width: 70%;">
<option value="Rtsp" data-i18n="identificationSource.rtsp"></option>
<option value="Image" data-i18n="identificationSource.image"></option>
</select>
</div>
<div class="form-row" id="node-input-identificationSourcePath-item">
<label for="node-input-identificationSourcePath"><i class="fa fa-bookmark-o"></i> <span data-i18n="identificationSource.path"></span></label>
<input type="text" id="node-input-identificationSourcePath" data-i18n="[placeholder]identificationSource.path" />
</div>
<div class="form-row">
<label for="node-input-identifyObject"><i class="fa fa-sign-out"></i> <span data-i18n="identifyObject"></span></label>
<select type="text" id="node-input-identifyObject" data-i18n="[placeholder]identifyObject" style="width: 70%;">
<option value="none" data-i18n="identifyObject.unlimited"></option>
<option value="person" data-i18n="identifyObject.person"></option>
<option value="car" data-i18n="identifyObject.car"></option>
<option value="sheep" data-i18n="identifyObject.sheep"></option>
<option value="cow" data-i18n="identifyObject.cow"></option>
</select>
</div>
</script>
This diff is collapsed.
<script type="text/x-red" data-help-name="ai-reasoning">
<p>Runs a system command and returns its output.</p>
<p>The node can be configured to either wait until the command completes, or to
send its output as the command generates it.</p>
<p>The command that is run can be configured in the node or provided by the received
message.</p>
</script>
{
"nodeName": "AI Reasoning",
"name": "Name",
"program": "Reasoning program",
"program.system": "System Default Inference Program (yoloV5)",
"program.custom": "Custom Python inference program",
"program.path": "Reasoning program",
"identificationSource": "Identification source",
"identificationSource.path": "Identification source path",
"identificationSource.rtsp": "Camera RTSP path",
"identificationSource.image": "Image png/jpeg path",
"identifyObject": "Identify object",
"identifyObject.unlimited": "No limit",
"identifyObject.person": "Person",
"identifyObject.car": "Car",
"identifyObject.sheep": "Sheep",
"identifyObject.cow": "Cow",
"stdout": "Standard output",
"stderr": "Standard error output",
"retcode": "Return code"
}
<script type="text/x-red" data-help-name="ai-reasoning">
<p>运行系统命令并返回其输出。</p>
<p>可以将节点配置为等待命令完成,或者在命令生成时发送其输出。</p>
<p>运行的命令可以在节点中配置,也可以由收到的消息提供。</p>
</script>
{
"nodeName": "AI推理",
"name": "名称",
"program": "推理程序",
"program.system": "系统默认推理程序(yoloV5)",
"program.custom": "自定义Python推理程序",
"program.path": "推理程序",
"identificationSource": "识别源",
"identificationSource.path": "识别源路径",
"identificationSource.rtsp": "摄像头RTSP路径",
"identificationSource.image": "图片png/jpeg路径",
"identifyObject": "识别物",
"identifyObject.unlimited": "无限制",
"identifyObject.person": "人",
"identifyObject.car": "车",
"identifyObject.sheep": "羊",
"identifyObject.cow": "牛",
"stdout": "标准输出",
"stderr": "标准错误输出",
"retcode": "返回码"
}
{
"name": "node-red-thingskit-ai-reasoning",
"version": "1.0.0",
"description": "",
"keywords": [],
"author": "",
"license": "ISC",
"node-red": {
"nodes": {
"ai-reasoning": "ai-reasoning.js"
}
}
}
\ No newline at end of file
<script type="text/javascript">
"use strict";
(() => {
// src/nodes/interval-multiples-timer/client/index.ts
RED.nodes.registerType("interval-multiples-timer", {
category: "common",
color: "#a6bbcf",
defaults: {
interval: { value: 5e3 },
payload: { value: "" },
topic: { value: "" },
name: { value: "" }
},
inputs: 0,
outputs: 1,
icon: "timer.png",
label: function() {
return this.name || "interval-multiples-timer";
}
});
})();
</script>
<script type="text/html" data-template-name="interval-multiples-timer">
<div class="form-row">
<label for="node-input-interval"><i class="fa fa-clock-o"></i> Interval [ms]</label>
<input type="number" id="node-input-interval">
</div>
<div class="form-row">
<label for="node-input-payload"><i class="fa fa-envelope"></i> Payload</label>
<input type="text" id="node-input-payload" placeholder="default = current timestamp">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/nodes/interval-multiples-timer/runtime/index.ts
var nodeInit = (RED) => {
function IntervalMultiplesTimerNodeConstructor(config) {
RED.nodes.createNode(this, config);
RED.nodes.createNode(this, config);
const node = this;
const interval = config.interval || 0;
let timer;
const timeHandler = function() {
const msg = {};
msg.topic = config.topic;
msg.payload = config.payload || Date.now();
node.send(msg);
timer = setTimeout(timeHandler, interval - Date.now() % interval);
};
timer = setTimeout(timeHandler, interval - Date.now() % interval);
node.on("close", function() {
clearTimeout(timer);
});
}
RED.nodes.registerType("interval-multiples-timer", IntervalMultiplesTimerNodeConstructor);
};
var runtime_default = nodeInit;
exports.default = runtime_default;
<script type="text/x-red" data-help-name="interval-multiples-timer">
<p>Node description goes here.</p>
</script>
\ No newline at end of file
<script type="text/x-red" data-help-name="interval-multiples-timer">
<p>Node description goes here.</p>
</script>
\ No newline at end of file
{
"name": "node-red-thingskit-interval-multiples-timer",
"version": "1.0.0",
"description": "",
"keywords": [],
"author": "",
"license": "ISC",
"node-red": {
"nodes": {
"interval-multiples-timer": "interval-multiples-timer.js"
}
}
}
\ No newline at end of file
<script type="text/html" data-help-name="mqtt-out">
<p>This node is primarily for reporting collected data to the specified device on the platform. When using it, simply select the corresponding product, organization, and the device you need to report to; then report according to the device model.</p>
<p>If the key of the collected data does not match the key defined in the device model, you can use the device model list in this node for association. Click the Add button below, and then select the corresponding device model.</p>
<p>For example, if the collected data is temperature, and the key you defined earlier is wendu, you would click Add in the device model list, enter wendu in the key field, and select temperature in the device model.</p>
<ul>
<li>Node Name: If not filled in, it will default to Data Reporting. If you want to customize it, enter your Node Name in the text box.</li>
<li>Product: Select the product corresponding to the device you want to report to.</li>
<li>Organization: Select the organization corresponding to the device you want to report to.</li>
<li>Device: Select the device you want to report to.</li>
</ul>
<p>Note: If the product identifier corresponds one-to-one with the event reporting fields, there is no need to configure the device model list.</p>
<p>There are mainly two data formats for reporting:</p>
<p>For "direct connection devices/gateway devices," the reporting format is:</p>
<pre><code>
{
"key1":"value1",
"key2":"value2"
}
</code></pre>
<p>For "gateway sub-devices," the reporting format is:</p>
<pre><code>
{
"Device_A_Sub":
[
{
"temperature": 42,
"humidity": 80
}
]
}
</code></pre>
</script>
<script type="text/html" data-help-name="mqtt-in">
<p>The command delivery node is designed to receive all command delivery content from the platform for a specified device. With this node, you can quickly select the corresponding device and directly receive commands sent to that device.</p>
<p>Note: After receiving the command, you can freely process it through a function node to complete the next logical operation. It should be noted that for <b>direct connection devices</b>, the command is as follows:</p>
<pre><code>
{
"key1":"value1"
}
</code></pre>
<p>While for <b>gateway sub-devices</b>, the delivered command is:</p>
<pre><code>
{
"key1":"value1",
"deviceName":"<b>some gateway sub-device</b>"
}
</code></pre>
<p>Compared to direct connection devices, the system automatically includes the sub-device name <b>deviceName</b>.</p>
</script>
<script type="text/html" data-help-name="mqtt-event">
<p>The event reporting node is mainly for users who need to report event information from the collected devices to the platform. The event reporting node can quickly help users configure data for reporting.</p>
<p>Usage:</p>
<p><b>First</b>, you need to add an event model for the product of the reporting device. Note: On the 【Product Details】 page, click on the 【Device Model】 tab, then click 【Edit Device Model】, and the 【Create】 button will appear; then click <b>Create Event Model</b>. Click the Create button, switch to the <b>Event</b> tab, enter the function name of the event (e.g., device alarm event/AI recognition event/device failure event), fill in the <b>identifier</b>, and choose the required 【event type】.</p>
<p><b>Second</b>, fill in the <b>output parameters</b>. These output parameters are the parameters that our devices are ready to report to the platform (similarly, fill in the function name, identifier, data type, etc.); at this point, the defined <b>identifier</b> corresponds one-to-one with the <b>event reporting fields</b>.</p>
<p>Note: If the product identifier corresponds one-to-one with the event reporting fields, there is no need to configure the device model list.</p>
<p>Reporting format:</p>
<pre><code>
{
"key1":"value1",
"key2":"value2"
}
</code></pre>
</script>
{
"in": {
"name": "Command Issuance"
},
"out": {
"name": "Data Reporting"
},
"event": {
"name": "Event Reporting"
},
"button": {
"plus": "Plus",
"removeAll": "Remove all",
"import": "Import",
"export": "Export"
},
"control": {
"name": "Name",
"product": "Product",
"organization": "Organization",
"device": "Device",
"owningGateway": "Owning gateway",
"event": "Event"
},
"text": {
"thingsModel": {
"name": "Things model list",
"key": "Key",
"value": "Things model"
},
"outputParams": "Output params list",
"paramsName": "Params name"
},
"placeholder": {
"input": "Place input",
"select": "Place select"
}
}
<script type="text/html" data-help-name="mqtt-out">
<p>主要是针对采集到的数据,进行上报到平台指定的设备中,在使用时,只需要选择对应的产品,组织以及您所需要上报的设备;然后根据物模型上报。</p>
<p>如果采集到的数据key与物模型定义的Key不一致,此时则可以利用该节点中的物模型列表进行关联;单击下面的【添加】按钮,然后选择你对应的物模型。</p>
<p>PS:比如,采集到的数据【温度,如果您前面定义的keywendu】,此时在物模型列表中,单击【添加】一行,键中填写wendu,而物模型中选择【温度】。</p>
<ul>
<li>节点名称:如果不填写则是【数据上报】,如果需要自定义,则文本框中输入你的【节点名称】</li>
<li>产品:选择你所需要上报的设备对应的产品</li>
<li>组织:选择你所需要上报的设备对应的组织</li>
<li>设备:选择你所需要上报的设备</li>
</ul>
<p>PS:如果【产品的标识符】与【事件上报字段】一一对应;则不用配置物模型列表。</p>
<p>针对数据上报,主要有两种数据格式上报:</p>
<p>对于"直连设备/网关设备"上报格式为:</p>
<pre><code>
{
"key1":"value1",
"key2":"value2"
}
</code></pre>
<p>对于"网关子设备"上报格式为:</p>
<pre><code>
{
"Device_A_Sub":
[
{
"temperature": 42,
"humidity": 80
}
]
}
</code></pre>
</script>
<script type="text/html" data-help-name="mqtt-in">
<p>命令下发节点,其目的就是接收某台设备,从平台处的所有命令下发内容;通过该节点,可以很快速的选择对应的设备,直接接收该设备下发的命令。</p>
<p>PS:接收到命令之后,可通过【function】节点,进行自由处理,完成下一步的逻辑操作。这些需要提醒的是,对于<b>【直连设备】</b>,下面的命令则是</p>
<pre><code>
{
"key1":"value1"
}
</code></pre>
<p><b>【网关子设备】</b>下发命令为</p>
<pre><code>
{
"key1":"value1",
"deviceName":"<b>某网关子设备</b>"
}
</code></pre>
<p>相比直连设备,系统会自动带子设备的名称<b>deviceName</b>。</p>
</script>
<script type="text/html" data-help-name="mqtt-event">
<p>事件上报节点,其主要目的,方便用户,需要对采集设备的事件信息进行上报到平台时,此时的事件上报节点能快速的帮助用户配置数据进行上报。</p>
<p>使用方法:</p>
<p><b>首先</b>,你需要对你上报设备的产品,进行事件模型添加。
PS:在【产品详情】页中,单击【物模型】页签,单击【编辑物模型】,此时会显示【创建】按钮;接着就是<b>创建事件模型</b>;单击【创建】按钮,在弹出框中,切换<b>【事件】标签</b>,输入事件的功能名称,如果设备告警事件/AI识别事件/设备故障事件等,<b>填写标识符</b>,然后选择你需要的【事件类型】。</p>
<p><b>其次</b>,就是<b>填写输出参数</b>,这个输出参数就是,咱们设备准备上报到平台时定义的参数(同样是填写功能名称、标识符、数据类型等);此时定义的【标识符】与【事件上报字段】一一对应。</p>
<p>PS:如果【产品的标识符】与【事件上报字段】一一对应;则不用配置物模型列表。</p>
<p>上报格式:</p>
<pre><code>
{
"key1":"value1",
"key2":"value2"
}
</code></pre>
</script>
{
"in": {
"name": "命令下发"
},
"out": {
"name": "数据上报"
},
"event": {
"name": "事件上报"
},
"button": {
"plus": "添加",
"removeAll": "移除所有",
"import": "导入",
"export": "导出"
},
"control": {
"name": "节点名称",
"product": "产品",
"organization": "组织",
"device": "设备",
"owningGateway": "所属网关",
"event": "事件"
},
"text": {
"thingsModel": {
"name": "物模型列表",
"key": "键",
"value": "物模型"
},
"outputParams": "输出参数列表",
"paramsName": "参数名"
},
"placeholder": {
"input": "请输入",
"select": "请选择"
}
}
This diff is collapsed.
This diff is collapsed.
{
"name": "node-red-thingskit-mqtt",
"version": "1.0.0",
"description": "",
"keywords": [],
"author": "",
"license": "ISC",
"node-red": {
"nodes": {
"mqtt": "mqtt.js"
}
}
}
\ No newline at end of file
name: Node.js CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
node-red: [2.x, 3.x, 4.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm install -g node-red@${{ matrix.node-red }}
- run: npm link node-red
- run: npm install -g mocha
- run: npm install -g semistandard
- run: npm install -g snazzy
- run: npm run build --if-present
- run: npm test
env:
CI: true
# node-red-contrib-aedes Changelog
## Jul 29, 2024, Version 0.13.2
### Notable changes
- New tests with NodeJS 22
## Jun 21, 2024, Version 0.13.1
### Notable changes
- Update aedes to version 0.51.2
## Feb 16, 2024, Version 0.13.0
### Notable changes
- Update aedes to version 0.51.0
## Dec 23, 2023, Version 0.12.0
### Notable changes
- Update aedes to version 0.50.1
## Mar 13, 2023, Version 0.11.1
### Notable changes
- LevelDB removed, crashes on certain systems
## Mar 13, 2023, Version 0.11.0
### Notable changes
- Add LevelDB persistence
## Mar 03, 2023, Version 0.10.0
### Notable changes
- Update aedes to version 0.49.0
## Dec 27, 2022, Version 0.9.1
### Notable changes
- Update aedes to version 0.48.1
- Update aedes-persistence-mongodb to version 9.1.1
## Oct 23, 2022, Version 0.9
### Notable changes
- Update aedes to version 0.48
- Update node-red-node-test-helper to version 0.3.0
## Jun 03, 2022, Version 0.8.2
### Notable changes
- Fix Scorecard Warnings
## May 29, 2022, Version 0.8.1
### Notable changes
- Fix issue with incomplete credentials
## May 22, 2022, Version 0.8
### Notable changes
- Update aedes to version 0.47
## Feb 18, 2022, Version 0.7
### Notable changes
- Fix Close Time Out Issue
## Oct 17, 2021, Version 0.6
### Notable changes
- Add output node for publish events
## Apr 23, 2021, Version 0.5.2
### Notable changes
- Update aedes to version 0.46
## Mar 08, 2021, Version 0.5.1
### Notable changes
- Update aedes to version 0.45
## Feb 25, 2021, Version 0.5.0
### Notable changes
- Add mqtt over websocket path (Thanks Ori Novanda)
## Feb, 21, 2021, Version 0.4.2
### Notable changes
- Update aedes to version 0.44.2
- Dependency badge from David-DM added again
## Dec, 22, 2020, Version 0.4.1
### Notable changes
- Dependency badge from David-DM removed
- Dependabot added
## Oct, 29, 2020, Version 0.4.0
### Notable changes
- Update Aedes to version 0.44
## Oct, 13, 2020, Version 0.3.7
### Notable changes
- Update Aedes to version 0.43
## May, 16, 2020, Version 0.3.6
### Notable changes
- Update Aedes to version 0.42
## April, 07, 2020, Version 0.3.5
### Notable changes
- Update Aedes to version 0.41
## March 26, 2020, Version 0.3.4
### Fixes
- Certificate loading (Reported in issue #17)
## March 26, 2020, Version 0.3.3
### Fixes
- Typing error on aedes.html (Reported in issue #17)
## March 22, 2020, Version 0.3.2
### Notable changes
- Update aedes-persistence-mongodb to version 8
## March 10, 2020, Version 0.3.1
### Notable changes
- Add secure WSS connection
## Feb 25, 2020, Version 0.3.0
### Notable changes
- Add secure SSL / TLS connection
### Fixes
- Reformat code to [semistandard](https://github.com/standard/semistandard)
- Prepare internationaization (only en-US implemented so far)
- Rearrange property windows to allow more features
## Feb 20, 2020, Version 0.2.0
### Notable changes
- Add status to node
### Fixes
- Move username and password to credentials
## Feb 17, 2020, Version 0.1.1
### Fixes
- Fix another "port already in use" error
## Feb 16, 2020, Version 0.1.0
### Notable changes
- Add authentication
- Add mqtt over websocket
### Fixes
- Fix "port already in use" errors
### Commits
- [[`Version 0.1.0`](https://github.com/martin-doyle/node-red-contrib-aedes/commit/9a0f2390674de155c5f48de4ad2415448417d1b9)] - Version 0.1.0
- [[`Add mqtt over websocket`](https://github.com/martin-doyle/node-red-contrib-aedes/commit/9a0f2390674de155c5f48de4ad2415448417d1b9)] - Add mqtt over websocket
- [[`Add authentication`](https://github.com/martin-doyle/node-red-contrib-aedes/commit/0005fc587cd8082b2055162b056055314ac694bc)] - Add authentication
## Feb 15, 2020, Initial commit
### Notable changes
- Initial commit
### Commits
- [[`Initial commit`](https://github.com/martin-doyle/node-red-contrib-aedes/commit/3b10df634bba92665d486ef83933eafc8d57f9dc)] - Initial commit
MIT License
Copyright (c) 2020 martin-doyle
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# node-red-contrib-aedes
MQTT Broker for Node-RED based on [Aedes](https://github.com/moscajs/aedes).
You can use the MQTT protocol in Node-RED without an external MQTT broker like Mosquitto.
![Node.js CI](https://github.com/martin-doyle/node-red-contrib-aedes/workflows/Node.js%20CI/badge.svg)
[![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat-square)](https://github.com/standard/semistandard)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/898bf62b040a4d999b150487e9cc837b)](https://www.codacy.com/manual/martin-doyle/node-red-contrib-aedes?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=martin-doyle/node-red-contrib-aedes&amp;utm_campaign=Badge_Grade)
<!--
[![Dependency Status](https://david-dm.org/martin-doyle/node-red-contrib-aedes.svg)](https://david-dm.org/martin-doyle/node-red-contrib-aedes)
[![devDependency Status](https://david-dm.org/martin-doyle/node-red-contrib-aedes/dev-status.svg)](https://david-dm.org/martin-doyle/node-red-contrib-aedes#info=devDependencies)
-->
[![Open Source Love](https://badges.frapsoft.com/os/mit/mit.svg?v=102)](https://github.com/ellerbrock/open-source-badge/)
[![NPM version](https://img.shields.io/npm/v/node-red-contrib-aedes.svg?style=flat)](https://www.npmjs.com/node-red-contrib-aedes)
## Background
This node was created because the original MQTT broker [node-red-contrib-mqtt-broker](https://github.com/zuhito/node-red-contrib-mqtt-broker) uses [mosca](https://github.com/moscajs/mosca) which is no longer maintained.
## Installation
You can install the node directly within the editor by using the [Palette Manager](https://nodered.org/docs/user-guide/editor/palette/manager).
To install the node from the command-line, you can use the following command from within your user data directory (by default, ```$HOME/.node-red```):
```sh
npm install node-red-contrib-aedes
```
## Flows
Just put this node on Node-RED and hit the deploy button. The MQTT Broker will run on your Node-RED instance.
![flows](./flows.png)
## Features
- Standard TCP Support
- WebSocket Support via port or path
- SSL / TLS
- Message Persistence (In-memory, LevelDB or MongoDB)
For more information see [Aedes](https://github.com/moscajs/aedes/blob/master/README.md#features).
## Server without public IP or behind firewall
If your server is behind a firewall or you cannot open any ports other than the standard http/https ports, the MQTT broker node can be accessible by public clients through a WebSocket path.
When your Node-RED server address is `https://yourserver/`, you can set the WebSocket to bind to, e.g., `"/ws/mqtt"` path, to have `wss://yourserver/ws/mqtt` WebSocket at port `443`.
You can also bind the WebSocket to the root `"/"` path and having `wss://yourserver/` WebSocket listening at port `443` (or `ws://yourserver/` at port `80`).
## License
Licensed under [MIT](./LICENSE).
This diff is collapsed.
This diff is collapsed.
[{"id":"2968a4fcf75e9496","type":"tab","label":"Aedes","disabled":false,"info":"","env":[]},{"id":"71f56412e0a1bd0b","type":"debug","z":"2968a4fcf75e9496","name":"Aedes Events","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":480,"y":300,"wires":[]},{"id":"94a8707a2c4a4308","type":"aedes broker","z":"2968a4fcf75e9496","name":"Aedes MQTT Broker","mqtt_port":"1884","mqtt_ws_bind":"port","mqtt_ws_port":"","mqtt_ws_path":"","cert":"","key":"","certname":"","keyname":"","dburl":"","usetls":false,"x":270,"y":320,"wires":[["71f56412e0a1bd0b"],["30bcabc71382bd19"]]},{"id":"30bcabc71382bd19","type":"debug","z":"2968a4fcf75e9496","name":"Aedes Publish Events","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":500,"y":340,"wires":[]},{"id":"a92eb1e50a7e0fb2","type":"inject","z":"2968a4fcf75e9496","name":"MQTT Message","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test","payload":"Test","payloadType":"str","x":280,"y":180,"wires":[["4195ccca2060a2c5"]]},{"id":"4195ccca2060a2c5","type":"mqtt out","z":"2968a4fcf75e9496","name":"MQTT Publisher","topic":"test","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"47a469b15c9c5f27","x":480,"y":180,"wires":[]},{"id":"5ce36754784a00e0","type":"mqtt in","z":"2968a4fcf75e9496","name":"MQTT Subscriber","topic":"test","qos":"0","datatype":"auto","broker":"47a469b15c9c5f27","nl":false,"rap":true,"rh":0,"inputs":0,"x":280,"y":240,"wires":[["ed51b3734a88ef79"]]},{"id":"ed51b3734a88ef79","type":"debug","z":"2968a4fcf75e9496","name":"MQTT Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":480,"y":240,"wires":[]},{"id":"47a469b15c9c5f27","type":"mqtt-broker","name":"","broker":"localhost","port":"1884","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
\ No newline at end of file
<script type="text/x-red" data-help-name="aedes broker">
<p>MQTT broker based on Barebone MQTT broker Aedes. You can use MQTT-in and MQTT-out nodes without an external broker like Mosquitto.</p>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>topic <span class="property-type">string</span></dt>
<dd>the topic of the event.</dd>
<dt>payload 1<span class="property-type">object</span></dt>
<dd>the content of all events from the broker except publish.</dd>
<dt>payload 2<span class="property-type">object</span></dt>
<dd>the content of the publish events from the broker.</dd>
</dl>
<h3>Details</h3>
<h3>References</h3>
<ul>
<li><a href="https://github.com/moscajs/aedes">Aedes</a> - Barebone MQTT broker that can run on any stream server, the node way</li>
</ul>
</script>
{
"aedes-mqtt-broker": {
"status": {
"connected": "connected __count__",
"connected_plural": "connected __count__"
},
"label": {
"mqtt_port": "MQTT port",
"mqtt_ws_port": "WS port",
"mqtt_ws_path": "WS path",
"use-tls": "Enable secure (SSL/TLS) connection",
"tls-config": "TLS Configuration",
"upload": "Upload",
"cert": "Certificate",
"key": "Private Key",
"persistence_bind": "Persistence",
"persistence_memory": "Memory",
"persistence_mongodb": "MongoDB",
"persistence_level": "LevelDB",
"dburl": "DB Url"
},
"placeholder": {
"mqtt_port": "Enter MQTT port",
"mqtt_ws_port": "Enter Websocket port. Leave blank to disable Websocket support",
"mqtt_ws_path": "Enter Websocket path. Leave blank to disable Websocket support",
"cert": "path to certificate (PEM format)",
"key": "path to private key (PEM format)",
"dburl": "mongodb://localhost:27017/mqtt",
"username": "leave blank to disable authentication",
"password": "leave blank to disable authentication"
},
"tabs-label": {
"connection": "Connection",
"security": "Security"
}
}
}
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../fast-xml-parser/src/cli/cli.js" "$@"
else
exec node "$basedir/../fast-xml-parser/src/cli/cli.js" "$@"
fi
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\fast-xml-parser\src\cli\cli.js" %*
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../fast-xml-parser/src/cli/cli.js" $args
} else {
& "$basedir/node$exe" "$basedir/../fast-xml-parser/src/cli/cli.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../fast-xml-parser/src/cli/cli.js" $args
} else {
& "node$exe" "$basedir/../fast-xml-parser/src/cli/cli.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../uuid/dist/bin/uuid" "$@"
else
exec node "$basedir/../uuid/dist/bin/uuid" "$@"
fi
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\uuid\dist\bin\uuid" %*
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../uuid/dist/bin/uuid" $args
} else {
& "$basedir/node$exe" "$basedir/../uuid/dist/bin/uuid" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../uuid/dist/bin/uuid" $args
} else {
& "node$exe" "$basedir/../uuid/dist/bin/uuid" $args
}
$ret=$LASTEXITCODE
}
exit $ret
# @aws-crypto/sha256-browser
SHA256 wrapper for browsers that prefers `window.crypto.subtle` but will
fall back to a pure JS implementation in @aws-crypto/sha256-js
to provide a consistent interface for SHA256.
## Usage
- To hash "some data"
```
import {Sha256} from '@aws-crypto/sha256-browser'
const hash = new Sha256();
hash.update('some data');
const result = await hash.digest();
```
- To hmac "some data" with "a key"
```
import {Sha256} from '@aws-crypto/sha256-browser'
const hash = new Sha256('a key');
hash.update('some data');
const result = await hash.digest();
```
## Test
`npm test`
export declare const SHA_256_HASH: {
name: "SHA-256";
};
export declare const SHA_256_HMAC_ALGO: {
name: "HMAC";
hash: {
name: "SHA-256";
};
};
export declare const EMPTY_DATA_SHA_256: Uint8Array;
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAwB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAExD,QAAA,iBAAiB,GAAgD;IAC5E,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,oBAAY;CACnB,CAAC;AAEW,QAAA,kBAAkB,GAAG,IAAI,UAAU,CAAC;IAC/C,GAAG;IACH,GAAG;IACH,GAAG;IACH,EAAE;IACF,GAAG;IACH,GAAG;IACH,EAAE;IACF,EAAE;IACF,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,EAAE;IACF,EAAE;IACF,GAAG;IACH,EAAE;IACF,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,EAAE;IACF,GAAG;IACH,GAAG;IACH,GAAG;IACH,EAAE;IACF,GAAG;IACH,EAAE;IACF,GAAG;IACH,EAAE;CACH,CAAC,CAAC"}
\ No newline at end of file
{"version":3,"file":"crossPlatformSha256.js","sourceRoot":"","sources":["../../src/crossPlatformSha256.ts"],"names":[],"mappings":";;;AAAA,qDAA8D;AAC9D,mDAA2D;AAE3D,uEAAoE;AACpE,kEAA2D;AAC3D,yCAAmD;AAEnD;IAGE,gBAAY,MAAmB;QAC7B,IAAI,IAAA,uCAAiB,EAAC,IAAA,iCAAY,GAAE,CAAC,EAAE;YACrC,IAAI,CAAC,IAAI,GAAG,IAAI,wBAAe,CAAC,MAAM,CAAC,CAAC;SACzC;aAAM;YACL,IAAI,CAAC,IAAI,GAAG,IAAI,kBAAQ,CAAC,MAAM,CAAC,CAAC;SAClC;IACH,CAAC;IAED,uBAAM,GAAN,UAAO,IAAgB,EAAE,QAAsC;QAC7D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAA,sBAAe,EAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,uBAAM,GAAN;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;IAED,sBAAK,GAAL;QACE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;IACH,aAAC;AAAD,CAAC,AAtBD,IAsBC;AAtBY,wBAAM"}
\ No newline at end of file
export * from "./crossPlatformSha256";
export { Sha256 as WebCryptoSha256 } from "./webCryptoSha256";
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,gEAAsC;AACtC,qDAA8D;AAArD,kHAAA,MAAM,OAAmB"}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment