From Clomosy Docs
No edit summary |
No edit summary |
||
| Line 43: | Line 43: | ||
It is a feature that returns the network path of the channel when a message arrives on the network. | It is a feature that returns the network path of the channel when a message arrives on the network. | ||
MyMQTT.ReceivedTopic | MyMQTT.ReceivedTopic | ||
:<span style="color:blue">'''Connected:'''</span> | |||
It is checked whether the connection is established or not. Returns true or false. If true, the connection has been established. | |||
MyMQTT.Connected | |||
:<span style="color:blue">'''Channel:'''</span> | |||
The term "Channel" represents messages directed to the MQTT broker or a topic. Subject is the address where messages are published or subscribed to. | |||
MyMQTT.Channel := 'clomosy';//project guid + channel | |||
:<span style="color:blue">'''Connect:'''</span> | |||
Mqtt connection is provided. | |||
MyMQTT.Connect; | |||
:<span style="color:blue">'''Send:'''</span> | |||
It is used to send the desired message to the Mqtt network. | |||
MyMQTT.Send('Hello!'); | |||
See [[Seminar_Demos | page]] for an example. | |||
Revision as of 10:33, 2 October 2023
- What is MQTT?
Message queuing telemetry support (MQTT) is defined as a low bandwidth consumption machine-to-machine protocol that helps IoT devices communicate with each other, with minimal code requirements and network footprint.
- How Does MQTT Work?
MQTT’s publish/subscribe (pub/sub) communication strategy, which aims to maximize bandwidth utilization, is a substitute for traditional consumer architecture directly interacting with an endpoint. However, in the pub/sub paradigm, the client who transmits the news (the publisher) is separated from the customers receiving the information (or the subscribers). Since neither the writers nor the customers communicate with each other immediately, their interactions in them are handled by third parties called brokers.
Publishers and subscribers are two types of MQTT clients, depending on whether the client is publishing or getting messages. One can combine the two features in a single MQTT client. A publish is when a device (or client) wishes to send information to the server (or broker). In the middle, there is a central server or broker that acts as a mediator. Each incoming message is filtered by the broker, who then sends them to the appropriate customers. (clomosy)
Now that we have learned this information, we can use it remotely by connecting to our device with this system created in our infrastructure using the TclMQTT component.
The first step required for this process on Clomosy is to define the TclMqtt variable. This variable must then be created on the form.
var MyMQTT : TclMQTT; begin MyMQTT := MyForm.AddNewMQTTConnection(bigPanel,'MyMQTT'); end;
- tbeOnMQTTStatusChanged:
This is an event that occurs when the state of the MQTT connection changes. When an event change occurs, the event written in the 3rd parameter is triggered.
MyForm.AddNewEvent(MyMQTT,tbeOnMQTTStatusChanged,'MyMQTTStatusChanged');
- tbeOnMQTTPublishReceived:
This is an event that occurs when an MQTT message is received. The event in the 3rd parameter is used to process the received message.
MyForm.AddNewEvent(MyMQTT,tbeOnMQTTPublishReceived,'MyMQTTPublishReceived');
- ReceivedAlright:
It returns true if there is an oncoming return on the network, otherwise it returns false.
MyMQTT.ReceivedAlright
- ReceivedMessage:
It is used to access messages coming from the network.
MyMQTT.ReceivedMessage
- ReceivedTopic:
It is a feature that returns the network path of the channel when a message arrives on the network.
MyMQTT.ReceivedTopic
- Connected:
It is checked whether the connection is established or not. Returns true or false. If true, the connection has been established.
MyMQTT.Connected
- Channel:
The term "Channel" represents messages directed to the MQTT broker or a topic. Subject is the address where messages are published or subscribed to.
MyMQTT.Channel := 'clomosy';//project guid + channel
- Connect:
Mqtt connection is provided.
MyMQTT.Connect;
- Send:
It is used to send the desired message to the Mqtt network.
MyMQTT.Send('Hello!');
See page for an example.
