Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "targetActorSelection": "/system/sharding/connection",
- "headers": {
- "aggregate": false
- },
- "piggybackCommand": {
- "type": "connectivity.commands:createConnection",
- "connection": {
- "id": "mqtt-connection-source",
- "connectionType": "mqtt",
- "connectionStatus": "open",
- "failoverEnabled": true,
- "uri": "tcp://91.121.93.94:1883",
- "sources": [{
- "addresses": ["my.mqtt.test/#"],
- "authorizationContext": ["nginx:ditto"],
- "qos": 0,
- "filters": []
- }],
- "mappingContext": {
- "mappingEngine": "JavaScript",
- "options": {
- "incomingScript": "function mapToDittoProtocolMsg(headers, textPayload, bytePayload, contentType) {const jsonString = String.fromCharCode.apply(null, new Uint8Array(bytePayload)); const jsonData = JSON.parse(jsonString); const thingId = jsonData.thingId.split(':'); const value = {measurements: {properties: {temperature: jsonData.temperature, humidity: jsonData.humidity}}}; return Ditto.buildDittoProtocolMsg(thingId[0], thingId[1], 'things', 'twin', 'commands', 'modify', '/features', headers, value);}",
- "outgoingScript": "function mapFromDittoProtocolMsg(namespace, id, group, channel, criterion, action, path, dittoHeaders, value, status, extra) {return null;}",
- "loadBytebufferJS": "false",
- "loadLongJS": "false"
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement