46 lines
1.1 KiB
Markdown
46 lines
1.1 KiB
Markdown
# MQTT Commands
|
||
|
||
## simple
|
||
|
||
```sh
|
||
mosquitto_sub -h 91.99.29.8 -t outdoor/king-arthur/sword/run
|
||
```
|
||
|
||
## safe
|
||
|
||
```sh
|
||
mosquitto_sub -L mqtts://nerdyssey.de:8883/outdoor/king-arthur/sword/run -d
|
||
mosquitto_sub -L mqtts://nerdyssey.de:8883/outdoor/king-arthur/sword/int -d
|
||
|
||
mosquitto_pub -L mqtts://nerdyssey.de:8883 -t outdoor/king-arthur/sword/run -m "SetMaintanance"
|
||
```
|
||
|
||
- `+` Single-level wildcard: `t1/+/sub2/sub3`
|
||
- `#` Multi-level wildcard: `t1/#/sub3`, `t1/#`
|
||
|
||
```sh
|
||
# Publishing topic with message
|
||
# -h: Host (optional)
|
||
# -t: Topic
|
||
# -m: Message
|
||
# -q: Quality of service
|
||
# -r: Retain (keep this after failed connection)
|
||
# -h: Print help info
|
||
mosquitto_pub -t someTopic -m 123 -q 1
|
||
mosquitto_pub -r -t someTopic -m "on"
|
||
mosquitto_pub -h 91.99.29.8 -t someTopic -m 123 -q 1
|
||
|
||
# Subscribing to
|
||
# -h: Host (optional)
|
||
# -t: Topic s
|
||
# + is wildcard
|
||
# # is wildcard for full subtree
|
||
# -T: Exclude topic
|
||
# -q: Quality of service
|
||
mosquitto_sub -t someTopic -q 1
|
||
mosquitto_sub -t someTopic/+/subTopic
|
||
mosquitto_sub -t bbc/# -T bbc/radio3
|
||
mosquitto_sub -h 91.99.29.8 -t someTopic -q 1
|
||
```
|
||
|