User Tools

Site Tools


getting_started_iotivity_services_for_tizen_0_9_1

IoTivity Services: Getting Started for Tizen

This guide provides instructions and resources to help developers set up the development environment, build the IoTivity stack and build sample applications for Tizen. 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 Tizen 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 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.

GBS

GBS (git-build-system) is a developer command line tool that supports Tizen package development. GBS is necessary to build the IoTivity code for Tizen platform. The following link contains information on how to install GBS.
https://developer.tizen.org/dev-guide/2.2.0/org.tizen.platform.development/html/platform_dev_env/gbs_installation.htm

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”

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

Build IoTivity Project for Tizen Platform with SCons

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

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

  $ source gbsbuild.sh

2. After successful build, extract the required libraries from generated rpm (iotivity-x.x-x.armv7l.rpm) to run the applications of iotivity services.

  Path for generated RPM: 
  <home directory>/GBS-ROOT/local/repos/tizen/armv7l/RPMS/iotivity-x.x.x.armv7l.rpm

Build and Run Protocol Plugin Manager Sample Application

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

The path for Protocol Plugin Manager directory is as following;

  iotivity/service/protocol-plugin/

The protocol-plugin directory includes following sub directories

Directories Description
build It contains the CMakeLists file for Tizen
lib It contains cpluff library used by plugin Manager.
plugin-manager It contains the APIs that control the plugins i.e. start Plugin, stop Plugin etc.
plugins It contains the plugins.The new plugins should be placed inside this folder
sample-app/tizen It contains the sample application for Tizen.

If you want to check how Protocol plugin works, you can run the Tizen sample application – PPMSampleApp.

Protocol Plugin Manager Sample Application

In this sample application, you can start “mqtt-fan” plugin, find a fan resource and perform some operations with the fan resource. The sample application initially creates an instance of PluginManager and starts the “mqtt-fan” plugin by passing its resource type (“oic.fan”) to startPlugins() API of PluginManager. The startPlugins() API internally creates a resource server. Then the application finds the resource server using the findResource() base API of OCPlatform. Once the fan resource found, application will send put request to change the power of the fan resource (1 - on, 0 - off) repeatedly until we close the application.

Pre-requisites

  1. Tizen SDK 2.3.

  2. Sample application uses boost libraries. Download it from http://www.boost.org/ and keep it unzipped.

  3. Mosquitto server should be running in the same subnet.
    Steps to run Mosquitto on linux:
    1. Install Mosquitto: apt-get install mosquitto
    2. Run Mosquitto on a particular port: mosquitto -p <PortNumber>

  4. Mosquitto server's IP address and Port number should be specified in the fanserver.cpp file before building the iotivity code for tizen: iotivity\service\protocol-plugin\plugins\mqtt-fan\src\fanserver.cpp .

    In the function start_fanserver, update the IP and Port number of the mosquitto server. Suppose the mosquitto server IP is : “192.168.1.8” and port is : 1666 then the code should be as shown below (Line 495 in fanserver.cpp):
            if (mosquitto_connect(myMosquitto, "192.168.1.8", 1666, 60) != MOSQ_ERR_SUCCESS)

Build procedure

  1. Open Tizen 2.3 IDE.

  2. Import PPMSampleApp to Tizen IDE.
    Follow the below steps for importing the sample application.
    1. File Menu→ Import → Tizen → Tizen Native Projects.
    2. Enter path for importing
      “iotivity/service/protocol-plugin/sample-app/tizen”.

  3. Copy the below mentioned libraries extracted from the IoTivity RPM to the lib folder in PPMSampleApp:
    • liboc.so
    • liboctbstack.so
    • liboc_logger.so
    • libconnectivity_abstraction.so
    • libuuid.so
    • libpmimpl.so
    • libppm.a

  4. Also, copy:
    • libboost_system.so and libboost_thread.so from <home directory>/GBS- ROOT/local/BUILD-ROOTS/scratch.armv7l.0/usr/lib to “lib” folder of the project.
    • fanserver_mqtt_plugin.so (from extracted RPM) to “/lib/plugins/mqtt-fan/” folder of the project.

  5. Include path to boost libraries as mentioned below:
    Right click the project in IDE → Properties → expand C/C++ Build → Settings → Tool Settings → select “includes” option under C++ Compiler → add the path of the unzipped boost libraries in the include paths area → Apply → OK.

  6. Build PPMSampleApp projects.

Run sample application

Right click the PPMSampleApp → Run As → Tizen Native Application

Build and Run Soft Sensor Manager Sample Application

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

The path for Soft Sensor Manager directory is as following:

  iotivity/service/soft-sensor-manager/

The soft-sensor-manager directory includes following sub directories:

Directories Description
Build It contains whole library files and binary files.
SampleApp/tizen It contains the SSM sample application. The application can be imported into tizen 2.3 SDK to build and to run.
SDK/cpp It conatins the C++ 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.

Pre-requisites

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.

