28 #define ADDRESS "tcp://mqtt.eclipse.org:1883" 29 #define CLIENTID "ExampleClientPub" 30 #define TOPIC "MQTT Examples" 31 #define PAYLOAD "Hello World!" 33 #define TIMEOUT 10000L 39 printf(
"Message with token value %d delivery confirmed\n", dt);
45 printf(
"Message arrived\n");
46 printf(
" topic: %s\n", topicName);
55 printf(
"\nConnection lost\n");
56 printf(
" cause: %s\n", cause);
59 int main(
int argc,
char* argv[])
70 printf(
"Failed to create client, return code %d\n", rc);
77 printf(
"Failed to set callbacks, return code %d\n", rc);
86 printf(
"Failed to connect, return code %d\n", rc);
98 printf(
"Failed to publish message, return code %d\n", rc);
103 printf(
"Waiting for publication of %s\n" 104 "on topic %s for client with ClientID: %s\n",
118 printf(
"Failed to disconnect, return code %d\n", rc);
void delivered(void *context, MQTTClient_deliveryToken dt)
#define MQTTCLIENT_SUCCESS
int MQTTClient_connect(MQTTClient handle, MQTTClient_connectOptions *options)
int MQTTClient_disconnect(MQTTClient handle, int timeout)
#define MQTTClient_message_initializer
MQTTAsync_connectOptions conn_opts
int msgarrvd(void *context, char *topicName, int topicLen, MQTTClient_message *message)
int MQTTClient_setCallbacks(MQTTClient handle, void *context, MQTTClient_connectionLost *cl, MQTTClient_messageArrived *ma, MQTTClient_deliveryComplete *dc)
MQTTClient_deliveryToken deliveredtoken
int MQTTClient_publishMessage(MQTTClient handle, const char *topicName, MQTTClient_message *message, MQTTClient_deliveryToken *deliveryToken)
void connlost(void *context, char *cause)
int main(int argc, char *argv[])
void MQTTClient_freeMessage(MQTTClient_message **message)
void MQTTClient_destroy(MQTTClient *handle)
void MQTTClient_free(void *memory)
#define MQTTCLIENT_PERSISTENCE_NONE
#define MQTTClient_connectOptions_initializer
int MQTTClient_deliveryToken
int MQTTClient_create(MQTTClient *handle, const char *serverURI, const char *clientId, int persistence_type, void *persistence_context)