Browse Source

Fixes regarding @xoseperez comments

sensors
Martins Ierags 5 years ago
parent
commit
951cc77dfb
3 changed files with 11 additions and 16 deletions
  1. +1
    -1
      code/espurna/config/general.h
  2. +2
    -4
      code/espurna/system.ino
  3. +8
    -11
      code/html/index.html

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

@ -181,7 +181,7 @@
#endif #endif
#ifndef HEARTBEAT_INTERVAL #ifndef HEARTBEAT_INTERVAL
#define HEARTBEAT_INTERVAL 300000 // Interval between heartbeat messages (in ms)
#define HEARTBEAT_INTERVAL 300 // Interval between heartbeat messages (in sec)
#endif #endif
#define UPTIME_OVERFLOW 4294967295 // Uptime overflow value #define UPTIME_OVERFLOW 4294967295 // Uptime overflow value


+ 2
- 4
code/espurna/system.ino View File

@ -82,8 +82,6 @@ unsigned long systemLoadAverage() {
} }
void _systemSetupHeartbeat() { void _systemSetupHeartbeat() {
if (getSetting("hbMode").length() == 0) setSetting("hbMode", HEARTBEAT_MODE);
if (getSetting("hbInterval").length() == 0) setSetting("hbInterval", HEARTBEAT_INTERVAL);
_heartbeat_mode = getSetting("hbMode", HEARTBEAT_MODE).toInt(); _heartbeat_mode = getSetting("hbMode", HEARTBEAT_MODE).toInt();
_heartbeat_interval = getSetting("hbInterval", HEARTBEAT_INTERVAL).toInt(); _heartbeat_interval = getSetting("hbInterval", HEARTBEAT_INTERVAL).toInt();
} }
@ -116,9 +114,9 @@ void systemLoop() {
} else if (_heartbeat_mode == HEARTBEAT_REPEAT || _heartbeat_mode == HEARTBEAT_REPEAT_STATUS) { } else if (_heartbeat_mode == HEARTBEAT_REPEAT || _heartbeat_mode == HEARTBEAT_REPEAT_STATUS) {
static unsigned long last_hbeat = 0; static unsigned long last_hbeat = 0;
#if NTP_SUPPORT #if NTP_SUPPORT
if ((_system_send_heartbeat && ntpSynced()) || (millis() - last_hbeat > _heartbeat_interval)) {
if ((_system_send_heartbeat && ntpSynced()) || (millis() - last_hbeat > _heartbeat_interval * 1000)) {
#else #else
if (_system_send_heartbeat || (millis() - last_hbeat > _heartbeat_interval)) {
if (_system_send_heartbeat || (millis() - last_hbeat > _heartbeat_interval * 1000)) {
#endif #endif
last_hbeat = millis(); last_hbeat = millis();
heartbeat(); heartbeat();


+ 8
- 11
code/html/index.html View File

@ -621,30 +621,27 @@
</div> </div>
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Heartbeat mode</label>
<label class="pure-u-1 pure-u-lg-1-4">Heartbeat message</label>
<select class="pure-u-1 pure-u-lg-1-4" name="hbMode" tabindex="15" > <select class="pure-u-1 pure-u-lg-1-4" name="hbMode" tabindex="15" >
<option value="0">HEARTBEAT_NONE</option>
<option value="1">HEARTBEAT_ONCE</option>
<option value="2">HEARTBEAT_REPEAT</option>
<option value="3">HEARTBEAT_REPEAT_STATUS</option>
<option value="0">Disabled</option>
<option value="1">On device startup</option>
<option value="2">Repeat after defined interval</option>
<option value="3">Repeat only device status</option>
</select> </select>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint"> <div class="pure-u-1 pure-u-lg-3-4 hint">
<strong>HEARTBEAT_NONE:</strong> no heartbeat at all, never.<br />
<strong>HEARTBEAT_ONCE:</strong> only on device startup.<br />
<strong>HEARTBEAT_REPEAT:</strong> on device startup and after HEARTBEAT_INTERVAL.<br />
<strong>HEARTBEAT_REPEAT_STATUS:</strong> on device startup full heartbeat information and after HEARTBEAT_INTERVAL only STATUS report.
Define when heartbeat message will be sent.
</div> </div>
</div> </div>
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Heartbeat interval</label> <label class="pure-u-1 pure-u-lg-1-4">Heartbeat interval</label>
<input name="hbInterval" class="pure-u-1 pure-u-lg-1-4" type="text" tabindex="16" />
<input name="hbInterval" class="pure-u-1 pure-u-lg-1-4" type="number" tabindex="16" />
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint"> <div class="pure-u-1 pure-u-lg-3-4 hint">
This is the interval in <strong>ms</strong> how often to send the heartbeat message.
This is the interval in <strong>seconds</strong> how often to send the heartbeat message.
</div> </div>
</div> </div>


Loading…
Cancel
Save