AWS IoT Embedded C Device SDK
Functions | Variables
subscribe_publish_sample.c File Reference

simple MQTT publish and subscribe on the same topic More...

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <signal.h>
#include <memory.h>
#include <sys/time.h>
#include <limits.h>
#include <aws_iot_mqtt_client.h>
#include "aws_iot_log.h"
#include "aws_iot_version.h"
#include "aws_iot_mqtt_client_interface.h"
#include "aws_iot_config.h"

Functions

void MQTTcallbackHandler (AWS_IoT_Client *pClient, char *topicName, uint16_t topicNameLen, IoT_Publish_Message_Params *params, void *pData)
 
void disconnectCallbackHandler (AWS_IoT_Client *pClient, void *data)
 
void parseInputArgsForConnectParams (int argc, char **argv)
 
int main (int argc, char **argv)
 

Variables

char certDirectory [PATH_MAX+1] = "../../../certs"
 Default cert location.
 
char HostAddress [255] = AWS_IOT_MQTT_HOST
 Default MQTT HOST URL is pulled from the aws_iot_config.h.
 
uint32_t port = AWS_IOT_MQTT_PORT
 Default MQTT port is pulled from the aws_iot_config.h.
 
uint32_t publishCount = 0
 This parameter will avoid infinite loop of publish and exit the program after certain number of publishes.
 

Detailed Description

This example takes the parameters from the aws_iot_config.h file and establishes a connection to the AWS IoT MQTT Platform. It subscribes and publishes to the same topic - "sdkTest/sub"

If all the certs are correct, you should see the messages received by the application in a loop.

The application takes in the certificate path, host name , port and the number of times the publish should happen.