Example isi application – Echelon ISI User Manual
Page 18
ISI Programmer’s Guide
16
Example ISI Application
Most of the ISI protocol is implemented by the
ISI engine
that is part of the ISI
library, and much of the related application development is to make calls to the
ISI engine’s API and override some of the ISI engine’s default implementations
with application-specific versions.
The ISI engine sends and receives ISI messages and manages the network
configuration of your device. You can create a simple ISI application by starting
the ISI engine, periodically calling the ISI engine, and processing any messages
that arrive. The following program is an example of a simple ISI application that
performs these tasks:
#pragma num_alias_table_entries 6
#include
when (reset) {
// Clear all tables and start the ISI engine
scaled_delay(31745UL);
// 800ms delay
IsiStartS(isiFlagNone);
}
mtimer repeating isiTimer = 1000ul / ISI_TICKS_PER_SECOND;
when (timer_expires(isiTimer)) {
// Call the ISI engine to perform periodic tasks
IsiTickS();
}
when (msg_arrives) {
if (IsiApproveMsg()) {
// Process an incoming ISI message
(void)
IsiProcessMsgS();
}
}
The first line includes a required compiler directive, followed by the standard
isi.h header file. This file specifies the available ISI library functions. These
functions are described in the rest of this guide.
The first when task is the reset task. In this task, a call to the IsiStartS() library
function initializes and starts the ISI engine. For ongoing maintenance, the
second when task periodically calls the IsiTickS() function 4 times each second.
Finally, the last when task identifies incoming application messages as ISI
messages with the IsiApproveMsg() library function, and processes them with the
IsiProcessMsgS() function.
To build an ISI application, you must link the application with one of the ISI
libraries as described in
Optimizing the Footprint of ISI Applications
in Chapter
5.