Updated Design: Dynamic MQTT node (markdown)

Nick O'Leary 2019-01-10 13:15:09 +00:00
parent ff8f122303
commit 549663b56c
1 changed files with 83 additions and 0 deletions

@ -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 `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"
}
~~~