Skip to content
Branch: master
Clone or download

IOTivity-lite setup

This repo contains bash scripts to setup a build enviroment to use DeviceBuilder with IOTivity-lite. The build enviroment is taylored to create OCF Server Devices.

The script setup the next repos (from github) in the folders:

  • iotivity-lite (OCF 1.3 version)
  • DeviceBuilder (latest version)
  • IOTDataModels (latest version) resource definitions that are used as input for the code generation


Installation of the enviroment can be done with a single curl command:

curl | bash

The curl command sets up the full environment (for Linux and Windows).

If one wants to know the details of what the script does: curl or look at

Executing the installation command requires:

  • internet access
  • system that contains the BASH shell script environment.

Note that installing git clients on windows installs a BASH shell script environment

Folder Structure After Installation

Folder structure after everything is installed and code is generated:

    |-- core             core resource definitions (in swagger) 
    |-- DeviceBuilder    The device builder tool chain
    |-- device_output    The output of device builder.
    |         |
    |         |-- code   The generated code.
    |               |    the files will be copied to folder iotivity/examples/OCFDeviceBuilder
    |               |- server.cpp
    |               |- server_security.dat         SVR data
    |               |- server_introspection.dat.h  introspection device data, encoded in header file
    |-- iotivity-lite         IOTivity Lite source code
    |        | 
    |        |-- apps
    |        |      |- device_builder_server.c            <--- generated code
    |        |
    |        |-- include
    |        |      |- server_introspection.dat.h         <--- generated introspection data
    |        |
    |        |-- port/<portinglayer>
    |                     |- device_builder_server        <--- executable (after creation on linux)
    |                     |- devbuildmake                 <--- makefile with the target
    |                     |- Makefile                     <--- original make file from IOTivity_lite
    |                     |- device_builder_server_creds  <--- SVR storage 
    |                                                          when the folder is not there has the meaning: 
    |                                                          The device is ready for onboarding
    |-- IOTDataModels    oneIOTa resource definitions (in swagger format)
    |-- IOTivity-Lite-setup   This github repo.
    |-- swagger2x        swagger2x code generation
    |-            generation command to convert the example.json in to code
    |-          building the generated code
    |-            run the generated code
    |-          reset the device to ready for onboarding state.
    |-      edits the iotivity-lite/apps/device_builder_server.cpp file with nano.
    |-     edits the example.json file with nano.
    |- example.json      the input for device builder scripts.
 legenda:  folder
              |-- folder
              |-- folder/subfolder
              |- file

The installDeviceBuilder script generates scripts in the top level folder (e.g. above this repo). These scripts are convienent scripts, e.g. they are short cuts for entering generation, build, excute and reset commands.

Development Setup

Typical development setup contains the following configuration:

         | PC/RaspberryPi |     
         | (dev system)   |             
         |  OCF server    |              
           --------------            ------------------             
          |              |   wifi   |  Android Device  |
Internet--|    router    |--------- |  (test system)   |
          |              |          | OCF Client (OTGC)| 
           --------------            ------------------         


  • Router = home router, with Wifi Access point to connect the Android device

    • The IP network should be IPv6 capable and have CoAP multicast enabled.
  • (Linux)PC/RaspberryPi = is the device that is being used to build the OCF server

  • Android Device = device used to run the OCF Client (OTGC):


Note that a windows (10) PC instead of an Android device can be used to run OCFDeviceSpy as OCF Client. see

Referenced Information:

repo description location
DeviceBuilder tool chain
swagger2x code generation
IOTivity-lite C code (latest)
IOTdataModels oneIOTa data models
core OCF core data models
OCF clients OCF development clients

Development Flow

The development flow is based on bash scripts, hence the flow is generalized for Linux based systems. The development flow is depicted the figure below:

          |              |     
          ||             --- edit the input file for the code generation
          |              |                 default file contains the binary switch resource
          |              |
          |    |             ---  generates the code & introspection file
          |              |             --- script contains the device type, 
           --------------                  change the argument to change the device type.
                 | initial code        --- in iotivity-lite tree, to build
                 v                     --- introspection header files
          |              |     
          | |<--------    --- edit the generated code
          |              |         |
           --------------          |
                 |                 |
                 | edited code     |
                 v                 |
           --------------          |
          |              |  build  |
          |   |---->----|   --- build the executable
          |              |  failed |
           --------------          |
                 |                 |
                 | ok              |
                 v                 |
           --------------          |
run       |              | modify  |
--------->|    |---->----      --- onboarding will change the security folder 
clients   |              | behaviour         in the executable folder
against    --------------                    to refresh/reset the security status execute
application      |
    Note: if is run again, the generated code is overwritten.
    e.g. before running that tool again, safe the file in the iotivivty tree to another name 
    if one wants to keep that code as reference

Initial Flow

These steps needs to be executed in the <>/iot-lite folder, e.g. the folder that gets created by running the curl installation command. The goal is to run an OCF server by creating code, building and running the OCF server application.


    Script to generate the code that represents the device.

    The input is the file used to generate the code is example.json.


    Script to build the generated code.

    The device_builder_server.c code is being build is located at <>/iot-lite/iotivity-lite/apps folder.


    script to run (launch/start) the compiled (generated) code.

    The script executes device_builder_server application in the <>/iot-lite/iotivity-lite/port/linux folder.

Repeat Flow

The repeat flow is modifying the generated code (without code generation):


    script to edit the generated code with Nano.


    script to build the generated code.


    script to run (launch/start) the compiled (generated) code.

If the device needs to be in ready for onboarding (for example after a crash), then run the script

OCF clients

Information and Installers about the OCF clients for development support can be found at:


This scripts edits the device builder input file with Nano. Nano is a small editor that can be used to edit files in windowless system.


Nano is supplied on various linux systems like ubuntu and pi. The file being edited is the file in iotivity tree. so please make sure when generating a new version, that a changed file is saved under a different name.

nano beginners guide:

input file

Device Builder input file information can be found at:

Generate Code


This script runs the DeviceBuilder application with the predefined arguments:

  • iot-lite/example.json as input file
  • light device as device type

changing the device type of the OCF Server

The device type can be change from oic.d.light (default) to something different. The following mechanisms are available to change the device type:

  • change the server code from oic.d.light to the specific value
    • search for oic.d.light in the server code, and change the value.
    • no need to re-generate the server code
    • can be done when one is already changing the server code.
  • change the file e.g. replace oic.d.light to something
    • to see the changes the code needs to be re-generated by running
    • can be done when no code has been changed yet.

Running this script generates the device_output folder AND copies the result to the correct executable folder in the iotivity-lite tree structure.

more info of the DeviceBuilder script can be found at:

Note that running will overwrite the made code changes!!

Edit Code


This scripts edits the generated C code device_builder_server.c with Nano. The script is starting the Nano editor with the generated code in the IOTivity tree. The saved file can be compiled without copy pasting.

Note that running will overwrite the made changes!!

Build Code


This script builds the app device_builder_server.c by means of make. e.g. run in the iotivity-lite/port/linux folder the make -f devbuildmake device_builder_server command

To build another port (e.g. OS):

  • uncomment out the listed port in the script, and comment out the default linux.

Run Code


This script executes the compiled executable in the folder where the executable resides in.

e.g. it executes the device_builder_server executable (e.g. the server application) in folder:


note that the executable needs to be started in folder where it recides to avoid issues with reading the security data.

Reset Device


This script deletes the SVR settings in the security folder:


The device will go to the ready for onboarding state.

Windows Specific Instructions

Windows specific instructions are available at :

You can’t perform that action at this time.