From e0723f6998bf9a8342a6f810691fba229da8d671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Mon, 8 Jan 2018 21:42:12 +0100 Subject: [PATCH] Send Thingspeak API key to web UI --- code/espurna/mqtt.ino | 8 ++++---- code/espurna/thinkspeak.ino | 37 ++++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index 03174bff..24a74021 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -549,8 +549,10 @@ void mqttSetBrokerIfNone(IPAddress ip, unsigned int port) { void mqttSetup() { - DEBUG_MSG_P(PSTR("[MQTT] MQTT_USE_ASYNC = %d\n"), MQTT_USE_ASYNC); - DEBUG_MSG_P(PSTR("[MQTT] MQTT_AUTOCONNECT = %d\n"), MQTT_AUTOCONNECT); + DEBUG_MSG_P(PSTR("[MQTT] Async %s, Autoconnect %s\n"), + MQTT_USE_ASYNC ? "ENABLED" : "DISABLED", + MQTT_AUTOCONNECT ? "ENABLED" : "DISABLED" + ); #if MQTT_USE_ASYNC @@ -592,8 +594,6 @@ void mqttSetup() { #else // not MQTT_USE_ASYNC - DEBUG_MSG_P(PSTR("[MQTT] Using SYNC MQTT library\n")); - _mqtt.setCallback([](char* topic, byte* payload, unsigned int length) { _mqttOnMessage(topic, (char *) payload, length); }); diff --git a/code/espurna/thinkspeak.ino b/code/espurna/thinkspeak.ino index 6a62ea95..c2cbea72 100644 --- a/code/espurna/thinkspeak.ino +++ b/code/espurna/thinkspeak.ino @@ -9,15 +9,15 @@ Copyright (C) 2018 by Xose PĂ©rez #if THINGSPEAK_SUPPORT #if THINGSPEAK_USE_ASYNC - #include - AsyncClient _tspk_client; +#include +AsyncClient _tspk_client; #else - #include - #if THINGSPEAK_USE_SSL - WiFiClientSecure _tspk_client; - #else - WiFiClient _tspk_client; - #endif +#include +#if THINGSPEAK_USE_SSL +WiFiClientSecure _tspk_client; +#else +WiFiClient _tspk_client; +#endif #endif const char THINGSPEAK_REQUEST_TEMPLATE[] PROGMEM = @@ -41,6 +41,7 @@ void _tspkWebSocketOnSend(JsonObject& root) { root["tspkVisible"] = 1; root["tspkEnabled"] = getSetting("tspkEnabled", THINGSPEAK_ENABLED).toInt() == 1; + root["tspkKey"] = getSetting("tspkKey"); JsonArray& relays = root.createNestedArray("tspkRelays"); for (byte i=0; i