Browse Source

Option to not clearing cache after sending data to Thingspeak.com (#1369)

alexa
Xose Pérez 5 years ago
parent
commit
606ef345bf
16 changed files with 17978 additions and 17895 deletions
  1. +2
    -2
      README.md
  2. +5
    -0
      code/espurna/config/general.h
  3. BIN
      code/espurna/data/index.all.html.gz
  4. BIN
      code/espurna/data/index.light.html.gz
  5. BIN
      code/espurna/data/index.rfbridge.html.gz
  6. BIN
      code/espurna/data/index.rfm69.html.gz
  7. BIN
      code/espurna/data/index.sensor.html.gz
  8. BIN
      code/espurna/data/index.small.html.gz
  9. +3130
    -3118
      code/espurna/static/index.all.html.gz.h
  10. +2982
    -2973
      code/espurna/static/index.light.html.gz.h
  11. +2587
    -2578
      code/espurna/static/index.rfbridge.html.gz.h
  12. +4064
    -4055
      code/espurna/static/index.rfm69.html.gz.h
  13. +2641
    -2629
      code/espurna/static/index.sensor.html.gz.h
  14. +2543
    -2535
      code/espurna/static/index.small.html.gz.h
  15. +11
    -4
      code/espurna/thinkspeak.ino
  16. +13
    -1
      code/html/index.html

+ 2
- 2
README.md View File

@ -4,9 +4,9 @@ ESPurna ("spark" in Catalan) is a custom firmware for ESP8285/ESP8266 based smar
It uses the Arduino Core for ESP8266 framework and a number of 3rd party libraries.
[![version](https://img.shields.io/badge/version-1.13.3-brightgreen.svg)](CHANGELOG.md)
[![branch](https://img.shields.io/badge/branch-sensors-orange.svg)](https://github.com/xoseperez/espurna/tree/sensors/)
[![branch](https://img.shields.io/badge/branch-dev-orange.svg)](https://github.com/xoseperez/espurna/tree/dev/)
[![license](https://img.shields.io/github/license/xoseperez/espurna.svg)](LICENSE)
[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=sensors)](https://travis-ci.org/xoseperez/espurna)
[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=dev)](https://travis-ci.org/xoseperez/espurna)
[![codacy](https://api.codacy.com/project/badge/Grade/c9496e25cf07434cba786b462cb15f49)](https://www.codacy.com/app/xoseperez/espurna/dashboard)
[![downloads](https://img.shields.io/github/downloads/xoseperez/espurna/total.svg)](https://github.com/xoseperez/espurna/releases)
<br />


+ 5
- 0
code/espurna/config/general.h View File

@ -1005,6 +1005,11 @@
#define THINGSPEAK_APIKEY "" // Default API KEY
#endif
#ifndef THINGSPEAK_CLEAR_CACHE
#define THINGSPEAK_CLEAR_CACHE 1 // Clear cache after sending values
// Not clearing it will result in latest values for each field being sent every time
#endif
#define THINGSPEAK_USE_ASYNC 1 // Use AsyncClient instead of WiFiClientSecure
// THINGSPEAK OVER SSL


BIN
code/espurna/data/index.all.html.gz View File


BIN
code/espurna/data/index.light.html.gz View File


BIN
code/espurna/data/index.rfbridge.html.gz View File


BIN
code/espurna/data/index.rfm69.html.gz View File


BIN
code/espurna/data/index.sensor.html.gz View File


BIN
code/espurna/data/index.small.html.gz View File


+ 3130
- 3118
code/espurna/static/index.all.html.gz.h
File diff suppressed because it is too large
View File


+ 2982
- 2973
code/espurna/static/index.light.html.gz.h
File diff suppressed because it is too large
View File


+ 2587
- 2578
code/espurna/static/index.rfbridge.html.gz.h
File diff suppressed because it is too large
View File


+ 4064
- 4055
code/espurna/static/index.rfm69.html.gz.h
File diff suppressed because it is too large
View File


+ 2641
- 2629
code/espurna/static/index.sensor.html.gz.h
File diff suppressed because it is too large
View File


+ 2543
- 2535
code/espurna/static/index.small.html.gz.h
File diff suppressed because it is too large
View File


+ 11
- 4
code/espurna/thinkspeak.ino View File

@ -25,6 +25,8 @@ const char THINGSPEAK_REQUEST_TEMPLATE[] PROGMEM =
"%s\r\n";
bool _tspk_enabled = false;
bool _tspk_clear = false;
char * _tspk_queue[THINGSPEAK_FIELDS] = {NULL};
bool _tspk_flush = false;
@ -45,6 +47,7 @@ void _tspkWebSocketOnSend(JsonObject& root) {
root["tspkEnabled"] = getSetting("tspkEnabled", THINGSPEAK_ENABLED).toInt() == 1;
root["tspkKey"] = getSetting("tspkKey");
root["tspkClear"] = getSetting("tspkClear", THINGSPEAK_CLEAR_CACHE).toInt() == 1;
JsonArray& relays = root.createNestedArray("tspkRelays");
for (byte i=0; i<relayCount(); i++) {
@ -71,6 +74,7 @@ void _tspkWebSocketOnSend(JsonObject& root) {
#endif
void _tspkConfigure() {
_tspk_clear = getSetting("tspkClear", THINGSPEAK_CLEAR_CACHE).toInt() == 1;
_tspk_enabled = getSetting("tspkEnabled", THINGSPEAK_ENABLED).toInt() == 1;
if (_tspk_enabled && (getSetting("tspkKey").length() == 0)) {
_tspk_enabled = false;
@ -221,10 +225,12 @@ void _tspkEnqueue(unsigned char index, char * payload) {
}
void _tspkClearQueue() {
for (unsigned char id=0; id<THINGSPEAK_FIELDS; id++) {
if (_tspk_queue[id] != NULL) {
free(_tspk_queue[id]);
_tspk_queue[id] = NULL;
if (_tspk_clear) {
for (unsigned char id=0; id<THINGSPEAK_FIELDS; id++) {
if (_tspk_queue[id] != NULL) {
free(_tspk_queue[id]);
_tspk_queue[id] = NULL;
}
}
}
}
@ -250,6 +256,7 @@ void _tspkFlush() {
}
}
// -----------------------------------------------------------------------------
bool tspkEnqueueRelay(unsigned char index, unsigned char status) {


+ 13
- 1
code/html/index.html View File

@ -1086,9 +1086,21 @@
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="tspkEnabled" tabindex="30" /></div>
</div>
<div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Clear cache</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="tspkClear" tabindex="31" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">
With every POST to thinkspeak.com only enqueued fields are sent.
If you select to clear the cache after every sending this will result in only those fields that have changed will be posted.
If you want all fields to be sent with every POST do not clear the cache.
</div>
</div>
<div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Thingspeak API Key</label>
<input class="pure-u-1 pure-u-lg-3-4" name="tspkKey" type="text" tabindex="31" />
<input class="pure-u-1 pure-u-lg-3-4" name="tspkKey" type="text" tabindex="32" />
</div>
<legend>Sensors &amp; actuators</legend>


Loading…
Cancel
Save