C implementation of the client-side OMA LwM2M protocol
Clone or download
dextero Anjay 1.14.0
- Added anjay_configuration_t::stored_notification_limit configuration
  option for limiting the maximum number of notifications stored when
  the client is offline.
Latest commit 21896ff Dec 4, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
avs_commons Anjay 1.13.0 Oct 4, 2018
cmake Anjay 1.10.2 Jul 10, 2018
config Anjay 1.10.0 Jun 28, 2018
demo Anjay 1.14.0 Dec 4, 2018
doc Anjay 1.13.0 Oct 4, 2018
examples Anjay 1.12.0 Sep 21, 2018
include_modules/anjay_modules Anjay 1.13.0 Oct 4, 2018
include_public/anjay Anjay 1.14.0 Dec 4, 2018
modules Anjay 1.13.0 Oct 4, 2018
src Anjay 1.14.0 Dec 4, 2018
test Anjay 1.14.0 Dec 4, 2018
tools Anjay 1.12.0 Sep 21, 2018
travis Used CMake 3 on CentOS on Travis Oct 4, 2018
.clang-format Anjay 1.12.0 Sep 21, 2018
.gitignore Anjay 1.12.0 Sep 21, 2018
.gitmodules Anjay 1.3.3 Jul 27, 2017
.travis.yml Anjay 1.13.0 Oct 4, 2018
CMakeLists.txt Anjay 1.14.0 Dec 4, 2018
CONTRIBUTING.rst Anjay 1.10.0 Jun 28, 2018
Doxyfile.in Anjay 1.1.0 Feb 22, 2017
LICENSE Anjay 1.0.0 Feb 8, 2017
NOTICE Anjay 1.6.0 Jan 8, 2018
README.Windows.md Anjay 1.10.0 Jun 28, 2018
README.md Anjay 1.14.0 Dec 4, 2018
covconfig Anjay 1.6.0 Jan 8, 2018
devconfig Anjay 1.13.0 Oct 4, 2018
ltoconfig Anjay 1.6.0 Jan 8, 2018
test_duplicates.py Anjay 1.6.0 Jan 8, 2018
test_headers.py Anjay 1.10.0 Jun 28, 2018
test_symbols.sh Anjay 1.6.0 Jan 8, 2018
test_visibility.py Anjay 1.6.0 Jan 8, 2018
valgrind_test.supp Fixed Travis problems and configuration Jan 11, 2018


Anjay LwM2M library

Build Status Coverity Status

What is Anjay?

Anjay is a C library that aims to be the reference implementation of the OMA Lightweight Machine-to-Machine (LwM2M) device management protocol. It eases development of fully-featured LwM2M client applications by taking care of protocol details, allowing the user to focus on device-specific aspects.

The project has been created and is actively maintained by AVSystem.

Supported features

  • LwM2M Bootstrap Interface:

    • Request
    • Finish
    • Write
    • Delete
    • Discover
  • LwM2M Client Registration Interface:

    • Register
    • Update
    • De-register
  • LwM2M Device Management and Service Enablement Interface:

    • Read
    • Discover
    • Write
    • Write-Attributes
    • Execute
    • Create
    • Delete
  • LwM2M Information Reporting Interface:

    • Observe
    • Notify
    • Cancel Observation
  • LwM2M Security modes:

    • DTLS with Certificates (if supported by backend TLS library)
    • DTLS with PSK (if supported by backend TLS library)
    • NoSec mode
  • Supported TLS backends:

    • mbed TLS
    • OpenSSL
    • tinydtls
  • CoAP data formats:

    • TLV
    • Opaque
    • Plain Text (including base64 encoding of opaque data)
  • CoAP BLOCK transfers (for transferring data that does not fit in a single UDP packet):

    • Block1 (sending / receiving requests)
    • Block2 (sending responses)
  • Pre-implemented LwM2M Objects:

    • Access Control
    • Security
    • Server
  • Stream-oriented persistence API

