Transmission is an MQTT module for Ignition that can publish files using MQTT Sparkplug. This tutorial shows how to configure MQTT Transmission to publish files from one Ignition system to another.
Files are transferred using Sparkplug over MQTT and which files get transferred and when they get transferred can be configured in a number of different ways.
The file transfer configuration also defines how quickly a file transfer occurs and how long before a timeout will occur on failure to receive host side acknowledgements which can be adjusted as required based on the size of files you are sending and any bandwidth constraints that you may have.
As noted in the prerequisites, you should have two Ignition systems installed at this point.
Begin by configuring the host system with MQTT Engine. Set the following:
At this point the Ignition system with MQTT Engine and MQTT Distributor is configured. However, the MQTT Server must be accessible to the Ignition system running MQTT Transmission and any other MQTT clients that may need to connect. In order for this to work port 1883 must be open to outside connections. Make sure this is allowed via your operating system's firewall configuration and any anti-virus software you may have installed.
|This configuration is not recommended for production systems. If running this in production, you should be using TLS encryption on port 8883. More information on how to configure TLS can be found here.|
Now switch to the Ignition system running MQTT Transmission and set the following.
When complete, it should look as follows. Select the Create New Files to save the settings.
At this point, everything should be configured to send files from MQTT Transmission to MQTT Engine. Open Ignition Designer on the system running MQTT Transmission. You should see a new set of tags there as shown below.
At this point, we just need to tell MQTT Transmission which file to send. Download this sample_file.zip which contains two text files. The two text files are:
Certain characters have special meanings when used in filenames such as "*" for wildcards, and "\" in filename paths. If a file you are trying to publish contains any of the characters listed below, it will prevent files from being written to the file system.
" * : < > ? / \ |
Leading and trailing spaces in filenames and filenames ending in '.' are also not supported.
Unzip this sample file to some location and note that location. When transferring any file, MQTT Transmission requires two files to be present before it will transfer the target file. The first is the file itself. The second is a file that has the same name as the target file followed by a '.md5' extension. The contents of that file must contain the Message Digest Algorithm 5 (or MD5 sum) of the file. The MD5 sum can be calculated using command line utilities on most operating systems. Here are some examples:
ubuntu@linux-host:~$ md5sum myfile.bin 07180622a24ebf905cf5f770cd54197a myfile.bin # In the above example, the md5 sum is: 07180622a24ebf905cf5f770cd54197a
user@osxhost:~$ md5 sample_file.txt MD5 (sample_file.txt) = 85324ffbcc7d97c478adf53796aff787 # In the above example, the md5 sum is: 85324ffbcc7d97c478adf53796aff787
Get-FileHash -Algorithm MD5 .\some_file.iso Algorithm Hash Path --------- ---- ---- MD5 80FD169D3FDADBC97E66C168F796B1BF C:\temp\some_file.iso # In the above example, the md5 sum is: 80FD169D3FDADBC97E66C168F796B1BF
With both files in place, we can now set the 'Publish File Path'. This path must be the full path to the target file to publish over MQTT. In this example, we're using the path of '/tmp/transmission/sample_file.txt'. However, on a Windows system that would look something like 'C:\full\path\to\my\sample_file.txt'. When this is set, you should see something like this
Finally, click the 'Publish File' boolean tag. This will begin the file publish process which will cause the file to be published. When the file is successfully transferred both files will be removed from the originating filesystem.
After doing so, you should see something similar to what is shown below.
You should also now see the file on the Ignition system with MQTT Engine installed. The file will be saved to the location you set as the 'Base File Directory' in your MQTT Engine namespace configuration for Sparkplug B.
There is also an option to 'automatically' publish files using MQTT Transmission. In the 'File' configuration of MQTT Transmission you can check a tickbox that is 'Enable Auto-Publish'. If this is enabled, MQTT Transmission will create a tag called 'Publish Files Folder' instead of 'Publish File Path' as shown below.
When configured this way, MQTT Transmission will scan the folder specified in the tag and will publish all files that appear in this directory automatically. Just as with the 'manual publish' option, an associated md5 sum file must be present and properly represent the md5 sum of the target file before it will be published.
The Advanced Settings section of the file transfer configuration define how quickly a file transfer occurs and how long before a timeout will occur on failure to receive host side acknowledgements.
Adjust these as required based on the size of files you are sending and any bandwidth constraints that you may have.