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 年前311 查看次数
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 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则