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 個月前檢視次數 57 次
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 個月前

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

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

回答問題指南