Add Thing-IF SDK v2
The Thing-IF SDK for Thing is provided as source code in GitHub. In this topic, we explain how to download the source code from GitHub, prepare the build environment, and build the libraries and test programs.
The source code contains the reference implementation for some environments. The reference implementation already includes libraries that provide some fundamental features like a socket and multi-task support. See here for more discussion.
Here, we present how to build the reference implementation for Linux. If you want to build programs for other environments, use this topic as a reference to create execution modules.
Preparation
You need the following preparations.
Get a GitHub account
Access the GitHub and create your account.
Install the build tools
Install and configure the build tools like git, gcc, make, Doxygen, and openssl.
The above preparation task is not Kii Cloud dependent, so please refer to the information on the Web for the detailed instructions.
Library structure
The SDK consists of the following four libraries:
tio
This is the SDK's main library. It provides features such as receiving commands and updating states.
kii
This library provides features such as sending and receiving data to and from Kii Cloud.
khc
This library provides the communication features compliant to HTTP 1.1.
jkii
This library provides the data parsing feature. The library uses
jsmn
internally.
A set of these four libraries is called ebisu (Embedded IoT Suite)
. See ebisu-doc for the details of these libraries.
Building libraries
Download the source code from GitHub and build it in the following steps.
Download thing-if SDK v2
In the working directory, execute the following command in the shell to download the SDK.
$ git clone https://github.com/KiiPlatform/ebisu $ cd ebisu
Build the SDK
If your environment is Linux, you can install the SDK onto your working directory with the cmake. Check the following commands for creating an SDK directory (.sdk) and installing the SDK.
$ mkdir .sdk $ cd .sdk $ cmake -DCMAKE_BUILD_TYPE=[RELEASE/DEBUG] [Path to ebisu/tio] $ make $ make DESTDIR=. install
If your environment is not Linux, use the Makefile for Linux as a reference to build libraries and execution modules.
Building sample programs
The directory tio/linux-sample in the downloaded source code contains a sample code. This sample code is handy for testing some fundamental features of the SDK. Please build it as needed.
Change the AppID and other parameters
The AppID and Host are hard-coded in the source code. Please modify them with an editor as follows:
The file to update is tio/linux_sample/example.h. Find the following two lines in the file and update them to your Kii Cloud application's values. See here to learn how to create a Kii Cloud application and how to find its AppID and other parameters. To learn how these constants are used in the SDK initialization, see here.
const char KII_APP_ID[] = "01234567"; const char KII_APP_HOST[] = "JP";
Build the sample program
Execute the make command in tio/linux-sample to build the sample program.
This sample will install the SDK in the make process, so you do not need to install the SDK manually.
$ cd tio/linux-sample $ make
Run some tests
The executable module exampleapp will be generated in the working directory when the build is done. Please read tio/linux_sample/README.mkd file and the source code for the available options.
Including libraries
Include the tio.h file in all the source files which will use the Thing-IF SDK.
#include "tio.h"
If you've built the SDK manually, you can use the SDK by adding {Path to .sdk}/usr/local/include
in the include path and {Path to .sdk}/usr/local/lib
in the library path.
Porting to Your Target Environment
The Thing-IF SDK provides an implementation sample for GT202(Freescale K22), Ti CC3200, Avnet IoT Starter Kit (WICED), and Linux. You can easily port the SDK to other environments.