AWS IoT Firmware
Firmware code for AWS IoT Devices
Classes | Macros | Functions
Bed Room Light Controller
Collaboration diagram for Bed Room Light Controller:

Classes

class  PowerCtrlHandler
 power controller class for the bed room light controller, responsible for handling an requests pertaining to the power controller namespace More...
 

Macros

#define SUBSCRIBE_TOPIC   "/bedRoomLightReq"
 topic that the bed room light controller subscribe to
 
#define PUBLISH_TOPIC   "/bedRoomLightRes"
 topic that the bed room light controller will publish replies to
 
#define LIGHT_CTRL_PIN   21
 pins used for controlling the relay to turn on/off the light
 
#define TOTAL_HANDLER   1
 change this if you use more or less handler
 
#define REGISTER_INTERRUPT()   {}
 empty since we don't use any interrupts
 
#define INITIALIZE_HANDLER()
 change this function to customize the list of handler More...
 

Functions

void handlePolling (struct mg_connection *mgCon, ParentHandler *handlerList[], char *jsonBuf)
 dummy empty function since bed room light controller has no polling need More...
 
 PowerCtrlHandler::PowerCtrlHandler (void)
 Construct a new Power Ctrl Handler:: Power Ctrl Handler object intialize a power controller handler for the bed room light controller.
 
HandlerError PowerCtrlHandler::handleRequest (struct mg_connection *mgCon, struct mg_str *message, char *commandName, char *response)
 implement the handle request function for the power control endpoint for the bedroom light controller More...
 
static void PowerCtrlHandler::setLightStatus (bool lightStatus)
 set the light status variable More...
 
static bool PowerCtrlHandler::getLightStatus (void)
 retrieve the status of the bed room lgiht More...
 
HandlerError PowerCtrlHandler::handleReport (char *stateReport)
 write a state report for the powercontroller endpoint to the given buffer More...
 

Detailed Description

Macro Definition Documentation

#define INITIALIZE_HANDLER ( )
Value:
static PowerCtrlHandler pwrController; \
static ParentHandler* _handlerList[TOTAL_HANDLER] = {&pwrController};
power controller class for the bed room light controller, responsible for handling an requests pertai...
Definition: power_ctrl_handler.hpp:29
the parent handler class that is the blueprint for other child handlers to implement, it also defines a couple functions that child handler can use
Definition: parent_handler.hpp:31
#define TOTAL_HANDLER
change this if you use more or less handler
Definition: device_config.hpp:43

change this function to customize the list of handler

Function Documentation

bool PowerCtrlHandler::getLightStatus ( void  )
static

retrieve the status of the bed room lgiht

Returns
true for light on
false for light off
void handlePolling ( struct mg_connection *  mgCon,
ParentHandler handlerList[],
char *  jsonBuf 
)

dummy empty function since bed room light controller has no polling need

Parameters
mgConmongoose network connection
handlerListlist of pointer to handler object
jsonBufjson buffer for writing data
HandlerError PowerCtrlHandler::handleReport ( char *  stateReport)
virtual

write a state report for the powercontroller endpoint to the given buffer

handle reports pertaining to power controller endpoint for pc controller

Parameters
stateReportbuffer to write report to
Returns
HandlerError Will read the last known state of the light and then make a report
Parameters
stateReportbuffer to write report to
Returns
HandlerError Will report the current PC is on or off

Implements ParentHandler.

HandlerError PowerCtrlHandler::handleRequest ( struct mg_connection *  mgCon,
struct mg_str *  message,
char *  commandName,
char *  response 
)
virtual

implement the handle request function for the power control endpoint for the bedroom light controller

handle request pertaining to power control endpoint for the pc controller

Parameters
mgConstruct representing connection to server
messagemessage sent to the mcu by the server
commandNamename of the command in the payload sent by the server
responsebuffer to write the response to
Returns
HandlerError

Turn the light on or off based on the command name then make a report of the new state

Parameters
mgConstruct representing connection to server
messagemessage sent to the mcu by the server
commandNamename of the command in the payload sent by the server
responsebuffer to write the response to
Returns
HandlerError Will read the command name and see whether to turn the pc on or off, then if the pc is not at the desired state, actuate the change then make a report of the new state to be sent back to the server

Implements ParentHandler.

void PowerCtrlHandler::setLightStatus ( bool  lightStatus)
static

set the light status variable

Parameters
lightStatusthe status to set