 }
 
 void manageRadioPower() {
-  boolean poweron = powersave == 0;
-  pinMode(2,OUTPUT);
-  digitalWrite(2,poweron);
-  if (!poweron) {
-    powersave--;
-  }
-}
-
+  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) {
+  digitalWrite(radioPowerPin,power);
+  radioOn = power;
+  if(power && !lastRadioOn) {
+    lastRadioOn = now;
+    lastRequest = requests;
+  } else if(!power && lastRadioOn) {
+    lastRadioOn = 0;
+  }
+}
+  
 void analogSample() {
   for (int i = 0; i < num(analog); i++) {
     analog[i] = analogRead(i);

  Serial.begin(115200L);
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();
}

void loop() {

#include <OneWire.h>
#define num(array) (sizeof(array)/sizeof(array[0]))

// pin assignments
byte radioPowerPin = 2;

// Ethernet Configuration

byte mac[] = { 0xEE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED   };
