   return atoi(buf);
 }
 
-boolean set_gauge_handler(TinyWebServer& web_server)
+boolean set_dial_handler(TinyWebServer& web_server)
 {
-  byte gauge = read_postdata_int(web_server);
-  analogWrite(PANEL_PIN, gauge);
-  web_server.send_error_code(200);
-  web_server.end_headers();
-  web_server << F("Setting gauge to ") << gauge << "\n";
+  byte dial = read_postdata_int(web_server);
+  analogWrite(PANEL_PIN, dial);
+  handler_response_common(web_server);
+  web_server << F("OK") << dial;
+  return true;
 }
 
-boolean beep_handler(TinyWebServer& web_server)
+boolean buzz_handler(TinyWebServer& web_server)
 {
   int length = read_postdata_int(web_server);
-  stop_beep_ms = millis() + length;
-  web_server.send_error_code(200);
-  web_server.end_headers();
-  web_server << F("Beeping for length ") << length << "\n";
+  stop_buzz_ms = millis() + length;
+  handler_response_common(web_server);
+  web_server << F("OK") << length;
   return true;
 }

#include <TinyWebServer.h>
#include <EthernetDHCP.h>

const int PANEL_PIN = 6;
const int RED_PIN = 11;
const int BLUE_PIN = 9;
const int GREEN_PIN = 10;
const int KNOB_PIN = 0;
const int SPEAKER_PIN = 4;

const int BT_RX = 2;
const int BT_TX = 3;

const int BEEP_HZ = 1720; // a pretty annoying pitch
const long BEEP_US = 1000000/BEEP_HZ;

const int CMD_TIMEOUT_MS = 20000;

int red = 255, green = 0, blue =0;
long stop_beep_ms = 0;
long last_cmd_ms = 0;
int on_duty=100, off_duty=500;



long last_ms = 0;

boolean knob_handler(TinyWebServer& web_server);
boolean set_leds_handler(TinyWebServer& web_server);
boolean set_dial_handler(TinyWebServer& web_server);
boolean buzz_handler(TinyWebServer& web_server);
boolean alive_handler(TinyWebServer& web_server);

TinyWebServer::PathHandler handlers[] = {
  // Register the index_handler for GET requests on /
  {"/", TinyWebServer::GET, &help_handler },
  {"/is_alive", TinyWebServer::GET, &alive_handler },
  {"/knob", TinyWebServer::GET, &knob_handler },
  {"/leds", TinyWebServer::POST, &set_leds_handler },
  {"/dial", TinyWebServer::POST, &set_dial_handler },
  {"/buzz", TinyWebServer::POST, &buzz_handler },
  {NULL}, // The array has to be NULL terminated this way
};

