Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions examples/paho-mqtt/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
APPLICATION = paho-mqtt-example

# If no BOARD is found in the environment, use this default:
BOARD ?= native

# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../..

# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
DEVELHELP ?= 1

# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

WIFI_SSID ?= "Your_WiFi_name"
WIFI_PASS ?= "Your_secure_password"

USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
USEMODULE += netdev_default
USEPKG += paho-mqtt

# paho-mqtt depends on TCP support, choose the stack you want
LWIP_IPV4 ?= 0

ifneq (0, $(LWIP_IPV4))
USEMODULE += ipv4_addr
USEMODULE += lwip_arp
USEMODULE += lwip_ipv4
USEMODULE += lwip_dhcp_auto
USEMODULE += lwip_sock_udp
CFLAGS += -DETHARP_SUPPORT_STATIC_ENTRIES=1
LWIP_IPV6 ?= 0
else
LWIP_IPV6 ?= 1
endif

ifneq (0, $(LWIP_IPV6))
USEMODULE += ipv6_addr
USEMODULE += lwip_ipv6_autoconfig
endif

USEMODULE += lwip_netdev
USEMODULE += lwip lwip_sock_ip
USEMODULE += lwip_tcp lwip_sock_tcp
USEMODULE += lwip_sock_async

USEMODULE += sock_async_event
####

include $(RIOTBASE)/Makefile.include

ifneq (,$(filter arch_esp,$(FEATURES_USED)))
CFLAGS += -DESP_WIFI_SSID=\"$(WIFI_SSID)\"
CFLAGS += -DESP_WIFI_PASS=\"$(WIFI_PASS)\"
endif
Comment thread
javierfileiv marked this conversation as resolved.
9 changes: 9 additions & 0 deletions examples/paho-mqtt/Makefile.board.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Put board specific dependencies here

ifneq (,$(filter arch_esp,$(FEATURES_USED)))
USEMODULE += esp_wifi
endif

ifeq ($(BOARD),native)
USEMODULE += netdev_default
endif
29 changes: 29 additions & 0 deletions examples/paho-mqtt/Makefile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BOARD_INSUFFICIENT_MEMORY := \
airfy-beacon \
calliope-mini \
i-nucleo-lrwan1 \
im880b \
microbit \
nrf6310 \
nucleo-f030r8 \
nucleo-f031k6 \
nucleo-f042k6 \
nucleo-f070rb \
nucleo-f072rb \
nucleo-f303k8 \
nucleo-f334r8 \
nucleo-l031k6 \
nucleo-l053r8 \
nucleo-f302r8 \
nrf51dongle \
stm32f030f4-demo \
stm32f0discovery \
stm32l0538-disco \
bluepill \
blackpill \
hifive1 \
hifive1b \
saml11-xpro \
saml10-xpro \
yunjia-nrf51822 \
#
50 changes: 50 additions & 0 deletions examples/paho-mqtt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
### About
This application demonstrates the usage of the Eclipse paho MQTT package in RIOT.

### Setup
For using this example, two prerequisites have to be fulfilled:

1. You need a running MQTT broker like Mosquitto broker for example. Take a look at
[Mosquitto Broker](https://mosquitto.org/). Check online any guide that will
help you setting up the broker into some port (a).
For example this one for debian base linux users
[How to setup a Mosquitto MQTT Server and receive data](https://www.digitalocean.com/community/questions/how-to-setup-a-mosquitto-mqtt-server-and-receive-data-from-owntracks).

2. Your RIOT node needs to be able to speak to that broker at the same port you set in 1.

### Setting up RIOT `native` on Linux
- Run `sudo ./dist/tools/tapsetup/tapsetup -c 1`

## Running the example
- Run on RIOT's root directory:

make -C examples/paho-mqtt all term

- To connect to a broker, use the `con` command:
```
con <broker ip addr> [port] [clientID] [user] [password] [keepalivetime]
```
* *broker ip addr*: IPv6 or IPv4 broker address.
* *port*: broker port. Default 1883
* *client ID*: is the client id you set up on the broker. Default can be set
through DEFAULT_MQTT_CLIENT_ID in your makefile. Otherwise is an empty string.
* *user*: the one set in the broker, check online tutorial to do it regarding chosen broker.
Default user can be set through DEFAULT_MQTT_USER in your makefile. Otherwise is an empty string.
* *password*: the one set in the broker, check online tutorial to do it regarding chosen broker.
Default user can be set through DEFAULT_MQTT_PWD in your makefile. Otherwise is an empty string.
* *keepalivetime*: keep alive in seconds for your client. Default 10 secs.

- To subscribe to a topic, run `sub` with the topic name as parameter and a QoS
level between 1 to 3, e.g.
```
sub hello/world 2
```
- To unsubscribe to a topic, run `unsub` with the topic name e.g.
```
unsub hello/world
```

- For publishing, use the `pub` command with a QoS level between 1 to 3:
```
pub hello/world "One more beer, please." 2
```
Loading