Browse Source

sys: hide internal details from the header

mcspr-patch-1
Maxim Prokhorov 3 years ago
parent
commit
1685b0350c
4 changed files with 19 additions and 11 deletions
  1. +1
    -1
      code/espurna/config/general.h
  2. +2
    -0
      code/espurna/rpnrules.cpp
  3. +0
    -6
      code/espurna/rpnrules.h
  4. +16
    -4
      code/espurna/system.cpp

+ 1
- 1
code/espurna/config/general.h View File

@ -41,7 +41,7 @@
#endif #endif
#ifndef HEARTBEAT_INTERVAL #ifndef HEARTBEAT_INTERVAL
#define HEARTBEAT_INTERVAL heartbeat::Seconds(300ul) // Interval between heartbeat messages
#define HEARTBEAT_INTERVAL 300 // Interval between heartbeat messages
#endif #endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------


+ 2
- 0
code/espurna/rpnrules.cpp View File

@ -10,6 +10,8 @@ Copyright (C) 2019 by Xose Pérez <xose dot perez at gmail dot com>
#if RPN_RULES_SUPPORT #if RPN_RULES_SUPPORT
#include <rpnlib.h>
#include "broker.h" #include "broker.h"
#include "light.h" #include "light.h"
#include "mqtt.h" #include "mqtt.h"


+ 0
- 6
code/espurna/rpnrules.h View File

@ -10,10 +10,4 @@ Copyright (C) 2019 by Xose Pérez <xose dot perez at gmail dot com>
#include "espurna.h" #include "espurna.h"
#if RPN_RULES_SUPPORT
#include <rpnlib.h>
void rpnSetup(); void rpnSetup();
#endif

+ 16
- 4
code/espurna/system.cpp View File

@ -312,6 +312,14 @@ unsigned char systemLoadAverage() {
namespace heartbeat { namespace heartbeat {
constexpr Mode defaultMode() {
return HEARTBEAT_MODE;
}
constexpr Seconds defaultInterval() {
return Seconds(HEARTBEAT_INTERVAL);
}
constexpr Mask defaultValue() { constexpr Mask defaultValue() {
return (Report::Status * (HEARTBEAT_REPORT_STATUS)) return (Report::Status * (HEARTBEAT_REPORT_STATUS))
| (Report::Ssid * (HEARTBEAT_REPORT_SSID)) | (Report::Ssid * (HEARTBEAT_REPORT_SSID))
@ -348,11 +356,11 @@ Mask currentValue() {
} }
Mode currentMode() { Mode currentMode() {
return getSetting("hbMode", HEARTBEAT_MODE);
return getSetting("hbMode", defaultMode());
} }
Seconds currentInterval() { Seconds currentInterval() {
return getSetting("hbInterval", HEARTBEAT_INTERVAL);
return getSetting("hbInterval", defaultInterval());
} }
Milliseconds currentIntervalMs() { Milliseconds currentIntervalMs() {
@ -504,6 +512,10 @@ void _systemUpdateLoadAverage() {
#if WEB_SUPPORT #if WEB_SUPPORT
uint8_t _systemHeartbeatModeToId(heartbeat::Mode mode) {
return static_cast<uint8_t>(mode);
}
bool _systemWebSocketOnKeyCheck(const char * key, JsonVariant& value) { bool _systemWebSocketOnKeyCheck(const char * key, JsonVariant& value) {
if (strncmp(key, "sys", 3) == 0) return true; if (strncmp(key, "sys", 3) == 0) return true;
if (strncmp(key, "hb", 2) == 0) return true; if (strncmp(key, "hb", 2) == 0) return true;
@ -512,8 +524,8 @@ bool _systemWebSocketOnKeyCheck(const char * key, JsonVariant& value) {
void _systemWebSocketOnConnected(JsonObject& root) { void _systemWebSocketOnConnected(JsonObject& root) {
root["hbReport"] = heartbeat::currentValue(); root["hbReport"] = heartbeat::currentValue();
root["hbInterval"] = getSetting("hbInterval", HEARTBEAT_INTERVAL).count();
root["hbMode"] = static_cast<uint8_t>(getSetting("hbMode", HEARTBEAT_MODE));
root["hbInterval"] = getSetting("hbInterval", heartbeat::defaultInterval()).count();
root["hbMode"] = _systemHeartbeatModeToId(getSetting("hbMode", heartbeat::defaultMode()));
} }
#endif #endif


Loading…
Cancel
Save