MVI69E-LDM-MQTT ♦ MQ Telemetry Transport
MQTT-LDM Library
CompactLogix® Platform
Quick Start Guide
ProSoft Technology, Inc.
Page 49 of 54
10.2.2 Callback Function Declarations
Functions
- Callbacks, called by MQTT-LDM Library during runtime, should be
implemented by the user application. The sample application provides a default
implementation of the callback functions.
int mqtt_ldm_read_value(plc_tag* tag, plc_value* value);
Called to read the value of a tag from the PLC.
The first input argument, tag, is the tag name to be read from the PLC.
The value read from the PLC is returned in the
output argument
value.
If successful, the read value is returned in the
output argument
value and the
function returns 0.
int mqtt_ldm_write_value(plc_tag* tag, plc_value* value);
Called to write a new value to a tag.
The first input argument, tag, is the tag name to be written to the PLC.
The input argument value is the value to be written to the PLC tag.
New values are received from MQTT broker by subscribing to specified
subscription topics in the configuration file.
int mqtt_ldm_is_connected_to_plc(void);
If the module is connected to the PLC, it returns 1. Otherwise, it returns 0.
int mqtt_ldm_get_status(char is_verbose, char** buffer, uint16_t max_size);
This function is used to get the current status of the communication with the PLC.
If the input argument
is_verbose
is not 0, then more detailed information is
returned.
When argument
is_verbose
has a non-zero value, sample application
mqtt-ldm-
sample-app-mvi69e
returns content of log file in the buffer.
The result is copied into the memory buffer. It may be pre-allocated by the caller.
In this case, its size is passed in the
max_size argument
. If the buffer points to
NULL, then
max_size
can still be used to limit the size of returned text.
If successful, return 0.
Examples of the use of these functions can be found in the source code of the sample
application.