AWS IoT Firmware
Firmware code for AWS IoT Devices
Files | Classes | Macros | Functions
Pc Controller
Collaboration diagram for Pc Controller:

Files

file  temp_sensor_handler.cpp
 TempSensorHandler source files for pc controller.
 
file  temp_sensor_handler.hpp
 header file for TempSensorHandler class of the pc controller device
 

Classes

class  PowerCtrlHandler
 power controller class for the bed room light controller, responsible for handling an requests pertaining to the power controller namespace More...
 
class  TempSensorHandler
 TempSensorHandler class, responsible for handling temperature sensor endpoint functionalities of aws. More...
 

Macros

#define SUBSCRIBE_TOPIC   "/pcReq"
 topic that the pc controller subscribe to
 
#define PUBLISH_TOPIC   "/pcRes"
 topic that the pc controller will publish replise to
 
#define PC_CTRL_PIN   5
 pins used to control the relay controlling the pc motherboard pins
 
#define PC_BUTTON_PIN   4
 pins used to sense the pc case switch actuation
 
#define ANALOG_PIN   0
 analog pins used for reading temperature sensor reading
 
#define TOTAL_HANDLER   2
 change this if you use more or less handler
 
#define REGISTER_INTERRUPT()
 Reigiter pc controller interrupt. More...
 
#define INITIALIZE_HANDLER()
 change this function to customize the list of handler More...
 
#define SWITCH_ON_STATE   1
 state of the pin when the relay is on
 
#define BUTTON_DEBOUNCE_MS   50
 debouncing period for the pc case switch
 
#define SWITCH_DELAY_MS   150
 the delay between turning on and turning off the relay controlling the pc motherboard pins, used to make sure that the switching actually has an observable effect
 
#define TMP36_COEFF   3300 / 1024
 TMP36 coefficient to convert from analog voltage to celsius.
 

Functions

void handlePolling (struct mg_connection *mgCon, ParentHandler *handlerList[], char *jsonBuf)
 dummy empty function since pc controller has no polling need More...
 
static void PowerCtrlHandler::buttonInterruptHandler (int pin, void *arg)
 handle the case power on switch interrupt More...
 
static void PowerCtrlHandler::setPcStatus (bool pcStatus)
 setter for the pc status variable More...
 
static bool PowerCtrlHandler::getPcStatus (void)
 used to get whether the pc is on or off More...
 
HandlerError TempSensorHandler::handleRequest (struct mg_connection *mgCon, struct mg_str *message, char *commandName, char *response)
 handle aws request pertainting to temperature sensor endpoint for the pc controller More...
 
HandlerError TempSensorHandler::handleReport (char *stateReport)
 handle state report pertainting to temperature sensor endpoint for the pc controller The function will mesasure the temperature(using the TMP36 sensor for now) and put it in areport and write it to a buffer More...
 

Detailed Description

Macro Definition Documentation

#define INITIALIZE_HANDLER ( )
Value:
static PowerCtrlHandler pwrController; \
static TempSensorHandler tempHandler; \
static ParentHandler* _handlerList[TOTAL_HANDLER] = {&pwrController, &tempHandler};
TempSensorHandler class, responsible for handling temperature sensor endpoint functionalities of aws...
Definition: temp_sensor_handler.hpp:31
power controller class for the bed room light controller, responsible for handling an requests pertai...
Definition: power_ctrl_handler.hpp:29
#define TOTAL_HANDLER
change this if you use more or less handler
Definition: device_config.hpp:54
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

change this function to customize the list of handler

#define REGISTER_INTERRUPT ( )
Value:
do { \
mgos_gpio_set_button_handler(PC_BUTTON_PIN, \
MGOS_GPIO_PULL_UP, \
MGOS_GPIO_INT_EDGE_NEG, \
NULL); \
} while (0)
static void buttonInterruptHandler(int pin, void *arg)
handle the case power on switch interrupt
Definition: power_ctrl_handler.cpp:58
#define PC_BUTTON_PIN
pins used to sense the pc case switch actuation
Definition: device_config.hpp:41
#define BUTTON_DEBOUNCE_MS
debouncing period for the pc case switch
Definition: power_ctrl_handler.hpp:35

Reigiter pc controller interrupt.

Register a button interrupt to actuate on pc's case power button

Function Documentation

void PowerCtrlHandler::buttonInterruptHandler ( int  pin,
void *  arg 
)
static

handle the case power on switch interrupt

Parameters
pinpin that the interrupt comes from
argany custom arguments that is to be passed to the interrupt handler, not used in This case When the user presses the power on swithc on the case, the interrupt will be called to actuate on that switch as well as update the status of the pc
bool PowerCtrlHandler::getPcStatus ( void  )
static

used to get whether the pc is on or off

Returns
true pc is on
false pc is off read the state variable to get the lastknown status of the pc
void handlePolling ( struct mg_connection *  mgCon,
ParentHandler handlerList[],
char *  jsonBuf 
)

dummy empty function since pc controller has no polling need

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 TempSensorHandler::handleReport ( char *  stateReport)
virtual

handle state report pertainting to temperature sensor endpoint for the pc controller The function will mesasure the temperature(using the TMP36 sensor for now) and put it in areport and write it to a buffer

Parameters
stateReportbuffer to write report to
Returns
HandlerError

Implements ParentHandler.

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

handle aws request pertainting to temperature sensor endpoint for the pc controller

Parameters
mgConstruct representing connection to server
messagemessage sent to the mcu by the server
responsebuffer to write the response to
Returns
HandlerError

This function is empty and is only here to fulfill the contract with the parent handler because the aws temperature sensor gets reading only through state report and not regular request

Implements ParentHandler.

void PowerCtrlHandler::setPcStatus ( bool  pcStatus)
static

setter for the pc status variable

Parameters
pcStatusthe status to change the variable to