iotivity / iotivity-constrained

This mirror is deprecated. Please visit https://github.com/iotivity/iotivity-lite for forking the IoTivity-Lite project. To contribute code to the project, please visit https://www.iotivity.org/get-involved, https://www.iotivity.org/
https://iotivity.org/getting-started
Apache License 2.0
66 stars 42 forks source link

Getting Started

IoTivity-Constrained is a lightweight implementation of the Open Connectivity Foundation <https://openconnectivity.org/>_ (OCF) standards for the Internet of Things (IoT).

It was designed to build secure and interoperable IoT applications in full compliance with the OCF specifications <https://openconnectivity.org/developer/specifications>_ with a limited footprint not exceeding the needs of the specifications. The stack architecture lends itself to be ported rapidly to any chosen hardware/OS environment.

IoT applications may be built for a wide variety of rich and resource-constrained devices across the IoT landscape. As a general guideline, it should be feasible to deploy applications on class 2 constrained devices (>256KB Flash, >64KB RAM), or better.

The project is open-source, and its code is distributed under the commercial-friendly Apache v2 license.

Contents

IoTivity-Constrained Architecture

.. image:: IoTivityConstrained-Arch.png :scale: 100% :alt: IoTivity-Constrained Architecture :align: center

IoTivity-Constrained's design presents the following features:

Project directory structure

api/* contains the implementations of client/server APIs, the resource model, utility and helper functions to encode/decode to/from OCF’s data model, module for encoding and interpreting type 4 UUIDs, base64 strings, OCF endpoints, and handlers for the discovery, platform and device resources.

messaging/coap/* contains a tailored CoAP implementation.

security/* contains resource handlers that implement the OCF security model.

utils/* contains a few primitive building blocks used internally by the core framework.

onboarding_tool/* contains the sample onboarding tool (OBT).

deps/* contains external project dependencies.

deps/tinycbor/* contains the tinyCBOR sources.

deps/mbedtls/* contains the mbedTLS sources.

patches/* contains patches for deps/mbedTLS and need to be applied once.

include/* contains all common headers.

include/oc_api.h contains client/server APIs.

include/oc_rep.h contains helper functions to encode/decode to/from OCF’s data model.

include/oc_helpers.h contains utility functions for allocating strings and arrays either dynamically from the heap or from pre-allocated memory pools.

include/oc_obt.h contains the collection of APIs for security onboarding and provisioning.

port/*.h collectively represents the platform abstraction.

port//* contains adaptations for each OS.

apps/* contains sample OCF applications.

Setup source tree

Grab source and dependencies using:

git clone --recursive https://github.com/iotivity/iotivity-constrained.git

Building sample applications on Linux

The entire build is specified in port/linux/Makefile. The output of the build consists of all static and dynamic libraries, and sample application binaries which are stored under port/linux.

Run make for a release mode build without debug output.

Add SECURE=0 to exclude the OCF security layer and mbedTLS. The security layer is built by default.

Add DEBUG=1 for a debug mode build with verbose debug output.

Add TCP=1 to include support for TCP endpoints and CoAP over TCP (RFC 8323).

Add IPV4=1 to include IPv4 support in the build. Excluding IPV4=1 produces an IPv6-only build.

Building sample applications on Windows

A Visual Studio project file can be found in port/windows/vs2015/IoTivity-Constrained.sln. Open the solution file in Visual Studio 2015 or newer. If the version of Visual Studio is newer a prompt should pop up asking if you would like to upgrade the visual studio project files. Agree to upgrade the files.

Select the version of the samples you would like to build. Debug/Release, x86/x64. From the build menu select Build Solution.

The samples can be run from Visual Studio by right clicking on the SimpleServer or SimpleClient project from the Solution Explorer and select Debug > Start new instance. Or the binaries can be run from the output folder port/windows/vs2015/{Debug|Release}/{Win32|x64}/.

The build options are hard coded into the visual studio project. The project defaults to using: dynamic memory allocation, OCF security layer is enabled and built, and IPv4 support is included in the build.

To change the build options the properties page for each project must be modified Right click on the project select Properties find C/C++ > Preprocessor > Preprocessor Definitions find the macro associated with the feature you wish to enable or disable. For example to disable the OCF security layer find and delete OC_SECURITY from the Preprocessor Definitions. The Preprocessor Definitions must match for all projects for them to build and run. Due to the difficulty keeping all the projects matching it is recommended to avoid modifying the Preprocessor Definitions unless necessary.

Note: The Linux, Windows, and native Android ports are the only adaptation layers that are actively maintained as of this writing.

Framework configuration

Build-time configuration options for an application are set in oc_config.h. This needs to be present in one of the include paths.

Pre-populated (sample) configurations for the sample applications for all targets are present in port/<OS>/oc_config.h.