Jump to content

MQTT C example: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1: Line 1:
<seo title="MQTT C Example | RidgeRun Developer" titlemode="replace" keywords="MQTT, message broker, publisher, subscriber, publisher-subscriber, metadata, message sharing, C example."  description="RidgeRun explains how to use MQTT with C. Learn how to easily test an MQTT C example!"></seo>
=What is MQTT?=
=What is MQTT?=


Line 36: Line 38:
</pre>
</pre>


 
The configuration of the publisher is as follows:
<pre>
#define ADDRESS    "tcp://mqtt.eclipseprojects.io:1883"
#define CLIENTID    "ExampleClientPub"
#define TOPIC      "MQTT Examples"
#define PAYLOAD    "Hello World!"
</pre>
Where each parameter represents:
* '''ADDRESS''': Address where the message broker server is running. This address typically includes the protocol (e.g., tcp), the broker's hostname or IP address, and the port number.
* '''CLIENTID''': Identifier of the client connected to the broker
* '''TOPIC''': Topic to which the publisher will send messages
* '''PAYLOAD''': This is the example message content that will be published, this is important in the context of this app, but it will change dynamically depending on the application.


==Creating Subscriber==
==Creating Subscriber==
Line 64: Line 77:
</pre>
</pre>
* The app will remain active listening for messages until the user closes it.
* The app will remain active listening for messages until the user closes it.
The configuration of the subscriber is as follows:
<pre>
#define ADDRESS    "tcp://mqtt.eclipseprojects.io:1883"
#define CLIENTID    "ExampleClientSub"
#define TOPIC      "MQTT Examples"
</pre>
Where each parameter represents:
* '''ADDRESS''': Address where the message broker server is running. This address typically includes the protocol (e.g., tcp), the broker's hostname or IP address, and the port number.
* '''CLIENTID''': Identifier of the client connected to the broker
* '''TOPIC''': Topic to which the subscriber will connect to receive messages.
{{ContactUs}}
[[Category:HowTo]]
Cookies help us deliver our services. By using our services, you agree to our use of cookies.