User Tools

Site Tools


getting_started_iotivity_services_for_linux_0_9_1

IoTivity Services: Getting Started for Linux

This guide provides instructions and resources to help developers set up the development environment, build the IoTivity stack and build sample applications for Linux. Developers should also read the IoTivity Programmer’s Guide before starting development to better understand IoTivity architecture and use cases.

Tools and Libraries

The following tools and libraries are necessary to build the IoTivity code in Linux for Linux platform. The commands and instructions provided in this section are specific to Ubuntu LTS 12.04. Open the terminal window, use the following instructions to install all the necessary tools and libraries to build an IoTivity project.

Ubuntu LTS 12.04

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

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

ssh

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

SCons is a build tool used for compiling IoTivity source code. Please refer to the following link to install SCons http://www.scons.org/doc/production/HTML/scons-user.html#chap-build-install

Doxygen

Doxygen is a documentation generation tool used to generate API documentation for the IoTivity project. Download and install doxygen by running following command in your terminal window.

  $ sudo apt-get install doxygen

Checking Out the Source Code

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.

Step 1: Create 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_here>”

For example John Doe with an email address john.doe@example.com would type:

  $ ssh-keygen –t rsa –C “John Doe john.doe@example.com”

After pressing the Enter key at several prompts, an ssh key-pair will be created at ~/.ssh/id_rsa.pub.

Step 2: Upload and register an ssh public key

1. Log in to IoTivity Gerrit.

2. Click on Settings on the top right side as shown here:

3. Click on SSH Public Keys and add key.

4. Open ~/.ssh/id_rsa.pub, copy the content, and paste the content in the “Add SSH Public Key” window.

5. Click Add.

Step 3: Setting up ssh

1. Open ~/.ssh/config in a text editor.

2. Add the following lines:

  Host iotivity gerrit.iotivity.org
  Hostname gerrit.iotivity.org
  IdentityFile ~/.ssh/id_rsa
  User <Insert_Your_Name_Here>
  Port 29418

3. 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

Step 4: Verify your ssh connection

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.

Step 5: Cloning the project source

To build the IoTivity resource stack:

1. Using your terminal window, browse to the directory where code will be checked out.

2. Execute the following command in the terminal window to clone the iotivity repository:

  $ git clone iotivity:iotivity
  or
  $ git clone ssh://gerrit.iotivity.org/iotivity

This command clones the repository in your current working directory.

Build IoTivity project for Linux Platform with SCons

To run the applications of IoTivity services on Linux machine, IoTivity stack should be built for Linux platform. SCons tool is used to build for Linux platform.

1. Build IoTivity base stack libraries and services libraries using this command. Run the below command in the top directory of IoTivity project.

  $ scons

2. After successful build, user can find the “out” folder in “~iotivity”

Build C/C++ API Reference Documentation

To build the API Reference Documentation

1. Navigate to iotivity/resource/docs folder using the terminal window.

2. Run the following command:

  $ doxygen

This command builds the API reference documentation in the output directory. The output directory for this command is resource/docs/html/index.html.

Run Protocol Plugin Manager Sample Application

Once the IoTivity base stack and services are built for Linux, you may follow the steps to execute the sample Protocol Plugin Linux application. In this context, we assume that the code was cloned into ‘iotivity’ folder.

The path for Protocol Plugin Manager is as following;

  iotivity/service/protocol-plugin/

The protocol-plugin directory includes following sub directories

Directories Description
lib It contains cpluff library used by plugin Manager.
plugin-manager Provides the APIs to control the plugins i.e. start Plugin, stop Plugin etc.
plugins It is the folder where plugins are located. If we want to add any new plugin it should be located under this folder.
sample-app/linux It has the sample application for Linux.

Pre-requisites

IoTivity code which is built for Linux platform.

Follow the given steps to run the Linux sample:

1. Copy “libpmimpl.so”

  From:“~/iotivity/out/linux/x86/release/service/protocol-plugin/plugin-manager”
  To:  “~/iotivity/service/protocol-plugin/sample-app/linux/mqtt”

2. Copy “mqttclient”

 From:“~/iotivity/out/linux/x86/release/service/protocol-plugin/sample-app/linux/mqtt”
 To:  “~/iotivity/service/protocol-plugin/sample-app/linux/mqtt”

3. Copy “fanserver_mqtt_plugin.so”

  From:“~/iotivity/out/linux/x86/release/service/protocol-plugin/plugins/mqtt-fan”
  To:  “~/iotivity/service/protocol-plugin/plugins/mqtt-fan”

4. Copy “plugin.xml”

  From: “~/iotivity/service/protocol-plugin/plugins/mqtt-fan/build/linux”
  To:  “~/iotivity/service/protocol-plugin/plugins/mqtt-fan”

Run the Linux Sample (mqttclient)

1. Set the Library path:

  export LD_LIBRARY_PATH=“~/iotivity/out/linux/x86/release/”

2. Change the directory to “~/iotivity/service/protocol-plugin/sample-app/linux/mqtt” and run the sample:

  ./mqttclient

Run Soft Sensor Manager Sample Application

