Commit ee4568ed authored by maniacbug's avatar maniacbug

Added server time to printout. Power disable/enable before/after sleeping. Changed timer to 4s.

parent 0d20f831
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <SPI.h> #include <SPI.h>
#include <avr/sleep.h> #include <avr/sleep.h>
#include <avr/power.h>
#include "nRF24L01.h" #include "nRF24L01.h"
#include "RF24.h" #include "RF24.h"
#include "printf.h" #include "printf.h"
...@@ -103,9 +104,9 @@ void setup(void) ...@@ -103,9 +104,9 @@ void setup(void)
// Prepare sleep parameters // Prepare sleep parameters
// //
// Only the ping out role sleeps. Wake up every 2s to send a ping // Only the ping out role sleeps. Wake up every 4s to send a ping
if ( role == role_ping_out ) if ( role == role_ping_out )
setup_watchdog(wdt_2s); setup_watchdog(wdt_4s);
// //
// Setup and configure rf radio // Setup and configure rf radio
...@@ -219,8 +220,9 @@ void loop(void) ...@@ -219,8 +220,9 @@ void loop(void)
// Fetch the payload, and see if this was the last one. // Fetch the payload, and see if this was the last one.
done = radio.read( &got_time, sizeof(unsigned long) ); done = radio.read( &got_time, sizeof(unsigned long) );
// Spew it // Spew it. Include our time, because the ping_out millis counter is unreliable
printf("Got payload %lu...",got_time); // due to it sleeping
printf("Got payload %lu @ %lu...",got_time,millis());
} }
// First, stop listening so we can talk // First, stop listening so we can talk
...@@ -265,9 +267,12 @@ void do_sleep(void) ...@@ -265,9 +267,12 @@ void do_sleep(void)
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
sleep_enable(); sleep_enable();
power_all_disable();
sleep_mode(); // System sleeps here sleep_mode(); // System sleeps here
sleep_disable(); // System continues execution here when watchdog timed out sleep_disable(); // System continues execution here when watchdog timed out
power_all_enable();
} }
// vim:ai:cin:sts=2 sw=2 ft=cpp // vim:ai:cin:sts=2 sw=2 ft=cpp
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