About OMA LwM2M

OMA LwM2M is a remote device management and telemetry protocol designed to conserve network resources. It is especially suitable for constrained wireless devices, where network communication is a major factor affecting battery life. LwM2M features secure (DTLS-encrypted) methods of remote bootstrapping, configuration and notifications over UDP or SMS.

More details about OMA LwM2M: Brief introduction to LwM2M

Quickstart guide


Ubuntu 16.04 LTS

sudo apt-get install git build-essential cmake libmbedtls-dev zlib1g-dev
# Optionally for tests:
sudo apt-get install libpython3-dev libssl-dev python3 python3-cryptography python3-jinja2 python3-sphinx python3-requests clang valgrind clang-tools
pip3 install grequests

CentOS 7

# Required for mbedtls-devel and python3.5
sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm
sudo yum install -y which git make cmake mbedtls-devel gcc gcc-c++

# Optionally for tests:
sudo yum install -y valgrind valgrind-devel openssl openssl-devel python35u python35u-devel python35u-pip python-sphinx python-sphinx_rtd_theme clang-analyzer
# Some test scripts expect Python >=3.5 to be available via `python3` command
# Use update-alternatives to create a /usr/bin/python3 symlink with priority 0
# (lowest possible)
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 0
sudo python3 -m pip install cryptography jinja2 requests grequests

macOS Sierra with Homebrew

brew install cmake mbedtls
# Optionally for tests:
brew install python3 openssl llvm
pip3 install cryptography sphinx sphinx_rtd_theme requests grequests


Windows support is currently in a preliminary stage. See README.Windows.md for details.

Running the demo client

To compile Anjay demo client and connect it to a local LwM2M server listening on default 5683 port:

git clone https://github.com/AVSystem/Anjay.git \
    && cd Anjay \
    && git submodule update --init \
    && cmake . \
    && make -j \
    && ./output/bin/demo --server-uri coap://

Detailed compilation guide

First, make sure all necessary submodules are downloaded and up-to-date:

git submodule update --init

By default demo client compiles with DTLS enabled and uses mbedtls as a DTLS provider, but you may choose other DTLS backends currently supported by setting DTLS_BACKEND in a CMake invocation to one of the following DTLS backends: openssl, mbedtls or tinydtls:

cmake . -DDTLS_BACKEND="mbedtls" && make -j

Or, if a lack of security (not recommended) is what you need for some reason:

cmake . -DDTLS_BACKEND="" && make -j

Compiled executables, including demo client, can be found in output/bin subdirectory.

For a detailed guide on configuring and compiling the project (including cross-compiling), see Compiling client applications.

To start the demo client:

# uses plain CoAP
./output/bin/demo --server-uri coap://

# uses DTLS in PSK mode, with PSK identity "foo" and secret key "bar" (hex-encoded)
./output/bin/demo --server-uri coaps:// --security-mode psk --identity 666f6f --key 626172

NOTE: When establishing a DTLS connection, the URI MUST use "coaps://". In NoSec mode (default), the URI MUST use "coap://".

Running tests on Ubuntu 16.04:

./devconfig && make check

Running tests on CentOS 7:

# NOTE: clang-3.4 static analyzer (default version for CentOS) gives false
# positives. --without-analysis flag disables static analysis.
./devconfig --without-analysis -DPython_ADDITIONAL_VERSIONS=3.5 && make check

Running tests on macOS Sierra:

# If the scan-build script is located somewhere else, then you need to
# specify a different SCAN_BUILD_BINARY. Below, we are assumming scan-build
# comes from an llvm package, installed via homebrew.
./devconfig -DSCAN_BUILD_BINARY=/usr/local/Cellar/llvm/*/bin/scan-build && make check


See LICENSE file.

Commercial support

Anjay LwM2M library comes with the option of full commercial support, provided by AVSystem.


Contributions are welcome! See our contributing guide.