User Tools

Site Tools


iotivity_tool_guide

IoTivity Tools

IoTivity Simulator

Using this tool we can simulate the OCF resources either with the help of Resource Model(RAML) file provided or manually through GUI wizards. Client feature can be used to test new resources created thoroughly to make sure its OCF compliant.


IoTivity Simulator is an eclipse plugin tool. It provides two perspectives.

Service Provider

  • OCF resources can be simulated by using Resource model definition(RAML) files.
  • OCF resources can also be created Using GUI wizards provided.
  • It manages creation, deletion, request handling and notifications of simulated resources.
  • It handles the requests received and sending appropriate responses to clients.
  • It provides support for changing attribute values both manually and automatically.

Below screenshot shows the “Service Provider Perspective” view. For details about the perspective, refer Simulator Eclipse Plug-In section.

Client Controller

  • Simulates functionality of OCF client.
  • It can find resources of interested types in the given network.
  • It provides support for observing resource changes.
  • It provides support for sending automatic requests (GET/PUT/POST) to remote resources with the help of remote resource RAML file.

Below screenshot shows the “Client Controller Perspective” view. For details about the perspective, refer Simulator Eclipse Plug-In section.

Using Simulator, you can test the working of an OCF device before purchasing the real hardware.

Installing the Eclipse Plugin

Two options are available to install the eclipse plugins. Choose any one of these options and proceed further as explained in the following sections.

  • Option 1: Direct Installation.
  • Option 2: Building the source code and Installing manually.

Option 1: Direct Installation

Pre-requisites

  1. Linux machine with internet access.
  2. Eclipse IDE(4.4 or above) for linux platform. If you need to install Eclipse, you can download it from http://www.eclipse.org/downloads.

Steps

  1. Start eclipse.
  2. Select Help > Install New Software…. In the dialog appears enter below mentioned URL in Work with text field and press enter key. Try with any of these URLs. If one URL doesn't seem to work, then try the alternative links (Following are the links for latest version. You can find the links to specific versions under “Available Versions” section).
  3. Uncheck Group items by category checkbox and Select simulator component and click Next.
  4. Review the features to be installed and then click Next.
  5. Read the license aggrement and then select I accept the terms of the license agreement. Click Finish.
  6. If you get security warning as shown below then click OK.
  7. Once installation is done, you will be asked to restart the eclipse. Click Yes.

Available Versions

Option 2: Building the source code and Installing manually

