28 #if defined(_WRS_KERNEL) 32 #define ADDRESS "tcp://mqtt.eclipse.org:1883" 33 #define CLIENTID "ExampleClientSub" 34 #define TOPIC "MQTT Examples" 35 #define PAYLOAD "Hello World!" 37 #define TIMEOUT 10000L 49 printf(
"\nConnection lost\n");
51 printf(
" cause: %s\n", cause);
53 printf(
"Reconnecting\n");
58 printf(
"Failed to start connect, return code %d\n", rc);
66 printf(
"Message arrived\n");
67 printf(
" topic: %s\n", topicName);
76 printf(
"Disconnect failed, rc %d\n", response->
code);
82 printf(
"Successful disconnection\n");
88 printf(
"Subscribe succeeded\n");
94 printf(
"Subscribe failed, rc %d\n", response->
code);
101 printf(
"Connect failed, rc %d\n", response->
code);
112 printf(
"Successful connection\n");
114 printf(
"Subscribing to topic %s\nfor client %s using QoS%d\n\n" 121 printf(
"Failed to start subscribe, return code %d\n", rc);
127 int main(
int argc,
char* argv[])
138 printf(
"Failed to create client, return code %d\n", rc);
145 printf(
"Failed to set callbacks, return code %d\n", rc);
157 printf(
"Failed to start connect, return code %d\n", rc);
175 }
while (ch!=
'Q' && ch !=
'q');
181 printf(
"Failed to start disconnect, return code %d\n", rc);
MQTTAsync_onFailure * onFailure
void onDisconnect(void *context, MQTTAsync_successData *response)
#define MQTTAsync_responseOptions_initializer
void onDisconnectFailure(void *context, MQTTAsync_failureData *response)
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)
void onConnectFailure(void *context, MQTTAsync_failureData *response)
void MQTTAsync_free(void *memory)
void MQTTAsync_freeMessage(MQTTAsync_message **message)
int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions *options)
MQTTAsync_connectOptions conn_opts
int MQTTAsync_subscribe(MQTTAsync handle, const char *topic, int qos, MQTTAsync_responseOptions *response)
int MQTTAsync_create(MQTTAsync *handle, const char *serverURI, const char *clientId, int persistence_type, void *persistence_context)
int main(int argc, char *argv[])
#define MQTTAsync_disconnectOptions_initializer
MQTTAsync_onFailure * onFailure
void connlost(void *context, char *cause)
MQTTAsync_onFailure * onFailure
#define MQTTAsync_connectOptions_initializer
MQTTAsync_onSuccess * onSuccess
void onSubscribe(void *context, MQTTAsync_successData *response)
void MQTTAsync_destroy(MQTTAsync *handle)
#define MQTTASYNC_SUCCESS
#define MQTTCLIENT_PERSISTENCE_NONE
void onSubscribeFailure(void *context, MQTTAsync_failureData *response)
void onConnect(void *context, MQTTAsync_successData *response)
int msgarrvd(void *context, char *topicName, int topicLen, MQTTAsync_message *message)
MQTTAsync_onSuccess * onSuccess
MQTTAsync_onSuccess * onSuccess