-
Notifications
You must be signed in to change notification settings - Fork 2.1k
paho-mqtt: add package and example #12647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 \ | ||
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.