Перейти к содержанию

Навигация

MQTT/en: различия между версиями

Новая страница: «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…»
(Новая страница: «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===


Подписаться можно не только на один топик, но и на группу топиков по метасиволу. В MQTT применяется два метасимвола: '''#''' и '''+'''. Метасимвол ''#'' означает любое количество уровней вложенных топиков. Выполним команду
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>
В результате мы получили не только значения с "контрола" устройства, но и топики с метаданными - название драйвера устройства и тип "контрола" - ''temperature''.
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.




12 063

правки