Build procedure

  1. Import SSMTesterApp to Tizen IDE.
    Follow the below steps for importing the sample application.
    1. File Menu→ Import → Tizen → Tizen Native Projects.
    2. Enter path for importing:
      “iotivity/service/soft-sensor-manager/SampleApp/tizen”

  2. Create a lib folder in SSMTesterApp (if not exists) and copy the below mentioned libraries extracted from the iotivity RPM:
    • liboc.so
    • liboctbstack.so
    • libconnectivity_abstraction.so
    • liboc_logger.so
    • libuuid.so
    • libSSMCore.so
    • libSSMSDK.a
    • libDiscomfortIndexSensor.so

  3. Also copy,
    • SoftSensorDescription.xml from “\service\soft-sensor-manager\SoftSensorPlugin“ to “lib” folder of the project.

  4. Build SSMTesterApp project.

Build and Run Things Manager Sample Application

Once the IoTivity base stack and services are built for Tizen, you may follow the steps to build and execute the sample Things Manager Tizen application. 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
Build It contains the build script files.
Sampleapp/tizen It contains the sample applications for Tizen.
Sdk It contains the SDK APIs for applications. The main functionality of this SDK is to provide developer-friendly APIs of Things manager component to application developers.

If you want to check how things-manager is working, you can run the Tizen sample applications – TMSampleApp and ConServerApp.

Pre-requisites

1. The sample applications (TMSampleApp, ConServerApp) depend on other Linux applications for functionality testing, so build iotivity project for Linux platform. (refer Readme.scons.txt available in iotivity home directory).

2. Con-server(Linux) and bootstrapserver(Linux) should be running in the same test environment for testing configuration features.

3. Lightserver(Linux) and bookmark(Linux) should be running in the same test environment to test group action features.

4. Sample application uses boost libraries which are available as a zipped folder under “iotivity/extlibs/boost”. Unzip it.

Build procedure

  1. Import TMSampleApp and ConServerApp to Tizen IDE. Follow the below steps for importing the sample applications.
    1. File Menu→ Import → Tizen → Tizen Native Projects
    2. Enter path for importing:
      “iotivity\service\things-manager\sampleapp\tizen”

  2. Create a lib folder in TMSampleApp and ConServerApp projects (if not exists) and copy the below mentioned libraries extracted from the iotivity RPM.
    • liboc.so
    • liboctbstack.so
    • libconnectivity_abstraction.so
    • liboc_logger.so
    • libuuid.so
    • libTGMSDKLibrary.so

  3. Include path to boost header files and libraries as mentioned below for both TMSampleApp and ConServerApp projects (Unzip the boost libraries if not done already)
    Right click the project in IDE → Properties → expand C/C++ Build → Settings → Tool Settings → select includes option under C++ Compiler → add the path of the unzipped boost libraries in the include paths area → Apply → OK

  4. Build TMSampleApp and ConServerApp projects and launch the applications.

Run the projects

  1. Launch TMSampleApp and ConServerApp projects on Tizen devices.

  2. To test GroupAction features
    1. Run Lightserver(Linux) and bookmark(Linux) on linux machine.
      Follow the below steps to run the lightserver and bookmark
      • export LD_LIBRARY_PATH to <iotivity>/out/linux/<arch>/release
      • Navigate to the below path:
        “iotivity/out/linux/{arch}/release/service/things-manager/sampleapp/linux/groupaction”
      • To run lightserver, execute the command: “./lightserver”
      • To run bookmark, execute the command “./bookmark”
    2. Using TMSampleApp, group action features can be tested.

  3. To test Configuration features
    1. Run bootstrapserver(Linux) on linux machine
      Follow the below steps to run the bootstrapserver
      • export LD_LIBRARY_PATH to iotivity/out/linux/{arch}/release
      • Navigate to the below path:
        “iotivity/out/linux/{arch}/release/service/things-manager/sampleapp/linux/configuration”
      • To run lightserver, execute the command: “./bootstrapserver”
    2. Using ConServerApp, configuration features can be tested.

Build and Run Notification Manager Sample Application

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

The path for Notification Manager directory is as following:

  iotivity/service/notification-manager/

Pre-requisites

  1. Sample application (NMSampleApp) 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. sampleprovider(Linux) application and sampleconsumer(Linux) application should be running in the same test environment for testing configuration features.
  3. Sample application (NMSampleApp) uses boost libraries which are available as a zipped folder under “iotivity/extlibs/boost”. Unzip it.

Build and Run procedure

  1. Import NMSampleApp to Tizen IDE.
    Follow the below steps for importing the sample application.
    1. File Menu→ Import → Tizen → Tizen Native Projects
    2. Enter path for importing
      “iotivity/service/notification-manager/SampleApp/tizen”

  2. Create a lib folder in NMSampleApp (if not exists) and copy the below mentioned libraries extracted from the iotivity RPM.
    • liboc.so
    • liboctbstack.so
    • libconnectivity_abstraction.so
    • liboc_logger.so
    • libNotificationManager.so
    • libuuid.so

  3. Include path to boost header files and libraries as mentioned below
    Right click the project in IDE → Properties → expand C/C++ Build → Settings → Tool Settings → select includes option under C++ Compiler → add the path of the unzipped boost libraries in the include paths area → Apply → OK.

  4. Build and run NMSampleApp project.
getting_started_iotivity_services_for_tizen_0_9_1.txt · Last modified: 2016/07/28 13:45 by Phil Coval