Add Thing-IF SDK
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.
You need the following preparations.
Get a GitHub account
Access the GitHub and create your account.
Configure the public key
While building the SDK, the sub-modules will be automatically downloaded via the SSH connection. You need to create a key pair and register the public key on GitHub for this.
If the public key is not set, you will get an error when you execute
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.
Download the source code from GitHub and build it in the following steps.
Download thing-if SDK
In the working directory, execute the following command in the shell to download the SDK.
$ git clone https://github.com/KiiPlatform/thing-if-ThingSDK $ cd thing-if-ThingSDK
Download the submodules (described in SDK Structure) with the following commands.
$ git submodule init $ git submodule update $ cd kii $ git submodule init $ git submodule update $ cd ../
Build the SDK
If your environment is Linux, execute the make command under the thing-if-ThingSDK directory to build the libkiithingifsdk.so file. You can integrate this file into your program as the SDK library.
If your environment is not Linux, use the Makefile for Linux as a reference to build libraries and execution modules.
Building sample programs
The linux-sample directory in the downloaded source code contains 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, AppKey, and Site are hard-coded in the source code. Please change them to the values of your application.
The file to update is linux_sample/example.h. Find the following three lines in the file and update them to your Kii Cloud application's value. 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 EX_APP_ID = "01234567"; const char EX_APP_KEY = "0123456789abcdef0123456789abcdef"; const char EX_APP_SITE = "JP";
Build the sample program
Execute the make command to build the sample program.
$ cd linux-sample $ make
Run some tests
The executable module example app will be generated in the working directory when the build is done. Please read linux_sample/README.mkd file and the source code for the available options.
Include the kii_thing_if.h file in all the source files which will use the Thing-IF SDK.
You can use the tuning function of the Thing SDK Embedded and parse JSON by including the kii_thing_if.h file. The kii_thing_if.h file internally includes the kii.h and kii_json.h files.
Porting to Your Target Environment
The Thing-IF SDK provides an implementation sample for Intel Edison, Ti CC3200, and Linux. You can easily port the SDK to other environments.
See Implementing OS-dependent Processes for the Thing SDK Embedded to learn how to port the SDK.