AWS IoT Firmware
Firmware code for AWS IoT Devices
power_ctrl_handler.hpp
1 
2 
16 #ifndef _POWER_CTRL_HANDLER_HPP
17 #define _POWER_CTRL_HANDLER_HPP
18 
19 #include "parent_handler.hpp"
20 
21 #include "event_handler_util.hpp"
22 
23 #include "frozen.h"
24 #include "mgos.h"
25 #include "mgos_mqtt.h"
26 
30 #define SWITCH_ON_STATE 1
31 
35 #define BUTTON_DEBOUNCE_MS 50
36 
42 #define SWITCH_DELAY_MS 150
43 
48 class PowerCtrlHandler : public ParentHandler {
49  public:
50  HandlerError handleRequest(struct mg_connection* mgCon,
51  struct mg_str* message,
52  char* commandName,
53  char* response);
54  HandlerError handleReport(char* stateReport);
55  ~PowerCtrlHandler(void){};
56  PowerCtrlHandler(void);
57  static void buttonInterruptHandler(int pin, void* arg);
58  static void setPcStatus(bool pcStatus);
59  static bool getPcStatus(void);
60 
61  private:
62  static HandlerError actuatePcChange(void);
63 
67  static bool _pcIsOn;
68 };
69 
70 #endif
71 
static void setPcStatus(bool pcStatus)
setter for the pc status variable
Definition: power_ctrl_handler.cpp:126
PowerCtrlHandler(void)
Construct a new Power Ctrl Handler:: Power Ctrl Handler object intialize a power controller handler f...
Definition: power_ctrl_handler.cpp:38
header file for event handler utils
static void buttonInterruptHandler(int pin, void *arg)
handle the case power on switch interrupt
Definition: power_ctrl_handler.cpp:58
HandlerError 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...
Definition: power_ctrl_handler.cpp:54
HandlerError handleReport(char *stateReport)
write a state report for the powercontroller endpoint to the given buffer
Definition: power_ctrl_handler.cpp:116
static bool getPcStatus(void)
used to get whether the pc is on or off
Definition: power_ctrl_handler.cpp:134
power controller class for the bed room light controller, responsible for handling an requests pertai...
Definition: power_ctrl_handler.hpp:29
contain class declaration for the ParentHandler class
HandlerError
enum defining errors that the system(including master handler and other child handler) may have ...
Definition: event_handler_util.hpp:37
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