This guide provides instructions and resources to help developers set up the development environment, build the IoTivity stack and build sample applications for Android platform. Developers should also read the IoTivity Programmer’s Guide before starting development to better understand IoTivity architecture and use cases.
The following tools and libraries are necessary to build the IoTivity code in Linux for Android platform. The commands and instructions provided in this section are specifically for Ubuntu LTS 12.04. Open the terminal window and use the following instructions to install all the necessary tools and libraries to build an IoTivity project.
Ubuntu LTS version 12.04 is the supported OS for building the IoTivity stack. The instructions may be different for other versions of Ubuntu and Linux.
Git is a source code management software. Git is necessary to gain access to the IoTivitiy source code. Use the following command to download and install git:
$ sudo apt-get install git-core
Secure Shell is required to connect to the git repository to check out the IoTivity source code. Secure Shell is typically part of the base operating system and should be included. If for any reason it is not available, it can be installed by running the following command in your terminal window:
$ sudo apt-get install ssh
SCons is a build tool used for compiling IoTivity source code. Please refer to the following link to install SCons:
Android NDK is a tool required for building IoTivity project for Android platform. Please refer the below links on how to install Android NDK:
If you do not need a proxy to access the internet just skip this section.
The gradle proxy setting are configured in $HOME/.gradle/gradle.properties if it does not exists create it.
systemProp.http.proxyHost=www.somehost.org systemProp.http.proxyPort=8080 systemProp.http.proxyUser=userid systemProp.http.proxyPassword=password systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost systemProp.https.proxyHost=www.somehost.org systemProp.https.proxyPort=8080 systemProp.https.proxyUser=userid systemProp.https.proxyPassword=password systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost
The Andoird build proxy settings are stored in this file: $HOME/.android/androidtool.cfg
http.proxyPort=<YOUR_PORT_NUMBER> sdkman.monitor.density=108 http.proxyHost=<YOUR_HTTP_PROXY_ADDRESS> sdkman.show.update.only=true sdkman.ask.adb.restart=false sdkman.force.http=true sdkman.show.updateonly=true
Gerrit is a web-based code review tool built on top of the git version control system. Gerrit’s main features are side-by-side difference viewing and inline commenting, streamlining code review. Gerrit allows authorized contributors to submit changes to the git repository after reviews are done. Contributors can have code reviewed with little effort, and get their changes quickly through the system.
The following five steps describe how to check out the source code on the development machine.
Note: skip Step 1 to use existing ssh keys.
On the terminal, type the following (replace “your name <your_email_address>” with your name and email address):
$ ssh-keygen –t rsa –C “your_name your_email_address”
For example John Doe with an email address firstname.lastname@example.org would type:
$ ssh-keygen –t rsa –C “John Doe email@example.com”
After pressing the Enter key at several prompts, an ssh key-pair will be created at ~/.ssh/id_rsa.pub.
A. Log in to IoTivity Gerrit.
B. Click on Settings on the top right side as shown here:
C. Click on SSH Public Keys and add key.
D. Open ~/.ssh/id_rsa.pub, copy the content, and paste the content in the “Add SSH Public Key” window.
E. Click Add.
A. Open ~/.ssh/config in a text editor.
B. Add the following lines:
Host iotivity gerrit.iotivity.org Hostname gerrit.iotivity.org IdentityFile ~/.ssh/id_rsa User <Insert_Your_Name_Here> Port 29418
C. To connect behind the proxy, add the following line after IdentityFile ~/.ssh/id_rsa with the appropriate proxy address and port:
ProxyCommand nc –X5 –x <proxy-address>:<port> %h %p
Execute the following command in the terminal window:
$ ssh gerrit.iotivity.org
Upon successful connection, the following message should appear indicating proper ssh and configuration connection.
∗∗∗∗ Welcome to Gerrit Code Review ∗∗∗∗
If the connection is not established, check for the proxy and use the proxy settings described in Step 3.
To build the IoTivity resource stack:
A. Using your terminal window, browse to the directory where code will be checked out.
B. Execute the following command in the terminal window to clone the oic-resource and oic-utilities repositories:
$ git clone iotivity:iotivity or $ git clone ssh://gerrit.iotivity.org/iotivity
This command clones the repository in your current working directory.
To run the applications of IoTivity services on Android targets, IoTivity stack should be built for Android platform. SCons tool is used to build for Android platform.
A. Build IoTivity base stack libraries and services libraries using this command. Run the below command in the top directory of IoTivity project.
$ scons TARGET_OS=android TARGET_ARCH=XXX TARGET_TRANSPORT=IP
Note: XXX can be x86, armeabi, armeabi-v7a, armeabi-v7a-hard.
B. After successful build, user can find the “out” folder having the libraries in the directory where scons command is given.
Once the IoTivity base stack and services are built for Android, you may follow the steps to run the sample Protocol Plugin Android application. In this context, we assume that the code was cloned into ‘iotivity’ folder.
The path for Protocol Plugin Manager directory is as follows;
The protocol-plugin directory includes following sub directories
|lib||It contains cpluff library used by plugin Manager.|
|plugin-manager/src||It has plugin manager service (.cpp and .h) files.|
|plugins/Android||It is the folder where plugins are located. If we want to add any new plugin it should be located under this folder.|
|plugin-manager/src/Android||It is the sample application for Android.|
A. Build the iotivity code to get the *.so libraries for Android platform.
B. Download felix.jar from http://felix.apache.org/downloads.cgi
C. Build gearnoti.jar, hue.jar and wemo.jar using a Plug-in project in Eclipse IDE
$ cd $ANDROID_SDK/build_tool/22.0.1 $ dx --dex --output=classes.dex $WEMO_JAR $ aapt add $WEMO_JAR classes.dex
A. Import PPM Sample Application project to Eclipse IDE. Follow the below steps for importing the sample application
B. Add external JARs felix.jar (as explained in Pre-requisites Section) and classes.jar to the Java Build path of the application.
Right click the project in IDE → Properties → Java Build Path → Libraries → Add External Jars → select classes.jar and felix.jar files → OK.
Path for the classes.jar: “(~/iotivity/android/android_api/base/build/intermediates/bundles/release)”
C. Create(if not exist) libs/armeabi/ folder in the above project and copy the below mentioned libraries:
Path for the above libs: “iotivity/android/android_api/base/libs/armeabi”
Path for the above libs: “iotivity/out/android/armeabi/release”
D. Copy gearnoti.jar, hue.jar, wemo.jar files created previously (refer Pre-requisites section) to the “assets/files” folder of the project.
E. Right click on the project → Build project
Right Click the project → Run As → Android Application. This will launch the application on the Android device.
Once the IoTivity base stack and services are built for Android, you may follow the steps to build and execute Soft Sensor Manager and its applications. In this context, we assume that the code was downloaded into ‘iotivity’ folder. The path for Soft Sensor Manager directory is as follows;
The soft-sensor-manager directory includes following sub directories
|build||It contains library files and binary files.|
|SampleApp/android||It contains the SSM sample application. The application can be imported into eclipse to build and to run on any android device.|
|SDK/java||It contains the Java SDK APIs for Soft Sensor Manager service.|
|SSMCore||It contains the SSM service codes|
|SoftSensorPlugin|| It contains the source codes, for example : soft sensors .
Examples of soft sensors are DiscomfortIndexSensor and IndoorTrajectorySensor.
Built libraries are located in this folder.
1. Sample application (SSMTesterApp) depends on other Linux applications for functionality testing , so build the iotivity project for Linux platform. (refer Readme.scons.txt available in iotivity home directory).
2. Run the Linux THSensorApp & Linux THSensorApp1 to test the SSM functionality.
Steps to run: - Export LD_LIBRARY_PATH to “<iotivity>/out/linux/<arch>/release”. - Run THSensorApp and THSensorApp1 application from the below path: <iotivity>/out/linux/<arch>/release/service/soft-sensor manager/ Note: '<iotivity>' is the path to 'iotivity' project.
Once the IoTivity base stack and services are built for Android, you may follow the steps to build and execute the sample Things Manager Android application. In this context, we assume that the code was cloned into ‘iotivity’ folder.
The path for Things Manager directory is as following:
3. The sample applications (Sample and con-server) depend on other Linux applications for functionality testing, so build iotivity project for Linux platform. (refer Readme.scons.txt available in iotivity home directory).
4. Con-server(Linux) and bootstrapserver(Linux) should be running in the same test environment for testing configuration features.
5. Lightserver(Linux) and bookmark(Linux) should be running in the same test environment to test group action features.
Once the IoTivity base stack and services are built for Android, you may follow the steps to build and execute the Resource Hosting Sample applications. In this context, we assume that the code was cloned into ‘iotivity’ folder.
The path for Resource Hosting directory is as following: