Echelon Mini FX User Manual

Page 108

Advertising
background image

Mini FX User's Guide

95

// TODO: process other application messages here (if any)
;
}
}

The second part of this segment provides visual feedback about the ISI enrollment status
to the user (through LED1 in this example). The ISI API provides an

IsiUpdateUserInterface() callback for this purpose:

IsiEvent isiState;

void IsiUpdateUserInterface(IsiEvent Event, unsigned Parameter)
{
isiState = Event;
SignalIsiState();
#pragma ignore_notused Parameter
}

void SignalIsiState(void)
{
if(isiState == isiPending
|| isiState == isiPendingHost) {
// Flash LED in any 'pending' state
isiLed ^= TRUE;
} else if(isiState == isiApproved
|| isiState == isiApprovedHost) {
// LED is solid on in any 'approved' state
isiLed = TRUE;
} else {
// LED is off otherwise:
isiState = isiLed = 0;
}
SetLeds(isiLed, nviSwitch.state);
}

The third part of this segment forwards user input to the ISI API:

//
// Handler to act when the user presses the ISI connect button
// (SW1 in this example). When the ISI engine is idle, this opens
// an ISI enrollment. When an enrollment is pending, this completes
// the enrollment. A pending enrollment is automatically cancelled
// after some time, but a more sophisticated user interface could,
// for example, detect a prolonged activation of SW1 and explicitly
// cancel the pending enrollment, or delete an existing connection.
//
void OnButtonPressed(void)
{
if(isiState == isiPending || isiState == isiApprovedHost) {
IsiCreateEnrollment(0);
} else if(isiState == isiNormal) {
IsiOpenEnrollment(0);
}
}


Finally, in the third segment, the application provides application-specific information to
ISI through a set of dedicated callback functions:

//
// When this application opens enrollment, ISI requests a CSMO data
// package from the application. This data informs all other devices
// on the type of enrollment on offer; its number, type and direction
// of network variables, etc.
//
// The following myCsmo constant describes this enrollment as "any
// network variable of type SNVT_switch":
//
static const IsiCsmoData myCsmo = {

Advertising