AWS IoT for ESP32 v1.0.0
An ESP-IDF based solution
lib_aws.h File Reference

An AWS library file. More...

Go to the source code of this file.

Data Structures

union  value_ut
 
struct  awsShadow_st
 AWS Shadow structure used by the library to handle shadow updates. You should initialize the callback handler and register this awsShadow_st by calling AWS_shadowDeltaRegister function to receive callbacks whenever the shadow element is updated. More...
 
struct  awsConfig_st
 AWS configuration structure used by the library. More...
 

Typedefs

typedef void(* awsShadowUpdateCallBack_t) (char *pKeyStr, void *pValue)
 Shadow update callback function type. The application should define the callback function and intialize it in the awsShadow_st configuration.
 

Enumerations

enum  awsIotStates_et {
  STATE_AWS_IDLE , STATE_AWS_INIT , STATE_AWS_START , STATE_AWS_PROVISIONING ,
  STATE_AWS_CONNECTED , STATE_AWS_DISCONNECTED , STATE_AWS_SUSPENDED , STATE_AWS_RESUME ,
  STATE_AWS_PROVISION_FAILED , STATE_AWS_MAX
}
 
enum  shadowValueType_et { SHADOW_VALUE_TYPE_INT , SHADOW_VALUE_TYPE_UINT , SHADOW_VALUE_TYPE_STRING , SHADOW_VALUE_TYPE_MAX }
 
enum  shadowUpdateType_et { SHADOW_UPDATE_TYPE_DESIRED , SHADOW_UPDATE_TYPE_REPORTED , SHADOW_UPDATE_TYPE_ALL , SHADOW_UPDATE_TYPE_MAX }
 

Functions

bool AWS_isConnected ()
 Check if the device is connected state. More...
 
awsIotStates_et AWS_getState ()
 Get the current state of AWS library. More...
 
const char * AWS_getStateString ()
 Get current state of AWS library as string. More...
 
const char * AWS_getThingName ()
 Get thing name. More...
 
void AWS_suspend ()
 Suspend AWS library. More...
 
void AWS_resume ()
 Resume AWS library from suspended state. More...
 
void AWS_close ()
 Disconnect and close the AWS IoT connection. More...
 
void AWS_restart ()
 Disconnect from AWS IoT and Reconnect back. More...
 
bool AWS_subscribe (char *pTopicStr, uint8_t qos_e)
 Subscribe to a given Topic on AWS IoT. More...
 
uint16_t AWS_subMsgAvailable ()
 Check if messages received for subscribed topics are available in the subscription message buffer. More...
 
bool AWS_subMsgRead (mqttMsg_st *ps_msg)
 Read the available message from the subscription message buffer. More...
 
bool AWS_publish (mqttMsg_st *ps_msg)
 Publish given message to AWS IoT. The message is queued in a Publish buffer, then gets published. More...
 
uint16_t AWS_pubMsgAvailable ()
 Check if message is available to publish in the Publish queue. More...
 
bool AWS_publishInProgress ()
 Check if library is still publishing messages. More...
 
bool AWS_shadowDeltaRegister (awsShadow_st *ps_shadow)
 Register a shadow element to receive callbacks whenever the shadow element is updated with a new value. More...
 
bool AWS_shadowUpdate (char *pKeyStr, void *pValue, shadowUpdateType_et updateType_e)
 Update the shadow element. More...
 
bool AWS_shadowDocumentUpdate (awsThingShadow_st as_thingShadow[], uint8_t maxKeys_u8, shadowUpdateType_et updateType_e)
 Update device shadow. More...
 
void AWS_printStatus ()
 Print the status of AWS IoT. More...
 
void AWS_printSubscribedTopics ()
 Print all of the subscribed topics. More...
 
void AWS_printCertificates ()
 Print the configured certificates. Prints ROOT CA, Client Cert. & Private key. More...
 

Detailed Description

An AWS library file.

AWS library handles AWS IoT events like Publish, Subscribe, Shadow updates, Connection events, Device Provisioning... etc.

Enumeration Type Documentation

◆ awsIotStates_et

An enum that represents states of AWS library. The AWS library will be in one of the following mode.

Enumerator
STATE_AWS_IDLE 

AWS idle state

STATE_AWS_INIT 

AWS init state

STATE_AWS_START 

AWS start state

STATE_AWS_PROVISIONING 

AWS device provisioning in progress

STATE_AWS_CONNECTED 

Device is connected to AWS

STATE_AWS_DISCONNECTED 

Device is disconnected from AWS

STATE_AWS_SUSPENDED 

AWS library is suspended state

STATE_AWS_RESUME 

Resumes AWS library from suspended state

STATE_AWS_PROVISION_FAILED 

AWS device provisioning has failed

STATE_AWS_MAX 

Total number of AWS states

◆ shadowUpdateType_et

An enum that represents all possible shadow update types.

Enumerator
SHADOW_UPDATE_TYPE_DESIRED 

Update Desired state

SHADOW_UPDATE_TYPE_REPORTED 

Update Reported state

SHADOW_UPDATE_TYPE_ALL 

Update both Desired & Reported states

SHADOW_UPDATE_TYPE_MAX 

Total number for update types

◆ shadowValueType_et

An enum that represents all possible shadow value types.

Enumerator
SHADOW_VALUE_TYPE_INT 

Shadow value type as integer

