working param setting etc..

Former-commit-id: 5e5f4be8455add9305cc6fd6bf4c2dba280bd796
master
Ondřej Hruška 9 years ago
parent c620976902
commit c883c02788
  1. 14
      html/pages/monitoring.tpl
  2. 14
      html_src/page_monitoring.php
  3. 2
      libesphttpd/core/httpd.c
  4. 2
      libesphttpd/html-minifier-conf.json
  5. 38
      user/page_monitoring.c
  6. 13
      user/reporting.c
  7. 1
      user/reporting.h

@ -36,11 +36,11 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Actual&nbsp;state:</th> <th>Status:</th>
<td> <td>
<span class="Valfield"> <span class="Valfield" style="vertical-align:middle;">
Δ = <span id="actual-dev">%curDeviation%</span>, Δ = <span id="actual-dev">%curDeviation%</span><br>
I<sub>rms</sub> = <span id="actual-rms">%curRMS%</span> mA I<sub>RMS</sub> = <span id="actual-rms">%curRMS%</span>&nbsp;mA
</span> </span>
<a onclick="page_mon.compareNow()" class="button btn-blue">Measure</a> <a onclick="page_mon.compareNow()" class="button btn-blue">Measure</a>
</td> </td>
@ -55,7 +55,7 @@
<tr> <tr>
<th><label for="rep-on">Reporting:</label></th> <th><label for="rep-on">Reporting:</label></th>
<td> <td>
<input type="checkbox" id="rep-on" name="enabled" value="1" %repEnableCheck%><!-- <input type="checkbox" id="rep-on" name="enabled" value="1" %rep_en%><!--
-->&nbsp;<label for="rep-on">enabled</label> -->&nbsp;<label for="rep-on">enabled</label>
</td> </td>
</tr> </tr>
@ -69,8 +69,8 @@
<tr> <tr>
<th>Service:</th> <th>Service:</th>
<td> <td>
<input type="radio" name="service" value="xv" id="rep-svc-xv" %repSvcCheckXv%>&nbsp;<label for="rep-svc-xv">Xively</label>&nbsp; <input type="radio" name="service" value="xv" id="rep-svc-xv" %svc_xv%>&nbsp;<label for="rep-svc-xv">Xively</label>&nbsp;
<input type="radio" name="service" value="ts" id="rep-svc-ts" %repSvcCheckTs%>&nbsp;<label for="rep-svc-ts">ThingSpeak</label> <input type="radio" name="service" value="ts" id="rep-svc-ts" %svc_ts%>&nbsp;<label for="rep-svc-ts">ThingSpeak</label>
</td> </td>
</tr> </tr>
<tr> <tr>

@ -13,11 +13,11 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Actual&nbsp;state:</th> <th>Status:</th>
<td> <td>
<span class="Valfield"> <span class="Valfield" style="vertical-align:middle;">
Δ = <span id="actual-dev">%curDeviation%</span>, Δ = <span id="actual-dev">%curDeviation%</span><br>
I<sub>rms</sub> = <span id="actual-rms">%curRMS%</span> mA I<sub>RMS</sub> = <span id="actual-rms">%curRMS%</span>&nbsp;mA
</span> </span>
<a onclick="page_mon.compareNow()" class="button btn-blue">Measure</a> <a onclick="page_mon.compareNow()" class="button btn-blue">Measure</a>
</td> </td>
@ -32,7 +32,7 @@
<tr> <tr>
<th><label for="rep-on">Reporting:</label></th> <th><label for="rep-on">Reporting:</label></th>
<td> <td>
<input type="checkbox" id="rep-on" name="enabled" value="1" %repEnableCheck%><!-- <input type="checkbox" id="rep-on" name="enabled" value="1" %rep_en%><!--
-->&nbsp;<label for="rep-on">enabled</label> -->&nbsp;<label for="rep-on">enabled</label>
</td> </td>
</tr> </tr>
@ -46,8 +46,8 @@
<tr> <tr>
<th>Service:</th> <th>Service:</th>
<td> <td>
<input type="radio" name="service" value="xv" id="rep-svc-xv" %repSvcCheckXv%>&nbsp;<label for="rep-svc-xv">Xively</label>&nbsp; <input type="radio" name="service" value="xv" id="rep-svc-xv" %svc_xv%>&nbsp;<label for="rep-svc-xv">Xively</label>&nbsp;
<input type="radio" name="service" value="ts" id="rep-svc-ts" %repSvcCheckTs%>&nbsp;<label for="rep-svc-ts">ThingSpeak</label> <input type="radio" name="service" value="ts" id="rep-svc-ts" %svc_ts%>&nbsp;<label for="rep-svc-ts">ThingSpeak</label>
</td> </td>
</tr> </tr>
<tr> <tr>

