mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-06 16:27:12 +01:00
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
This commit is contained in:
@@ -17,8 +17,14 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
|
||||
#include "settings.h"
|
||||
#include "telnet.h"
|
||||
#include "web.h"
|
||||
#include "ntp.h"
|
||||
#include "utils.h"
|
||||
#include "ws.h"
|
||||
|
||||
#if DEBUG_WEB_SUPPORT
|
||||
#include <ArduinoJson.h>
|
||||
#endif
|
||||
|
||||
#if DEBUG_UDP_SUPPORT
|
||||
#include <WiFiUdp.h>
|
||||
WiFiUDP _udp_debug;
|
||||
@@ -367,6 +373,24 @@ void debugConfigureBoot() {
|
||||
debugConfigure();
|
||||
}
|
||||
|
||||
bool _debugHeartbeat(heartbeat::Mask mask) {
|
||||
if (mask & heartbeat::Report::Uptime)
|
||||
DEBUG_MSG_P(PSTR("[MAIN] Uptime: %s\n"), getUptime().c_str());
|
||||
|
||||
if (mask & heartbeat::Report::Freeheap)
|
||||
infoHeapStats();
|
||||
|
||||
if ((mask & heartbeat::Report::Vcc) && (ADC_MODE_VALUE == ADC_VCC))
|
||||
DEBUG_MSG_P(PSTR("[MAIN] Power: %lu mV\n"), ESP.getVcc());
|
||||
|
||||
#if NTP_SUPPORT
|
||||
if ((mask & heartbeat::Report::Datetime) && (ntpSynced()))
|
||||
DEBUG_MSG_P(PSTR("[MAIN] Time: %s\n"), ntpDateTime().c_str());
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void debugConfigure() {
|
||||
|
||||
// HardwareSerial::begin() will automatically enable this when
|
||||
@@ -408,6 +432,10 @@ void debugConfigure() {
|
||||
}
|
||||
#endif // DEBUG_LOG_BUFFER
|
||||
|
||||
systemHeartbeat(_debugHeartbeat,
|
||||
getSetting("dbgHbMode", heartbeat::currentMode()),
|
||||
getSetting("dbgHbIntvl", heartbeat::currentInterval()));
|
||||
|
||||
}
|
||||
|
||||
#endif // DEBUG_SUPPORT
|
||||
|
||||
Reference in New Issue
Block a user