Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ditto-dev] Exposing digital twin data via MQTT
  • From: "Maute Stefan (IOC/PAP-DDM-TH)" <Stefan.Maute@xxxxxxxx>
  • Date: Mon, 12 Apr 2021 11:46:44 +0000
  • Accept-language: de-DE, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 139.15.153.200) smtp.rcpttodomain=eclipse.org smtp.mailfrom=bosch.io; dmarc=pass (p=reject sp=none pct=100) action=none header.from=bosch.io; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T8XTWUCVnHxb395TqB+7hPtmjoys0RpUXqsBh8egNOQ=; b=ASEk7smYo3iCfjzwmazpcAyH5iDGqCp9v4yDIsOu5xM9v9rWfCv2TdrB5mmpxnWJDq5FPfTKgOizMxf7rxDTNPTTPpPy8VoHpAUWwPHSNfKFuDdC6twBtaWXLgW0Gzvm2cLSctGMdV2McY4sVku8aOPC/jEK5NTAc/2vHCdSbB/2OrlqYlVpgSU8lk1IeOHtbEpBSm3VEQLM6wNYdBTJ7zDRaPFsbYG2agXzk/Gq6vBHHMsoW53yDcA854eUOsWP+T/axYywwFjMsuGQqahk6YH2kGAoJ6U/rP+f4Smur0Xz+gnmS38D9qNbyZkwVTIwwvC3VgqgfHkYogJpc/ePiQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U3ZDiSDzgM6Kjf/MVORkI19YEwB+mBUlhBGBFcc2gMUgOSeVmqXWcToZIJf2q+M/vDUjMzXu3xoGmMHjPF+NQbZV/HijO/zSOHcJJ9J8jkynXtSXR8MH5MlY1aBEONAPNYcPR24VVgBz82fQER69bN2BI7O1K+zm7BKMIi06lg/eTvWB0S47L3raQGn9eoFfmui5756Dozb1knjvQrAy80j1Znv/gGAbflahPApePXT7W7wo0NBvz0+fUMZnD2Ruw3e6pUBsGY6taZUhL4qhpbLRg0d83wRyQYtIUKOeSeHSqrMT/P9DLYaT02xuYEgOuBmNhaFE1r2y+a21I5vZsQ==
  • Delivered-to: ditto-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/ditto-dev/>
  • List-help: <mailto:ditto-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/ditto-dev>, <mailto:ditto-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/ditto-dev>, <mailto:ditto-dev-request@eclipse.org?subject=unsubscribe>
  • Thread-index: Adcve8u38j1YBQn2Q5OiQr6bKiinpgAEtxsQ
  • Thread-topic: Exposing digital twin data via MQTT

Hello Adam,

 

Thank you for reaching out to the Ditto team.

 

First of all to understand your use case a bit better I have a question: You want to update the thing via MQTT and receive afterwards the changes via MQTT? Is this correct?

 

Maybe it is a good start to enable the connection logs and have a look at the logs for the connection.

Another option is to enable the Debug logs of the connectivity service: https://www.eclipse.org/ditto/installation-operating.html#dynamically-adjust-log-levels

 

Best regards,

Stefan Maute


Von: ditto-dev <ditto-dev-bounces@xxxxxxxxxxx> Im Auftrag von Olek, Adam via ditto-dev
Gesendet: Montag, 12. April 2021 11:16
An: ditto-dev@xxxxxxxxxxx
Cc: Olek, Adam <adam.olek@xxxxxxxxx>
Betreff: [ditto-dev] Exposing digital twin data via MQTT

 

Dear Ditto team,

we're investigating capabilities of Ditto and we've got small problem with exposing data via Ditto connectivity.

Our case is:

- we've created simple digital twin in Ditto

- it is updated with MQTT protocol and it’s work

- no update from digital twin is received after modification of digital twin's features

 

Below I'll describe our configuration.

Our simple digital twin definition:

{

    "policyId": "my.test:policy",

    "attributes": {

        "manufacturer": "Aptiv",

        "VIN": "0815666337"

    },

    "features": {

        "transmission": {

            "properties": {

                "rpm": 0,

                "encoder": 0

            }

        }

    }

}

 

Policy definition:

{

    "policyId": "my.test:policy",

    "entries": {

        "owner": {

            "subjects": {

                "nginx:ditto": {

                    "type": "nginx basic auth user"

                }

            },

            "resources": {

                "thing:/": {

                    "grant": ["READ","WRITE"],

                    "revoke": []

                },

                "policy:/": {

                    "grant": ["READ","WRITE"],

                    "revoke": []

                },

                "message:/": {

                    "grant": ["READ","WRITE"],

                    "revoke": []

                }

            }

        }

    }

}

 

Also different subjects were used and it didn’t help.

 

Connection definition:

{

    "targetActorSelection": "/system/sharding/connection",

    "headers": {

               "aggregate": false

    }, 

    "piggybackCommand": {

        "type": "connectivity.commands:modifyConnection",

        "connection": {

            "id": "mqtt-aptiv-car-connection-123",

            "connectionType": "mqtt",

            "connectionStatus": "open",

            "failoverEnabled": true,

            "uri": "tcp://IP_ADDRESS:1883",

            "sources": [{

                "addresses": ["aptiv-car/#"],

                "authorizationContext": ["nginx:ditto"],

                "qos": 0,

                "filters": []

            }],

            "targets": [{

                "address": "aptiv-car-pub/{{ thing:name }}",

                "topics": [

                "_/_/things/twin/events",

                "_/_/things/live/messages"

                ],

                "authorizationContext": ["nginx:ditto"],

                "qos": 0

            }],

            "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 = {transmission: {properties: {rpm: jsonData.rpm, encoder: jsonData.encoder}}}; 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) {let headers = dittoHeaders; let textPayload = '{}'; let bytePayload = null; let contentType = 'text/plain; charset=UTF-8'; return  Ditto.buildExternalMsg(headers, textPayload, bytePayload, contentType);}",

                    "loadBytebufferJS": "false",

                     "loadLongJS": "false"

                }

            }

        }

    }

}

 

So far outgoingScript is setting an empty paylod, only brackets. I've also experimented with application/json as contentType.

 

After setting the whole setup we are able to update our model with MQTT. Inside Ditto containers logs with information that data was received are visible but there is no information that any data after digital twin update was sent. Also no such information is visible inside MQTT broker.

 

Should I modify "targets" in connection configuration? Maybe policy is incorrect? How can I check if outgoingScript is executed(it cannot access the filesystem, it cannot print anything)?

 

This email is quite long but I hope I’ve described everything correct and all needed details are included.

 

Regards,

Adam Olek


Back to the top