12 063
правки
(Новая страница: «You can also subscribe to messages from the Linux console using the mosquitto_sub utility (for a full description of the utility, see [http://mosquitto.org/man/mo…») |
(Новая страница: «You can subscribe not just for one topic, but for a group of topics by metasymbol. In MQTT we use two special characters: '''#''' and '''+'''. The special charact…») |
||
Строка 121: | Строка 121: | ||
===Metacharacters=== | ===Metacharacters=== | ||
You can subscribe not just for one topic, but for a group of topics by metasymbol. In MQTT we use two special characters: '''#''' and '''+'''. The special character '''#''' means any number of levels of nested topics. Execute the command | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
root@wirenboard:~# mosquitto_sub -t '/devices/wb-w1/#' -v | root@wirenboard:~# mosquitto_sub -t '/devices/wb-w1/#' -v | ||
Строка 129: | Строка 129: | ||
/devices/wb-w1/controls/28-0115a48fcfff 22.75 | /devices/wb-w1/controls/28-0115a48fcfff 22.75 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
As a result, we got not only the values from the ''control'' device, but also topics with metadata - the name of the device driver and the type of "control" - temperature. There is also a metacharacter '''+''', which denotes one level, not an arbitrary number,as '''#''': | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
mosquitto_sub -v -t "/config/widgets/+/name" | mosquitto_sub -v -t "/config/widgets/+/name" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
In this case we will get the names of all widgets. | |||
правки