Echelon ISI User Manual

Page 54

Advertising
background image

ISI Programmer’s Guide

52

Here is the quick start example from Chapter 1:


#include <isi.h>

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();

}
}

While this application can attach to a network, send status messages, and receive
the status messages from other devices, it has no way of establishing a

connection to any other device in the network. It also has no way of interacting
with the user, which means it cannot relay information to the user, nor can it

receive input from the user. This chapter expands the example to implement

support for one connection, with simple user interaction of the connection status.

To support connections, you must define at least one network variable, call
IsiOpenEnrollment() to open manual or controlled enrollment, call

IsiInitiateAutoEnrollment() to start automatic enrollment, and call

IsiCreateEnrollment() or IsiExtendEnrollment() to accept a connection invitation
for manual or controlled enrollment. For the example, one network variable is

defined that controls the state of a light. This network variable is created with
the following code:

network input SNVT_switch nviLight;

The IsiCreateEnrollment() or IsiExtendEnrollment() call is typically made when
the user activates the Connect button for an assembly that is in the pending

state. To track the state for each assembly, you can override the
IsiUpdateUserInterface() callback function. Because the example application

supports only one assembly, state tracking is simple and can be implemented

with a single variable.

The following code overrides the IsiUpdateUserInterface() callback function to
get updates of the state of the ISI engine:


// Last known state variable. This is used when providing
// user input back to the ISI engine (below)
IsiEvent deviceState = isiNormal;

// IsiUpdateUserInterface() override

Advertising