mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Updated Design: Dynamic MQTT node (markdown)
parent
ff8f122303
commit
549663b56c
@ -27,3 +27,86 @@ Some observations from this design:
|
|||||||
|
|
||||||
- the control node is controlling the `mqtt-broker` node. Other regular nodes can also use that `mqtt-broker` node so will also be effected by changes.
|
- the control node is controlling the `mqtt-broker` node. Other regular nodes can also use that `mqtt-broker` node so will also be effected by changes.
|
||||||
- the `mqtt-broker` config node will have a new option to not auto-connect. This would be used where the decision to connect is left to the application's use of the control node.
|
- the `mqtt-broker` config node will have a new option to not auto-connect. This would be used where the decision to connect is left to the application's use of the control node.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### `msg.mqttControl`
|
||||||
|
|
||||||
|
This message property is used to control the `mqtt-control` node. It's content determines the action the control node will take.
|
||||||
|
|
||||||
|
#### Connect
|
||||||
|
|
||||||
|
The connect action will connect the mqtt-control node if it is not currently connected.
|
||||||
|
|
||||||
|
If the broker is already connected, the action will be ignored. (**Q**: or should it cause a disconnect and reconnect?)
|
||||||
|
|
||||||
|
The `broker` object can contain any property to override the mqtt-broker node.
|
||||||
|
|
||||||
|
~~~
|
||||||
|
msg.mqttControl = {
|
||||||
|
"action": "connect",
|
||||||
|
"broker": {
|
||||||
|
"url": "mqtt://localhost:1883",
|
||||||
|
"clientid": "my-client-id",
|
||||||
|
"keepalive": 60,
|
||||||
|
"clean": true
|
||||||
|
"username": "",
|
||||||
|
"password": "",
|
||||||
|
"birth": {
|
||||||
|
"topic":"",
|
||||||
|
"qos": "",
|
||||||
|
"retain": false,
|
||||||
|
"payload": ""
|
||||||
|
},
|
||||||
|
"close": {
|
||||||
|
"topic":"",
|
||||||
|
"qos": "",
|
||||||
|
"retain": false,
|
||||||
|
"payload": ""
|
||||||
|
},
|
||||||
|
"will": {
|
||||||
|
"topic":"",
|
||||||
|
"qos": "",
|
||||||
|
"retain": false,
|
||||||
|
"payload": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
#### Disconnect
|
||||||
|
|
||||||
|
~~~
|
||||||
|
msg.mqttControl = {
|
||||||
|
"action": "disconnect"
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
#### Subscribe
|
||||||
|
|
||||||
|
~~~
|
||||||
|
msg.mqttControl = {
|
||||||
|
"action": "subscribe",
|
||||||
|
"topic": "a/b/c"
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
#### Unsubscribe
|
||||||
|
|
||||||
|
~~~
|
||||||
|
msg.mqttControl = {
|
||||||
|
"action": "unsubscribe",
|
||||||
|
"topic": "a/b/c"
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
#### Publish
|
||||||
|
|
||||||
|
The publish action will use the same standard properties as the existing `mqtt out` node. But the `msg.mqttControl` property *must* be present to tell the control node to publish.
|
||||||
|
~~~
|
||||||
|
msg.mqttControl = {
|
||||||
|
"action": "publish"
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user