Skip to content

Commit

Permalink
Added FEATURE_RECEIVE
Browse files Browse the repository at this point in the history
  • Loading branch information
user2684 committed Feb 25, 2018
1 parent 9a9c8e2 commit a64dcda
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NodeManager.ino
Expand Up @@ -97,6 +97,7 @@ FEATURE_INTERRUPTS | ON | allow managing interrupt-based sensors l
FEATURE_CONDITIONAL_REPORT | ON | allow reporting a measure only when different from the previous or above/below a given threshold | -
FEATURE_EEPROM | ON | allow keeping track of some information in the EEPROM | -
FEATURE_SLEEP | ON | allow managing automatically the complexity behind battery-powered sleeping sensors | -
FEATURE_RECEIVE | ON | allow the node to receive messages; can be used by the remote API or for triggering the sensors | -
FEATURE_TIME | OFF | allow keeping the current system time in sync with the controller | https://github.com/PaulStoffregen/Time
FEATURE_RTC | OFF | allow keeping the current system time in sync with an attached RTC device (requires FEATURE_TIME)| https://github.com/JChristensen/DS3232RTC
FEATURE_SD | OFF | allow for reading from and writing to SD cards | -
Expand Down Expand Up @@ -275,6 +276,7 @@ FEATURE_SD | OFF | allow for reading from and writing to SD
#define FEATURE_CONDITIONAL_REPORT OFF
#define FEATURE_EEPROM OFF
#define FEATURE_SLEEP ON
#define FEATURE_RECEIVE ON
#define FEATURE_TIME OFF
#define FEATURE_RTC OFF
#define FEATURE_SD OFF
Expand Down Expand Up @@ -396,11 +398,13 @@ void loop() {
node.loop();
}

#if FEATURE_RECEIVE == ON
// receive
void receive(const MyMessage &message) {
// call NodeManager receive routine
node.receive(message);
}
#endif

#if FEATURE_TIME == ON
// receiveTime
Expand Down
4 changes: 4 additions & 0 deletions NodeManagerLibrary.h
Expand Up @@ -521,7 +521,9 @@ class Sensor {
void presentation();
void setup();
void loop(MyMessage* message);
#if FEATURE_RECEIVE == ON
void receive(MyMessage* message);
#endif
// abstract functions, subclasses need to implement
virtual void onBefore();
virtual void onSetup();
Expand Down Expand Up @@ -1734,7 +1736,9 @@ class NodeManager {
void presentation();
void setup();
void loop();
#if FEATURE_RECEIVE == ON
void receive(const MyMessage & msg);
#endif
private:
#if FEATURE_POWER_MANAGER == ON
PowerManager* _powerManager = nullptr;
Expand Down
4 changes: 4 additions & 0 deletions NodeManagerLibrary.ino
Expand Up @@ -642,11 +642,13 @@ void Sensor::interrupt() {
}
#endif

#if FEATURE_RECEIVE == ON
// receive a message from the radio network
void Sensor::receive(MyMessage* message) {
// a request would make the sensor executing its main task passing along the message
loop(message);
}
#endif

// return the requested child
Child* Sensor::getChild(int child_id) {
Expand Down Expand Up @@ -4335,6 +4337,7 @@ void NodeManager::loop() {
#endif
}

#if FEATURE_RECEIVE == ON
// dispacth inbound messages
void NodeManager::receive(const MyMessage &message) {
#ifdef NODEMANAGER_DEBUG
Expand Down Expand Up @@ -4364,6 +4367,7 @@ void NodeManager::receive(const MyMessage &message) {
#endif
}
}
#endif

#if FEATURE_TIME == ON
// receive the time from the controller and save it
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -99,6 +99,7 @@ FEATURE_INTERRUPTS | ON | allow managing interrupt-based sensors l
FEATURE_CONDITIONAL_REPORT | OFF | allow reporting a measure only when different from the previous or above/below a given threshold | -
FEATURE_EEPROM | OFF | allow keeping track of some information in the EEPROM | -
FEATURE_SLEEP | ON | allow managing automatically the complexity behind battery-powered sleeping sensors | -
FEATURE_RECEIVE | ON | allow the node to receive messages; can be used by the remote API or for triggering the sensors | -
FEATURE_TIME | OFF | allow keeping the current system time in sync with the controller | https://github.com/PaulStoffregen/Time
FEATURE_RTC | OFF | allow keeping the current system time in sync with an attached RTC device (requires FEATURE_TIME)| https://github.com/JChristensen/DS3232RTC
FEATURE_SD | OFF | allow for reading from and writing to SD cards | -
Expand Down

0 comments on commit a64dcda

Please sign in to comment.