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

System library header file. More...

Go to the source code of this file.

Data Structures

struct  systemInitConfig_st
 System configuration structure. The application should define the system configuration variable and configure it before calling SYSTEM_init function. More...
 

Typedefs

typedef void(* systemEventCb_t) (systemEvents_et eventId)
 System events callback function type. The application should define the callback function and initialize the system configuration with the callback function to receive the system events.
 

Enumerations

enum  systemMode_et {
  SYSTEM_MODE_IDLE , SYSTEM_MODE_TEST , SYSTEM_MODE_CONFIG , SYSTEM_MODE_NORMAL ,
  SYSTEM_MODE_OTA , SYSTEM_MODE_ABORT , SYSTEM_MODE_MAX
}
 
enum  systemEvents_et {
  EVENT_WIFI_CONNECTED , EVENT_WIFI_DISCONNECTED , EVENT_AWS_CONNECTED , EVENT_AWS_DISCONNECTED ,
  EVENT_BLE_CONNECTED , EVENT_BLE_AUTHENTICATED , EVENT_BLE_DISCONNECTED , EVENT_MQTT_CONNECTED ,
  EVENT_MQTT_DISCONNECTED , EVENT_MAX
}
 

Functions

bool SYSTEM_init (systemInitConfig_st *s_pConfig)
 Initiliaze the system with given configuration. More...
 
bool SYSTEM_startFirmwareUpdate (firmUpdateType_et e_type, char *pUrlStr)
 Initialize the device for OTA firmware update and put the system into SYSTEM_MODE_OTA mode. More...
 
bool SYSTEM_startFileDownload (char *pUrlStr)
 Start firmware file download. More...
 
void SYSTEM_restart (uint32_t restartDelay_u32)
 Restarts device. More...
 
systemMode_et SYSTEM_getMode ()
 Get the system mode. More...
 
const char * SYSTEM_getModeString ()
 Get the system mode as string. More...
 
void SYSTEM_abort (char *pMsgStr, const char *pFunNameStr, uint32_t errorCode_u32)
 Puts the system in abort mode and restarts the system. More...
 
const char * SYSTEM_getDeviceName ()
 Get the device name as registered in AWS IoT. More...
 
const char * SYSTEM_getMacAddr ()
 Get the MAC address of the device. More...
 
const char * SYSTEM_getResetCause ()
 Get the cause of device reset. More...
 

Detailed Description

System library header file.

The system library initialiezes the hardware peripherals required by the system by handling core operations like handling connectivity events for WiFi, BLE, AWS IoT operations, Flash storage operations, printing device logs & OTA firmware updates.

Enumeration Type Documentation

◆ systemEvents_et

An enum that represents System events. The system notifes the application about these events using a callback of type systemEventCb_t.

Enumerator
EVENT_WIFI_CONNECTED 

WiFi is connected

EVENT_WIFI_DISCONNECTED 

WiFi is disconnected

EVENT_AWS_CONNECTED 

Device is connected to AWS IoT endpoint

EVENT_AWS_DISCONNECTED 

Device is disconnected to AWS IoT endpoint

EVENT_BLE_CONNECTED 

Device is connected to BLE central device

EVENT_BLE_AUTHENTICATED 

A BLE xentral device has authenticated successfully

EVENT_BLE_DISCONNECTED 

Device is disconnected from BLE central device

EVENT_MQTT_CONNECTED 

Device is connected to MQTT broker

EVENT_MQTT_DISCONNECTED 

Device is disconnected from MQTT broker

EVENT_MAX 

Total number of system events

◆ systemMode_et

An enum that represents System modes. The system will always be in one of the following mode.

Enumerator
SYSTEM_MODE_IDLE 

System idle state

SYSTEM_MODE_TEST 

Test mode

SYSTEM_MODE_CONFIG 

Device is waiting for configuration

SYSTEM_MODE_NORMAL 

Device is configured/provisioned to run AWS IoT

SYSTEM_MODE_OTA 

System is in OTA mode to perform firmware update

SYSTEM_MODE_ABORT 

System abort mode

SYSTEM_MODE_MAX 

Total number of system modes

Function Documentation

◆ SYSTEM_abort()

void SYSTEM_abort ( char *  pMsgStr,
const char *  pFunNameStr,
uint32_t  errorCode_u32 
)

Puts the system in abort mode and restarts the system.

Parameters
[in]pMsgStrError message
[in]pFunNameStrFunction that called SYSTEM_abort
[in]errorCode_u32Error code
Return values
none

◆ SYSTEM_getDeviceName()

const char * SYSTEM_getDeviceName ( )

Get the device name as registered in AWS IoT.

Parameters
none
Returns
Thing name as string

◆ SYSTEM_getMacAddr()

const char * SYSTEM_getMacAddr ( )

Get the MAC address of the device.

Parameters
none
Returns
Device's MAC address as string

◆ SYSTEM_getMode()

systemMode_et SYSTEM_getMode ( )

Get the system mode.

Parameters
none
Returns
The current mode of the system

◆ SYSTEM_getModeString()

const char * SYSTEM_getModeString ( )

Get the system mode as string.

Returns
The current mode of the system as string
Return values
IDLEstring for SYSTEM_MODE_IDLE
TESTstring for SYSTEM_MODE_TEST
CONFIGstring for SYSTEM_MODE_CONFIG
NORMALstring for SYSTEM_MODE_NORMAL
OTAstring for SYSTEM_MODE_OTA
ABORTstring for SYSTEM_MODE_ABORT

◆ SYSTEM_getResetCause()

const char * SYSTEM_getResetCause ( )

Get the cause of device reset.

Parameters
none
Returns
System reset reason as string value
Return values
NO_MEANwrite some description here
POWERON_RESETwrite some description here
SW_RESETwrite some description here
OWDT_RESETwrite some description here
DEEPSLEEP_RESETwrite some description here
SDIO_RESETwrite some description here
TG0WDT_SYS_RESETwrite some description here
TG1WDT_SYS_RESETwrite some description here
RTCWDT_SYS_RESETwrite some description here
INTRUSION_RESETwrite some description here
TGWDT_CPU_RESETwrite some description here
SW_CPU_RESETwrite some description here
EXT_CPU_RESETwrite some description here
RTCWDT_BROWN_OUT_RESETwrite some description here
RTCWDT_RTC_RESETwrite some description here

◆ SYSTEM_init()

bool SYSTEM_init ( systemInitConfig_st s_pConfig)

Initiliaze the system with given configuration.

Parameters
[in]s_pConfigPointer to system configuration structure.
Returns
Initialization status
Return values
trueon success
falseon failure

◆ SYSTEM_restart()

void SYSTEM_restart ( uint32_t  restartDelay_u32)

Restarts device.

Parameters
[in]restartDelay_u32Delay (ms) after which system should be restarted
Return values
none

◆ SYSTEM_startFileDownload()

bool SYSTEM_startFileDownload ( char *  pUrlStr)

Start firmware file download.

Parameters
[in]pUrlStrURL of file to be downloaded
Returns
File download started status
Return values
trueon success
falseon failure

◆ SYSTEM_startFirmwareUpdate()

bool SYSTEM_startFirmwareUpdate ( firmUpdateType_et  e_type,
char *  pUrlStr 
)

Initialize the device for OTA firmware update and put the system into SYSTEM_MODE_OTA mode.

Parameters
[in]e_typeFirmware update type
[in]pUrlStrURL of firmware binary file
Returns
OTA trigger status
Return values
trueon success
falseon failure