Changes

Jump to: navigation, search
no edit summary
{{InfoBoxTop}}
{{AppliesToSBCLynx}}
{{AppliesToIoT}}
{{InfoBoxBottom}}
{{WarningMessage|text=This application note was validated against specific versions of the kit only. It may not work with other versions. Supported versions are listed in the ''History'' section.}}
== History ==
{| class="wikitable" border="1"
|0.6.0
|May 2017
|Added TBDsection "Configuring SBC Lynx as an MQTT broker"
|-
|}
==Introduction==
[[:Category:SBC_Lynx|SBC Lynx ]] is extremely flexible in terms of [[Connectors,_buttons_and_switches_(SBC_Lynx)|communication interfaces]] and [[Additional_industrial_I/Os_(XUAL)|I/O ports]]. When used in combination with a Linux distribution such as [[XUELK-AN-002:_Running_Debian_distribution|Debian]], it is an ideal solution to implement compact highly-integrated cost-effective gateways/supervisors for [http://internetofthingsagenda.techtarget.com/definition/Industrial-Internet-of-Things-IIoT Industrial Internet of Things applications (IIoT)].
IIoT is a vast field that includes several disciplines. At field level, the typical IIoT system requires
==Device-to-device communications==
===Configuring SBC Lynx as a an MQTT broker===This example shows how to install a an MQTT broker on SBC Lynx, running Debian distribution. "MQTT, a simple, lightweight, publish/subscribe messaging protocol on top of the TCP/IP protocol, is the ideal protocol for the emerging IoT world" [1] and is becoming one on the most common protocols used for machine-to-machine communications.
In contrast to HTTP with its request/response paradigm, MQTT is based on a publish/subscribe model, as depicted in the following image. This makes it suitable for "Internet of Things" messaging where even highly constrained devices are used (low power sensors, mobile devices, embedded computers, microcontrollers, etc.).
[[File:MQTT-architecture.png|thumb|center|600px]]
Publish/Subscribe way of communication is an event-driven way of communicating and it enables messages to be pushed to clients. The central communication point is the MQTT broker (server). It is in charge of routing all messages between the senders and the rightful receivers. Each client (sensors) that publishes (transmits) a message to the broker includes a topic into the message. The topic is the routing information for the broker. Each client that wants to receive messages subscribes to a certain topic and the broker delivers all messages with the matching topic to the client. For more details, please refer to the publicly available resource resources such as [http://www.steves-internet-guide.com/mqtt/ this link].
The procedure was tested on an [[XUELK-AN-002:_Running_Debian_distribution|SBC Lynx running Debian Jessie distribution]].
First, import the repository package signaling key:
<pre class="board-terminal mw-collapsible mw-collapsed">
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquito-repo.gpg.key
</pre>
 
 
Make the reposioty available for the mqtt:
<pre class="board-terminal mw-collapsible mw-collapsed">
cd /etc/apt/sources.lit.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list
</pre>
  Install mosquito Mosquitto<pre class="board-terminal mw-collapsible mw-collapsed">
sudo apt-get update
sudo apt-get install mosquitto
</pre>
7. Install Mosquitto developer libraries to develop MQTT clients<pre class="board-terminal">
sudo apt-get install libmosquitto-dev
8. Execute the given below command to install Mosquitto client packages$sudo apt-get install mosquitto-clients9. Ensure that Mosquitto broker is running$sudo service mosquitto status</pre>
10. simple test of Execute the broker Open a terminal and issue the given below following command to subscribe the topic “mqtt”install Mosquitto client packages1$mosquitto_sub -h localhost -t "mqtt<pre class=" board-vOpen another terminal and issue the given below command to publish message to the topic “mqtt”1">$mosquitto_pub -h localhost sudo apt-t "mqtt" get install mosquitto-m "Hello MQTT"clientsNow the message “Hello MQTT” will be displayed in the first terminal where the topic “mqtt” is subscribed.</pre>
Ensure that Mosquitto broker is running
<pre class="board-terminal">
sudo service mosquitto status
</pre>
 
 
To verify that the broker is running properly, you can perform this simple test.
 
Open a terminal and issue this command to subscribe the topic <code>mqtt</code>
<pre class="board-terminal">
mosquitto_sub -h localhost -t "mqtt" -v
</pre>
 
 
Open another terminal and issue the given below command to publish message to the topic <code>mqtt</code>
<pre class="board-terminal">
mosquitto_pub -h localhost -t "mqtt" -m "Hello MQTT"
</pre>
Now, we can also test the functionality of message <code>Hello MQTT</code> will be displayed in the installed broker (Mosquito), we will need two client one as a publisher and one as subscriberfirst terminal where the topic <code>mqtt</code> was subscribed.
==References==
dave_user, Administrators
5,138
edits

Navigation menu