EnigmaIOT  0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BasicController.h
Go to the documentation of this file.
1 // BasicController.h
2 
3 #ifndef _BASICCONTROLLER_h
4 #define _BASICCONTROLLER_h
5 
6 #if defined(ARDUINO) && ARDUINO >= 100
7 #include "Arduino.h"
8 #else
9 #include "WProgram.h"
10 #endif
11 
12 //#define DEBUG_SERIAL
13 
15 #define CONTROLLER_CLASS_NAME BasicController
16 static const char* CONTROLLER_NAME = "EnigmaIOT controller template";
17 
18 #if SUPPORT_HA_DISCOVERY
19 #include <haTrigger.h>
20 #endif
21 
22 // --------------------------------------------------
23 // You may define data structures and constants here
24 // --------------------------------------------------
25 
27 protected:
28  // --------------------------------------------------
29  // add all parameters that your project needs here
30  // --------------------------------------------------
31 
32 public:
38  void setup (EnigmaIOTNodeClass* node, void* data = NULL);
39 
48  bool processRxCommand (const uint8_t* address, const uint8_t* buffer, uint8_t length, nodeMessageType_t command, nodePayloadEncoding_t payloadEncoding);
49 
53  void loop ();
54 
59 
64 
70 
75  bool loadConfig ();
76 
80  void connectInform ();
81 
82 protected:
87  bool saveConfig ();
88 
94  bool sendCommandResp (const char* command, bool result);
95 
100  // You can send a 'hello' message when your node starts. Useful to detect unexpected reboot
101  const size_t capacity = JSON_OBJECT_SIZE (10);
102  DynamicJsonDocument json (capacity);
103  json["status"] = "start";
104  json["device"] = CONTROLLER_NAME;
105  char version_buf[10];
106  snprintf (version_buf, 10, "%d.%d.%d",
108  json["version"] = String (version_buf);
109 
110  return sendJson (json);
111  }
112 
118 
119  // ------------------------------------------------------------
120  // You may add additional method definitions that you need here
121  // ------------------------------------------------------------
122 };
123 
124 #endif
125 
CONTROLLER_CLASS_NAME::configManagerStart
void configManagerStart()
Called when wifi manager starts config portal.
nodeMessageType
nodeMessageType
Message code definition.
Definition: EnigmaIOTNode.h:35
CONTROLLER_CLASS_NAME::loop
void loop()
Executes repetitive tasks on controller.
ENIGMAIOT_PROT_VERS
static const uint8_t ENIGMAIOT_PROT_VERS[3]
EnitmaIoT Version.
Definition: EnigmaIoTconfig.h:16
CONTROLLER_CLASS_NAME::processRxCommand
bool processRxCommand(const uint8_t *address, const uint8_t *buffer, uint8_t length, nodeMessageType_t command, nodePayloadEncoding_t payloadEncoding)
Processes received GET or SET commands.
CONTROLLER_CLASS_NAME::saveConfig
bool saveConfig()
Saves output module configuration.
CONTROLLER_CLASS_NAME::buildHADiscovery
void buildHADiscovery()
Sends a HA discovery message for a single entity. Add as many functions like this as number of entiti...
CONTROLLER_CLASS_NAME
Definition: ButtonController.h:27
EnigmaIOTjsonController::sendJson
bool sendJson(DynamicJsonDocument &json)
Sends a JSON encoded message to lower layer.
Definition: EnigmaIOTjsonController.h:170
CONTROLLER_CLASS_NAME::sendCommandResp
bool sendCommandResp(const char *command, bool result)
Send response to commands to gateway.
CONTROLLER_CLASS_NAME::~CONTROLLER_CLASS_NAME
~CONTROLLER_CLASS_NAME()
Default destructor.
nodePayloadEncoding_t
nodePayloadEncoding_t
Definition: EnigmaIOTNode.h:58
haTrigger.h
Home Assistant trigger integration.
CONTROLLER_CLASS_NAME::connectInform
void connectInform()
Executed as soon as node is registered on EnigmaIOT network.
CONTROLLER_CLASS_NAME::configManagerExit
void configManagerExit(bool status)
Called when wifi manager exits config portal.
data
@ data
Definition: GwOutput_generic.h:23
EnigmaIOTNodeClass
Main node class. Manages communication with gateway and allows sending and receiving user data.
Definition: EnigmaIOTNode.h:134
CONTROLLER_CLASS_NAME::setup
void setup(EnigmaIOTNodeClass *node, void *data=NULL)
Initializes controller structures.
EnigmaIOTjsonController.h
Prototype for JSON/MSGPACK based controller node.
CONTROLLER_CLASS_NAME::sendStartAnouncement
bool sendStartAnouncement()
Sends a notification message including configurable controller name and protocol version.
Definition: BasicController.h:99
status
@ status
Definition: GwOutput_generic.h:25
CONTROLLER_CLASS_NAME::loadConfig
bool loadConfig()
Loads output module configuration.
EnigmaIOTjsonController
Definition: EnigmaIOTjsonController.h:34
CONTROLLER_NAME
static const char * CONTROLLER_NAME
Definition: BasicController.h:16