Distributed Publish & Subscribe for IoT
Building and Running


Prerequisites

Linux

  • gcc or clang
  • SCons
  • libuv

    libuv version 1.15 or higher is required.

    Note
    Many Linux distribution ship with libuv installed, the scons script checks if installed libuv can be used and if not pulls down the source code and builds libuv in ext/libuv
  • SWIG

    SWIG is only required if building the Python or JavaScript bindings.

  • NASM

    NASM is only required to build the optimized SHA-512 implementation.

Windows

  • Visual Studio

    Note
    In Visual Studio 2015, Visual C++ is not installed by default. When installing, be sure to choose Custom installation and then choose the C++ components you require. Or, if Visual Studio is already installed, choose File | New | Project | C++ and you will be prompted to install the necessary components.
  • Latest Python 2.7 Release
  • SCons

    Note
    The SCons installer will not detect the 64-bit installation of Python. Instead, download the zip file and follow the installation instructions in SCons README.txt.
  • libuv

    libuv version 1.15 or higher is required.

    Note
    By default the scons script will pull down the source code and build libuv in ext\libuv. To use a pre-built libuv set the UV_PATH to point to the libuv installation folder.
  • SWIG

    SWIG is only required if building the Python or JavaScript bindings. Chocolatey provides another means to install this dependency.

  • MinGW

    MinGW is only required if building the Go binding. Chocolatey provides another means to install this dependency.

  • NASM

    NASM is only required to build the optimized SHA-512 implementation. Chocolatey provides another means to install this dependency.

Yocto

Yocto Project through the OpenEmbedded build system provides an open source development environment targeting the ARM, MIPS, PowerPC and x86 architectures for a variety of platforms including x86-64 and emulated ones.

Documentation

The C API documentation is generated using Doxygen. The Python (pydoc) and JavaScript API (JSDoc) documentation is generated from the Doxygen output.

Doxygen can be downloaded from here: Doxygen

Building the documentation requires the scons DoxygenBuilder tool. This page has instructions on how to install the builder.

Building

Linux and Windows

To build the DPS libraries, examples, bindings, and documentation run scons.

$ scons [variant=debug|release] [transport=udp|tcp|dtls] [bindings=all|none|{python,nodejs,go}]

To build with a different compiler use the CC and CXX build options or the –tool option.

$ scons CC=clang CXX=clang++
$ scons --tool=mingw

Depending on the platform and compiler only a subset of bindings are supported.

PlatformCompiler Bindings
Linux gcc python,nodejs,go
Linux clang python,nodejs
Windows cl python
Windows gcc (MinGW)go

To see the complete list of build options run scons –help. The default build configuration is variant=release transport=udp bindings=all.

Note
A limitation of the current implementation is that the transport must be configured at compile time.

The scons script pulls down source code from three external projects (mbedtls, libuv, and safestringlib) into the ./ext directory. If necessary these projects can be populated manually:

$ git clone https://github.com/ARMmbed/mbedtls ext/mbedtls
$ git clone https://github.com/01org/safestringlib.git ext/safestring
$ git clone https://github.com/libuv/libuv.git ext/libuv
Note
The ext projects are populated the first time DPS is built. To update these projects you need to manually do a git pull or delete the project directory and rerun scons.

Yocto

Clone the poky repository and configure the Yocto environment. Refer to Yocto Project Quick Start for more information.

Clone the libuv Yocto project and yocto/recipes-connectivity/dps to the Yocto Project directory. Modify the value of SRCREV_dps in dps_git.bb to the last commit of dps.

The Yocto Project directory needs to be included in BBLAYERS of conf/bblayers.conf. Refer to Yocto Wiki for more information.

From the root directory of the Yocto Project, initialize the Yocto environment, provide a meaningful build directory name and build Yocto DPS.

$ source oe-init-build-env mybuilds
$ bitbake dps

Applications

In the ./application subdirectory there is a simple SConscript that can be used as a template for building your own statically linked DPS C application. Copy the application tree somewhere and add your source and header files to the src and include directories.

To build:

scons -C <dps-root-dir> application=<your-application-dir> bindings=none

Running

Examples

There are C, Python, JS (node.js), and Go examples.

The C examples are found in ./examples, the Python examples are in ./py_scripts, the JS examples are in ./js_scripts and the Go examples are in ./go/src. Refer to the README.md in each of those directories for more info.

The C examples are installed in ./build/dist/bin. There are some some test scripts in ./test_scripts that run some more complex scenarios using the example programs. The test script tree1 builds a small mesh and shows how publications sent to any node in the mesh get forwarded to the matching subscribers. The script reg1 uses the registry, reg_pubs, and reg_subs examples programs to build a dynamic mesh using the experimental discovery service.