|
|
@ -7,10 +7,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
httpd_cgi_state FLASH_FN cgiMonCompare(HttpdConnData *connData) |
|
|
|
httpd_cgi_state FLASH_FN cgiMonCompare(HttpdConnData *connData) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (connData->conn == NULL) { |
|
|
|
if (connData->conn == NULL) return HTTPD_CGI_DONE; |
|
|
|
//Connection aborted. Clean up.
|
|
|
|
|
|
|
|
return HTTPD_CGI_DONE; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
httpdStartResponse(connData, 200); |
|
|
|
httpdStartResponse(connData, 200); |
|
|
|
httpdHeader(connData, "Content-Type", "application/json"); |
|
|
|
httpdHeader(connData, "Content-Type", "application/json"); |
|
|
@ -23,11 +20,12 @@ httpd_cgi_state FLASH_FN cgiMonCompare(HttpdConnData *connData) |
|
|
|
|
|
|
|
|
|
|
|
if (suc && rpt_result.ready) { |
|
|
|
if (suc && rpt_result.ready) { |
|
|
|
// success
|
|
|
|
// success
|
|
|
|
sprintf(buf, "{\"success\": true, \"deviation\": "); |
|
|
|
char *bb = buf; |
|
|
|
my_ftoa(buf+strlen(buf),rpt_result.deviation, 2); |
|
|
|
bb += sprintf(bb, "{\"success\": true, \"deviation\": "); |
|
|
|
sprintf(buf, ", \"rms\": "); |
|
|
|
bb += my_ftoa(bb,rpt_result.deviation, 2); |
|
|
|
my_ftoa(buf+strlen(buf),rpt_result.i_rms, 2); |
|
|
|
bb += sprintf(bb, ", \"rms\": "); |
|
|
|
sprintf(buf, "}"); |
|
|
|
bb += my_ftoa(bb,rpt_result.i_rms, 2); |
|
|
|
|
|
|
|
bb += sprintf(bb, "}"); |
|
|
|
|
|
|
|
|
|
|
|
httpdSend(connData, buf, -1); |
|
|
|
httpdSend(connData, buf, -1); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -40,10 +38,7 @@ httpd_cgi_state FLASH_FN cgiMonCompare(HttpdConnData *connData) |
|
|
|
|
|
|
|
|
|
|
|
httpd_cgi_state FLASH_FN cgiMonSetRef(HttpdConnData *connData) |
|
|
|
httpd_cgi_state FLASH_FN cgiMonSetRef(HttpdConnData *connData) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (connData->conn == NULL) { |
|
|
|
if (connData->conn == NULL) return HTTPD_CGI_DONE; |
|
|
|
//Connection aborted. Clean up.
|
|
|
|
|
|
|
|
return HTTPD_CGI_DONE; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
httpdStartResponse(connData, 200); |
|
|
|
httpdStartResponse(connData, 200); |
|
|
|
httpdHeader(connData, "Content-Type", "application/json"); |
|
|
|
httpdHeader(connData, "Content-Type", "application/json"); |
|
|
@ -59,14 +54,7 @@ httpd_cgi_state FLASH_FN cgiMonSetRef(HttpdConnData *connData) |
|
|
|
|
|
|
|
|
|
|
|
httpd_cgi_state FLASH_FN cgiMonitoringCfg(HttpdConnData *connData) |
|
|
|
httpd_cgi_state FLASH_FN cgiMonitoringCfg(HttpdConnData *connData) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (connData->conn == NULL) { |
|
|
|
if (connData->conn == NULL) return HTTPD_CGI_DONE; |
|
|
|
//Connection aborted. Clean up.
|
|
|
|
|
|
|
|
return HTTPD_CGI_DONE; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
httpdStartResponse(connData, 200); |
|
|
|
|
|
|
|
httpdHeader(connData, "Content-Type", "application/json"); |
|
|
|
|
|
|
|
httpdEndHeaders(connData); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
// TODO
|
|
|
|
HttpdPostData *post = connData->post; |
|
|
|
HttpdPostData *post = connData->post; |
|
|
@ -84,7 +72,7 @@ httpd_cgi_state FLASH_FN cgiMonitoringCfg(HttpdConnData *connData) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// interval=secs
|
|
|
|
// interval=secs
|
|
|
|
blen = httpdFindArg(post->buff, "enabled", buf, 64); |
|
|
|
blen = httpdFindArg(post->buff, "interval", buf, 64); |
|
|
|
if (blen != -1) { |
|
|
|
if (blen != -1) { |
|
|
|
rpt_conf.interval = (uint32_t)atoi(buf); |
|
|
|
rpt_conf.interval = (uint32_t)atoi(buf); |
|
|
|
} |
|
|
|
} |
|
|
@ -146,19 +134,19 @@ httpd_cgi_state FLASH_FN tplMonitoring(HttpdConnData *connData, char *token, voi |
|
|
|
} |
|
|
|
} |
|
|
|
httpdSend(connData, buf, -1); |
|
|
|
httpdSend(connData, buf, -1); |
|
|
|
|
|
|
|
|
|
|
|
} else if (streq(token, "repEnableCheck")) { |
|
|
|
} else if (streq(token, "rep_en")) { |
|
|
|
if (rpt_conf.enabled) httpdSend(connData, "checked", -1); |
|
|
|
if (rpt_conf.enabled) httpdSend(connData, "checked", -1); |
|
|
|
|
|
|
|
|
|
|
|
} else if (streq(token, "repInterval")) { // interval in seconds
|
|
|
|
} else if (streq(token, "repInterval")) { // interval in seconds
|
|
|
|
sprintf(buf, "%d", rpt_conf.interval); |
|
|
|
sprintf(buf, "%d", rpt_conf.interval); |
|
|
|
httpdSend(connData, buf, -1); |
|
|
|
httpdSend(connData, buf, -1); |
|
|
|
|
|
|
|
|
|
|
|
} else if (streq(token, "repSvcCheckXv")) { // Xively checkbox
|
|
|
|
} else if (streq(token, "svc_xv")) { // Xively checkbox
|
|
|
|
if (rpt_conf.service == RPT_XIVELY) { |
|
|
|
if (rpt_conf.service == RPT_XIVELY) { |
|
|
|
httpdSend(connData, "checked", -1); |
|
|
|
httpdSend(connData, "checked", -1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else if (streq(token, "repSvcCheckTs")) { // ThingSpeak checkbox
|
|
|
|
} else if (streq(token, "svc_ts")) { // ThingSpeak checkbox
|
|
|
|
if (rpt_conf.service == RPT_THINGSPEAK) { |
|
|
|
if (rpt_conf.service == RPT_THINGSPEAK) { |
|
|
|
httpdSend(connData, "checked", -1); |
|
|
|
httpdSend(connData, "checked", -1); |
|
|
|
} |
|
|
|
} |
|
|
|