From d692bc9a2d6c7a82a9c1b48869a3d686b114469c Mon Sep 17 00:00:00 2001 From: Walter Arca Yi Date: Sun, 28 Jun 2020 22:50:27 +0800 Subject: [PATCH] fix some compile errors. (#524) --- MySensors_NodeManager.h | 7 +++++++ nodemanager/Constants.h | 2 +- nodemanager/InternalTimer.cpp | 4 ++-- nodemanager/InternalTimer.h | 6 +++--- nodemanager/Node.cpp | 2 ++ nodemanager/Sensor.cpp | 4 ++-- nodemanager/Sensor.h | 4 ++-- sensors/SensorConfiguration.h | 4 ++-- sensors/SensorDHT.h | 2 +- 9 files changed, 22 insertions(+), 13 deletions(-) diff --git a/MySensors_NodeManager.h b/MySensors_NodeManager.h index 151ed657..c0d4895f 100644 --- a/MySensors_NodeManager.h +++ b/MySensors_NodeManager.h @@ -25,6 +25,13 @@ // include NodeManager's constants #include "nodemanager/Constants.h" +/*********************************** +Platform dependent variation +*/ +#if defined(CHIP_STM32) +#define isnan std::isnan +#endif + /*********************************** Include required third-party libraries */ diff --git a/nodemanager/Constants.h b/nodemanager/Constants.h index baec1e60..c80f3d07 100644 --- a/nodemanager/Constants.h +++ b/nodemanager/Constants.h @@ -37,7 +37,7 @@ enum status { }; //define Timer mode -enum timer_mode { +enum nm_timer_mode { NOT_CONFIGURED, TIME_INTERVAL, IMMEDIATELY, diff --git a/nodemanager/InternalTimer.cpp b/nodemanager/InternalTimer.cpp index cc954adc..65945004 100644 --- a/nodemanager/InternalTimer.cpp +++ b/nodemanager/InternalTimer.cpp @@ -28,12 +28,12 @@ InternalTimer::InternalTimer() { } // set the timer mode -void InternalTimer::setMode(timer_mode mode) { +void InternalTimer::setMode(nm_timer_mode mode) { _mode = mode; } // get the timer mode -timer_mode InternalTimer::getMode() { +nm_timer_mode InternalTimer::getMode() { return _mode; } diff --git a/nodemanager/InternalTimer.h b/nodemanager/InternalTimer.h index 1828145e..513ccf67 100644 --- a/nodemanager/InternalTimer.h +++ b/nodemanager/InternalTimer.h @@ -28,8 +28,8 @@ class NodeManager; class InternalTimer { public: InternalTimer(); - void setMode(timer_mode mode); - timer_mode getMode(); + void setMode(nm_timer_mode mode); + nm_timer_mode getMode(); void setValue(unsigned long value); unsigned long getValue(); // start the timer @@ -41,7 +41,7 @@ class InternalTimer { // return true if the time is over bool isOver(); private: - timer_mode _mode = NOT_CONFIGURED; + nm_timer_mode _mode = NOT_CONFIGURED; unsigned long _value = 0; // s unsigned long _target = 0; // ms bool _is_running = false; diff --git a/nodemanager/Node.cpp b/nodemanager/Node.cpp index 4c14d1e9..cc84de91 100644 --- a/nodemanager/Node.cpp +++ b/nodemanager/Node.cpp @@ -296,8 +296,10 @@ void NodeManager::loop() { } #endif } +#if NODEMANAGER_INTERRUPTS == ON // reset the last interrupt pin _last_interrupt_pin = -1; +#endif #if NODEMANAGER_POWER_MANAGER == ON // turn off the pin powering all the sensors powerOff(); diff --git a/nodemanager/Sensor.cpp b/nodemanager/Sensor.cpp index 05c84980..88bcc514 100644 --- a/nodemanager/Sensor.cpp +++ b/nodemanager/Sensor.cpp @@ -82,13 +82,13 @@ void Sensor::setInterruptStrict(bool value) { } #endif -void Sensor::setReportTimerMode(timer_mode value) { +void Sensor::setReportTimerMode(nm_timer_mode value) { _report_timer->setMode(value); } void Sensor::setReportTimerValue(unsigned long value) { _report_timer->setValue(value); } -void Sensor::setMeasureTimerMode(timer_mode value) { +void Sensor::setMeasureTimerMode(nm_timer_mode value) { _measure_timer->setMode(value); } void Sensor::setMeasureTimerValue(unsigned long value) { diff --git a/nodemanager/Sensor.h b/nodemanager/Sensor.h index fa9a3488..15143f3a 100644 --- a/nodemanager/Sensor.h +++ b/nodemanager/Sensor.h @@ -51,11 +51,11 @@ class Sensor { // [20] After how many days the sensor will report back its measure (default: 10 minutes) void setReportIntervalDays(uint8_t value); // [24] Set the way the timer used for reporting to the gateway should operate. It can be either TIME_INTERVAL (e.g. report every X seconds with the amount of time set with setReportTimerValue()), IMMEDIATELY (e.g. report at every cycle, useful for sensors like actuators which should report as soon as the value has changed), DO_NOT_REPORT (e.g. never report, useful for when there is no need to report, like a Display) and when NODEMANAGER_TIME is ON, EVERY_MINUTE/EVERY_HOUR/EVERY_DAY (e.g. to report the value set in the previous timeframe, useful for sensors reporting an accumulated value linked to a timeframe at regular intervals), AT_MINUTE/AT_HOUR/AT_DAY (e.g. report at a given minute/hour/day, useful if the measure is expected at a specified time, set with setReportTimerValue()) - void setReportTimerMode(timer_mode value); + void setReportTimerMode(nm_timer_mode value); // [25] Set the value for the reporting timer's mode which has been set with setReportTimerMode() void setReportTimerValue(unsigned long value); // [26] Set the way the timer used for taking measures should operate. Takes the same parameters as setReportTimerMode(). If not set explicitly, will be set as the reporting timer - void setMeasureTimerMode(timer_mode value); + void setMeasureTimerMode(nm_timer_mode value); // [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 void setMeasureTimerValue(unsigned long value); // return true if it is the first execution of loop on this sensor diff --git a/sensors/SensorConfiguration.h b/sensors/SensorConfiguration.h index f6f18766..ed7a0fe5 100644 --- a/sensors/SensorConfiguration.h +++ b/sensors/SensorConfiguration.h @@ -105,9 +105,9 @@ class SensorConfiguration: public Sensor { case 13: sensor->powerOn(); break; case 14: sensor->powerOff(); break; #endif - case 24: sensor->setReportTimerMode((timer_mode)request.getValueInt()); break; + case 24: sensor->setReportTimerMode((nm_timer_mode)request.getValueInt()); break; case 25: sensor->setReportTimerValue(request.getValueInt()); break; - case 26: sensor->setMeasureTimerMode((timer_mode)request.getValueInt()); break; + case 26: sensor->setMeasureTimerMode((nm_timer_mode)request.getValueInt()); break; case 27: sensor->setMeasureTimerValue(request.getValueInt()); break; case 16: sensor->setReportIntervalMinutes(request.getValueInt()); break; case 17: sensor->setReportIntervalSeconds(request.getValueInt()); break; diff --git a/sensors/SensorDHT.h b/sensors/SensorDHT.h index def5ae9f..ebb7e8e3 100644 --- a/sensors/SensorDHT.h +++ b/sensors/SensorDHT.h @@ -52,7 +52,7 @@ class SensorDHT: public Sensor { // define what to do during setup void onLoop(Child* child) { nodeManager.sleepOrWait(_dht->getMinimumSamplingPeriod()+100); - _dht->readSensor(true); + // _dht->readSensor(true); // temperature sensor if (child->getType() == V_TEMP) { // read the temperature