working thingspeak reporting

Former-commit-id: 3e6c47cbb4aab5331b18b3caf8112bede7b1075f
master
Ondřej Hruška 9 years ago
parent 324ce7b5bf
commit bbc2f08e25
  1. 6
      html/js/all.js
  2. 8
      html/pages/monitoring.tpl
  3. 17
      html_src/js-src/page_mon.js
  4. 6
      html_src/js/all.js
  5. 8
      html_src/page_monitoring.php
  6. 11
      user/reporting.c

File diff suppressed because one or more lines are too long

@ -73,14 +73,14 @@
<input type="radio" name="service" value="ts" id="rep-svc-ts" %svc_ts%>&nbsp;<label for="rep-svc-ts">ThingSpeak</label>
</td>
</tr>
<tr>
<th><label for="rep-feed">Feed/Channel:</label></th>
<td><input type="text" name="feed" id="rep-feed" value="%repFeed%"></td>
</tr>
<tr>
<th><label for="rep-key">API key:</label></th>
<td><input type="text" name="key" id="rep-key" value="%repKey%"></td>
</tr>
<tr class="xv-only">
<th><label for="rep-feed">Feed ID:</label></th>
<td><input type="text" name="feed" id="rep-feed" value="%repFeed%"></td>
</tr>
<tr>
<th>&nbsp;</th>
<td><input type="submit" value="Save changes"></td>

@ -49,7 +49,22 @@ var page_mon = (function() {
});
};
function updateXvOnly() {
// is xively
var isXv = $('#rep-svc-xv')[0].checked;
if (isXv) {
$('.xv-only').removeClass('hidden');
} else {
$('.xv-only').addClass('hidden');
}
}
mon.init = function() {
updateXvOnly();
$('#rep-svc-xv,#rep-svc-ts').on('change', updateXvOnly);
setInterval(function() {
$().get(_root + '/mon/status', function(resp, status) {
if (status == 200) {
@ -60,7 +75,7 @@ var page_mon = (function() {
$('#actual-dev').html(numfmt(j.deviation, 2));
$('#actual-rms').html(numfmt(j.rms, 2));
} else {
throw 'Capture failed.';
console.error('Capture failed.');
}
} catch(e) {
errorMsg(e);

File diff suppressed because one or more lines are too long

@ -50,14 +50,14 @@
<input type="radio" name="service" value="ts" id="rep-svc-ts" %svc_ts%>&nbsp;<label for="rep-svc-ts">ThingSpeak</label>
</td>
</tr>
<tr>
<th><label for="rep-feed">Feed/Channel:</label></th>
<td><input type="text" name="feed" id="rep-feed" value="%repFeed%"></td>
</tr>
<tr>
<th><label for="rep-key">API key:</label></th>
<td><input type="text" name="key" id="rep-key" value="%repKey%"></td>
</tr>
<tr class="xv-only">
<th><label for="rep-feed">Feed ID:</label></th>
<td><input type="text" name="feed" id="rep-feed" value="%repFeed%"></td>
</tr>
<tr>
<th>&nbsp;</th>
<td><input type="submit" value="Save changes"></td>

@ -123,7 +123,7 @@ static void FLASH_FN do_send_report(void)
char hdrs_buf[100];
switch (rpt_conf.service) {
case RPT_XIVELY:;
case RPT_XIVELY:
bb += sprintf(bb, "deviation,");
bb += my_ftoa(bb, rpt_result.deviation, 2);
bb += sprintf(bb, "\nI_rms,");
@ -141,7 +141,14 @@ static void FLASH_FN do_send_report(void)
break;
case RPT_THINGSPEAK:
warn("------- TODO: REPORT TO THINGSPEAK -------");
bb += sprintf(bb, "key=%s", rpt_conf.key);
bb += sprintf(bb, "&field1=");
bb += my_ftoa(bb, rpt_result.deviation, 2);
bb += sprintf(bb, "&field2=");
bb += my_ftoa(bb, rpt_result.i_rms, 2);
http_post("http://api.thingspeak.com/update", buf, NULL, http_callback_showstatus);
break;
}
}

Loading…
Cancel
Save