|
EnigmaIOT
0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
|
Go to the documentation of this file.
9 using namespace placeholders;
20 #define ONE_WIRE_BUS 4
36 const size_t capacity = JSON_OBJECT_SIZE (2);
37 DynamicJsonDocument json (capacity);
40 return sendJson (json);
45 #if SUPPORT_HA_DISCOVERY
60 sensors =
new DallasTemperature (oneWire);
62 sensors->setWaitForConversion (
false);
63 sensors->requestTemperatures ();
65 time_t start = millis ();
68 if (!enigmaIotNode->getNode ()->getSleepy ()) {
69 if (!(enigmaIotNode->getNode ()->getSleepy ())) {
70 sendStartAnouncement ();
75 while (!sensors->isConversionComplete ()) {
78 DEBUG_WARN (
"Conversion completed in %d ms", millis () - start);
79 tempC = sensors->getTempCByIndex (0);
87 DEBUG_DBG (
"Finish begin");
98 if (!tempSent && enigmaIotNode->isRegistered()) {
99 if (sendTemperature (tempC)) {
121 DEBUG_INFO (
"==== CCost Controller Configuration start ====");
126 DEBUG_INFO (
"==== CCost Controller Configuration result ====");
140 #if SUPPORT_HA_DISCOVERY
146 uint8_t* msgPackBuffer;
149 DEBUG_WARN (
"JSON object instance does not exist");
168 msgPackBuffer = (uint8_t*)malloc (bufferLen);
172 DEBUG_INFO (
"Resulting MSG pack length: %d", len);
174 if (!sendHADiscovery (msgPackBuffer, len)) {
175 DEBUG_WARN (
"Error sending HA discovery message");
183 free (msgPackBuffer);
186 #endif // SUPPORT_HA_DISCOVERY
constexpr auto CONFIG_FILE
Custom configuration file name.
size_t measureMessage()
Gets needed buffer size for discovery message.
nodeMessageType
Message code definition.
size_t getAnounceMessage(int bufferlen, uint8_t *buffer)
Gets entity anounce message to be sent over EnigmaIOT message.
virtual void connectInform()
Used to notify controller that it is registered on EnigmaIOT network.
void loop() override
This should be called periodically for module handling.
void setValueField(const char *payload)
Defines a json key that defines sensor value. When setting this, setValueTemplate () should not be ca...
void setDeviceClass(haSensorClass_t devClass)
Define sensor class as haSensorClass_t https://www.home-assistant.io/integrations/sensor....
void configManagerStart() override
Called when wifi manager starts config portal.
bool saveConfig() override
Saves output module configuration.
void setUnitOfMeasurement(const char *payload)
Set unit of measure https://www.home-assistant.io/integrations/sensor.mqtt/#unit_of_measurement.
void connectInform()
Used to notify controller that it is registered on EnigmaIOT network.
bool sendCommandResp(const char *command, bool result) override
Sends command processing response acknowledge.
void configManagerExit(bool status) override
Called when wifi manager exits config portal.
Main node class. Manages communication with gateway and allows sending and receiving user data.
void setNameSufix(const char *payload)
Sets name suffix. Used for multi entity nodes.
void setup(EnigmaIOTNodeClass *node, void *data=NULL)
Initialize data structures.
bool sendTemperature(float temp)
bool processRxCommand(const uint8_t *address, const uint8_t *buffer, uint8_t length, nodeMessageType_t command, nodePayloadEncoding_t payloadEncoding) override
Called to process a downlink command.
bool loadConfig() override
Loads output module configuration.
void setExpireTime(uint payload)
Defines the number of seconds after the sensor’s state expires, if it’s not updated....