28 #if defined(_WRS_KERNEL) 32 #define ADDRESS "tcp://mqtt.eclipse.org:1883" 33 #define CLIENTID "ExampleClientPub" 34 #define TOPIC "MQTT Examples" 35 #define PAYLOAD "Hello World!" 37 #define TIMEOUT 10000L 47 printf(
"\nConnection lost\n");
48 printf(
" cause: %s\n", cause);
50 printf(
"Reconnecting\n");
55 printf(
"Failed to start connect, return code %d\n", rc);
62 printf(
"Disconnect failed\n");
68 printf(
"Successful disconnection\n");
78 printf(
"Message send failed token %d error code %d\n", response->
token, response->
code);
84 printf(
"Failed to start disconnect, return code %d\n", rc);
95 printf(
"Message with token value %d delivery confirmed\n", response->
token);
101 printf(
"Failed to start disconnect, return code %d\n", rc);
109 printf(
"Connect failed, rc %d\n", response ? response->
code : 0);
121 printf(
"Successful connection\n");
131 printf(
"Failed to start sendMessage, return code %d\n", rc);
142 int main(
int argc,
char* argv[])
150 printf(
"Failed to create client object, return code %d\n", rc);
156 printf(
"Failed to set callback, return code %d\n", rc);
167 printf(
"Failed to start connect, return code %d\n", rc);
171 printf(
"Waiting for publication of %s\n" 172 "on topic %s for client with ClientID: %s\n",
MQTTAsync_onFailure * onFailure
int messageArrived(void *context, char *topicName, int topicLen, MQTTAsync_message *m)
void onSendFailure(void *context, MQTTAsync_failureData *response)
void onDisconnect(void *context, MQTTAsync_successData *response)
#define MQTTAsync_responseOptions_initializer
int MQTTAsync_disconnect(MQTTAsync handle, const MQTTAsync_disconnectOptions *options)
int MQTTAsync_setCallbacks(MQTTAsync handle, void *context, MQTTAsync_connectionLost *cl, MQTTAsync_messageArrived *ma, MQTTAsync_deliveryComplete *dc)
int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions *options)
void onDisconnectFailure(void *context, MQTTAsync_failureData *response)
MQTTAsync_connectOptions conn_opts
int MQTTAsync_create(MQTTAsync *handle, const char *serverURI, const char *clientId, int persistence_type, void *persistence_context)
#define MQTTAsync_disconnectOptions_initializer
MQTTAsync_onFailure * onFailure
MQTTAsync_onFailure * onFailure
#define MQTTAsync_connectOptions_initializer
MQTTAsync_onSuccess * onSuccess
void MQTTAsync_destroy(MQTTAsync *handle)
#define MQTTASYNC_SUCCESS
int MQTTAsync_sendMessage(MQTTAsync handle, const char *destinationName, const MQTTAsync_message *message, MQTTAsync_responseOptions *response)
#define MQTTCLIENT_PERSISTENCE_NONE
void connlost(void *context, char *cause)
void onSend(void *context, MQTTAsync_successData *response)
void onConnect(void *context, MQTTAsync_successData *response)
#define MQTTAsync_message_initializer
int main(int argc, char *argv[])
MQTTAsync_onSuccess * onSuccess
MQTTAsync_onSuccess * onSuccess
void onConnectFailure(void *context, MQTTAsync_failureData *response)