zephyr/samples/net/paho_mqtt_shell
Flavio Santes 0224e3577e samples/net/mqtt: Add a MQTT interactive shell
Add a MQTT interactive shell that can connect, disconnect, subscribe,
publish, read published messages and ping to the MQTT gateway.

Origin: Original

Jira: ZEP-364
Change-Id: Ie85e7b8b9290cb8e80548886aea74a8427b2323b
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-05-30 20:23:53 -05:00
..
src samples/net/mqtt: Add a MQTT interactive shell 2016-05-30 20:23:53 -05:00
Kbuild samples/net/mqtt: Add a MQTT interactive shell 2016-05-30 20:23:53 -05:00
Makefile samples/net/mqtt: Add a MQTT interactive shell 2016-05-30 20:23:53 -05:00
README samples/net/mqtt: Add a MQTT interactive shell 2016-05-30 20:23:53 -05:00
prj_ethernet.conf samples/net/mqtt: Add a MQTT interactive shell 2016-05-30 20:23:53 -05:00

README

MQTT shell example
==================

This sample shows how to create an interactive MQTT client using the
Zephyr shell and the Paho's MQTT Library.

Instructions
------------

1. Read carefully the README file in samples/net/paho_mqtt_client.

2. Clone Paho's MQTT Library:

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

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

So far, IPv4 addresses are still hard-coded in the config.h file.

Quick guide
-----------

The Zephyr shell allows you to type commands in the debug console.

To connect with the gateway, use the following command:

mqtt_shell> repeat_until_ok connect zephyr_galileo

repeat_until_ok will iterate until the command returns 0.

To ping the gateway:

mqtt_shell> ping

To subscribe to any zephyr's subtopic, type the following command:

mqtt_shell> subscribe zephyr/#

In your host, open another terminal and publish some random messages:

mosquitto_pub  -t "zephyr/lamps" -m "lamp1:OK"

mosquitto_pub  -t "zephyr/doors" -m "door3:OPEN"

To read these messages from Galileo, type:

mqtt_shell> read
topic: zephyr/lamps, msg: lamp1:OK

mqtt_shell> read
topic: zephyr/doors, msg: door3:OPEN

Observe that the Galileo MQTT shell is subscribed to "zephyr/#".

To publish a message:

mqtt_shell> publish zephyr "Hello!"

To repeat a command multiple times:

mqtt_shell> repeat 5 ping

This will send 5 consecutive pings to the gateway.