Pre-requisites

  1. Linux machine with internet access.
  2. Eclipse IDE(4.4 or above) with PDE(Plug-in Development Environment) support (Please refer Eclipse PDE setup section given below).
  3. Simulator has dependency on java, if java is not available in your system install the same (https://help.ubuntu.com/community/Java). We need java compiler 1.7 or above. After installing, Set the JAVA_HOME environment variable(ex: export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386).
  4. Download the latest version of IoTivity codebase from https://www.iotivity.org/downloads/ and extract it. (Note: For IoTivity version 1.2.1, an additional patch is required. Download the patch from https://gerrit.iotivity.org/gerrit/#/c/15369/2 and apply it to the downloaded IoTivity source code).
  5. Execute the “scons SIMULATOR=1 TARGET_TRANSPORT=IP TARGET_OS=linux SECURED=0” command from the IoTivity home directory(Location where the codebase is extracted. Ex: /home/user1/Downloads/iotivity) in the terminal to build Simulator specific libraries along with the IoTivity native libraries.
  6. During the build process, you will be prompted to download the packages required for build such as tinycbor and yaml. Please download those packages using the command which will be shown on-screen. After download completes, execute the command “scons SIMULATOR=1 TARGET_TRANSPORT=IP TARGET_OS=linux SECURED=0” again to continue the build process.
  7. Simulator application requires libconnectivity_abstraction.so, liboc.so, liboctbstack.so, and liboc_logger.so native libraries and libSimulatorManager.so, libRamlParser.so simulator specific libraries, all of which are generated in ~/<IoTivity home directory>/out/linux/<arch>/release directory.

Eclipse PDE setup

Please ignore this step if PDE is already installed in eclipse.

  • Open Eclipse → Help → Install new software → Add → Location(http://download.eclipse.org/eclipse/updates/4.4 (Version based on your eclipse), Name can be given anything, It will display all the list of updates available, select all PDE related items and follow the wizard steps to complete the installation.

Setting up and launching the Eclipse plug-in projects

  1. Import the below projects into Eclipse IDE using File → Import → Select 'Existing projects into Workspace' under General category → click next → Browse to the location as given below →Click Finish.
    • Service Provider Plugin: ~/<IoTivity home directory>/service/simulator/java/eclipse-plugin/ServiceProviderPlugin
    • Client Controller Plugin: ~/<IoTivity home directory>/service/simulator/java/eclipse-plugin/ClientControllerPlugin
    • Simulator Java SDK: ~/<IoTivity home directory>/service/simulator/java/sdk
  2. Service Provider Plugin and Client Controller Plugin are the Simulator plugin projects.
  3. Create a folder named libs in both the plugin projects. (Right-Click on the ServiceProviderPlugin → New → Folder → Specify the folder name as libs → Finish. Please do the same for ClientControllerPlugin project as well.)
  4. Export the Simulator Java SDK project as a JAR file named Simulator.jar. (Right click the Simulator Java SDK project → Export → select 'JAR file' option under Java → Next → Specify the name of the JAR file as Simulator.jar → Finish).
  5. Copy the Simulator.jar file into the libs folder of both the plugin projects(ClientControllerPlugin\libs\Simulator.jar and ServiceProviderPlugin\libs\Simulator.jar).
  6. Create a folder named linux-x86(If the libraries built on 32-bit machine) or linux-x86_64(If the libraries built on 64-bit machine) under /libs folder of both the plugin projects. (Right-Click on the libs folder which we created in the previous step → New → Folder → Specify the folder name → Finish. Please do this for both plugin projects.)
  7. Copy the libraries libSimulatorManager.so, libRamlParser.so, libconnectivity_abstraction.so, liboc.so, liboctbstack.so, and liboc_logger.so generated previously in ~/iotivity/out/linux/<arch>/release directory into the corresponding libs/<arch> folder of both the plug-in projects. If the libraries built on 32-bit machine, then copy them into /libs/linux-x86 and if the libraries are 64-bit, then copy them into /libs/linux-x86_64.
  8. Right click the project → Run as Eclipse Application.
  9. After launching if it doesn't show the Simulator perspectives(Service Provider & Client Controller), please choose the perspective manually from Windows→ Open Perspective → Other.

RAML and Json Schema requirements to Simulate a OIC Resource

  1. Each RAML Resource needs to provide a valid displayName and URI.
  2. RAML file defines the essential Methods supported by the resource. Supported Methods include GET, PUT, POST and DELETE. GET is a mandatory method to be supported that needs to be present with its valid response status as 200 specifying all the attributes describing the Resource.
  3. Each Request and Response can specify a schema which can be either inlined in RAML file or can be included in a separate Json Schema file.
  4. Json Schema need to provide the attributes such as “rt” and “if”. If these attributes are not present in json schema, then default values will be constructed(Default value for “rt” is “oic.r.abc” where abc will be replaced with the last word/token in the resource URI, Default value for “if” is “oic.if.baseline”).
  5. Attributes specified in Json schema may optionally provide a default value.
  6. For utilizing automation feature of Simulator, Attributes need to have AllowedValues(enum) or range(minumum,maximum) specified in the schema.
  7. If default value for attributes is not specified in Json Schema, the first value in the enum or range will be taken as the default value. If enum and range are not available, then a default value based on the data type of the attribute will be taken(Example: 0 for integer and false for boolean).
  8. RAML example can be found at BinarySwitch. Note: Please convert the word document to raml before testing it from Simulator plug-in(Change the extension of the file from .doc to .raml).

Simulator Eclipse Plug-In

Simulator Manager It manages creation/deletion of single or multiple simulated resources as per the configurations provided. It creates the simulator resource either with the information provided from RAML file or with the information provided through GUI wizards.

When you click on Create button in Resource Manager pane of Service Provider perspective, a dialog is shown where you can either select “Simple resource(From RAML)” and browse for a RAML file or you can select “Simple resource” and create it manually. Multi-instance creation support is available only while creating resource through RAML.

Now the list of resources created will be displayed in the Resource Manager pane. When a resource is selected, it shows the attributes and properties of the selected resource in Attribute Manager pane and Properties pane respectively as shown in the below screenshot.

If you wish to delete a resource, select the resource and right-click on it, which shows a menu to delete that resource. To delete one or more resource(s) at a time, click on the Delete button in Resource Manager pane which will open a dialog showing all resources, select the resources and click OK. Screenshot is shown below.

Simulator Resource Server It represents a simulated resource and handles all the requests received and sends proper responses to client. When server receives any GET/PUT/POST/OBSERVE requests, service provider perspective shows the log messages with the request information and sends appropriate responses as shown in below few screenshots. Also service provider perspective shows a list of observers for a selected resource in Resource Observers tab in Properties pane.

Double-clicking log entries opens a new dialog which shows more information such as payload.

Service Provider provides automation feature where all possible values for a given attribute or all attributes of a selected resource are changed sequentially as shown in below screenshots. To start attribute level automation, click on an attribute in Attribute Manager pane and tick the Automation column checkbox (by default it will be disabled), a dialog will be shown where you can input the type of automation you want - NORMAL (only once) or RECURRENT (in a loop) and choose a suitable Update Frequency (duration between updating values of an attribute) and click OK. This will trigger attribute-level automation. To start resource-level automation, right click a resource and select Start Automation. Select Automation type and update frequency and click OK. This triggers resource-level automation.

Simulator Client It searches for the resources available in the network based on the users interested resources type. To find resources in the network, click on Find Resources button of Client-Controller perspective and either select “All” to search for all available resources or perform a customized search by selecting “Specific Resource Types” and click OK.

Simulator Remote Resource It represents a remote server from client side and provides interface for sending different requests to server. Discovered resources are shown in Resource Manager panel. If you perform frequent operations on few specific resources, you can right click on each of them and click on Add to Favorites. These resources will be shown in Favorite Resources tab of Resource Manager pane. If you want to perform any operations on a found resource, select the resource and click on GET/PUT/POST buttons in Attribute Manager pane. A dialog will be shown where you can modify the values of attributes if required and click OK. This will send corresponding messages to Server and receive responses from server. Response payload will be shown in Simulator Log panel.

Client-Controller also supports Automation where GET/PUT/POST messages are automatically generated and set for all possible values of each attribute of a resource. To use this feature, RAML file must be loaded. To start using this feature, select a resource you want to automate to send requests and right-click on it which shows menu to load the RAML file. After loading the proper RAML file of the selected resource, automation button in Attribute Manager pane will be enabled.

Automation Settings dialog will be shown where you can select the request types you want to automate and click OK. Simulator Log pane displays the requests sent and responses received from server. Refer below screenshots.

Simulator User Guide can be downloaded from here.

iotivity_tool_guide.txt · Last modified: 2017/05/16 13:43 by Phil Coval