Introducing SMCP

Tuesday, January 29, 2013 by darco
Posted in , , ,

As some of you know, I've been working on a CoAP stack for embedded devices for some time now. Things have gotten to the point now where I'd like see if other people are interested in using it and/or contributing. So today I am announcing that I am making my first release: SMCP-0.6.

What is CoAP?

If you are wondering what CoAP is, a good explanation comes from the abstract of draft-ietf-core-coap-13:

The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with constrained nodes and constrained (e.g., low-power, lossy) networks. The nodes often have 8-bit microcontrollers with small amounts of ROM and RAM, while constrained networks such as 6LoWPAN often have high packet error rates and a typical throughput of 10s of kbit/s. The protocol is designed for machine-to-machine (M2M) applications such as smart energy and building automation.

CoAP provides a request/response interaction model between application endpoints, supports built-in discovery of services and resources, and includes key concepts of the Web such as URIs and Internet media types. CoAP easily interfaces with HTTP for integration with the Web while meeting specialized requirements such as multicast support, very low overhead and simplicity for constrained environments.

What is SMCP?

The CoAP stack I have developed is called SMCP. It has the following features:

SMCP also comes with some useful tools:

  • smcpctl — a powerful command line tool for browsing and configuring CoAP nodes. Familiar Unix-style commands (ls, cat, rm, etc.) and tab-completion just work.
  • smcpd — a modular CoAP server, intended to make it easy to add CoAP support to existing servers. Includes a CoAP-to-HTTP proxy.
  • smcp-plugtest-client/smcp-plugtest-server — For testing correctness and interoperability with other implementations.

Despite all of this, SMCP can be easily whittled down to the bare minimum requirements for an application. One of the goals of SMCP is to implement a full-featured CoAP stack, but most embedded applications don't need all of these capabilities. Because of this, SMCP is designed so that you can individually enable or disable features depending on your needs (See src/smcp/smcp-opts.h).

For example, SMCP has the ability to have more than once instance, but embedded platforms will never need more than one. Passing around a reference to a global variable that will never change is wasteful, so when compiled with SMCP_EMBEDDED turned on, we transparently (via some preprocessor magic) ignore the reference to the SMCP instance from all of the functions that take it. This makes it easy to use the same codebase for both embedded and non-embedded applications. There are other configuration options for doing things like limiting malloc() usage, avoiding use of printf() (and variants), enabling/disabling observing, etc.

Getting Started

The best way to get started is to have a look at some example code which uses SMCP:

Contiki Support

SMCP fully supports Contiki. To build the Contiki examples, just make sure that the CONTIKI environment variable is set point to your Contiki root, like so:

$ cd contiki-src/examples/smcp-plugtest
$ make CONTIKI=~/Projects/contiki TARGET=minimal-net

API Docs and Mailing list

You can find an online version of the API documentation here:

I've also set up a mailing list:,

What's next

There is still plenty of work to be done. The documentation needs to be improved. More platforms need to be tested. Bugs need to be found and fixed.

Things are quite usable and useful as they are, but they could be so much better. Which is why I'm releasing early. Please let me know your thoughts!