Structure with Gateway
This page explains the system structure when you are using the gateway. See also SDK Structure Overview for better understanding.
The following figure illustrates the structure of end nodes being connected via the gateway.
Mobile App
You can develop a mobile app for controlling things. End users will use this application to control the gateway and end nodes.
You need to integrate both Kii Cloud SDK and Thing-IF SDK in your mobile app. All the fundamental features are supported by Thing-IF SDK, but some features like user authentication need to be performed with Kii Cloud SDK (as you will need to do so when you are using Thing-IF SDK without gateway).
The SDK in the mobile app will access both Thing Interaction Framework and the gateway (gateway agent).
- Sending commands and browsing the thing state is made via Thing Interaction Framework over the internet. These operations can be performed outside the local network.
- Registering and replacing end nodes need to be performed inside the local network since the mobile app needs to access the gateway directly.
Gateway (Hardware/OS)
The gateway environment, such as the hardware and its OS, need to be prepared by you. You can use develop a new dedicated hardware (i.e., home server) or use the existing gateway product.
Gateway Agent
The gateway agent is a server process that runs on the gateway. You can download and leverage the agent that is a set of built binary files.
The gateway agent has the following three communication roles:
Serving as a client of Thing Interaction Framework
To interact with Thing Interaction Framework, the gateway agent connects to the Internet via HTTPS and MQTT. Requests to Thing Interaction Framework are sent via HTTPS, and the push notifications are received via MQTT. Only one MQTT connection is used even if multiple end nodes are connected to the gateway.
Serving as an HTTP server for the mobile app
The gateway agent serves as an HTTP server to accept the accesses from the mobile app via Wi-Fi.
The gateway agent provides REST API for registering and replacing end nodes. The mobile app can execute these API via the SDK to manage the things.
Serving as an MQTT server for the converter
The gateway agent acts as an MQTT server to accept the accesses from the converter (and end nodes).
The gateway agent controls end nodes together with the converter by sending commands to the end nodes and by receiving the states from the end nodes. It will communicate with the converter in the MQTT protocol, translate the data in MQTT protocol into the REST API of Thing Interaction Framework, and send it to Thing Interaction Framework via the Internet.
Converter
The converter acts as the gateway's interface for end nodes. The end node developer needs to implement the corresponding converter. The converter is responsible for translating the protocols that the end nodes speak (e.g., Bluetooth and Zigbee) into the MQTT protocol that the gateway agent accepts. If the gateway is implemented using the embedded Linux, you will implement the converter as a daemon process.
You can use our reference implementation when developing the converter. The reference implementation is provided with the source code, so you can use it as a skeleton to implement the necessary protocol quickly.
The reference implementation of the converter will be provided soon.
The converter supports only the features covered by Thing Interaction Framework. The features covered by Kii Cloud SDK and push notifications are not supported (it is possible to execute the REST API directly from the converter just like the Kii Cloud REST client).
The target end nodes are distinguished by the MQTT topic names in the MQTT protocol. The converter, therefore, can use one MQTT session to communicate with multiple end nodes at the same time.
The converter can be structured in one of the following ways:
- Implement dedicated converter processes for each end node type (as illustrated in the previous figure).
- Implement a single converter process that will handle multiple protocols.
End Nodes
The end nodes are the thing hardware and software that will access Thing Interaction Framework via the gateway. They are invisible from the gateway (i.e., only the converter is visible), so their entities can be freely distributed in any form.
Kii Cloud Application
You need to create an application on Kii Cloud for your IoT solution. You can create the application on the developer portal. All Thing Interaction Framework features will be run under this application.