sys: clean-up system-specific functions
- shrink utils source file, move heartbeat and boot management into system
- improvise with 'heartbeat' functionality. include scheduler implementation that will
manage the per-module heartbeat callbacks with individual 'mode' and
'interval' settings. current ones are mqtt (including relays, lights, thermostat), debug and
influxdb. preserve heartbeat NONE, ONCE and REPEAT, REPEAT_STATUS is effectively a hbReport & status bit.
- mqtt heartbeat is managed through mqttHeartbeat() callbacks
- tweak mqtt callbacks to use lists instead of the vector, slighly reducing the size of the .bin
- update WebUI, include report setting and update hbMode values
- make sure general.h settings include new heartbeat,
move constant definitions outside of the header
- correctly include dependencies through the .cpp, avoid leaking
internal details.
- as a side-effect, base headers are no longer included recursively
3 years ago sys: clean-up system-specific functions
- shrink utils source file, move heartbeat and boot management into system
- improvise with 'heartbeat' functionality. include scheduler implementation that will
manage the per-module heartbeat callbacks with individual 'mode' and
'interval' settings. current ones are mqtt (including relays, lights, thermostat), debug and
influxdb. preserve heartbeat NONE, ONCE and REPEAT, REPEAT_STATUS is effectively a hbReport & status bit.
- mqtt heartbeat is managed through mqttHeartbeat() callbacks
- tweak mqtt callbacks to use lists instead of the vector, slighly reducing the size of the .bin
- update WebUI, include report setting and update hbMode values
- make sure general.h settings include new heartbeat,
move constant definitions outside of the header
- correctly include dependencies through the .cpp, avoid leaking
internal details.
- as a side-effect, base headers are no longer included recursively
3 years ago sys: clean-up system-specific functions
- shrink utils source file, move heartbeat and boot management into system
- improvise with 'heartbeat' functionality. include scheduler implementation that will
manage the per-module heartbeat callbacks with individual 'mode' and
'interval' settings. current ones are mqtt (including relays, lights, thermostat), debug and
influxdb. preserve heartbeat NONE, ONCE and REPEAT, REPEAT_STATUS is effectively a hbReport & status bit.
- mqtt heartbeat is managed through mqttHeartbeat() callbacks
- tweak mqtt callbacks to use lists instead of the vector, slighly reducing the size of the .bin
- update WebUI, include report setting and update hbMode values
- make sure general.h settings include new heartbeat,
move constant definitions outside of the header
- correctly include dependencies through the .cpp, avoid leaking
internal details.
- as a side-effect, base headers are no longer included recursively
3 years ago sys: clean-up system-specific functions
- shrink utils source file, move heartbeat and boot management into system
- improvise with 'heartbeat' functionality. include scheduler implementation that will
manage the per-module heartbeat callbacks with individual 'mode' and
'interval' settings. current ones are mqtt (including relays, lights, thermostat), debug and
influxdb. preserve heartbeat NONE, ONCE and REPEAT, REPEAT_STATUS is effectively a hbReport & status bit.
- mqtt heartbeat is managed through mqttHeartbeat() callbacks
- tweak mqtt callbacks to use lists instead of the vector, slighly reducing the size of the .bin
- update WebUI, include report setting and update hbMode values
- make sure general.h settings include new heartbeat,
move constant definitions outside of the header
- correctly include dependencies through the .cpp, avoid leaking
internal details.
- as a side-effect, base headers are no longer included recursively
3 years ago |
|
- /*
-
- MQTT MODULE
-
- Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
- Updated secure client support by Niek van der Maas < mail at niekvandermaas dot nl>
-
- */
-
- #pragma once
-
- #include "espurna.h"
-
- #include <functional>
-
- // These will be concatenated to the MQTT_TOPIC base to form the actual topic
-
- #define MQTT_TOPIC_JSON "data"
- #define MQTT_TOPIC_ACTION "action"
- #define MQTT_TOPIC_RELAY "relay"
- #define MQTT_TOPIC_LED "led"
- #define MQTT_TOPIC_BUTTON "button"
- #define MQTT_TOPIC_IP "ip"
- #define MQTT_TOPIC_SSID "ssid"
- #define MQTT_TOPIC_BSSID "bssid"
- #define MQTT_TOPIC_VERSION "version"
- #define MQTT_TOPIC_UPTIME "uptime"
- #define MQTT_TOPIC_DATETIME "datetime"
- #define MQTT_TOPIC_TIMESTAMP "timestamp"
- #define MQTT_TOPIC_FREEHEAP "freeheap"
- #define MQTT_TOPIC_VCC "vcc"
- #define MQTT_TOPIC_STATUS "status"
- #define MQTT_TOPIC_MAC "mac"
- #define MQTT_TOPIC_RSSI "rssi"
- #define MQTT_TOPIC_MESSAGE_ID "id"
- #define MQTT_TOPIC_APP "app"
- #define MQTT_TOPIC_INTERVAL "interval"
- #define MQTT_TOPIC_HOSTNAME "host"
- #define MQTT_TOPIC_DESCRIPTION "desc"
- #define MQTT_TOPIC_TIME "time"
- #define MQTT_TOPIC_RFOUT "rfout"
- #define MQTT_TOPIC_RFIN "rfin"
- #define MQTT_TOPIC_RFLEARN "rflearn"
- #define MQTT_TOPIC_RFRAW "rfraw"
- #define MQTT_TOPIC_UARTIN "uartin"
- #define MQTT_TOPIC_UARTOUT "uartout"
- #define MQTT_TOPIC_LOADAVG "loadavg"
- #define MQTT_TOPIC_BOARD "board"
- #define MQTT_TOPIC_PULSE "pulse"
- #define MQTT_TOPIC_SPEED "speed"
- #define MQTT_TOPIC_IRIN "irin"
- #define MQTT_TOPIC_IROUT "irout"
- #define MQTT_TOPIC_OTA "ota"
- #define MQTT_TOPIC_TELNET_REVERSE "telnet_reverse"
- #define MQTT_TOPIC_CURTAIN "curtain"
- #define MQTT_TOPIC_CMD "cmd"
-
- using mqtt_callback_f = std::function<void(unsigned int type, const char * topic, char * payload)>;
- struct MqttMessage {
- String topic;
- String message;
- };
-
- void mqttHeartbeat(heartbeat::Callback);
- void mqttRegister(mqtt_callback_f callback);
-
- String mqttTopic(const char * magnitude, bool is_set);
- String mqttTopic(const char * magnitude, unsigned int index, bool is_set);
-
- String mqttMagnitude(const char* topic);
-
- bool mqttSendRaw(const char * topic, const char * message, bool retain);
- bool mqttSendRaw(const char * topic, const char * message);
-
- void mqttSend(const char * topic, const char * message, bool force, bool retain);
- void mqttSend(const char * topic, const char * message, bool force);
- void mqttSend(const char * topic, const char * message);
-
- void mqttSend(const char * topic, unsigned int index, const char * message, bool force, bool retain);
- void mqttSend(const char * topic, unsigned int index, const char * message, bool force);
- void mqttSend(const char * topic, unsigned int index, const char * message);
-
- void mqttSendStatus();
- void mqttFlush();
-
- void mqttEnqueue(const char* topic, const char* message);
-
- const String& mqttPayloadOnline();
- const String& mqttPayloadOffline();
- const char* mqttPayloadStatus(bool status);
-
- void mqttSetBroker(IPAddress ip, uint16_t port);
- void mqttSetBrokerIfNone(IPAddress ip, uint16_t port);
-
- void mqttSubscribeRaw(const char * topic);
- void mqttSubscribe(const char * topic);
-
- void mqttUnsubscribeRaw(const char * topic);
- void mqttUnsubscribe(const char * topic);
-
- void mqttEnabled(bool status);
- bool mqttEnabled();
-
- bool mqttForward();
-
- bool mqttConnected();
-
- void mqttDisconnect();
- void mqttSetup();
|