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. 21
      user/reporting.c
  7. 1
      user/reporting.h

@ -36,11 +36,11 @@
</td>
</tr>
<tr>
<th>Actual&nbsp;state:</th>
<th>Status:</th>
<td>
<span class="Valfield">
Δ = <span id="actual-dev">%curDeviation%</span>,
I<sub>rms</sub> = <span id="actual-rms">%curRMS%</span> mA
<span class="Valfield" style="vertical-align:middle;">
Δ = <span id="actual-dev">%curDeviation%</span><br>
I<sub>RMS</sub> = <span id="actual-rms">%curRMS%</span>&nbsp;mA
</span>
<a onclick="page_mon.compareNow()" class="button btn-blue">Measure</a>
</td>
@ -55,7 +55,7 @@
<tr>
<th><label for="rep-on">Reporting:</label></th>
<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>
</td>
</tr>
@ -69,8 +69,8 @@
<tr>
<th>Service:</th>
<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="ts" id="rep-svc-ts" %repSvcCheckTs%>&nbsp;<label for="rep-svc-ts">ThingSpeak</label>
<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" %svc_ts%>&nbsp;<label for="rep-svc-ts">ThingSpeak</label>
</td>
</tr>
<tr>

@ -13,11 +13,11 @@
</td>
</tr>
<tr>
<th>Actual&nbsp;state:</th>
<th>Status:</th>
<td>
<span class="Valfield">
Δ = <span id="actual-dev">%curDeviation%</span>,
I<sub>rms</sub> = <span id="actual-rms">%curRMS%</span> mA
<span class="Valfield" style="vertical-align:middle;">
Δ = <span id="actual-dev">%curDeviation%</span><br>
I<sub>RMS</sub> = <span id="actual-rms">%curRMS%</span>&nbsp;mA
</span>
<a onclick="page_mon.compareNow()" class="button btn-blue">Measure</a>
</td>
@ -32,7 +32,7 @@
<tr>
<th><label for="rep-on">Reporting:</label></th>
<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>
</td>
</tr>
@ -46,8 +46,8 @@
<tr>
<th>Service:</th>
<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="ts" id="rep-svc-ts" %repSvcCheckTs%>&nbsp;<label for="rep-svc-ts">ThingSpeak</label>
<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" %svc_ts%>&nbsp;<label for="rep-svc-ts">ThingSpeak</label>
</td>
</tr>
<tr>

@ -207,7 +207,7 @@ int ICACHE_FLASH_ATTR httpdFindArg(char *line, char *arg, char *buff, int buffLe
p=(char*)strstr(p, "&");
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
}

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

@ -7,10 +7,7 @@
httpd_cgi_state FLASH_FN cgiMonCompare(HttpdConnData *connData)
{
if (connData->conn == NULL) {
//Connection aborted. Clean up.
return HTTPD_CGI_DONE;
}
if (connData->conn == NULL) return HTTPD_CGI_DONE;
httpdStartResponse(connData, 200);
httpdHeader(connData, "Content-Type", "application/json");
@ -23,11 +20,12 @@ httpd_cgi_state FLASH_FN cgiMonCompare(HttpdConnData *connData)
if (suc && rpt_result.ready) {
// success
sprintf(buf, "{\"success\": true, \"deviation\": ");
my_ftoa(buf+strlen(buf),rpt_result.deviation, 2);
sprintf(buf, ", \"rms\": ");
my_ftoa(buf+strlen(buf),rpt_result.i_rms, 2);
sprintf(buf, "}");
char *bb = buf;
bb += sprintf(bb, "{\"success\": true, \"deviation\": ");
bb += my_ftoa(bb,rpt_result.deviation, 2);
bb += sprintf(bb, ", \"rms\": ");
bb += my_ftoa(bb,rpt_result.i_rms, 2);
bb += sprintf(bb, "}");
httpdSend(connData, buf, -1);
} else {
@ -40,10 +38,7 @@ httpd_cgi_state FLASH_FN cgiMonCompare(HttpdConnData *connData)
httpd_cgi_state FLASH_FN cgiMonSetRef(HttpdConnData *connData)
{
if (connData->conn == NULL) {
//Connection aborted. Clean up.
return HTTPD_CGI_DONE;
}
if (connData->conn == NULL) return HTTPD_CGI_DONE;
httpdStartResponse(connData, 200);
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)
{
if (connData->conn == NULL) {
//Connection aborted. Clean up.
return HTTPD_CGI_DONE;
}
httpdStartResponse(connData, 200);
httpdHeader(connData, "Content-Type", "application/json");
httpdEndHeaders(connData);
if (connData->conn == NULL) return HTTPD_CGI_DONE;
// TODO
HttpdPostData *post = connData->post;
@ -84,7 +72,7 @@ httpd_cgi_state FLASH_FN cgiMonitoringCfg(HttpdConnData *connData)
}
// interval=secs
blen = httpdFindArg(post->buff, "enabled", buf, 64);
blen = httpdFindArg(post->buff, "interval", buf, 64);
if (blen != -1) {
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);
} else if (streq(token, "repEnableCheck")) {
} else if (streq(token, "rep_en")) {
if (rpt_conf.enabled) httpdSend(connData, "checked", -1);
} else if (streq(token, "repInterval")) { // interval in seconds
sprintf(buf, "%d", rpt_conf.interval);
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) {
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) {
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.");
PayloadParser pp = pp_start(dg->payload, dg->length);
rpt_result.deviation = pp_float(&pp);
rpt_result.i_rms = pp_float(&pp);
rpt_result.success = (dg->type == DG_SUCCESS);
if (dg->type == DG_SUCCESS) {
PayloadParser pp = pp_start(dg->payload, dg->length);
rpt_result.deviation = pp_float(&pp);
rpt_result.i_rms = pp_float(&pp);
} else {
error("FAIL resp from sbmp.");
}
rpt_result.ready = true; // signal to waiting loop
}
@ -110,10 +116,11 @@ static void FLASH_FN do_send_report(void)
info("Sending report...");
switch (rpt_conf.service) {
case RPT_XIVELY:
// TODO send request
warn("------- TODO: REPORT TO XIVELY -------");
break;
case RPT_THINGSPEAK:
warn("------- TODO: REPORT TO THINGSPEAK -------");
break;
}
}
@ -135,7 +142,9 @@ bool FLASH_FN capture_and_report(void)
uart_poll();
if (rpt_result.ready) {
do_send_report();
if (rpt_result.success) {
do_send_report();
}
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 */
bool FLASH_FN capture_reporting_reference(void)
{
info("Capturing refernece...");
info("Capturing reference...");
uint16_t sesn;
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 */
typedef struct {
bool ready;
bool success;
float deviation;
float i_rms;
} ReportingResult;

Loading…
Cancel
Save