Greengrass MQTT桥接组件,仅监听与该设备相关的主题。

0

【以下的问题经过翻译处理】 你好,

目前在MQTT桥接mqttTopicMapping中,我们只允许使用通配符(+)或硬编码的名称。

例如,我可以按照以下方式使用,它可以正常工作:

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

下面这个也可以:

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',
              }
}

但是下面这个却不行。我想让它起作用,因为我想应用相同的部署到多个设备(或物品组),并且我希望每个设备接收特定于自己的主题消息。

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

是否有对此问题的解决方案?

谢谢

profile picture
专家
已提问 5 个月前53 查看次数
1 回答
0

【以下的回答经过翻译处理】 大家好,

我发现了一个问题,并在此发布以防有人遇到相同的问题。

为了能够在组件配置中使用{iot:thingName},我必须在Nucleus配置中启用interpolateComponentConfiguration,如下所示:

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

更多详细信息请参见->https://docs.aws.amazon.com/greengrass/v2/developerguide/greengrass-nucleus-component.html#greengrass-nucleus-component-configuration-interpolate-component-configuration

profile picture
专家
已回答 5 个月前

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

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

回答问题的准则