...
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 | ||||
---|---|---|---|---|
|
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 | ||||
---|---|---|---|---|
|
Include Page | ||||
---|---|---|---|---|
|
setParameter<networkId>
as described in the Serial API Guide is equivalent to dn_ipmt_setParameter_networkId()
. Note | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Commands in the
setParameter<networkId> takes a parameter ID (here networkId ) as the first argument. The
|
The
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: Include Page _def_clib _def_clib
...
- Install an ISR handler for an interrupt-capable GPIO on your microcontroller - when
UART_TX_RTSn
is asserted, the ISR sets the GPIO connected toUART_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 delayUART_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.