     // If a capture is in progress, handle that state machine.
     if (state == 7 && capture) { // ignore if we're still sending something else.
       if (capture == 1 && cam.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) {
-        log ("H","image ready");
         capture = 2;
         imglen = cam.read_fifo_length();
+        xlognum ("H","image ready", imglen);
         cam.CS_LOW();
         cam.set_fifo_burst();
       }
+      if (capture == 3) {
+        rsend ("done");
+        capture = 0;
+      }
+
       if (capture == 2) {
-        log ("H","packet");
+        xlognum ("H","packet",imglen);
         uint8_t temp, temp_last;
         uint32_t len = imglen;
         int found_end = 0;

    state = 5;
}
void state_5_6 () {
    log("H","listening");
    state = 6;
}
void state_6_7 () {
    log("H", "connect");
    rsend ("Welcome to Coffeebot");
    state = 7;
}
void state_7_6 () {
    log("H", "disconnect");
    state = 6;
}
void state_8_7 () {


void h_handle_line () {
    hlinebuf[hlineoff] = '\0';
    xlog (">", hlinebuf);
    wsend(hlinebuf);
    hlineoff = 0;
}
