From Clomosy Docs

(Created page with "<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> function AddNewMQTTConnection(AComponent: TCLComponent; xName: string): TclMQTT; </div>")
 
No edit summary
Line 2: Line 2:
function AddNewMQTTConnection(AComponent: TCLComponent; xName: string): TclMQTT;
function AddNewMQTTConnection(AComponent: TCLComponent; xName: string): TclMQTT;
</div>
</div>
<span style="color:blue"><b>AComponent</b></span> : Specifies the parent of the object to be defined.<br>
<span style="color:blue"><b>xName</b></span> : The name of the defined TclMqtt object should be written.<br>
The MQTT protocol allows data transmission between devices or systems. This component can connect to an MQTT broker to perform operations like sending data (publish) or receiving data (subscribe).<br>
<div class="alert alert-info" role="alert" data-bs-theme="light">
For more information about MQTT, please visit the [[MQTT | page]].
</div>
<div class="table-responsive">
{| class="wikitable" style="border: 2px solid #c3d7e0"
! style="background-color: #c3d7e0"| Feature  !!style="background-color: #c3d7e0"| Use of !!style="background-color: #c3d7e0"| Definition
|-
|TclMQTT || MQTT1 : TclMQTT; || A variable belonging to the TclMQTT class is created.
|-
|AddNewMQTTConnection || MQTT1 = Form1.AddNewMQTTConnection(Panel1,'MQTT1'); || A new TclMQTT object is added to the form.
|-
|Connect ||MQTT1.Connect; || Mqtt connection is provided.
|-
|Connected || MQTT1.Connected || It is checked whether the connection is established or not. Returns true or false. If true, the connection has been established.
|-
|Channel || MQTT1.Channel = 'clomosy';//project guid + 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.
|-
|Send ||MQTT1.Send('Hello!'); || It is used to send the desired message to the Mqtt network.
|-
|tbeOnMQTTStatusChanged || Form1.AddNewEvent(MQTT1,tbeOnMQTTStatusChanged,'MyMQTTStatusChanged'); || 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.
|-
|tbeOnMQTTPublishReceived || Form1.AddNewEvent(MQTT1,tbeOnMQTTPublishReceived,'MyMQTTPublishReceived'); || 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.
|-
|ReceivedAlright || MQTT1.ReceivedAlright || It returns true if there is an oncoming return on the network, otherwise it returns false.
|-
|ReceivedMessage || MQTT1.ReceivedMessage || It is used to access messages coming from the network.
|-
|ReceivedTopic || MQTT1.ReceivedTopic || It is a feature that returns the network path of the channel when a message arrives on the network.
|}
</div>
<b>Example</b><br>
<pre>
</pre>

Revision as of 14:32, 18 November 2024

AComponent : Specifies the parent of the object to be defined.

xName : The name of the defined TclMqtt object should be written.

The MQTT protocol allows data transmission between devices or systems. This component can connect to an MQTT broker to perform operations like sending data (publish) or receiving data (subscribe).

Feature Use of Definition
TclMQTT MQTT1 : TclMQTT; A variable belonging to the TclMQTT class is created.
AddNewMQTTConnection MQTT1 = Form1.AddNewMQTTConnection(Panel1,'MQTT1'); A new TclMQTT object is added to the form.
Connect MQTT1.Connect; Mqtt connection is provided.
Connected MQTT1.Connected It is checked whether the connection is established or not. Returns true or false. If true, the connection has been established.
Channel MQTT1.Channel = 'clomosy';//project guid + 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.
Send MQTT1.Send('Hello!'); It is used to send the desired message to the Mqtt network.
tbeOnMQTTStatusChanged Form1.AddNewEvent(MQTT1,tbeOnMQTTStatusChanged,'MyMQTTStatusChanged'); 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.
tbeOnMQTTPublishReceived Form1.AddNewEvent(MQTT1,tbeOnMQTTPublishReceived,'MyMQTTPublishReceived'); 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.
ReceivedAlright MQTT1.ReceivedAlright It returns true if there is an oncoming return on the network, otherwise it returns false.
ReceivedMessage MQTT1.ReceivedMessage It is used to access messages coming from the network.
ReceivedTopic MQTT1.ReceivedTopic It is a feature that returns the network path of the channel when a message arrives on the network.

Example