Thursday, September 19, 2013

txThings - "Good enough" is good enough

Long time no see! Last update here was posted more than a year ago. There are multiple reasons for that, but the most important one is that I decided to pause embedded development for a while, and learn more about application layer, and user applications. For a start I decided to write a library for CoAP - new protocol for Internet of Things. I also decided to write it in Python, using Twisted framework. The development has been quite slow, but last month I accidentaly found pyvideo.org site with various Python related videos, and found a brilliant talk by Alex Martelli : "Good enough is good enough"



After watching the video, I decided to quickly finish the work on current features, and release the first version of library, with some features completed, and some missing. I hope to get some feedback from users, so that I can improve the library.

txThings - CoAP Python library

I've decided to call the library txThings - Twisted has a tradition of calling modules with plural nouns (also Coap LIbrary for Twisted gave really bad acronym ;) ).

txThings has the following features:
  • support for draft-ietf-core-coap-13 - including automatic piggyback/separate response handling. No caching support.
  • support for draft-ietf-core-block-12 (no support for server initiative though - waiting for the resolution)
  • limited support for RFC6690 (Core Link Format) - server only.
Other nice things:
  • txThings works nicely on RaspberryPi
  • txThings is compatible with Kivy - brilliant new Python GUI library (I'll post some examples soon).
  • txThings is fully asynchronous (thanks to twisted framework)

txThings installation HowTo

txThings is posted on Github. The easiest way to get it is to clone the repository to your local machine using the command below:

git clone git://github.com/mwasilak/txThings.git

Library contains CoAP code (inside "iot" directory) and three examples:
  • server.py - CoAP server that starts on localhost, port 5683 and hosts several resources
  • client_GET.py - example client which performs GET request to localhost, port 5683
  • client_PUT.py - example client which performs PUT request to localhost, port 5683
Client_GET and client_PUT both use port 61616 - to use them simultaneously change port number in one of the clients. Server will send blockwise responses for default settings. To use txThings you need Python 2.7 with Twisted installed (I suggest using the latest Twisted version, but older releases also work - tested with 11.1).

Current work

Next step is to add Observe and full Core Link Format support to txThings. I am also planning to continue investigating Kivy library.

If you are interested in using txThings and have any questions, don't hesitate to contact me.