Overview & Code Organization
The
abstracts the serial API of SmartMesh devices into a set of functions your application can call.
To issue to a command to a device over its serial API, your application calls the corresponding function. The
handles formatting serial frames and HDLC framing, as well as matching commands and responses.
Notifications received from the device result in a callback function being called. The
handles parsing the serial notification frames and sending a serial API acknowledgement to the device when necessary.
The
is designed with the following constraints in mind:
It is written in pure C. In particular, no hardware-specific code is present in the
, allowing it to be used as-is in any C-based platforms. To use the
on your platform, you have to implement a handful of functions (see Porting).
It is not tied to any operating system. The
only deals with formatting and parsing serial frames. It can be used as-is in single threaded environments (see for example the Arduino Example Applications section). If you are operating in a multi-threaded environment (e.g. you are using a Real-Time Operating System), you can use locking functions (see the Porting section).
Source Code Organization
The
can be downloaded at https://github.com/dustcloud/sm_clib.
Directory Structure
That repository contains the following directories:
the
sm_clib/directory contains the library itself, as a collection of headers (.h) and source code files (.c):main modules:
dn_ipmg.cimplements the SmartMesh IP Manager serial API.dn_ipmt.cimplements the SmartMesh IP Mote serial API.dn_whmt.cimplements the SmartMesh WirelessHART Mote serial API.
helper modules:
dn_serial_mg.cimplements low-level serial formatting for communicating with the SmartMesh IP Manager.dn_serial_mt.cimplements low-level serial formatting for communicating with the SmartMesh IP Mote and SmartMesh WirelessHART mote.dn_hdlc.cimplements HDLC framing over a serial connection, following RFC1662.
header files for porting:
dn_endianness.hcontains the prototypes of the functions you need to implement to support different endianness.dn_lock.hcontains the prototypes of the functions you need to implement to support a multi-threaded environment.dn_uart.hcontains the prototypes of the functions you need to allow theto communicate over your (micro-)processor's serial port.
the
examples/directory contains sample applications which use the. These examples are built for the Arduino Due.
The
arduino/Libraries/directory contains the libraries used by the sample applications.The
arduino/MoteBlink/directory contains the MoteBlink sample application.The
arduino/Triangle2manager/directory contains the Triangle2manager sample application.
What about the SmartMesh WirelessHART manager?
Interacting with the SmartMesh WirelessHART manager is best done through its XML-RPC interface. The
targets serial API interfaces, and hence does not support the SmartMesh WirelessHART manager.