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
EXPERTE
gefragt vor 5 Monaten56 Aufrufe
1 Antwort
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
EXPERTE
beantwortet vor 5 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen