MQTT/en: различия между версиями
(Новая страница: «Customers who want to monitor the temperature value, "subscribe" to this topic, and they receive new messages - changing temperature values. One such client is th…») |
(Новая страница: «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…») |
||
Строка 112: | Строка 112: | ||
Customers who want to monitor the temperature value, "subscribe" to this topic, and they receive new messages - changing temperature values. One such client is the web interface. | Customers who want to monitor the temperature value, "subscribe" to this topic, and they receive new messages - changing temperature values. One such client is the web interface. | ||
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/mosquitto_sub-1.html The article]): | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
root@wirenboard:~# mosquitto_sub -t '/devices/wb-w1/controls/28-0115a48fcfff' -v // | root@wirenboard:~# mosquitto_sub -t '/devices/wb-w1/controls/28-0115a48fcfff' -v //receive messages from a topic of the 1-Wire device with ID: 28-0115a48fcfff | ||
/devices/wb-w1/controls/28-0115a48fcfff 22.75 // | /devices/wb-w1/controls/28-0115a48fcfff 22.75 //in this line and below is the output of the utility received messages | ||
/devices/wb-w1/controls/28-0115a48fcfff 22.75 | /devices/wb-w1/controls/28-0115a48fcfff 22.75 | ||
/devices/wb-w1/controls/28-0115a48fcfff 22.75 | /devices/wb-w1/controls/28-0115a48fcfff 22.75 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | ===Metacharacters=== | ||
Подписаться можно не только на один топик, но и на группу топиков по метасиволу. В MQTT применяется два метасимвола: '''#''' и '''+'''. Метасимвол ''#'' означает любое количество уровней вложенных топиков. Выполним команду | Подписаться можно не только на один топик, но и на группу топиков по метасиволу. В MQTT применяется два метасимвола: '''#''' и '''+'''. Метасимвол ''#'' означает любое количество уровней вложенных топиков. Выполним команду |