Greengrass MQTT Bridge component to listen only topics specific for the thing

0

Hi, It seems currently we are only allowed to use wildcard (+), or hard coded thing names in MQTT Bridge mqttTopicMapping.

For example I can do as follows and it works;

mqttTopicMapping: {
              HelloWorldIotCore: {
                topic: 'clients/+/hello/world',
                source: 'LocalMqtt',
                target: 'IotCore',
              },
              IotCoreToDevice: {
                topic: 'clients/+/iotcore/to/device',
                source: 'IotCore',
                target: 'LocalMqtt',
              }
}

This one works too;

mqttTopicMapping: {
              HelloWorldIotCore: {
                topic: 'clients/hardcoded_thing_name/hello/world',
                source: 'LocalMqtt',
                target: 'IotCore',
              },
              IotCoreToDevice: {
                topic: 'clients/hardcoded_thing_name/iotcore/to/device',
                source: 'IotCore',
                target: 'LocalMqtt',
              }
}

But this one does not work. I want this to work because I want to apply the same deployment to multiple devices (or thing group) and I want each device to receive topic messages specific for itself.

mqttTopicMapping: {
              HelloWorldIotCore: {
                topic: 'clients/{iot:thingName}/hello/world',
                source: 'LocalMqtt',
                target: 'IotCore',
              },
              IotCoreToDevice: {
                topic: 'clients/{iot:thingName}/iotcore/to/device',
                source: 'IotCore',
                target: 'LocalMqtt',
              }
}

Any solution for this problem?

Thanks

已提問 1 年前檢視次數 317 次
1 個回答
0
已接受的答案

Hi,

I found the problem and posting here in case anybody suffers from the same problem.

In order to be able to {iot:thingName} in component configurations I had to enable interpolateComponentConfiguration on Nucleus configuration like below:

configurationUpdate: {
          merge: JSON.stringify({
            interpolateComponentConfiguration: true,
          }),
        },

More details here -> https://docs.aws.amazon.com/greengrass/v2/developerguide/greengrass-nucleus-component.html#greengrass-nucleus-component-configuration-interpolate-component-configuration

已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南