Commit ce0b430f authored by user2684's avatar user2684
Browse files

Added sleep_between_send also during presentation when configured

parent 702a05c7
...@@ -279,7 +279,7 @@ void Sensor::_send(MyMessage & message) { ...@@ -279,7 +279,7 @@ void Sensor::_send(MyMessage & message) {
// send the message, multiple times if requested // send the message, multiple times if requested
for (int i = 0; i < _retries; i++) { for (int i = 0; i < _retries; i++) {
// if configured, sleep beetween each send // if configured, sleep beetween each send
if (_sleep_between_send > 0) wait(_sleep_between_send); if (_sleep_between_send > 0) sleep(_sleep_between_send);
#if DEBUG == 1 #if DEBUG == 1
Serial.print(F("SEND D=")); Serial.print(F("SEND D="));
Serial.print(message.destination); Serial.print(message.destination);
...@@ -2003,13 +2003,11 @@ void NodeManager::before() { ...@@ -2003,13 +2003,11 @@ void NodeManager::before() {
pinMode(_reboot_pin, OUTPUT); pinMode(_reboot_pin, OUTPUT);
digitalWrite(_reboot_pin, HIGH); digitalWrite(_reboot_pin, HIGH);
} }
#if SLEEP_MANAGER == 1 // setup the sleep interrupt pin
// setup the sleep interrupt pin if (_sleep_interrupt_pin > -1) {
if (_sleep_interrupt_pin > -1) { // set the interrupt when the pin is connected to ground
// set the interrupt when the pin is connected to ground setInterrupt(_sleep_interrupt_pin,FALLING,HIGH);
setInterrupt(_sleep_interrupt_pin,FALLING,HIGH); }
}
#endif
// setup the interrupt pins // setup the interrupt pins
if (_interrupt_1_mode != MODE_NOT_DEFINED) { if (_interrupt_1_mode != MODE_NOT_DEFINED) {
pinMode(INTERRUPT_PIN_1,INPUT); pinMode(INTERRUPT_PIN_1,INPUT);
...@@ -2064,6 +2062,7 @@ void NodeManager::presentation() { ...@@ -2064,6 +2062,7 @@ void NodeManager::presentation() {
Serial.println(F("RADIO OK")); Serial.println(F("RADIO OK"));
#endif #endif
// Send the sketch version information to the gateway and Controller // Send the sketch version information to the gateway and Controller
if (_sleep_between_send > 0) sleep(_sleep_between_send);
sendSketchInfo(SKETCH_NAME,SKETCH_VERSION); sendSketchInfo(SKETCH_NAME,SKETCH_VERSION);
// present the service as a custom sensor to the controller // present the service as a custom sensor to the controller
_present(CONFIGURATION_CHILD_ID, S_CUSTOM); _present(CONFIGURATION_CHILD_ID, S_CUSTOM);
...@@ -2077,6 +2076,7 @@ void NodeManager::presentation() { ...@@ -2077,6 +2076,7 @@ void NodeManager::presentation() {
for (int i = 0; i < 255; i++) { for (int i = 0; i < 255; i++) {
if (_sensors[i] == 0) continue; if (_sensors[i] == 0) continue;
// call each sensor's presentation() // call each sensor's presentation()
if (_sleep_between_send > 0) sleep(_sleep_between_send);
_sensors[i]->presentation(); _sensors[i]->presentation();
} }
#if DEBUG == 1 #if DEBUG == 1
...@@ -2197,7 +2197,7 @@ void NodeManager::_send(MyMessage & message) { ...@@ -2197,7 +2197,7 @@ void NodeManager::_send(MyMessage & message) {
// send the message, multiple times if requested // send the message, multiple times if requested
for (int i = 0; i < _retries; i++) { for (int i = 0; i < _retries; i++) {
// if configured, sleep beetween each send // if configured, sleep beetween each send
if (_sleep_between_send > 0) wait(_sleep_between_send); if (_sleep_between_send > 0) sleep(_sleep_between_send);
#if DEBUG == 1 #if DEBUG == 1
Serial.print(F("SEND D=")); Serial.print(F("SEND D="));
Serial.print(message.destination); Serial.print(message.destination);
...@@ -2422,10 +2422,8 @@ void NodeManager::_sleep() { ...@@ -2422,10 +2422,8 @@ void NodeManager::_sleep() {
Serial.print(F(", M=")); Serial.print(F(", M="));
Serial.println(interrupt_mode); Serial.println(interrupt_mode);
#endif #endif
#if SLEEP_MANAGER == 1 // when waking up from an interrupt on the wakup pin, stop sleeping
// when waking up from an interrupt on the wakup pin, stop sleeping if (_sleep_interrupt_pin == pin_number) _sleep_mode = IDLE;
if (_sleep_interrupt_pin == pin_number) _sleep_mode = IDLE;
#endif
} }
} }
// coming out of sleep // coming out of sleep
...@@ -2456,6 +2454,7 @@ void NodeManager::_present(int child_id, int type) { ...@@ -2456,6 +2454,7 @@ void NodeManager::_present(int child_id, int type) {
Serial.print(F(", T=")); Serial.print(F(", T="));
Serial.println(type); Serial.println(type);
#endif #endif
if (_sleep_between_send > 0) sleep(_sleep_between_send);
present(child_id,type,"",_ack); present(child_id,type,"",_ack);
} }
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
#define PERSIST 0 #define PERSIST 0
// if enabled, send a SLEEPING and AWAKE service messages just before entering and just after leaving a sleep cycle and STARTED when starting/rebooting // if enabled, send a SLEEPING and AWAKE service messages just before entering and just after leaving a sleep cycle and STARTED when starting/rebooting
#define SERVICE_MESSAGES 0 #define SERVICE_MESSAGES 1
// if enabled, a battery sensor will be created at BATTERY_CHILD_ID and will report vcc voltage together with the battery level percentage // if enabled, a battery sensor will be created at BATTERY_CHILD_ID and will report vcc voltage together with the battery level percentage
#define BATTERY_SENSOR 1 #define BATTERY_SENSOR 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment