AWS IoT for ESP32 v1.0.0
An ESP-IDF based solution
lib_aws.h
Go to the documentation of this file.
1
8#ifndef _LIB_AWS_H_
9#define _LIB_AWS_H_
10
11#include "lib_config.h"
12#include "lib_msg.h"
13#include "stdutils.h"
14
20typedef enum
21{
33
38typedef enum
39{
45
50typedef enum
51{
58
63typedef union
64{
65 uint32_t val_u32;
66 int32_t val_i32;
67 char str[LENGTH_AWS_SHADOW_BUFFER];
68} value_ut;
69
75typedef void (*awsShadowUpdateCallBack_t)(char *pKeyStr, void *pValue);
76
77typedef struct
78{
79 char keyStr[LENGTH_AWS_SHADOW_KEY];
80 value_ut value_e;
81 shadowValueType_et valType_e;
82} awsThingShadow_st;
83
92typedef struct
93{
96 char keyStr[LENGTH_AWS_SHADOW_KEY];
98 uint8_t isUpdated_b8;
100
104typedef struct
105{
106 char hostNameStr[LENGTH_HTTP_URL];
107 uint16_t port_u16;
114 const char *pThingNameStr;
116
125
132
147const char *AWS_getStateString();
148
154const char *AWS_getThingName();
155
162
169
176
183
192bool AWS_subscribe(char *pTopicStr, uint8_t qos_e);
193
201
210
220
229
238
248
258bool AWS_shadowUpdate(char *pKeyStr, void *pValue, shadowUpdateType_et updateType_e);
259
269bool AWS_shadowDocumentUpdate(awsThingShadow_st as_thingShadow[], uint8_t maxKeys_u8, shadowUpdateType_et updateType_e);
270
277
284
292
293#endif
void AWS_suspend()
Suspend AWS library.
bool AWS_subscribe(char *pTopicStr, uint8_t qos_e)
Subscribe to a given Topic on AWS IoT.
void AWS_printSubscribedTopics()
Print all of the subscribed topics.
uint16_t AWS_subMsgAvailable()
Check if messages received for subscribed topics are available in the subscription message buffer.
bool AWS_shadowDocumentUpdate(awsThingShadow_st as_thingShadow[], uint8_t maxKeys_u8, shadowUpdateType_et updateType_e)
Update device shadow.
awsIotStates_et AWS_getState()
Get the current state of AWS library.
uint16_t AWS_pubMsgAvailable()
Check if message is available to publish in the Publish queue.
shadowValueType_et
Definition: lib_aws.h:39
@ SHADOW_VALUE_TYPE_MAX
Definition: lib_aws.h:43
@ SHADOW_VALUE_TYPE_STRING
Definition: lib_aws.h:42
@ SHADOW_VALUE_TYPE_INT
Definition: lib_aws.h:40
@ SHADOW_VALUE_TYPE_UINT
Definition: lib_aws.h:41
bool AWS_isConnected()
Check if the device is connected state.
bool AWS_publishInProgress()
Check if library is still publishing messages.
void AWS_resume()
Resume AWS library from suspended state.
bool AWS_publish(mqttMsg_st *ps_msg)
Publish given message to AWS IoT. The message is queued in a Publish buffer, then gets published.
void(* awsShadowUpdateCallBack_t)(char *pKeyStr, void *pValue)
Shadow update callback function type. The application should define the callback function and intiali...
Definition: lib_aws.h:75
void AWS_printCertificates()
Print the configured certificates. Prints ROOT CA, Client Cert. & Private key.
const char * AWS_getStateString()
Get current state of AWS library as string.
bool AWS_shadowUpdate(char *pKeyStr, void *pValue, shadowUpdateType_et updateType_e)
Update the shadow element.
shadowUpdateType_et
Definition: lib_aws.h:51
@ SHADOW_UPDATE_TYPE_REPORTED
Definition: lib_aws.h:53
@ SHADOW_UPDATE_TYPE_MAX
Definition: lib_aws.h:56
@ SHADOW_UPDATE_TYPE_DESIRED
Definition: lib_aws.h:52
@ SHADOW_UPDATE_TYPE_ALL
Definition: lib_aws.h:54
void AWS_close()
Disconnect and close the AWS IoT connection.
void AWS_printStatus()
Print the status of AWS IoT.
void AWS_restart()
Disconnect from AWS IoT and Reconnect back.
awsIotStates_et
Definition: lib_aws.h:21
@ STATE_AWS_CONNECTED
Definition: lib_aws.h:26
@ STATE_AWS_PROVISION_FAILED
Definition: lib_aws.h:30
@ STATE_AWS_DISCONNECTED
Definition: lib_aws.h:27
@ STATE_AWS_SUSPENDED
Definition: lib_aws.h:28
@ STATE_AWS_START
Definition: lib_aws.h:24
@ STATE_AWS_PROVISIONING
Definition: lib_aws.h:25
@ STATE_AWS_MAX
Definition: lib_aws.h:31
@ STATE_AWS_IDLE
Definition: lib_aws.h:22
@ STATE_AWS_INIT
Definition: lib_aws.h:23
@ STATE_AWS_RESUME
Definition: lib_aws.h:29
bool AWS_shadowDeltaRegister(awsShadow_st *ps_shadow)
Register a shadow element to receive callbacks whenever the shadow element is updated with a new valu...
bool AWS_subMsgRead(mqttMsg_st *ps_msg)
Read the available message from the subscription message buffer.
const char * AWS_getThingName()
Get thing name.
Configuration header file.
MQTT message header file.
AWS configuration structure used by the library.
Definition: lib_aws.h:105
uint16_t port_u16
Definition: lib_aws.h:107
char * pRootCaStr
Definition: lib_aws.h:108
char * pClaimCertStr
Definition: lib_aws.h:111
char * pThingCertStr
Definition: lib_aws.h:109
const char * pThingNameStr
Definition: lib_aws.h:114
char * pThingPrivateKeyStr
Definition: lib_aws.h:110
char * pClaimPrivateKeyStr
Definition: lib_aws.h:112
char * pClaimTemplateStr
Definition: lib_aws.h:113
AWS Shadow structure used by the library to handle shadow updates. You should initialize the callback...
Definition: lib_aws.h:93
value_ut value_e
Definition: lib_aws.h:97
shadowValueType_et valType_e
Definition: lib_aws.h:94
awsShadowUpdateCallBack_t callBackHandler
Definition: lib_aws.h:95
uint8_t isUpdated_b8
Definition: lib_aws.h:98
Structure to represent MQTT message.
Definition: lib_msg.h:48
Definition: lib_aws.h:64
uint32_t val_u32
Definition: lib_aws.h:65
int32_t val_i32
Definition: lib_aws.h:66