Awareness on AWS IoT and Thing Shadows

Note : This article contains assumptions.

AWS IoT has been announced. AWS IoT has prepared a Managed MQTT Server, and it seems to be appreciated that MQTT evaluates that it takes care of MQTT Server, which is difficult to operate.

But it is not. The essence of AWS IoT is the mechanism of Thing Shadows.

However, I have not used it properly yet, please point out if there is a mistake.

Thing Shadows

In IoT AWS, Things it has been defined that thing. There are two kinds of Things.

Things
Actual physical things. device
Thing Shadow
Things state on network (AWS)

Things is as it is. The new one is Thing Shadow. This is "a (virtual) mapping of physical devices onto the network".

Things and Thing Shadow are connected one to one. If there is any change in Things, a change will also occur in Thing Shadows. Inversely also. If you make a change to Thing Shadows, it also makes a change to Things.

That is,

  • Physical space
  • Virtual space

It is nothing other than that it was integrated.

Information on Thing Shadow

The implementation of Thing Shadow is just JSON.:

{
    "state" : {
        "desired" : {
          "color" : "RED",
          "sequence" : [ "RED", "GREEN", "BLUE" ]
        },
        "reported" : {
          "color" : "GREEN"
        }
    },
    "metadata" : {
        "desired" : {
            "color" : {
                "timestamp" : 12345
            },
            "sequence" : {
                "timestamp" : 12345
            }
        },
        "reported" : {
            "color" : {
                "timestamp" : 12345
            }
        }
    },
    "version" : 10,
    "clientToken" : "UniqueClientToken",
    "timestamp": 123456789
}

Here important is possessed by each state and the Metadata, desired and reported is.

1. When Thing is updated

When Thing is updated, which is a physical thing, the information is notified to Thing Shadow by MQTT or HTTPS.

Along with this, reported of state will be updated.

2. When Thing Shadow is updated

Thing Shadow can be updated in virtual space by MQTT or HTTP. In that case, desired information is updated.

In this case, desired and reported If there is a difference, the message is sent to the Thing (not necessarily the one) that subscribe to this Thing Shadow. Thing can receive this and update its own information. Then, when you can update, reported to update the Thing Shadow as.


With these actions, Thing and Thing Shadows can be synchronized. If, repoted and desired If you are different are not synchronized, it will be called.

More say, as API, update / get / delete are prepared for each accepted and rejected we are available. For this reason, I tried to update Things Shadows, but I can understand that I could not do it.

Difference from MQTT

So far, I have explained Things and Thing Shadows. By the way, AWS IoT does not have the following functions of MQTT.

  • Retain
  • Will
  • QoS 2

Why. That is because there is a Thing Shadow.

  • Retain is Shadow itself
  • Wll does not need to be in the first place as there is no offline state
  • Synchronization with QoS 2 can be realized using Shadow's desired / reported

Would not it be nice to emphasize that AWS IoT is not a message protocol called MQTT but is for handling "state"?

Summary

If you capture AWS IoT as just a Managed MQTT Server, you will miss the essence. It may be fun to look back at something about the fusion of virtual space and physical space, Internet of Things, and so on.

In addition, still this time Rule it does not depress respect. By combining Thing Shadows / Rule, you should be able to create a machine - to - machine, Things - to - Things world without human intervention.

It was a bit of an emotional story that I did not write in this blog so much. (Actually, I was doing this kind of research more than 10 years ago, I am glad that it expanded to this point, I decided to write it momentum)