我是亚马逊网络服务IoT的新手,现在尝试使用现有的资源来理解主要概念。当我使用aws iot-data命令试图将数据发布到亚马逊网络服务保留主题之一时,我遇到了一个奇怪的行为。假设我想要更新某个stub thing的名为stubShadow的命名卷影(我正在使用AWS IoT Dashboard中的Test选项卡):
aws iot-data update-thing-shadow --thing-name stub --shadow-name stubShadow \
--cli-binary-format raw-in-base64-out \
--payload '{"state":{"desired":{"ColorRGB":[0,11,11]}},"clientToken":"21b21b21-bfd2-4279-8c65-e2f697ff4fab"}' /dev/stdout它工作得很好,我可以观察$aws/things/stub/shadow/name/stubShadow/update/accepted主题的更新。
现在我想使用topic参数发布一条消息。下面是一个示例:
aws iot-data publish --topic "$aws/things/stub/shadow/name/stubShadow/update" \
--cli-binary-format raw-in-base64-out \
--payload '{"state":{"reported":{"ColorRGB":[0,11,11]}},"clientToken":"21b21b21-bfd2-4279-8c65-e2f697ff4fab"}'什么都没发生。我想知道向AWS服务主题发送直接消息的命令有什么问题?我是不是错过了什么?因为对于常规的(手动创建的)主题,它工作得很好。
发布于 2020-10-21 05:57:23
就像document说的,
payload是stringify json消息的base64编码表示
{"state":{"reported":{"ColorRGB":[0,11,11]}}}
console.log(btoa(JSON.stringify({"state":{"reported":{"ColorRGB":[0,11,11]}}})))
负载:eyJzdGF0ZSI6eyJyZXBvcnRlZCI6eyJDb2xvclJHQiI6WzAsMTEsMTFdfX19
aws iot-data publish --topic "$aws/things/stub/shadow/name/stubShadow/update" --payload 'eyJzdGF0ZSI6eyJyZXBvcnRlZCI6eyJDb2xvclJHQiI6WzAsMTEsMTFdfX19'
https://stackoverflow.com/questions/64427485
复制相似问题