Program - SR_<name function template>

Program Contained in the Function Template

The function template provides a program which has been created in programming language ST (Structured Text). This program is added under the Application node within a folder with the name assigned within the Add Function From Template dialog box. The program has the same name as the folder with the prefix SR_. A program-call is added automatically to the associated task.

The program implements the state machine for the http client with the following states:

State

Description

Idle

If the command xCmdConnect or xCmdConnectTls is detected, the connection to the http server is initiated.

Connected

If the command xCmdPost or xCmdGet is detected, the corresponding request is sent to the connected http server.

ResponseAvailable

The received response is processed and data is stored in the corresponding variables sResponseHeader and sResponseContent. Afterwards, the processing is acknowledged.

Error

If the command xCmdReset is detected, the http client is reset.

The logic implementing the DNS client is provided in the action DnsClient. This action is called from the program as long as the value of the variable sServerIp is a null string.