Understanding the AWS IoT Core communication patterns

Communication patterns in IoT are more complex compared to, for example, the client-server pattern. Typically, there is no single side that initiates the communication. Sometimes it is the backend that wants to send the configuration, sometimes it is the device that wants to send sensor data.

While the patterns are more complex, the underlying communication channels are pretty simple, since they rely on sending messages on topics working in a publisher-subscriber model.

For sending simple asynchronous messages, the publisher-subscriber pattern is sufficient. One side sends something and the other side receives it. It is simple and efficient, but it is not enough to perform tasks working in a request-reply model.

AWS IoT Core provides services that are more than just sending a message. For example, we can manage device configuration using the AWS SDK, and IoT Core takes care of sending appropriate messages on specified topics. These functions expose what is called the “MQTT API” (API over MQTT), which is fully managed by AWS. All we have to do is implement the corresponding device-side functions.

Let’s look closer at how these APIs are defined. First, AWS specifies some MQTT topics that are reserved for specific functions. These topics are documented here. Then, there are specific message formats that are sent over these topics. In most cases, they are formatted as JSONs. AWS defines the meaning of all fields and whether they are required or not. Having these two things, all we need to know is how to use them. Let’s take IoT Jobs as an example: there is a document that describes what the device should do after it starts: which topics to subscribe to, and what messages to publish. It describes exactly what will happen in given scenario.

For many functions, the design is similar: there is a topic on which the device sends a request, and a pair of “accepted” and “rejected” topics on which the backend sends its responses.

Understanding these patterns is key to using AWS IoT Core effectively. The IoT backend can do a lot of things for us, and in the next posts in this series, I will explore the available services in detail.

In this blog series, I will explore the AWS IoT Core, its functions, capabilities, and simple examples.