@ -207,7 +207,7 @@ int ICACHE_FLASH_ATTR httpdFindArg(char *line, char *arg, char *buff, int buffLe
p=(char*)strstr(p, "&"); p=(char*)strstr(p, "&");
if (p!=NULL) p+=1; if (p!=NULL) p+=1;
} }
warn("Finding %s in %s: Not found :/", arg, line); // warn("Finding %s in %s: Not found :/", arg, line);
return -1; //not found return -1; //not found
} }

@ -7,7 +7,7 @@
"collapseBooleanAttributes": true, "collapseBooleanAttributes": true,
"removeTagWhitespace": true, "removeTagWhitespace": true,
"removeAttributeQuotes": true, "removeAttributeQuotes": true,
"removeRedundantAttributes": true, "removeRedundantAttributes": false,
"useShortDoctype": true, "useShortDoctype": true,
"removeEmptyAttributes": true, "removeEmptyAttributes": true,
"removeScriptTypeAttributes": true, "removeScriptTypeAttributes": true,

@ -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);
} }

@ -96,9 +96,15 @@ static void FLASH_FN compare_ref_cb(SBMP_Endpoint *ep, SBMP_Datagram *dg, void *
info("Measurement complete."); info("Measurement complete.");
rpt_result.success = (dg->type == DG_SUCCESS);
if (dg->type == DG_SUCCESS) {
PayloadParser pp = pp_start(dg->payload, dg->length); PayloadParser pp = pp_start(dg->payload, dg->length);
rpt_result.deviation = pp_float(&pp); rpt_result.deviation = pp_float(&pp);
rpt_result.i_rms = pp_float(&pp); rpt_result.i_rms = pp_float(&pp);
} else {
error("FAIL resp from sbmp.");
}
rpt_result.ready = true; // signal to waiting loop rpt_result.ready = true; // signal to waiting loop
} }
@ -110,10 +116,11 @@ static void FLASH_FN do_send_report(void)
info("Sending report..."); info("Sending report...");
switch (rpt_conf.service) { switch (rpt_conf.service) {
case RPT_XIVELY: case RPT_XIVELY:
// TODO send request warn("------- TODO: REPORT TO XIVELY -------");
break; break;
case RPT_THINGSPEAK: case RPT_THINGSPEAK:
warn("------- TODO: REPORT TO THINGSPEAK -------");
break; break;
} }
} }
@ -135,7 +142,9 @@ bool FLASH_FN capture_and_report(void)
uart_poll(); uart_poll();
if (rpt_result.ready) { if (rpt_result.ready) {
if (rpt_result.success) {
do_send_report(); do_send_report();
}
return true; // done return true; // done
} }
@ -166,7 +175,7 @@ static void FLASH_FN store_ref_cb(SBMP_Endpoint *ep, SBMP_Datagram *dg, void **o
/** Capture reference vector for monitoring */ /** Capture reference vector for monitoring */
bool FLASH_FN capture_reporting_reference(void) bool FLASH_FN capture_reporting_reference(void)
{ {
info("Capturing refernece..."); info("Capturing reference...");
uint16_t sesn; uint16_t sesn;
sbmp_ep_send_message(dlnk_ep, DG_REQUEST_STORE_REF, NULL, 0, &sesn, NULL); sbmp_ep_send_message(dlnk_ep, DG_REQUEST_STORE_REF, NULL, 0, &sesn, NULL);

@ -24,6 +24,7 @@ typedef struct {
/** Comapre result is stored here */ /** Comapre result is stored here */
typedef struct { typedef struct {
bool ready; bool ready;
bool success;
float deviation; float deviation;
float i_rms; float i_rms;
} ReportingResult; } ReportingResult;

Loading…
Cancel
Save