22 #define ADDRESS "tcp://mqtt.eclipse.org:1883" 23 #define CLIENTID "ExampleClientSub" 24 #define TOPIC "MQTT Examples" 25 #define PAYLOAD "Hello World!" 27 #define TIMEOUT 10000L 33 printf(
"Message with token value %d delivery confirmed\n", dt);
39 printf(
"Message arrived\n");
40 printf(
" topic: %s\n", topicName);
49 printf(
"\nConnection lost\n");
50 printf(
" cause: %s\n", cause);
53 int main(
int argc,
char* argv[])
62 printf(
"Failed to create client, return code %d\n", rc);
69 printf(
"Failed to set callbacks, return code %d\n", rc);
78 printf(
"Failed to connect, return code %d\n", rc);
83 printf(
"Subscribing to topic %s\nfor client %s using QoS%d\n\n" 87 printf(
"Failed to subscribe, return code %d\n", rc);
96 }
while (ch!=
'Q' && ch !=
'q');
100 printf(
"Failed to unsubscribe, return code %d\n", rc);
107 printf(
"Failed to disconnect, return code %d\n", rc);
#define MQTTCLIENT_SUCCESS
int MQTTClient_connect(MQTTClient handle, MQTTClient_connectOptions *options)
volatile MQTTClient_deliveryToken deliveredtoken
int MQTTClient_disconnect(MQTTClient handle, int timeout)
int msgarrvd(void *context, char *topicName, int topicLen, MQTTClient_message *message)
MQTTAsync_connectOptions conn_opts
int MQTTClient_setCallbacks(MQTTClient handle, void *context, MQTTClient_connectionLost *cl, MQTTClient_messageArrived *ma, MQTTClient_deliveryComplete *dc)
int MQTTClient_unsubscribe(MQTTClient handle, const char *topic)
void connlost(void *context, char *cause)
void MQTTClient_freeMessage(MQTTClient_message **message)
void delivered(void *context, MQTTClient_deliveryToken dt)
void MQTTClient_destroy(MQTTClient *handle)
int MQTTClient_subscribe(MQTTClient handle, const char *topic, int qos)
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)
int main(int argc, char *argv[])