TwinCAT
The TwinCAT router is configured by an XML in order to establish a connection with one or more routers.
To do this the XML files described here can be saved with any desired name in the folder C:\TwinCAT\3.x\Target\Routes (Windows CE: \Hard Disk\TwinCAT\3.x\Target\Routes\) (x = TwinCAT version number). Saved changes are accepted when the TwinCAT router is initialized, which takes place, for example, during the transition RUN->CONFIG or CONFIG->CONFIG.
The XML file has the following structure:
<?xml version="1.0" encoding="ISO-8859-1"?>
<TcConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.beckhoff.com/schemas/2015/12/TcConfig">
<RemoteConnections>
<Mqtt>
<Address Port="1883">BROKER-ADDRESS</Address>
<Topic>VirtualAmsNetwork1</Topic>
<User>CX-123456</User>
</Mqtt>
</RemoteConnections>
</TcConfig>
A connection is established for this and the TwinCAT router logs onto the broker, which is reachable via BROKER-ADDRESS, with the given name (in this case CX-123456) and the port 1883. The BROKER-ADDRESS is thereby the IP or name of the computer on which the broker is running.
The TwinCAT router is at the same time a device on the network "VirtualAmsNetwork1" in the broker, which is reflected in the topics used as described in Architecture.
The <User> element thereby specifies the user at MQTT level and can be used in the broker, e.g. in the Broker, to configure accesses.
Optionally, the <Mqtt> element can carry an attribute, ClientId, in order to specify the MQTT ClientId. This is otherwise formed from the <User> and an arbitrary string.
This configuration establishes an unencrypted connection; encryption options are documented under Security.