blob: ec3d021e6d90877c94fa111f739e5c4aed4d8e42 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2015 - 2017 TU Wien ACIN, fortiss GmbH
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.
SPDX-License-Identifier: EPL-2.0
Contributors:
Martin Melik Merkumians, Monika Wenger, Alois Zoitl, Jose Cabral
- initial API and implementation and/or initial documentation
-->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>MQTT with Eclipse Paho</title>
<link rel="stylesheet" type="text/css" href="../help.css">
</head>
<body>
<h1 id="topOfPage">MQTT with Eclipse Paho</h1>
<p>This section will show you how to make applications communicate using <a href="http://www.eclipse.org/paho/" target="_blank">MQTT Paho</a>. 4DIAC uses a layered communication architecture. For MQTT Paho, a bottom layer has been realized, connecting MQTT Paho and the FBDK layer. <span class="specificText">Please consider that with the current implementation it is not possible to connect to more than one MQTT Paho broker on one Device</span>.</p>
<p>Since you need MQTT Paho, you need to install the libraries in your computer. Therefore you need to download the code and compile it. You will need the same tools needed for FORTE (git, cmake, compilers). The process is based on the normal compilation of FORTE, but the MQTT feature is enabled. <a href="../../html/installation/install.html#ownFORTE" target="_blank">Here's</a> a quick link to FORTE's compilation. For the installation please follow the next steps:</p>
<ol>
<li>Checkout and build MQTT Paho (if you are using Windows, some commands might change):
<div class="code">$ git clone https://github.com/eclipse/paho.mqtt.c.git
$ cd paho.mqtt.c</div></li>
<li><p>Use CMake to generate the files to compile in a similar way you would use for compiling FORTE. The options in CMake for Paho are less and easy to understand. You will export the files to [binPaho]. Then do</p>
<div class="code">$ cd [binPaho]
$ make</div></li>
<li>Configure FORTE compilation files by starting CMake as you usually and follow the next steps:
<ol>
<li>Check FORTE_COM_PAHOMQTT in CMake</li>
<li>Set <span class="specificText">FORTE_COM_PAHOMQTT_INCLUDE_DIR</span> in CMake to the folder where the header files of Paho are.</li>
<li>Verify that the library specified in <span class="specificText">FORTE_COM_PAHOMQTT_LIB</span> has the same name as the one you compiled. If not, change it.</li>
<li>Set <span class="specificText">FORTE_COM_PAHOMQTT_LIB_DIR</span> to the folder where <span class="specificText">FORTE_COM_PAHOMQTT_LIB</span> is located.</li>
<li>Configure CMake until nothing is marked red afterwards generate with CMake.</li>
<li>Build forte</li>
</ol>
</li>
<li>In case you use MQTT Paho on a Virtual Machine use NAT and configure forwarding for port 1883, which is the default port on a MQTT Paho broker. IP addresses for the forwarding can be empty.</li>
<li>To communicate with MQTT Paho use the Publish/Subscribe Function Blocks of 4DIAC and configure its ID data input as follows:
<div class="code">raw[].mqtt[tcp://ip:port, cientID, topic]</div>
<img src="../../html/communication/img/mqttExample.png" alt="Example of MQTT" />
<p class="attention"><span class="inlineTitle">Attention</span>: When using the raw[] layer in your ID, the RD_1 of your subscriber and the SD_1 of your publishers must be connected to a STRING type data. Also, you can only use PUBLISHER_1 and SUSBCRIBER_1, not others function blocks wit more inputs or outputs.</p>
<p>The main reason for this additional "raw" parameter is that mqtt does not define a payload format. With the additional param you specify in 4diac a so called communication layer to be used on top of MQTT. This communication layer is now in charge of taking the data from IEC 61499 and generate an according payload format or take the payload and transform it for the FB's outputs. The raw-layer is just accepting strings and sends the raw string content.</p>
</li>
</ol>
<h1>Where to go from here?</h1>
<p>Go back to Protocols index:</p>
<p><a href="../../html/communication/communicationIndex.html">Communication Index</a></p>
<p>If you want to go back to the Start Here page, we leave you here a fast access</p>
<p><a href="../../html/startHere/startHere.html">Start Here page</a></p>
<p class="goToTop">Or <a href="#topOfPage">Go to top</a></p>
</body>
</html>