+ (void)recv_buf;
+ (void)recv_len;
+ (void)name;
+
+ status.tot_req++;
+ uint16_t volt = adc_read(1);
+
+ //Update board status.
+ sprintf(status.last_connected_ip, "%d.%d.%d.%d", IP_ADDR_TO_INT_TUPLE(client->pcb.ip->remote_ip.addr));
+ sprintf(status.local_ip, "%d.%d.%d.%d", IP_ADDR_TO_INT_TUPLE(client->pcb.ip->local_ip.addr));
+
+ sprintf((char *)tx_buf, "{ \"local_ip\":\"%s\",\"last_connected_ip\":\"%s\", \"temp\":%d.%d,\"volt\":%d,\"up_time\":%ld,\"tot_req\":%d, \
+\"leds\":{ \"0\":\"%d\", \"1\":\"%d\", \"2\":\"%d\"}}",
+ status.local_ip, status.last_connected_ip,
+ status.internal_temp / 10, status.internal_temp % 10,
+ volt, status.up_time, status.tot_req,
+ GET_LED_STATUS(status.led_status, 0),
+ GET_LED_STATUS(status.led_status, 1),
+ GET_LED_STATUS(status.led_status, 2));
+
+
+
+
+ http_sendOk(client, HTTP_CONTENT_JSON);
+ netconn_write(client, tx_buf, strlen((char *)tx_buf), NETCONN_COPY);
+ return 0;
+}
+
+static int cgi_logo(struct netconn *client, const char *name, char *recv_buf, size_t recv_len)
+{
+ (void)recv_buf;
+ (void)recv_len;
+ (void)name;
+
+ http_sendOk(client, HTTP_CONTENT_JPEG);
+ netconn_write(client, bertos_logo_jpg, bertos_logo_jpg_len, NETCONN_NOCOPY);
+ return 0;
+}
+
+/*
+ * Return the internal micro temperature string.
+ */
+static int cgi_temp(struct netconn *client, const char *name, char *recv_buf, size_t recv_len)
+{
+ (void)recv_buf;
+ (void)recv_len;
+ (void)name;
+
+ sprintf((char *)tx_buf, "[%d.%d]", status.internal_temp / 10, status.internal_temp % 10);
+
+ http_sendOk(client, HTTP_CONTENT_JSON);
+ netconn_write(client, tx_buf, strlen((char *)tx_buf), NETCONN_COPY);
+ return 0;
+}
+
+
+/*
+ * Return the board uptime.
+ */
+static int cgi_uptime(struct netconn *client, const char *name, char *recv_buf, size_t recv_len)
+{
+ (void)recv_buf;
+ (void)recv_len;
+ (void)name;
+
+ sec_to_strDhms(status.up_time, (char *)tx_buf, sizeof(tx_buf));
+
+ http_sendOk(client, HTTP_CONTENT_JSON);
+ netconn_write(client, tx_buf, strlen((char *)tx_buf), NETCONN_COPY);
+ return 0;
+}
+
+/*
+ * Return the VR1 potentiometer voltage.
+ */
+static int cgi_resistor(struct netconn *client, const char *name, char *recv_buf, size_t recv_len)
+{
+ (void)recv_buf;
+ (void)recv_len;
+ (void)name;
+
+ uint16_t volt = ADC_RANGECONV(adc_read(1), 0, 3300);
+ kprintf("volt %d\n", volt);
+ sprintf((char *)tx_buf, "[ \"%d.%dV\" ]", volt / 1000, volt % 1000);
+
+ http_sendOk(client, HTTP_CONTENT_JSON);
+ netconn_write(client, tx_buf, strlen((char *)tx_buf), NETCONN_COPY);
+ return 0;
+}
+
+
+#define CGI_LED_ID_KEY "n"
+#define CGI_LED_CMD_KEY "set"
+
+static char key_value[80];
+
+/*
+ * Reply to client the request string.
+ */
+static int cgi_led(struct netconn *client, const char *name, char *recv_buf, size_t recv_len)
+{
+ (void)recv_buf;
+ (void)recv_len;
+ (void)name;
+
+ char *query_str = strstr(name, "?") + 1;
+ size_t query_str_len = strlen(query_str);
+ int led_id;
+ int led_cmd;
+
+ int len = http_tokenizeGetRequest(query_str, query_str_len);
+
+ LOG_INFO("Found %d key/value pair\n", len);
+
+ if (http_getValue(query_str, query_str_len, CGI_LED_ID_KEY, key_value, sizeof(key_value)) < 0)