Skip to main content

Device SDK Overview

The Spotflow Device SDK is a set of libraries that enable you to connect your Devices to the Spotflow IoT Platform. The Device SDK provides the following features:

  • Simple interface: Instead of manually calling the Platform API and communicating via MQTT, you can use the provided libraries for Python and C.
  • Data persistence: All the Messages are temporarily stored in a local database file until they are successfully sent to the Platform. Therefore, you don't have to worry about losing data if connection fails or the Device restarts.
  • Connection handling: The Device SDK automatically reconnects to the Platform in the case of an Internet connection failure.

Architecture

The Device SDK provides a public interface that you can use to register the Device to the Platform and send data in the form of Messages. After it is initialized, the Device SDK spawns background threads that handle ongoing communication with the Platform:

  • They use the Platform API to periodically refresh the Registration Token.
  • They maintain the connection with the Platform MQTT Broker. The MQTT connection is used, among others, to send Messages to the Platform.
  • They upload the contents of large Messages to the Platform, because MQTT is unsuitable for this scenario.

The public interface does not communicate with the Platform directly so that it doesn't block the execution of your software if the Internet connection is slow or unreliable. Instead, it stores all the outgoing Messages in the local database file. The background threads extract the Messages from the file and send them to the Platform. If the Internet connection works, each Message is sent immediately. Otherwise, the pending Messages are sent when the connection is restored in the order in which they were stored in the local database file.

The following diagram summarizes how the Device SDK works:

Requirements

We currently compile the Device SDK for Linux, Windows, and macOS (macOS is now supported only in Python). Supported CPU architectures for each operating system are listed for each language: Python, C.

Contact us if you need the Device SDK for a different operating system and CPU architecture combination. It should be possible to compile the Device SDK for any operating system that supports the following:

  • File system: The local database file is essential for ensuring data persistence.
  • Threading: Multiple threads handle the connection in the background, making the public interface of the Device SDK simple.

Source Code

We're working on making the Device SDK open-source. If you want early access to the source code, contact us and describe your use case.