User Manual

126 Developing a LonTalk Stack Device Application
Sending an Application Message to the
Network
Call the LonSendMsg() function to send an application message. This function
forwards the message to the LonTalk host stack, which in turn transmits the
message on the network. After the message is sent, the LonTalk host stack calls
the LonEventReady() callback handler function to inform the application that
an event has been enqueued. When the application calls the LonEventPump()
function, the LonTalk API calls your LonMsgCompleted() event handler
function. This function notifies your application of the success or failure of the
transmission. You can use this function for any application-specific processing of
message transmission completion.
To be able to send an application message, the LonTalk Stack device must be
configured and online. If the application calls the LonSendMsg() function when
the device is either not configured or not online, the function returns the
LonApiOffline error code.
You can send an application message as a request message that causes the
generation of a response by the receiving device or devices. If you send a request
message, the receiving device (or devices) sends a response (or responses) to the
message. When the Echelon Smart Transceiver or Neuron Chip receives a
response, it enqueues the response and calls the LonEventReady() callback
handler function to inform that application that an event has been enqueued.
When the application calls the LonEventPump() function, the LonTalk API
calls your LonResponseArrived() event handler function for each response it
receives.
Receiving an Application Message from the
Network
When the LonTalk host stack receives an application message from the network,
it forwards the message to the LonEventPump() function in the LonTalk API,
which in turn calls your LonMsgArrived() callback handler function. Your
implementation of this function must process the application message.
The LonTalk host stack does not call the LonMsgArrived() callback handler
function if an application message is received while the LonTalk Stack device is
either unconfigured or offline.
If the message is a request message, your implementation of the
LonMsgArrived() callback handler function must determine the appropriate
response and send it using the LonSendResponse() function.
Handling Management Commands
LONWORKS installation and maintenance tools use network management
commands to set and maintain the network configuration for a device. The
LonTalk host stack automatically handles most network management commands
that are received from these tools. A few network management commands might
require additional application-specific processing, so the LonTalk API forwards
the request to your application through the network management callbacks.
These commands are requests for your application to wink, go offline, go online,