Instruction Manual

ISI Programmer’s Guide 40
// drive the ISI-related LED:
switch(isiState) {
...
case isiApproved:
case isiApprovedHost:
SetConnectLed(LED_ON);
break;
...
}
}
EXAMPLE 2
The following example opens controlled enrollment for a simple assembly
with one network variable and accepts the invitation when requested by the
connection controller:
void sendControlResponse(boolean success) {
IsiMessage ctrlResp;
ctrlResp.Header.Code = isiCtrp;
ctrlResp.Ctrp.Success = success;
memcpy(ctrlResp.Ctrp.NeuronID,
read_only_data.neuron_id, NEURON_ID_LEN);
resp_out.code = isiApplicationMessageCode;
memcpy(resp_out.data, &ctrlResp,
sizeof(IsiMessageHeader)+sizeof(IsiCtrp));
resp_send();
}
when (msg_arrives) {
IsiMessage inMsg;
unsigned myAssembly;
if (IsiApproveMsg()) {
memcpy(&inMsg, msg_in.data, sizeof(IsiMessage));
myAssembly = nvoValue::global_index;
if (inMsg.Header.Code == isiCtrq) {
if (inMsg.Ctrq.Control == isiOpen &&
inMsg.Ctrq.Parameter == myAssembly) {
sendControlResponse(TRUE);
IsiOpenEnrollment(myAssembly);
} else if (inMsg.Ctrq.Control == isiCreate &&
inMsg.Ctrq.Parameter == myAssembly) {
sendControlResponse(TRUE);
IsiCreateEnrollment(myAssembly);
} else if (inMsg.Ctrq.Control == isiFactory) {
sendControlResponse(TRUE);
IsiReturnToFactoryDefaults();
} else {
sendControlResponse(FALSE);
}
} else {
(void) IsiProcessMsgS();
}
}
}