12 063
правки
(Новая страница: «If a button is pressed in the web interface, the web interface sends a message to the MQTT queue, the device driver receives it and sends a command to the device.») |
(Новая страница: «== 1 Examples of work via the MQTT queue == ===Getting the value from the temperature sensor and displaying it in the web interface=== File:Web-devices-1-wire.p…») |
||
Строка 6: | Строка 6: | ||
If a button is pressed in the web interface, the web interface sends a message to the MQTT queue, the device driver receives it and sends a command to the device. | If a button is pressed in the web interface, the web interface sends a message to the MQTT queue, the device driver receives it and sends a command to the device. | ||
== | == 1 Examples of work via the MQTT queue == | ||
=== | ===Getting the value from the temperature sensor and displaying it in the web interface=== | ||
[[File:Web-devices-1-wire.png|400px|thumb| | [[File:Web-devices-1-wire.png|400px|thumb|Sensor readings and its unique identifier on the '''Devices''' page of the web interface]] | ||
Assume that a [[1-Wire/en]] bus temperature sensor is connected to the Wiren Board. Let's see how the sensor data comes into the web interface via the message queue: | |||
# | #The driver that is responsible for this hardware function ([https://github.com/contactless/wb-homa-drivers/tree/master/wb-homa-w1 wb-homa-w1]) polls the 1-Wire sensors connected to the controller. | ||
# | #When a value is received, the driver queues a message that resembles the following: <pre>/devices/wb-w1/controls/28-0115a48fcfff 23.25</pre>It means that the 1-Wire device (ID 28-0115a48fcfff)registers a value of 23.25°C. | ||
# | #The web interface that receives all messages from the queue (it is subscribed to all messages) receives this message and displays the sensor value to the page. | ||
=== | ===Pressing a button in the web interface and switching the relay on the external module=== | ||
[[File:Web-devices-serial.png|400px|thumb| | [[File:Web-devices-serial.png|400px|thumb|Web interface after pressing relay 1 on the relay module [[WB-MRM2/en| MRM2]] CONNECTED via RS-485]] | ||
Suppose that the relay module WB-MRM2 is connected to the controller via the [[RS-485/en| RS-485]] bus. The user presses the relay button in the web interface and switches it on. Let's see how the command from the web interface gets to the external module: <pre>/devices/wb-mrm2_130/controls/Relay 1/on 1</pre>It means that the device WB-MRM2 with the address ''130'' must transfer Relay 1 to the state of the logical unit - "on". | |||
#[[Драйвер wb-mqtt-serial/en|The wb-mqtt-serial driver]] responsible for this hardware function receives this message (it is subscribed to all messages related to RS-485 devices) and sends a command to turn on the first relay via the RS-485 bus to the relay module. | |||
#[[Драйвер wb-mqtt-serial]] | #The WB-MRM2 relay module receives a command from the controller, switches the relay and sends back a notification ("Relay 1 is on"). | ||
# | #The wb-mqtt-serial driver receives this notification over RS-485 and sends the message to the queue:<pre>/devices/wb-mrm2_130/controls/Relay 1 1</pre>It means that the first relay on the WB-MRM2 device with address ''130'' is in the logical 1 state (is "on"). | ||
# | |||
== Принцип работы очереди сообщений == | == Принцип работы очереди сообщений == |
правки