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

Echo received Delta message. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <limits.h>
#include "aws_iot_log.h"
#include "aws_iot_version.h"
#include "aws_iot_mqtt_client_interface.h"
#include "aws_iot_shadow_interface.h"
#include "aws_iot_config.h"

Functions

void parseInputArgsForConnectParams (int argc, char **argv)
 
void DeltaCallback (const char *pJsonValueBuffer, uint32_t valueLength, jsonStruct_t *pJsonStruct_t)
 
void UpdateStatusCallback (const char *pThingName, ShadowActions_t action, Shadow_Ack_Status_t status, const char *pReceivedJsonDocument, void *pContextData)
 
int main (int argc, char **argv)
 
bool buildJSONForReported (char *pJsonDocument, size_t maxSizeOfJsonDocument, const char *pReceivedDeltaData, uint32_t lengthDelta)
 This function builds a full Shadow expected JSON document by putting the data in the reported section. More...
 

Variables

char certDirectory [PATH_MAX+1] = "../../../certs"
 
char HostAddress [255] = AWS_IOT_MQTT_HOST
 
uint32_t port = AWS_IOT_MQTT_PORT
 
bool messageArrivedOnDelta = false
 
char stringToEchoDelta [SHADOW_MAX_SIZE_OF_RX_BUFFER]
 

Detailed Description

This application will echo the message received in delta, as reported. for example: Received Delta message { "state": { "switch": "on" } } This delta message means the desired switch position has changed to "on"

This application will take this delta message and publish it back as the reported message from the device. { "state": { "reported": { "switch": "on" } } }

This update message will remove the delta that was created. If this message was not removed then the AWS IoT Thing Shadow is going to always have a delta and keep sending delta any time an update is applied to the Shadow This example will not use any of the json builder/helper functions provided in the aws_iot_shadow_json_data.h.

Note
Ensure the buffer sizes in aws_iot_config.h are big enough to receive the delta message. The delta message will also contain the metadata with the timestamps

Function Documentation

bool buildJSONForReported ( char *  pJsonDocument,
size_t  maxSizeOfJsonDocument,
const char *  pReceivedDeltaData,
uint32_t  lengthDelta 
)
Parameters
pJsonDocumentBuffer to be filled up with the JSON data
maxSizeOfJsonDocumentmaximum size of the buffer that could be used to fill
pReceivedDeltaDataThis is the data that will be embedded in the reported section of the JSON document
lengthDeltaLength of the data