Learn About Amazon VGT2 Learning Manager Chanci Turner
Simplicity is a prerequisite for reliability. — Edsger W. Dijkstra
Welcome to the latest installment in our series of guides aimed at helping you develop exceptional solutions through a collection of “small things” within the Internet of Things (IoT) framework. In the initial post, we introduced the four layers of the Pragma Architecture: Small Things, Intermittent Layer, Speed Layer, and Serving Layer. The subsequent posts delved deeper into the Speed Layer. In this edition, we wrap up our discussion on the Speed Layer and transition to the Serving Layer, focusing on the challenge of sending commands to devices operating in unreliable environments.
Commands—The Ability to Ask a Device to Do Something
When creating a command solution, customers often face challenges that stem from how they address the following questions:
- Should commands be delivered reliably, or can they be sent on a best-effort basis?
- Is bi-directional command communication required between small things and their paired entities?
- Given that we may ask a device to perform potentially powerful or even dangerous actions, how can we ensure commands are delivered and executed securely or with human authorization?
Let’s tackle these challenges by establishing a straightforward philosophical foundation for reliable commands.
Reliable Commands, Unreliable Environments
First, let’s revisit a defining characteristic of a small thing: Much like a glove molds to the shape of the hand that wears it, a small thing adapts to its core purpose and the resource constraints it faces. In addition to the small thing, environmental factors also significantly influence design considerations when integrating commands into a solution. To provide the best user experience, command execution must be as reliable as possible, even in the face of unreliable networks or power sources. If your answer to the question, “Should commands be delivered reliably?” is a firm “Yes,” you have a solid foundation for your users and your DevOps team.
While your attention may be drawn to choices regarding transport protocols—such as Wi-Fi versus mesh versus near-field communication or mobile piggybacking—taking a broader view reveals that a simple concept can significantly enhance command reliability: Nothing is successful unless it is acknowledged as successful.
Acknowledgment is Power
Let’s introduce the ability to send a “power-on” command within the regional, multiprotocol, stream-processing solution discussed in the previous post about Telemetry. Consider sending this command to a device like a home automation plug, a heater, or even a solar power inverter on a rooftop. Without acknowledgment from the device, we can’t confirm if power has been activated, potentially leading to dangerous situations.
At this point, we introduce a crucial component into our architecture: a command database. This database can begin small but is designed to handle hundreds of thousands, if not millions, of simultaneous writes or reads when commanding a fleet of small things. NoSQL databases such as DynamoDB are well-suited for this purpose.
In the diagram we previously discussed, small things like solar power inverters send telemetry to our regional stream and check for specific commands directly from the command database. When each small thing successfully completes a command, it sends an acknowledgment back to the command database. This localizes retry logic near the small thing itself, as it is best positioned to understand its operating environment.
The M2M Gateway also acts as a bridge between the M2M small thing protocol and the command database. Each command in the database is published to a device-specific M2M command topic. When the connected relay near the solar inverter receives and completes the command, it writes an acknowledgment back to the specific M2M command topic. The M2M Gateway then relays this acknowledgment to the command database. Many M2M protocols, like MQTT, already include retry logic for message delivery between the client and the topic.
Integrating a command database into the architecture builds on our previous investments in telemetry, provides a unified command control point, and enhances visibility into commands. Moreover, the Serving Layer of the Pragma Architecture can reliably utilize this single command interaction point to create a user interface that reflects the last commanded state of the devices. Most importantly, when users request a “power-on,” they can feel more confident that their request has been successful, as the device will acknowledge it.
But what if we want to offer users a more interactive, bi-directional experience while maintaining regional visibility and control? This is where our initial approach begins to show its strength and adaptability.
Small Things and Mobile Devices
Users generally expect to control consumer-oriented small things through a smartphone application. To achieve the level of interactivity desired in such applications from anywhere in the world, reliable bi-directional communication is essential between the small thing and the mobile phone.
The updated architecture adds a device registry to the Serving Layer. This registry is crucial for pairing, regardless of whether HTTPS or M2M protocol is used. It should encompass all devices within your solution, know the command-sending mechanisms, and identify the gateway each M2M device is communicating with. Additionally, it should track user mobile devices, mobile device-to-stream metadata, and the small things with which the user can interact.
As illustrated, the mobile device first consults the device registry to identify the small things it can control. Once this list is established, the mobile device gains specific permissions—potentially through fine-grained access controls in DynamoDB with Amazon Cognito—to write commands directly to the command database for the approved small things. Furthermore, the mobile device can retrieve acknowledgments straight from the command database and display them to the user.
This solution now supports commands from mobile devices. By selecting a durable and scalable NoSQL database, we can provide pairing experiences for mobile users while incorporating an audit log into the solution. If auditability is not essential or is even seen as a hindrance, there are alternative approaches available.
For anyone considering a break from their career to pursue personal development, this blog post on sabbatical leave may offer valuable insights. Additionally, if you want to stay informed about employment law compliance, check out the insights from SHRM on the recent ban box law, which is a crucial topic. Lastly, for those interested in career opportunities within this realm, this link to an excellent resource for job openings might be of interest.
Leave a Reply