zephyr/samples/net/paho_mqtt_client
Flavio Santes 65ccf8330f samples/net/mqtt: Fix mqtt_connect function
Remove erroneous initialization of 'data' via memset.
Set keep alive interval to 0.

Change-Id: I5da4649985efd39b37bbbdc6ae21a856f9e40b13
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-05-31 11:22:01 -05:00
..
src samples/net/mqtt: Fix mqtt_connect function 2016-05-31 11:22:01 -05:00
Kbuild
Makefile
README
prj_ethernet.conf samples/net/mqtt: Reduce tx/rx buffer size and update mqtt_publish_read 2016-05-30 17:26:02 -05:00

README

MQTT sample using the Paho's MQTT Packet Library.

Requirements
------------

* An Ethernet LAN for testing purposes.

* A MQTT 3.1.1 Gateway running in the LAN.

* A Galileo Dev Board connected to the LAN.

* A FTDI 6-pin cable to see debugging information from Galileo.

The Mosquitto MQTT implementation is used in this document.
However, any MQTT 3.1.1 compliant gateway must work. See
http://mosquitto.org/ for more details.


Building instructions
---------------------

* Change src/config.h according to your network configuration.

* Download the Paho's MQTT Embedded C Library.
  See http://www.eclipse.org/paho/clients/c/embedded/ for more
  information about Paho's MQTT Packet Library.

  Inside samples/net/paho_mqtt_client, run the following commands:

  git clone https://git.eclipse.org/r/paho/org.eclipse.paho.mqtt.embedded-c paho

  Now "paho" contains the MQTT Packet Library.

* make pristine && make are enough to build this sample.

* Follow the steps indicated here:

  https://www.zephyrproject.org/doc/board/galileo.html

  to load the binary into the Galileo Dev Board.


Usage
-----

* From a terminal, run the gateway:

  mosquitto -v

* Connect the FTDI cable to the Galileo. Open a terminal and run:

  screen /dev/ttyUSB0 115200

* Turn on the Galileo.

* Galileo's MQTT Client will publish to the topic "zephyr" the
  following message: "Hello World from Zephyr!"

* A subscriber is needed in order to receive the messages sent by the
  Galileo. For example, the following command must be executed from a
  terminal to create a MQTT subscriber:

    mosquitto_sub -t zephyr

  If this command is executed from a computer other than the gateway,
  the host must be specified.

* To publish a message, the following command can be used:

    mosquitto_pub -t zephyr -m "Hello World"

  The "Hello World" message must be displayed in the Galileo's debugging
  console.


Final Remakrs
-------------

The provided source code perhaps does not exemplify the best way to use
Paho's MQTT in Zephyr. For example, PINGREQ must be sent periodically,
but not too often as in this use-case. Furthermore, DISCONNECT is never
used here.