     } else {
         event = scheduler.pollWaiting();
     }
-    switch (event) {
-        case TASK_ANNOUNCE:
-            // Repeat every minute for the first five minutes, then once per hour
-            scheduler.timer(TASK_ANNOUNCE, millis() < 300000 ? 600 : 36000);
-
-            sendAnnouncement();
-            break;
-
-#if 0
-        case MEASURE:
-            // reschedule these measurements periodically
-            scheduler.timer(MEASURE, MEASURE_PERIOD);
-
-            doMeasure();
-
-            // every so often, a report needs to be sent out
-            if (++reportCount >= REPORT_EVERY) {
-                reportCount = 0;
-                scheduler.timer(REPORT, 0);
-            }
-            break;
-
-        case REPORT:
-            doReport();
-            break;
-#endif
-    }
-}
+    if(event == TASK_ANNOUNCE) {
+        // Repeat every minute for the first five minutes, then once per hour
+        scheduler.timer(TASK_ANNOUNCE, millis() < 300000 ? 600 : 36000);
+
+        sendAnnouncement();
+    } else if(event == TASK_REPORT) {
+        // Transmit any buffered measurements
+        Serial.print("\r\n=> ");
+        for(byte j=0; j<databufferpos; j++) {
+            printInt(databuffer[j]);
+            Serial.print(",");
+        }
+        Serial.print("\r\n");
+        serialFlush();
+
+        rf12_sleep(RF12_WAKEUP);
+        rf12_sendNow(0, databuffer, databufferpos);
+        rf12_sendWait(RADIO_SYNC_MODE);
+        rf12_sleep(RF12_SLEEP);
+
+        databufferpos = 1;  // Don't overwrite header
+    } else if(event >= TASK_MEASURE0 && event <= TASK_MEASURE0+MAX_PLUGS) {
+        // Take the measurement for the given plug and then schedule a report
+        Plug &plug = plugs[event-TASK_MEASURE0];
+
+        scheduler.timer(event, scale_as_int(plug.period));
+
+        measurePlug(plug, 1);
+        if(scheduler.idle(TASK_REPORT))
+            scheduler.timer(TASK_REPORT, 1);
+    }
+}

    Serial.print("Doing measurements:\r\n");
    for(byte n=0; n<count; n++) {
        for(byte i=0; i<numPlugs; i++) {
            measurePlug(plugs[i], n == 0);
        }
        if( (n+1) < count )
            Sleepy::loseSomeTime(1000);
    }
}

static void prompt()


    for(byte i=0; i<numPlugs; i++) {
        init_measure(plugs[i]);
        // Measure only after a minute, so the user can interrupt
        scheduler.timer(TASK_MEASURE0+i, 600);
    }
    showHelp();
    showConfig();
