Open farshidtz opened 5 years ago
DRAFT Updated main config file:
{
"id": "example-dgw",
"description": "Example Device Gateway Configuration",
"protocols": {
"HTTP": {
"publicEndpoint": "http://fqdn-of-the-host:8080",
"bindAddr": "0.0.0.0",
"bindPort": 8080,
"basePath": "/rest"
},
"MQTT": {
"discover": false, // discover from service catalog
"discoverID": "main_broker",
"uri": "tcp://localhost:1883",
"offlineBuffer": 100
}
},
"serviceCatalog": {
"endpoint": "http://localhost:8082",
"ttl": 120
}
}
DRAFT Updated resource config:
{
"name": "MQTTSwitch", // service id becomes example-dgw/MQTTSwitch
"description": "MQTT test switch service",
"meta": {},
"agent": {
"type": "service",
"dir": "agent-examples/mqtt-switch",
"exec": "switch.sh"
},
"contentType": "application/json",
"protocols": [
{
"type": "MQTT",
"methods": [
"PUB",
"SUB"
],
"pubTopic": "test/switch/pub",
"pubRetained": true, // overrides default (false)
"pubQoS": 2, // overrides default (1)
"subTopic": "test/switch/sub",
"subQoS": 2, // overrides default (1)
"broker": { // overrides default (main config file)
"discover": false,
"discoverID": "main_broker",
"uri": "tcp://localhost:1883",
"offlineBuffer": 100
}
},
{
"type": "HTTP",
"methods": [
"GET",
"PUT"
],
"path": "mqtt_switch"
}
]
}
@dschowta what about this:
SUB using different topic and broker:
{
"name": "MQTTSwitch",
"description": "MQTT test switch service",
"meta": {},
"agent": {
"type": "service",
"dir": "agent-examples/mqtt-switch",
"exec": "switch.sh"
},
"contentType": "application/json",
"protocols": [
{
"type": "MQTT",
"methods": [
"PUB"
],
"topic": "test/switch/pub",
"retained": true,
"qos": 2
},
{
"type": "MQTT",
"methods": [
"SUB"
],
"topic": "test/switch/sub",
"qos": 2,
"broker": {
"discover": false,
"discoverID": "main_broker",
"uri": "tcp://localhost:1883",
"prefix": "example-dgw",
"offlineBuffer": 100
}
},
{
"type": "HTTP",
"methods": [
"GET",
"PUT"
],
"path": "mqtt_switch"
}
]
}
In this example, SUB and PUB can be merged when they share the same topic and broker.
A protocol definition like this would lead to a device getting back its own outgoing messages and potentially cause an endless loop.
{
"type": "MQTT",
"methods": [
"PUB", "SUB"
],
"topic": "test/switch",
}
Could use the following and programmatically enforce different topics for PUB and SUB:
{
"type": "MQTT",
"pubTopic": "dummy/pub",
"pubQoS": 1,
"pubRetained": false,
"subTopic": "dummy-device",
"subQoS": 1
}
Also, in the above format, we won't be using method
term in place of the MQTT Control Packet
.
Device Gateway is not directly dealing with devices and resources. It is rather dealing with a process and exposing services on its behalf.
Current main config file example:
Device/resource config file (example: system):
Device/resource config file (example: mqtt-switch):
Device/resource config file (example: speakers):
Device/resource config file (example: dummy):
Device/resource config file (example: remote-tasks):