From 34c72859efec178ee69ac48e500970eb2f887d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Thu, 11 Jan 2018 12:06:58 +0100 Subject: [PATCH] Small changes --- code/espurna/config/arduino.h | 1 + code/espurna/config/general.h | 6 +++--- code/espurna/domoticz.ino | 4 ++++ code/espurna/mqtt.ino | 7 ++----- code/espurna/ntp.ino | 5 ++--- code/espurna/utils.ino | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/code/espurna/config/arduino.h b/code/espurna/config/arduino.h index 8d4a6c03..74d957df 100644 --- a/code/espurna/config/arduino.h +++ b/code/espurna/config/arduino.h @@ -93,6 +93,7 @@ //-------------------------------------------------------------------------------- //#define ANALOG_SUPPORT 1 +//#define BH1750_SUPPORT 1 //#define BMX280_SUPPORT 1 //#define DALLAS_SUPPORT 1 //#define DHT_SUPPORT 1 diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 8d27fc36..32a56b51 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -396,7 +396,7 @@ PROGMEM const char* const custom_reset_string[] = { // ----------------------------------------------------------------------------- #ifndef SPIFFS_SUPPORT -#define SPIFFS_SUPPORT 0 // Do not add support for SPIFFS by default +#define SPIFFS_SUPPORT 0 // Do not add support for SPIFFS by default #endif // ----------------------------------------------------------------------------- @@ -427,7 +427,7 @@ PROGMEM const char* const custom_reset_string[] = { #ifndef MQTT_USE_ASYNC -#define MQTT_USE_ASYNC 1 // Use AysncMQTTClient (1) or PubSubClient +#define MQTT_USE_ASYNC 1 // Use AysncMQTTClient (1) or PubSubClient (0) #endif // MQTT OVER SSL @@ -699,7 +699,7 @@ PROGMEM const char* const custom_reset_string[] = { #define NTP_UPDATE_INTERVAL 1800 // NTP check every 30 minutes // ----------------------------------------------------------------------------- -// FAUXMO +// ALEXA // ----------------------------------------------------------------------------- // This setting defines whether Alexa support should be built into the firmware diff --git a/code/espurna/domoticz.ino b/code/espurna/domoticz.ino index 37e8b2f5..2351dc8c 100644 --- a/code/espurna/domoticz.ino +++ b/code/espurna/domoticz.ino @@ -74,6 +74,8 @@ void _domoticzMqtt(unsigned int type, const char * topic, const char * payload) }; +#if WEB_SUPPORT + void _domoticzWebSocketOnSend(JsonObject& root) { root["dczVisible"] = 1; @@ -99,6 +101,8 @@ void _domoticzWebSocketOnSend(JsonObject& root) { } +#endif // WEB_SUPPORT + void _domoticzConfigure() { _dcz_enabled = getSetting("dczEnabled", DOMOTICZ_ENABLED).toInt() == 1; _domoticzMqttSubscribe(_dcz_enabled); diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index 5e98781c..5f2c7102 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -233,10 +233,6 @@ void _mqttWebSocketOnSend(JsonObject& root) { root["mqttUseJson"] = getSetting("mqttUseJson", MQTT_USE_JSON).toInt() == 1; } -void _mqttConfigure() { - if (getSetting("mqttClientID").length() == 0) delSetting("mqttClientID"); -} - #endif void _mqttCallback(unsigned int type, const char * topic, const char * payload) { @@ -483,6 +479,7 @@ void mqttConfigure() { _mqtt_qos = getSetting("mqttQoS", MQTT_QOS).toInt(); _mqtt_retain = getSetting("mqttRetain", MQTT_RETAIN).toInt() == 1; _mqtt_keepalive = getSetting("mqttKeep", MQTT_KEEPALIVE).toInt(); + if (getSetting("mqttClientID").length() == 0) delSetting("mqttClientID"); // Enable if (getSetting("mqttServer", MQTT_SERVER).length() == 0) { @@ -565,7 +562,7 @@ void mqttSetup() { #if WEB_SUPPORT wsOnSendRegister(_mqttWebSocketOnSend); - wsOnAfterParseRegister(_mqttConfigure); + wsOnAfterParseRegister(mqttConfigure); #endif } diff --git a/code/espurna/ntp.ino b/code/espurna/ntp.ino index d387e4ac..97d7d39c 100644 --- a/code/espurna/ntp.ino +++ b/code/espurna/ntp.ino @@ -13,7 +13,6 @@ Copyright (C) 2016-2018 by Xose PĂ©rez #include #include -WiFiEventHandler _ntp_wifi_onSTA; Ticker _ntp_delay; // ----------------------------------------------------------------------------- @@ -86,8 +85,8 @@ void ntpSetup() { } }); - _ntp_wifi_onSTA = WiFi.onStationModeGotIP([](WiFiEventStationModeGotIP ipInfo) { - _ntpConfigure(); + wifiRegister([](justwifi_messages_t code, char * parameter) { + if (code == MESSAGE_CONNECTED) _ntpConfigure(); }); #if WEB_SUPPORT diff --git a/code/espurna/utils.ino b/code/espurna/utils.ino index 1aca5b6d..cb1ebcd5 100644 --- a/code/espurna/utils.ino +++ b/code/espurna/utils.ino @@ -11,7 +11,7 @@ Ticker _defer_reset; String getIdentifier() { char buffer[20]; - snprintf_P(buffer, sizeof(buffer), PSTR("ESPURNA_%06X"), ESP.getChipId()); + snprintf_P(buffer, sizeof(buffer), PSTR("%s_%06X"), APP_NAME, ESP.getChipId()); return String(buffer); }