+ f_mount(0, NULL);
+ LOG_INFO("Umount FAT filesystem.\n");
+ }
+ else
+ {
+ http_sendFileNotFound(client);
+ netconn_write(client, http_sd_not_present, http_sd_not_present_len, NETCONN_NOCOPY);
+ }
+
+ return 0;
+}
+
+/*
+ * Return to client a string that display the CHIP ID information.
+ * See datasheet for more detail.
+ */
+static int cgi_chipInfo(struct netconn *client, const char *name, char *revc_buf, size_t revc_len)
+{
+ (void)revc_buf;
+ (void)revc_len;
+ (void)name;
+
+ sprintf((char *)tx_buf, "{ \"core_name\":\"%s\", \"arch_name\":\"%s\", \"sram_size\":\"%s\",\
+ \"flash_size\":\"%s\", \"mem_boot_type\":\"%s\" }",
+ chipid_eproc_name(CHIPID_EPRCOC()),
+ chipid_archnames(CHIPID_ARCH()),
+ chipid_sramsize(CHIPID_SRAMSIZ()),
+ chipid_nvpsize(CHIPID_NVPSIZ()),
+ chipid_nvptype(CHIPID_NVTYP()));
+
+ http_sendOk(client);
+ netconn_write(client, tx_buf, strlen((char *)tx_buf), NETCONN_COPY);
+
+ return 0;
+}
+
+/*
+ * Static cgi table where we associate callback to page.
+ */
+static HttpCGI cgi_table[] =
+{
+ { CGI_MATCH_WORD, "echo", cgi_echo },
+ { CGI_MATCH_NAME, "get_temperature", cgi_temp },
+ { CGI_MATCH_NAME, "get_uptime", cgi_uptime },
+ { CGI_MATCH_NAME, "get_resistor", cgi_resistor },
+ { CGI_MATCH_NAME, "set_led", cgi_led },
+ { CGI_MATCH_WORD, "status", cgi_status },
+ { CGI_MATCH_NAME, "get_chipinfo", cgi_chipInfo },
+ { CGI_MATCH_NAME, "bertos_logo_jpg", cgi_logo },
+ { CGI_MATCH_NONE, NULL, NULL }
+};
+
+
+int main(void)
+{
+ struct netconn *server;
+
+ /* Hardware initialization */
+ init();
+ http_init(http_htmPageLoad, cgi_table);
+
+ proc_new(status_process, NULL, KERN_MINSTACKSIZE * 2, NULL);
+
+ dhcp_start(&netif);
+ while (!netif.ip_addr.addr)
+ timer_delay(DHCP_FINE_TIMER_MSECS);
+ kprintf("dhcp ok: ip = %d.%d.%d.%d\n", IP_ADDR_TO_INT_TUPLE(netif.ip_addr.addr));
+
+ server = netconn_new(NETCONN_TCP);
+ netconn_bind(server, IP_ADDR_ANY, 80);
+ netconn_listen(server);
+
+ while (1)
+ {
+ http_poll(server);