mqtt_create

Creates an MQTT client and returns its connection handle.

C Language

MQTT mqtt_create();

ExampleMQTT Vuser Functions

Arguments

None

General

mqtt_create creates one MQTT client and returns that client's handle. The client is discarded on Vuser termination.

Two clients per Vuser can be created.

Return Values

The MQTT client handle.

Parameterization

Standard parameterization is not available for this function.

Example

This example shows how to create a connection handle, connect, and disconnect.

/* Declare MQTT client handle variable */

MQTT client;


/* Create client object and assign its handle to a variable */

client = mqtt_create();


/* Connect MQTT client to a broker at test.broker.com using TCP port number 1883 and insecure channel */

mqtt_connect(client, "tcp://test.broker.com:1883");


/*

..... Script logic .....

*/


/* Disconnect MQTT client from the broker */

mqtt_disconnect(client);