SHADOW_VALUE_TYPE_UINT 

Shadow value type as unsigned integer

SHADOW_VALUE_TYPE_STRING 

Shadow value type as string

SHADOW_VALUE_TYPE_MAX 

Total number of shadow value types

Function Documentation

◆ AWS_close()

void AWS_close ( )

Disconnect and close the AWS IoT connection.

Parameters
none
Returns
none

◆ AWS_getState()

awsIotStates_et AWS_getState ( )

Get the current state of AWS library.

Parameters
none
Returns
Current state of AWS library awsIotStates_et

◆ AWS_getStateString()

const char * AWS_getStateString ( )

Get current state of AWS library as string.

Parameters
none
Returns
String version of AWS states.
Return values
IDLE- for STATE_AWS_IDLE
INIT- for STATE_AWS_INIT
START- for STATE_AWS_START
PROVISIONING- for STATE_AWS_PROVISIONING
CONNECTED- for STATE_AWS_CONNECTED
DISCONNECTED- for STATE_AWS_DISCONNECTED
SUSPENDED- for STATE_AWS_SUSPENDED
RESUME- for STATE_AWS_RESUME
PROVISION_FAILED- for STATE_AWS_PROVISION_FAILED

◆ AWS_getThingName()

const char * AWS_getThingName ( )

Get thing name.

Parameters
none
Returns
The thing name as registed with AWS IoT.

◆ AWS_isConnected()

bool AWS_isConnected ( )

Check if the device is connected state.

Parameters
none
Returns
AWS connection status
Return values
truewhen connected
falsewhen not connected

◆ AWS_printCertificates()

void AWS_printCertificates ( )

Print the configured certificates. Prints ROOT CA, Client Cert. & Private key.

Parameters
none
Returns
none

◆ AWS_printStatus()

void AWS_printStatus ( )

Print the status of AWS IoT.

Parameters
none
Returns
none

◆ AWS_printSubscribedTopics()

void AWS_printSubscribedTopics ( )

Print all of the subscribed topics.

Parameters
none
Returns
none

◆ AWS_publish()

bool AWS_publish ( mqttMsg_st ps_msg)

Publish given message to AWS IoT. The message is queued in a Publish buffer, then gets published.

Parameters
[in]mqttMsg_stMQTT message type for publishing
Returns
Publish status
Return values
truewhen message is queued for publishing
falseon errors

◆ AWS_publishInProgress()

bool AWS_publishInProgress ( )

Check if library is still publishing messages.

Parameters
none
Returns
Status to indicate whether publish is in progress or not
Return values
truewhen library is publishing messages
falsewhen it's not publishing

◆ AWS_pubMsgAvailable()

uint16_t AWS_pubMsgAvailable ( )

Check if message is available to publish in the Publish queue.

Parameters
none
Returns
Status to indiciate if message available for publishing
Return values
trueif message is available for publishing
falseif no message is available

◆ AWS_restart()

void AWS_restart ( )

Disconnect from AWS IoT and Reconnect back.

Parameters
none
Returns
none

◆ AWS_resume()

void AWS_resume ( )

Resume AWS library from suspended state.

Parameters
none
Returns
none

◆ AWS_shadowDeltaRegister()

bool AWS_shadowDeltaRegister ( awsShadow_st ps_shadow)

Register a shadow element to receive callbacks whenever the shadow element is updated with a new value.

Parameters
[in]awsShadow_stshadow element to receive callback on update
Returns
Status to indicate if callback is registered
Return values
trueregisted successfully
falsewhen failed

◆ AWS_shadowDocumentUpdate()

bool AWS_shadowDocumentUpdate ( awsThingShadow_st  as_thingShadow[],
uint8_t  maxKeys_u8,
shadowUpdateType_et  updateType_e 
)

Update device shadow.

Parameters
[in]awsThingShadow_stThe Device shadow
[in]maxKeys_u8Max keys to update
[in]shadowUpdateType_etType of shadow update
Returns
Shadow update status
Return values
trueon success
falseon failure

◆ AWS_shadowUpdate()

bool AWS_shadowUpdate ( char *  pKeyStr,
void *  pValue,
shadowUpdateType_et  updateType_e 
)

Update the shadow element.

Parameters
[in]pKeyStrA key representing shadow element
[in]pValueNew value of the shadow element
[in]shadowUpdateType_etType of shadow update
Returns
Shadow update status
Return values
trueon success
falseon failure

◆ AWS_subMsgAvailable()

uint16_t AWS_subMsgAvailable ( )

Check if messages received for subscribed topics are available in the subscription message buffer.

Parameters
none
Returns
Number of bytes available.

◆ AWS_subMsgRead()

bool AWS_subMsgRead ( mqttMsg_st ps_msg)

Read the available message from the subscription message buffer.

Parameters
[out]mqttMsg_stMQTT message type
Returns
Message read status
Return values
truewhen message is read successfully from the buffer.
falseon errors

◆ AWS_subscribe()

bool AWS_subscribe ( char *  pTopicStr,
uint8_t  qos_e 
)

Subscribe to a given Topic on AWS IoT.

Parameters
[in]pTopicStrtopic as string
[in]qos_eQOS level
Returns
Subscription status
Return values
trueon success
falseon failure

◆ AWS_suspend()

void AWS_suspend ( )

Suspend AWS library.

Parameters
none
Returns
none