Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The behavior of the examples is covered in the Examples section.  The examples have been ported to the Arduino Due and the MSP430FR4133 LaunchPad.  Porting the

Include Page
_def_clib
_def_clib
 involves implementing some functions that are specific to the hardware platform (and possibly OS/RTOS) you will be using. Details for porting to other platforms are found in the Porting To Your Hardware section. 

Overview

The primary C Library interface is through the functions defined in the device's header file, e.g. dn_ipmg.h or dn_ipmt.h

Initialization of the interface must be performed first using the appropriate init function, which also registers callbacks for connection status, API responses, and notifications. The connection to the device is performed through the initiateConnect function. Following the successful completion of the initiateConnect and a status callback indicating the connection is established, API functions can be performed. 

All callbacks are performed in the context of the RX handler, which holds a lock for managing the state of the API protocol.  

Note

The application must not call API functions from within a callback function. 


Driving the Mote State Machine

We focus here on the mote , but the concepts apply equally to the manager.– the manager does not need to be driven through the same state machine. 

There are a number of steps your application must take to have the mote join a network and be ready for you to send data. These steps are outlined in the SmartMesh IP Application Note "Data Publishing for SmartMesh IP" (there is an equivalent app note for SmartMesh WirelessHART).  The app note focuses on the bytes exchanged, but the

Include Page
_def_clib
_def_clib
 handles the conversion of API commands into the raw bytes shown.  The 
Include Page
_def_clib
_def_clib
uses similar naming to the SmartMesh IP Mote Serial API Guide - e.g. setParameter<networkId> as described in the Serial API Guide is equivalent to dn_ipmt_setParameter_networkId().  

Note

Commands in the

Include Page
_def_clib
_def_clib
are called in a way that differs slightly from they way they are documented in the SmartMesh IP Mote Serial API Guide.  In the Serial API guide, there is a generic command for getting/setting parameters - e.g. setParameter<networkId> takes a parameter ID (here networkId) as the first argument.  The 
Include Page
_def_clib
_def_clib
 handles this for you - the set/get operation for each parameter is its own commandfunction.

 


The

Include Page
_def_clib
_def_clib
 examples use a Finite State Machine (FSM) to drive the mote through the necessary steps. The FSM acts like a big while(1) loop - the code moves from state to state such that main() never exits. Using an FSM is a design choice - many other architectures are possible. The FSM uses the following states:

...

  • Install an ISR handler for an interrupt-capable GPIO on your microcontroller - when UART_TX_RTSn is asserted, the ISR sets the GPIO connected to UART_TX_CTSn.  This will allow the mote to begin sending data. You may be able to check if the microcontroller is busy in transmit, and delay UART_TX_CTSn until it is done.
  • If this is a response, you can de-assert UART_TX_CTSn in your reply callback. If this is a notification, you can de-assert it in your notification callback.