Once the IoTivity base stack and services are built for Linux, you may follow the steps to execute Soft Sensor Manager and its applications. In this context, we assume that the code was cloned into iotivity folder. The path for Soft Sensor Manager is as following;

  iotivity/service/soft-sensor-manager/

The soft-sensor-manager directory includes following sub directories

Directories Description
build Whole library files and binary files would be made in this folder
SampleApp/linux There are two types of sample applications; application for UI, and application for physical sensors.

For UI application, there is SSMTesterApp in linux folder
For physical sensors,
1) Temperature and Humidity sensors, THSensorApp, in linux folder and arduino folder.
In the two directories, in linux folder and arduino folder , there are two TemperaterHumiditySensor applications, THSensorApp and THSensorApp1, and they are for DiscomfortSoftSensor which aggregates two TemperaterHumiditySensors to calculate current discomfort index in the given room.
*Note: THSensorApp, THSensorApp1, SSMTesterApp and few other applications are available in root directory of soft-sensor-manager (~/iotivity/out/linux/<arch>/release/soft-sensor-manager/) and can be directly launched after setting the LD_LIBRARY_PATH environment variable as specified in the below section.
2) Trackee_Thing and Reference_Thing for IndoorTrajectorySensor in arduino folder
SDK/cpp Provides the C++ SDK APIs for Soft Sensor Manager service.
SSMCore The SSM service codes
SoftSensorPlugin The source codes for example soft sensors can be located in this folder.
Examples of soft sensors are DiscomfortIndexSensor and IndoorTrajectorySensor.

Built libraries can be located in this folder.

  iotivity/out/linux/{TARGET_ARCH}/release

If you want to check how soft sensor manager works, you can run the sample applications – THSensorApp, THSensorApp1 and SSMTesterApp. Both THSensorApp and THSensorApp1 should be started before SSMTesterApp.

To initiate THSensorApp, please enter as following:

  $ cd iotivity/out/linux/{TARGET_ARCH}/release/service/soft-sensor-manager/
  $ export LD_LIBRARY_PATH=“~/iotivity/out/linux/x86/release/”
  $ ./THSensorApp

To initiate THSensorApp1, please enter as following:

  $ cd iotivity/out/linux/{TARGET_ARCH}/release/service/soft-sensor-manager/
  $ export LD_LIBRARY_PATH=“~/iotivity/out/linux/x86/release/”
  $ ./THSensorApp1

To initiate SSMTesterApp, please enter as following:

  $ cd iotivity/out/linux/{TARGET_ARCH}/release/service/soft-sensor-manager/
  $ export LD_LIBRARY_PATH=“~/iotivity/out/linux/x86/release/”
  $ ./SSMTesterApp

Run Things Manager Sample Application

Once the IoTivity base stack and services are built for Linux, you may follow the steps to execute Things Manager and its applications. In this context, we assume that the code was cloned into iotivity folder. The path for Things Manager is as following;

  iotivity/service/things-manager/

The things-manager directory includes following sub directories

Directories Description
sdk The SDK APIs for applications is located. The main functionality of this SDK is to provide developer-friendly APIs of Things manager component to application developers.
sampleapp It is the sample application on Ubuntu. Basically, the input and output of application on Ubuntu are displayed in the console.
build Whole library files and binary files would be made in this folder.

The way to run Things Manager sample application is much similar to each one of all applications. For this reason, the below describes a way to run a configuration resource server as an example.

1. Set the Library path:

  export LD_LIBRARY_PATH=“~/iotivity/out/linux/x86/release/”

2. Change directory as following:

  $ cd ~/iotitivity/out/linux/x86_64/release/service/things-manager/sampleapp/linux/configuration

3. To run a configuration resource server, please enter as following:

  $ ./con-server

Run Notification Manager Sample Application

Once the IoTivity base stack and services are built for Linux, you may follow the steps to execute Notification Manager and applications. In this context, we assume that the code was cloned into iotivity folder. The path for Soft Sensor Manager is as following;

  iotivity/service/notification-manager/

The notification-manager directory includes following sub directories

Directories Description
build Whole library files and binary files would be made in this folder
SampleApp There are three types of sample application; application for Provider, application for Consumer and application for Notification Manager.

For Provider, there is the SampleProviderApp which is a TemperatureHumiditySensor in linux and Tizen.
For Consumer, there is the SampleConsumer which is a ClientApp in linux and Tizen.
For Notification Manager, there is the SampleNotificationManager App.
NotificationManager The source code location for Notification Manager

To run SampleProvider, please enter as following;

  $ cd iotivity/out/linux/x86/release/service/notification-manager/SampleApp/linux 
  $ ./sampleprovider

To run Sample for NotificationManager, please enter as following;

  $ cd  iotivity/out/linux/x86/release/service/notification-manager/SampleApp/linux
  $ ./notificationmanager

To run SampleConsumer, please enter as following;

  $ cd  iotivity/out/linux/x86/release/service/notification-manager/SampleApp/linux
  $ ./sampleconsumer
getting_started_iotivity_services_for_linux_0_9_1.txt · Last modified: 2015/07/13 13:32 by Senthil Kumar G S