Skip to content

Commit

Permalink
Merge pull request #1357 from samson0v/master
Browse files Browse the repository at this point in the history
Updated MQTT connector (new config format)
  • Loading branch information
imbeacon authored Apr 9, 2024
2 parents c1fca01 + 4766def commit 8a06209
Show file tree
Hide file tree
Showing 19 changed files with 870 additions and 74 deletions.
Empty file.
36 changes: 36 additions & 0 deletions tests/unit/connectors/mqtt/data/attribute_requests/new_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"broker": {
"name": "Default Local Broker",
"host": "127.0.0.1",
"port": 1883,
"clientId": "ThingsBoard_gateway",
"version": 5,
"maxMessageNumberPerWorker": 10,
"maxNumberOfWorkers": 100,
"sendDataOnlyOnChange": false,
"security": {
"type": "anonymous"
}
},
"dataMapping": [],
"requestsMapping": {
"serverSideRpc": {},
"connectRequests": {},
"disconnectRequests": {},
"attributeRequests": [
{
"retain": false,
"topicFilter": "v1/devices/me/attributes/request",
"deviceInfo": {
"deviceNameExpressionSource": "message",
"deviceNameExpression": "${serialNumber}"
},
"attributeNameExpressionSource": "message",
"attributeNameExpression": "${versionAttribute}, ${pduAttribute}",
"topicExpression": "devices/${deviceName}/attrs",
"valueExpression": "${attributeKey}: ${attributeValue}"
}
],
"attributeUpdates": {}
}
}
26 changes: 26 additions & 0 deletions tests/unit/connectors/mqtt/data/attribute_requests/old_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"broker": {
"name": "Default Local Broker",
"host": "127.0.0.1",
"port": 1883,
"clientId": "ThingsBoard_gateway",
"version": 5,
"maxMessageNumberPerWorker": 10,
"maxNumberOfWorkers": 100,
"sendDataOnlyOnChange": false,
"security": {
"type": "anonymous"
}
},
"mapping": [],
"attributeRequests": [
{
"retain": false,
"topicFilter": "v1/devices/me/attributes/request",
"deviceNameJsonExpression": "${serialNumber}",
"attributeNameJsonExpression": "${versionAttribute}, ${pduAttribute}",
"topicExpression": "devices/${deviceName}/attrs",
"valueExpression": "${attributeKey}: ${attributeValue}"
}
]
}
31 changes: 31 additions & 0 deletions tests/unit/connectors/mqtt/data/attribute_updates/new_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"broker": {
"name": "Default Local Broker",
"host": "127.0.0.1",
"port": 1883,
"clientId": "ThingsBoard_gateway",
"version": 5,
"maxMessageNumberPerWorker": 10,
"maxNumberOfWorkers": 100,
"sendDataOnlyOnChange": false,
"security": {
"type": "anonymous"
}
},
"dataMapping": [],
"requestsMapping": {
"serverSideRpc": {},
"connectRequests": {},
"disconnectRequests": {},
"attributeRequests": {},
"attributeUpdates": [
{
"retain": true,
"deviceNameFilter": ".*",
"attributeFilter": "uploadFrequency",
"topicExpression": "sensor/${deviceName}/${attributeKey}",
"valueExpression": "{\"${attributeKey}\":\"${attributeValue}\"}"
}
]
}
}
25 changes: 25 additions & 0 deletions tests/unit/connectors/mqtt/data/attribute_updates/old_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"broker": {
"name": "Default Local Broker",
"host": "127.0.0.1",
"port": 1883,
"clientId": "ThingsBoard_gateway",
"version": 5,
"maxMessageNumberPerWorker": 10,
"maxNumberOfWorkers": 100,
"sendDataOnlyOnChange": false,
"security": {
"type": "anonymous"
}
},
"mapping": [],
"attributeUpdates": [
{
"retain": true,
"deviceNameFilter": ".*",
"attributeFilter": "uploadFrequency",
"topicExpression": "sensor/${deviceName}/${attributeKey}",
"valueExpression": "{\"${attributeKey}\":\"${attributeValue}\"}"
}
]
}
38 changes: 38 additions & 0 deletions tests/unit/connectors/mqtt/data/connect_requests/new_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"broker": {
"name": "Default Local Broker",
"host": "127.0.0.1",
"port": 1883,
"clientId": "ThingsBoard_gateway",
"version": 5,
"maxMessageNumberPerWorker": 10,
"maxNumberOfWorkers": 100,
"sendDataOnlyOnChange": false,
"security": {
"type": "anonymous"
}
},
"dataMapping": [],
"requestsMapping": {
"serverSideRpc": {},
"connectRequests": [
{
"topicFilter": "sensor/connect",
"deviceInfo": {
"deviceNameExpressionSource": "message",
"deviceNameExpression": "${serialNumber}"
}
},
{
"topicFilter": "sensor/+/connect",
"deviceInfo": {
"deviceNameExpressionSource": "topic",
"deviceNameExpression": "(?<=sensor/)(.*?)(?=/connect)"
}
}
],
"disconnectRequests": {},
"attributeRequests": {},
"attributeUpdates": {}
}
}
26 changes: 26 additions & 0 deletions tests/unit/connectors/mqtt/data/connect_requests/old_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"broker": {
"name": "Default Local Broker",
"host": "127.0.0.1",
"port": 1883,
"clientId": "ThingsBoard_gateway",
"version": 5,
"maxMessageNumberPerWorker": 10,
"maxNumberOfWorkers": 100,
"sendDataOnlyOnChange": false,
"security": {
"type": "anonymous"
}
},
"mapping": [],
"connectRequests": [
{
"topicFilter": "sensor/connect",
"deviceNameJsonExpression": "${serialNumber}"
},
{
"topicFilter": "sensor/+/connect",
"deviceNameTopicExpression": "(?<=sensor/)(.*?)(?=/connect)"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"broker": {
"name": "Default Local Broker",
"host": "127.0.0.1",
"port": 1883,
"clientId": "ThingsBoard_gateway",
"version": 5,
"maxMessageNumberPerWorker": 10,
"maxNumberOfWorkers": 100,
"sendDataOnlyOnChange": false,
"security": {
"type": "anonymous"
}
},
"dataMapping": [],
"requestsMapping": {
"serverSideRpc": {},
"connectRequests": {},
"disconnectRequests": [
{
"topicFilter":"sensor/disconnect",
"deviceInfo":{
"deviceNameExpressionSource":"message",
"deviceNameExpression":"${serialNumber}"
}
},
{
"topicFilter":"sensor/+/disconnect",
"deviceInfo":{
"deviceNameExpressionSource":"topic",
"deviceNameExpression":"(?<=sensor/)(.*?)(?=/disconnect)"
}
}
],
"attributeRequests": {},
"attributeUpdates": {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"broker": {
"name": "Default Local Broker",
"host": "127.0.0.1",
"port": 1883,
"clientId": "ThingsBoard_gateway",
"version": 5,
"maxMessageNumberPerWorker": 10,
"maxNumberOfWorkers": 100,
"sendDataOnlyOnChange": false,
"security": {
"type": "anonymous"
}
},
"mapping": [],
"disconnectRequests": [
{
"topicFilter": "sensor/disconnect",
"deviceNameJsonExpression": "${serialNumber}"
},
{
"topicFilter": "sensor/+/disconnect",
"deviceNameTopicExpression": "(?<=sensor/)(.*?)(?=/disconnect)"
}
]
}
Loading

0 comments on commit 8a06209

Please sign in to comment.