Echelon ISI User Manual

Page 83

Advertising
background image

81

ISI Programmer’s Guide

unsigned assembly) {
IsiMessage request;
msg_out_addr destination;

request.Header.Code = isiCtrq;

request.Msg.Ctrq.Control = command;
request.Msg.Ctrq.Parameter = assembly;

destination.nrnid.type = NEURON_ID;

destination.nrnid.domain = PRIMARY_DOMAIN;
destination.nrnid.rpt_timer = ENCODED_RPT_TIMER;
destination.nrnid.subnet = 0;
destination.nrnid.retry = RETRY_COUNT;

destination.nrnid.tx_timer = ENCODED_TX_TIMER;
memcpy(destination.nrnid.nid, neuronId, NEURON_ID_LEN);

IsiMsgSend(&request, sizeof(IsiMessageHeader)+sizeof(IsiCtrq),

REQUEST, &destination);
}

// State information for this enrollment controller.

// Using this state information allows the application to track
// completion of the entire process, and possibly to cancel out
// upon failure.

enum {

idle, // do nothing

opening, // open enrollment with host, awaiting response from host

enrolling, // enrolling members, awaiting responses from each member

creating // close enrollment and create connection

} controlState;

// Hold data to open enrollment on a host, enroll one member, and close

// enrollment with the host. The structure is filled in by the
// ConnectTwoDevices function and used with the when (resp_arrives) task.

typedef struct {

unsigned

neuronId[NEURON_ID_LEN];

unsigned

assembly;

} ControlledAssembly;

struct {
ControlledAssembly

host;

ControlledAssembly

member;

} controlJob;

when (resp_arrives) {
IsiMessage response;

if (resp_in.code == isiApplicationMessageCode) {

memcpy(&response, resp_in.data, resp_in.len);

if (response.Header.Code == isiCtrp) {

// This is a controlled enrollment response

if (response.Msg.Ctrp.Success) {

// This is a successful response. See where we are

// and proceed to next step, if any:

switch(controlState)

{

case opening:

// Host has opened; enroll member

ControlCommand(controlJob.member.neuronId,

isiCreate,

controlJob.member.assembly);

controlState

=

enrolling;

Advertising