gpt4 book ai didi

amazon-web-services - aws IoT 'device' 和 'thingShadow' 类有什么区别?

转载 作者:行者123 更新时间:2023-12-04 08:09:43 30 4
gpt4 key购买 nike

我有一个订阅和发布到 aws IoT 上的主题的应用程序。我想知道“device”和“thingShadow”这两个类之间的区别是什么。这个library给出了两者的例子,它们似乎都有相似的功能。

最佳答案

device class用于订阅和发布有关 MQTT 主题的消息,以用于遥测和消息传递。

thingShadow classwrapper around the device class ,它提供了额外的方法,例如 .register , .update delete 它们旨在与设备阴影进行交互。此类还发出与影子生命周期相关的特定事件,例如 status , delta foreignStateChange .

[...] the thingShadow class allows devices to update, be notified of changes to, get the current state of, or delete Thing Shadows from AWS IoT.



所以基本上,如果您使用设备阴影,请使用 thingShadow类,否则你可以使用 device类(class)。

编辑:

为了进一步扩展 AWS IoT 的基本原理,您有两种设备之间的通信方案:
  • 由于 AWS IoT 实现标准 MQTT接口(interface),您可以使用名为 publish-subscribe 的模式使用主题与您的设备进行通信。 .您的应用可以订阅主题并等待设备在其上发布消息。同样,您的应用程序可以在设备主题上发布消息并让设备接收它。
  • AWS IoT 实现了称为 device shadow 的第二个通信接口(interface)。 ,即使设备断开连接,您也可以对设备进行寻址,并在您的应用程序和设备本身之间保持同步状态。 AWS 文档清楚地解释了它。

  • A thing shadow (sometimes referred to as a device shadow) is a JSON document that is used to store and retrieve current state information for a thing (device, app, and so on). The Thing Shadows service maintains a thing shadow for each thing you connect to AWS IoT. You can use thing shadows to get and set the state of a thing over MQTT or HTTP, regardless of whether the thing is connected to the Internet. Each thing shadow is uniquely identified by its name.



    这两个接口(interface)可以在 SDK 中使用 device class 进行寻址。用于订阅和发布 MQTT 主题,以及 thing shadow class检索、更新或删除设备事物影子文档。

    关于amazon-web-services - aws IoT 'device' 和 'thingShadow' 类有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44910791/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com