[RFC] Zephyr IoT Protocols

Flavio Santes <flavio.santes@...>

[RFC] Zephyr IoT Protocols

Problem definition

Currently, Zephyr does not support any machine-to-machine protocol 
(M2M). These protocols were defined for inter-communication between 
devices or nodes in a constrained networking environment [1].

Aim and scope

This document proposes the integration of M2M protocols to Zephyr. 
Specifically, we are interested in the following protocols: 
CoAP [3], LightweightM2M (LWM2M) [2], MQTT [4] and MQTT-SN [5].

State of the art

LWM2M is a device-management protocol frequently used on the top of 
CoAP. CoAP requires UDP as a transport protocol. Optionally, CoAP may 
use DTLS (on the top of UDP) for securing communications between 

On the other hand, MQTT, a publish-subscribe messaging protocol, 
requires TCP as a transport protocol and may use TLS to create a secure

A lightweight version of MQTT for sensor networks (MQTT-SN) can be 
deployed in almost any kind of network and it doesn't require any 
specific transport protocol. MQTT-SN was created with short-range 
wireless networks in mind. However, MQTT-SN can be used with wired or
wireless networks.

Support for short-range wireless communications in Zephyr is present
via Bluetooth. Furthermore, the Zephyr's TCP/IP stack only offers UDP. 
So far, TCP is work in progress. Zephyr offers a networking security
layer by means of DTLS.

Reference implementations 

  LWM2M + CoAP (wakaama)
    A plain C BSD-licensed implementation of LWM2M is available at [6].

  MQTT client library
    A client-side plain C implementation, licensed under the Eclipse
    Public License [7].

  MQTT client full implementation
    Project Paho provides a full implementation in C++ licensed under
    the Eclipse Public License [8].

    C library licensed under the Eclipse Public License [9].

Integrating M2M protocols with Zephyr

MQTT relies on TCP as a transport protocol, and this could be an 
stopper. So far, there is no evidence of any other inconvenience for 
integrating LWM2M, CoAP and MQTT-SN.

Proposed roadmap

The integration of the M2M protocols could fit into the lib/m2m 
directory (to be created), generating a directory per protocol:

|-- m2m
    |-- coap
    |-- lwm2m
    |-- mqtt
    |-- mqtt_sn

MQTT-SN can be the first protocol added to Zephyr, given the few 
dependencies involved in its development and testing. We can continue
with CoAP/LWM2M and finally with MQTT. However, it's not clear if the 
Zephyr's licenses are compatible with the Eclipse Public License, so 
this could be a stopper (we can always write the code from scratch if
this license is incompatible with Zephyr's).


[1] Terminology for Constrained-Node Networks
    C. Bormann, et al.
    May, 2014

[2] OMA Lightweight M2M (LWM2M) protocol
    Open Mobile Alliance
    December, 2013

[3] The Constrained Application Protocol (CoAP)
    Z. Shelby, et al.
    June, 2014

[4] MQTT Version 3.1.1 
    Andrew Banks and Rahul Gupta 
    October 2014

[5] MQTT For Sensor Networks Protocol Specification Version 1.2
    Andy Stanford-Clark and Hong Linh Truong    
    November, 2014

[6] LWM2M implementation - Wakaama Project
    Eclipse Foundation

[7] MQTT C client - Eclipse Paho
    Eclipse Foundation
    GIT repo:

[8] MQTT C/C++ Embedded clients - Eclipse Paho
    Eclipse Foundation
    GIT repo:

[9] MQTT-SN - Eclipse Paho
    Eclipse Foundation
    GIT repo:

Join devel@lists.zephyrproject.org to automatically receive all group messages.