Skip to content

Commit ccddc1d

Browse files
authored
Fix conditional report issues (#430)
1 parent e917cde commit ccddc1d

File tree

6 files changed

+13
-4
lines changed

6 files changed

+13
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ The following methods are available for all the child:
502502
#if NODEMANAGER_CONDITIONAL_REPORT == ON
503503
// force to send an update after the configured number of minutes
504504
void setForceUpdateTimerValue(unsigned long value);
505-
// never report values below this threshold (default: FLT_MIN)
505+
// never report values below this threshold (default: -FLT_MAX)
506506
void setMinThreshold(float value);
507507
// never report values above this threshold (default: FLT_MAX)
508508
void setMaxThreshold(float value);

nodemanager/Child.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ void Child::sendValue(bool force) {
141141
// do not send if no samples have been collected, unless instructed otherwise
142142
if (! _send_without_value && _samples == 0) return;
143143
#if NODEMANAGER_CONDITIONAL_REPORT == ON
144-
if (! force) {
144+
// ignore conditional reporting settings if forced to report or if it is the first run
145+
if (! force || ! _sensor->getFirstRun()) {
145146
// if the value is a number
146147
if (_format != STRING) {
147148
// if below or above the thresholds, do not send the value

nodemanager/Child.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class Child {
8282
#if NODEMANAGER_CONDITIONAL_REPORT == ON
8383
// force to send an update after the configured number of minutes
8484
void setForceUpdateTimerValue(unsigned long value);
85-
// never report values below this threshold (default: FLT_MIN)
85+
// never report values below this threshold (default: -FLT_MAX)
8686
void setMinThreshold(float value);
8787
// never report values above this threshold (default: FLT_MAX)
8888
void setMaxThreshold(float value);
@@ -122,7 +122,7 @@ class Child {
122122
double _last_value = 0;
123123
const char* _last_value_string = "";
124124
Timer* _force_update_timer = new Timer();
125-
float _min_threshold = FLT_MIN;
125+
float _min_threshold = -FLT_MAX;
126126
float _max_threshold = FLT_MAX;
127127
float _value_delta = 0;
128128
#endif

nodemanager/Node.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ void NodeManager::loop() {
558558
// send the message, multiple times if requested
559559
for (int i = 0; i < _retries; i++) {
560560
if (mGetPayloadType(_message) == P_INT16) debug_verbose(PSTR(LOG_MSG "SEND(%d) t=%d p=%d\n"),_message.sensor,_message.type,_message.getInt());
561+
if (mGetPayloadType(_message) == P_LONG32) debug_verbose(PSTR(LOG_MSG "SEND(%d) t=%d p=%ld\n"),_message.sensor,_message.type,_message.getLong());
561562
if (mGetPayloadType(_message) == P_FLOAT32) debug_verbose(PSTR(LOG_MSG "SEND(%d) t=%d p=%d.%02d\n"),_message.sensor,_message.type,(unsigned int)_message.getFloat(), (unsigned int)(_message.getFloat()*100)%100);
562563
if (mGetPayloadType(_message) == P_STRING) debug_verbose(PSTR(LOG_MSG "SEND(%d) t=%d p=%s\n"),_message.sensor,_message.type,_message.getString());
563564
send(_message, _ack);

nodemanager/Sensor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ void Sensor::setReportIntervalDays(uint8_t value) {
108108
setReportIntervalSeconds(value*86400UL);
109109
}
110110

111+
// return true if it is the first execution of loop on this sensor
112+
bool Sensor::getFirstRun() {
113+
return _first_run;
114+
}
115+
111116
// register a child
112117
void Sensor::registerChild(Child* child) {
113118
children.push(child);

nodemanager/Sensor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class Sensor {
5858
void setMeasureTimerMode(timer_mode value);
5959
// [27] Set the value for the reporting timer's mode which has been set with setReportTimerMode() If not set explicitely, will be set with the same value as the reporting timer
6060
void setMeasureTimerValue(unsigned long value);
61+
// return true if it is the first execution of loop on this sensor
62+
bool getFirstRun();
6163
// list of configured child
6264
List<Child*> children;
6365
// return the child object based on the provided child_id

0 commit comments

Comments
 (0)