Application specific utility functions, Callback handler function, Application-specific utility functions – Echelon LonTal Stack User Manual

Page 225

Advertising
background image

LonTalk Stack Developer’s Guide

213

The two network variables are defined in the model file, which is described in

Model File.

The myNvUpdateOccurred() function is shown below.

/*
* This function is called by the FTXL LonNvUpdateOccurred
* event handler, indicating that a network variable input
* has arrived.
*/
void myNvUpdateOccurred(const unsigned nvIndex,
const LonReceiveAddress* const pNvInAddr) {
switch (nvIndex) {
case LonNvIndexNviVolt:
{
/* process update to nviVolt. */
ProcessNviVoltUpdate();
break;
}
/* Add more input NVs here, if any */

default:
break;
}
}

Application-Specific Utility Functions

The simple example application includes the following application-specific utility
functions:

ProcessNviVoltUpdate(): Performs range checking for the network

variables, sets the output network variable to double the value of the
input network variable, and propagates the output network variable to

the network.

ProcessOnlineEvent(): Calls the ProcessNviVoltUpdate() function

when the device goes online.

These functions are defined in the main.c file.

Callback Handler Function

To signal to the main application the occurrence of certain types of events, the

LonTalk API calls specific callback handler functions. For the simple voltage
actuator example application, only one of the API’s callback handler functions

has been implemented to provide application-specific behavior.
The FtxlHandlers.c file contains the modified LonEventReady() function,
which is called when the LonTalk Host stack receives a network event. This

function simply calls the myEventReady() function in the main.c file that
provides the application-specific behavior. This functional separation approach

keeps changes to the LonTalk Interface Developer utility-generated files to a

minimum. For a production-level application, you can place application-specific
code wherever your application design requires it.

Advertising