#include #include "cgi.h" #include "espfs.h" static char *map_names[] = { "esp-bridge", "jn-esp-v2", "esp-01" }; static char* map_func[] = { "reset", "isp", "conn_led", "ser_led" }; static uint8_t map_asn[][4] = { { 12, 13, 0, 14 }, // esp-bridge { 12, 13, 0, 2 }, // jn-esp-v2 { 0, 2, 12, 13 }, // esp-01 }; // Cgi to return choice of pin assignments int ICACHE_FLASH_ATTR cgiPinsGet(HttpdConnData *connData) { char buff[1024]; int len; if (connData->conn==NULL) { return HTTPD_CGI_DONE; // Connection aborted } len = os_sprintf(buff, "{ \"curr\":\"esp-bridge\", \"map\": [ "); for (int i=0; iconn==NULL) { return HTTPD_CGI_DONE; // Connection aborted } jsonHeader(connData, 200); return HTTPD_CGI_DONE; } int ICACHE_FLASH_ATTR cgiPins(HttpdConnData *connData) { if (connData->requestType == HTTPD_METHOD_GET) { return cgiPinsGet(connData); } else if (connData->requestType == HTTPD_METHOD_POST) { return cgiPinsSet(connData); } else { jsonHeader(connData, 404); return HTTPD_CGI_DONE; } }