AWS IoT Firmware
Firmware code for AWS IoT Devices
parent_handler.hpp
Go to the documentation of this file.
1 
14 #ifndef _PARENT_HANDLER_HPP
15 #define _PARENT_HANDLER_HPP
16 
17 #include "event_handler_util.hpp"
18 
19 #include <stdarg.h>
20 #include <stdint.h>
21 #include <string.h>
22 
23 #include "frozen.h"
24 #include "mgos.h"
25 #include "mgos_mqtt.h"
26 
32  public:
33  ParentHandler(void);
34  virtual ~ParentHandler(void) {}
35  virtual HandlerError handleRequest(struct mg_connection* mgCon,
36  struct mg_str* message,
37  char* commandName,
38  char* response) = 0;
39  virtual HandlerError handleReport(char* stateReport) = 0;
40 
41  HandlerError createReport(char* report, const char* fmt, uint8_t totalArg, ...);
42 
43  bool canHandleRequest(char* requestNameSpace);
44  char* getNameSpace(void);
45 
46  protected:
52 };
53 
54 #endif
55 
bool canHandleRequest(char *requestNameSpace)
used to check if a handler object can handle a request with a specific namespace
Definition: parent_handler.cpp:71
char * getNameSpace(void)
return the command namespace that the handler support
Definition: parent_handler.cpp:80
header file for event handler utils
char _nameSpace[MAX_NAMESPACE_LEN]
namespace that the handler supports, all child classes must initialize this variable to let the maste...
Definition: parent_handler.hpp:51
HandlerError createReport(char *report, const char *fmt, uint8_t totalArg,...)
used for generating a json report string based on the format given, usually child handler uses this t...
Definition: parent_handler.cpp:43
#define MAX_NAMESPACE_LEN
maximum length in characters of the namespace name sent by the server
Definition: event_handler_util.hpp:31
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