A simple Google search about ‘the number of IoT devices in 2021’ displays 149 million results. Different companies and research bodies have predicted the range of 21 billion to 46 billion for IoT devices in 2021. Juniper Research’s report estimates that we are set to hit the 46 billion mark. The connected world is increasing at an exponential rate. The impact of it on our lives and business operations is also increasing at a massive level.
We are at a place where enterprises consider mobile not as a device that operates in isolation. The trend of marketing and selling mobile apps as independent products is about to change. System integrators, manufacturers, solution providers and even consumers want to integrate IoT and mobile app development. The goal is to enhance accessibility to manage, operate and maintain IoT solutions anywhere, anytime.
A mobile app as a discrete product is replacing an interconnected system through an IoT app development platform. Each stakeholder tries championing the ways to provide easy handling of the IoT ecosystem in consumer’s hands. The challenge is to develop an IoT mobile app quickly using IoT mobile SDK, and interface IoT devices and other IoT-related data sources with the IoT platform using a smartphone. This blog showcases the basics of SDK with an architecture diagram, best practices for building an SDK and an example about how we integrate devices with IoTConnect using IoTConnect SDK.
Every developer has heard the acronym ‘SDK’ – software development kit. The name suggests that it is a kit with a set of software tools and programs that developers use to create applications.
SDK tools come with a range of things, from open-source libraries, developer guides, processes, code samples to documentation. SDKs are built to use on specific platforms and are available in different languages like Java, Python, C#, etc. For example, creating an Android app on the Java platform requires Java SDKs, Universal Windows Platform apps require the .NET SDKs and iOS apps the iOS SDKs.
SDKs are designed for device-cloud and cloud-device communications through different channels. But it mainly happens through HTTPS and MQTT protocols. While HTTP is a well-known and widely used application protocol, it is normally full of traffic for IoT applications. On the other hand, MQTT works based on the publishing and subscribe mechanism, making it suitable for the IoT world.
The open-source libraries of SDKs are designed so that any IoT mobile app can do data transition using HTTP and MQTT effortlessly. These libraries support events that are created in an IoT platform. Hence, the open-source library of an SDK reduces the design and development process of periodic time callbacks and message-based callbacks. Developing such libraries for each app and target environment is, of course, not herculean but not as easy as pie. That’s why SDKs are valuable.
The following picture shows an architecture diagram of a device SDK.
One-liner best practices for building an SDK
A well-built SDK can improve developer experience, speed up the device integration and accelerate new features rollout. An SDK is simply a guest in the host app. Hence, SDK tools are mainly responsible for an app to be well built, which in return allow companies to gain repeat customers. The following one-liner best practices exactly make SDK tools to do so.
Simplicity: The SDK initialization should not require more than a line using credentials.
Platform naming conventions: Every platform has different typographical and grammatical naming conventions. For example, the Java platform’s naming conventions are well-established, as mentioned in The Java Language Specification. So, SDKs should stick to those naming conventions for making app developers’ work easy.
Status codes: When a server responds to a browser request, status codes are always in the HTTP header. But users only see them when something goes wrong. Servers use status codes to communicate, ‘something is not right.’ Hence, SDKs should include developer-friendly conventional status codes. No doubt, SDKs can contain a set of custom status codes as well if needed.
No adverse effect on the host app: A well-built SDK should never negatively affect the host app’s performance.
Memory leaks: The best way to avoid memory leaks is to validate any SDK using profiling tools with performance and stress testing.
Disaster-proof SDK: Any unpredicted conduct due to connection loss or unexpected API behavior like 500 errors should not crash an SDK.
Enable SSL: Use SSL to take security seriously by encrypting HTTP traffic from all networking calls.
Hide symbols: The internals of a binary library hold the significant intellectual property. It is important to hide them to protect intellectual property. Hence, use the strip command to hide what’s exposed in a shared library.
Class documentation: Have a clear and robust documentation. Use code description formats like Appledocs, Javadocs, Kdocs, etc., to easily write and maintain SDK documentation.
There are, of course, many more best practices which our developers take care of while developing an IoT mobile SDK.
SDK integration includes many steps. First, initialize the device after creating the template. Based on the device connection, it implements a callback function. Successful execution of Init() enables telemetry data publication using the device SDK. Because the SDK relies on cached data from Init, it needs to establish a secure MQTT connection with the message broker to send data. Once the data communication is established, synchronize device configuration or conditions. Finally, send an acknowledgment to the cloud.
In all, a well-built mobile SDK saves developers’ time and efforts in building an IoT mobile app. No wonder that the competition in the SDK market keeps growing as in the apps market. That’s why a priority to the user experience when developing an IoT mobile SDK can help an individual to stand out from the crowd. The above-mentioned and many other SDK development best practices can be helpful to build and deploy mobile SDK into the host app seamlessly.