EnigmaIOT  0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
DashButtonController.h
Go to the documentation of this file.
1 // BasicController.h
2 
3 #ifndef _DASHBUTTONCONTROLLER_h
4 #define _DASHBUTTONCONTROLLER_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 
14 #ifdef ESP32
15 #include <SPIFFS.h>
16 #endif
17 
19 #define CONTROLLER_CLASS_NAME DashButtonController
20 static const char* CONTROLLER_NAME = "DashButton controller";
21 
22 #if SUPPORT_HA_DISCOVERY
23 #include <haTrigger.h>
24 #endif
25 
26 // --------------------------------------------------
27 // You may define data structures and constants here
28 // --------------------------------------------------
29 
31 protected:
32  // --------------------------------------------------
33  // add all parameters that your project needs here
34  // --------------------------------------------------
35  bool buttonPressSent = false;
36 public:
37  void setup (EnigmaIOTNodeClass* node, void* data = NULL);
38 
39  bool processRxCommand (const uint8_t* address, const uint8_t* buffer, uint8_t length, nodeMessageType_t command, nodePayloadEncoding_t payloadEncoding);
40 
41  void loop ();
42 
44 
49 
55 
60  bool loadConfig ();
61 
62  void connectInform ();
63 
64 protected:
69  bool saveConfig ();
70 
71  bool sendCommandResp (const char* command, bool result);
72 
74  // You can send a 'hello' message when your node starts. Useful to detect unexpected reboot
75  const size_t capacity = JSON_OBJECT_SIZE (10);
76  DynamicJsonDocument json (capacity);
77  json["status"] = "start";
78  json["device"] = CONTROLLER_NAME;
79  char version_buf[10];
80  snprintf (version_buf, 10, "%d.%d.%d",
82  json["version"] = String (version_buf);
83 
84  return sendJson (json);
85  }
86 
88 
89  // ------------------------------------------------------------
90  // You may add additional method definitions that you need here
91  // ------------------------------------------------------------
92 };
93 
94 #endif
95 
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()
This should be called periodically for module handling.
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)
Called to process a downlink command.
CONTROLLER_CLASS_NAME::saveConfig
bool saveConfig()
Saves output module configuration.
CONTROLLER_CLASS_NAME::buildHADiscovery
void buildHADiscovery()
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_NAME
static const char * CONTROLLER_NAME
Definition: DashButtonController.h:20
CONTROLLER_CLASS_NAME::sendCommandResp
bool sendCommandResp(const char *command, bool result)
Sends command processing response acknowledge.
CONTROLLER_CLASS_NAME::~CONTROLLER_CLASS_NAME
~CONTROLLER_CLASS_NAME()
nodePayloadEncoding_t
nodePayloadEncoding_t
Definition: EnigmaIOTNode.h:58
haTrigger.h
Home Assistant trigger integration.
CONTROLLER_CLASS_NAME::connectInform
void connectInform()
Used to notify controller that it 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
CONTROLLER_CLASS_NAME::buttonPressSent
bool buttonPressSent
Definition: DashButtonController.h:35
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)
Initialize data structures.
EnigmaIOTjsonController.h
Prototype for JSON/MSGPACK based controller node.
CONTROLLER_CLASS_NAME::sendStartAnouncement
bool sendStartAnouncement()
Send a message to notify node has started running.
Definition: DashButtonController.h:73
status
@ status
Definition: GwOutput_generic.h:25
CONTROLLER_CLASS_NAME::loadConfig
bool loadConfig()
Loads output module configuration.
EnigmaIOTjsonController
Definition: EnigmaIOTjsonController.h:34