SendDataAsString_OnChange

SendDataAsString_OnChange 1:

This method is called once to send data to the broker. Unlike the classic SendData() method, the JSON document is passed directly at this point. In this way, the user achieves greater flexibility, but in return must send a correctly constructed JSON document to the app.

The method is intended for users experienced in handling JSON documents. In case of incorrectly formatted JSON documents, the information cannot be displayed in the app.

The SendDataAsString method transmits the data as a retain message. With the SendDataAsString_OnChange method, on the other hand, it is possible to transfer individual parts of the data in order to save data traffic. However, it should be noted that with the SendDataAsString_OnChange method the messages are not sent as retain messages and are therefore only known to currently connected app instances. The data must be kept ready in the TwinCAT project and sent as a complete data block when a new client is connected using the SendDataAsString method.

Syntax

METHOD SendDataAsString_OnChange : BOOL
VAR_INPUT
    sJsonString : POINTER TO STRING;
    nJsonLen    : UINT;
END_VAR

SendDataAsString_OnChange 2: Return value

Name

Type

Description

SendDataAsString_OnChange

BOOL

The method returns the return value TRUE if the call was successful.

SendDataAsString_OnChange 3: Inputs

Name

Type

Description

sJsonString

POINTER TO STRING

Pointer to the JSON string to be sent.

nJsonLen

UINT

Length of the JSON string

Possible errors are output at the outputs bError and hrErrorCode of the function block instance.