-
 // Copyright (c) 2011, Ward Cunningham
 // Released under MIT and GPLv2
 

  }
}

void manageRadioPower() {
  if(radioOn && (lastRequest == requests) && (now-lastRadioOn >= 3600*1000))) {
    // radio has been on for a while, but received no requests, may be wedged, try rebooting
    powerRadio(false);
    delay(2000);
    powerRadio(true);
  } else {
    if(radioPowerMode == 0 || !topOfHour { // stay on
      if(!radioOn) {
        powerRadio(true);
      } 
    } else if(radioPowerMode == 1) { // on at 58m30s, off at 4m15s after hour
      // remove integer hours from time, just interested in phase ... not needed if we get a sync often enough relative to wrapping
      while(now-topOfHour > (3600*1000)) {
        topOfHour += 3600*1000;
      }
      unsigned long time_after_hour = (now-topOfHour) % (3600*1000);
      if(radioOn && (time_after_hour > (4*60+15)*1000)) {
        powerRadio(false);
      } else if (!radioOn && (time_after_hour > (58*60+30)*1000)) {
        powerRadio(true);
    }
  }
}

void powerRadio(boolean power) {


unsigned long requests = 0;
unsigned long lastRequest = 0; // records the request number at time of the most recent radio powerup
byte radioPowerMode = 1; // indicates which power management algorith to use

// Sensor Configuration

