A simple connected window example demonstrating the use of Thing Shadow.
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_shadow_interface.h>
#include "aws_iot_log.h"
#include "aws_iot_version.h"
#include "aws_iot_shadow_json_data.h"
#include "aws_iot_config.h"
#include "aws_iot_mqtt_client_interface.h"
|
| #define | ROOMTEMPERATURE_UPPERLIMIT 32.0f |
| |
|
#define | ROOMTEMPERATURE_LOWERLIMIT 25.0f |
| |
|
#define | STARTING_ROOMTEMPERATURE ROOMTEMPERATURE_LOWERLIMIT |
| |
|
#define | MAX_LENGTH_OF_UPDATE_JSON_BUFFER 200 |
| |
|
|
void | ShadowUpdateStatusCallback (const char *pThingName, ShadowActions_t action, Shadow_Ack_Status_t status, const char *pReceivedJsonDocument, void *pContextData) |
| |
|
void | windowActuate_Callback (const char *pJsonString, uint32_t JsonStringDataLen, jsonStruct_t *pContext) |
| |
|
void | parseInputArgsForConnectParams (int argc, char **argv) |
| |
|
int | main (int argc, char **argv) |
| |
|
|
char | certDirectory [PATH_MAX+1] = "../../../certs" |
| |
|
char | HostAddress [255] = AWS_IOT_MQTT_HOST |
| |
|
uint32_t | port = AWS_IOT_MQTT_PORT |
| |
|
uint8_t | numPubs = 5 |
| |
| #define ROOMTEMPERATURE_UPPERLIMIT 32.0f |
The goal of this sample application is to demonstrate the capabilities of shadow. This device(say Connected Window) will open the window of a room based on temperature It can report to the Shadow the following parameters:
- temperature of the room (double)
- status of the window (open or close) It can act on commands from the cloud. In this case it will open or close the window based on the json object "windowOpen" data[open/close]
The two variables from a device's perspective are double temperature and bool windowOpen The device needs to act on only on windowOpen variable, so we will create a primitiveJson_t object with callback The Json Document in the cloud will be { "reported": { "temperature": 0, "windowOpen": false }, "desired": { "windowOpen": false } }