Add check HASP_USE_* > 0

This commit is contained in:
fvanroie 2020-05-07 00:35:49 +02:00
parent e974bd7f03
commit 34ca47d104
8 changed files with 46 additions and 46 deletions

View File

@ -19,7 +19,7 @@ extern "C" {
* INCLUDES * INCLUDES
*********************/ *********************/
#if HASP_USE_APP #if HASP_USE_APP>0
/********************* /*********************
* DEFINES * DEFINES

View File

@ -199,7 +199,7 @@ void configWriteConfig()
bool writefile = false; bool writefile = false;
bool changed = false; bool changed = false;
#if HASP_USE_WIFI #if HASP_USE_WIFI>0
if(settings[F("wifi")].as<JsonObject>().isNull()) settings.createNestedObject(F("wifi")); if(settings[F("wifi")].as<JsonObject>().isNull()) settings.createNestedObject(F("wifi"));
changed = wifiGetConfig(settings[F("wifi")]); changed = wifiGetConfig(settings[F("wifi")]);
if(changed) { if(changed) {
@ -207,7 +207,7 @@ void configWriteConfig()
writefile = true; writefile = true;
} }
#endif #endif
#if HASP_USE_MQTT #if HASP_USE_MQTT>0
if(settings[F("mqtt")].as<JsonObject>().isNull()) settings.createNestedObject(F("mqtt")); if(settings[F("mqtt")].as<JsonObject>().isNull()) settings.createNestedObject(F("mqtt"));
changed = mqttGetConfig(settings[F("mqtt")]); changed = mqttGetConfig(settings[F("mqtt")]);
if(changed) { if(changed) {
@ -216,7 +216,7 @@ void configWriteConfig()
writefile = true; writefile = true;
} }
#endif #endif
#if HASP_USE_TELNET #if HASP_USE_TELNET>0
if(settings[F("telnet")].as<JsonObject>().isNull()) settings.createNestedObject(F("telnet")); if(settings[F("telnet")].as<JsonObject>().isNull()) settings.createNestedObject(F("telnet"));
changed = telnetGetConfig(settings[F("telnet")]); changed = telnetGetConfig(settings[F("telnet")]);
if(changed) { if(changed) {
@ -225,7 +225,7 @@ void configWriteConfig()
writefile = true; writefile = true;
} }
#endif #endif
#if HASP_USE_MDNS #if HASP_USE_MDNS>0
if(settings[F("mdns")].as<JsonObject>().isNull()) settings.createNestedObject(F("mdns")); if(settings[F("mdns")].as<JsonObject>().isNull()) settings.createNestedObject(F("mdns"));
changed = mdnsGetConfig(settings[F("mdns")]); changed = mdnsGetConfig(settings[F("mdns")]);
if(changed) { if(changed) {
@ -233,7 +233,7 @@ void configWriteConfig()
writefile = true; writefile = true;
} }
#endif #endif
#if HASP_USE_HTTP #if HASP_USE_HTTP>0
if(settings[F("http")].as<JsonObject>().isNull()) settings.createNestedObject(F("http")); if(settings[F("http")].as<JsonObject>().isNull()) settings.createNestedObject(F("http"));
changed = httpGetConfig(settings[F("http")]); changed = httpGetConfig(settings[F("http")]);
if(changed) { if(changed) {
@ -348,23 +348,23 @@ void configSetup()
haspSetConfig(settings[F("hasp")]); haspSetConfig(settings[F("hasp")]);
// otaGetConfig(settings[F("ota")]); // otaGetConfig(settings[F("ota")]);
#if HASP_USE_WIFI #if HASP_USE_WIFI>0
Log.verbose(F("Loading WiFi settings")); Log.verbose(F("Loading WiFi settings"));
wifiSetConfig(settings[F("wifi")]); wifiSetConfig(settings[F("wifi")]);
#endif #endif
#if HASP_USE_MQTT #if HASP_USE_MQTT>0
Log.verbose(F("Loading MQTT settings")); Log.verbose(F("Loading MQTT settings"));
mqttSetConfig(settings[F("mqtt")]); mqttSetConfig(settings[F("mqtt")]);
#endif #endif
#if HASP_USE_TELNET #if HASP_USE_TELNET>0
Log.verbose(F("Loading Telnet settings")); Log.verbose(F("Loading Telnet settings"));
telnetSetConfig(settings[F("telnet")]); telnetSetConfig(settings[F("telnet")]);
#endif #endif
#if HASP_USE_MDNS #if HASP_USE_MDNS>0
Log.verbose(F("Loading MDNS settings")); Log.verbose(F("Loading MDNS settings"));
mdnsSetConfig(settings[F("mdns")]); mdnsSetConfig(settings[F("mdns")]);
#endif #endif
#if HASP_USE_HTTP #if HASP_USE_HTTP>0
Log.verbose(F("Loading HTTP settings")); Log.verbose(F("Loading HTTP settings"));
httpSetConfig(settings[F("http")]); httpSetConfig(settings[F("http")]);
#endif #endif

View File

@ -31,11 +31,11 @@
#define SERIAL_SPEED 115200 #define SERIAL_SPEED 115200
#endif #endif
#if HASP_USE_TELNET != 0 #if HASP_USE_TELNET > 0
#include "hasp_telnet.h" #include "hasp_telnet.h"
#endif #endif
#if HASP_USE_SYSLOG != 0 #if HASP_USE_SYSLOG > 0
#include "Syslog.h" #include "Syslog.h"
#ifndef SYSLOG_SERVER #ifndef SYSLOG_SERVER
@ -122,7 +122,7 @@ void debugStart()
// log/logf method) // log/logf method)
} }
#if HASP_USE_SYSLOG != 0 #if HASP_USE_SYSLOG > 0
void syslogSend(uint8_t priority, const char * debugText) void syslogSend(uint8_t priority, const char * debugText)
{ {
if(strlen(debugSyslogHost) != 0 && WiFi.isConnected()) { if(strlen(debugSyslogHost) != 0 && WiFi.isConnected()) {
@ -133,7 +133,7 @@ void syslogSend(uint8_t priority, const char * debugText)
void debugSetup() void debugSetup()
{ {
#if HASP_USE_SYSLOG != 0 #if HASP_USE_SYSLOG > 0
syslog = new Syslog(syslogClient, debugSyslogProtocol == 0 ? SYSLOG_PROTO_IETF : SYSLOG_PROTO_BSD); syslog = new Syslog(syslogClient, debugSyslogProtocol == 0 ? SYSLOG_PROTO_IETF : SYSLOG_PROTO_BSD);
syslog->server(debugSyslogHost, debugSyslogPort); syslog->server(debugSyslogHost, debugSyslogPort);
syslog->deviceHostname(mqttNodeName); syslog->deviceHostname(mqttNodeName);
@ -158,7 +158,7 @@ bool debugGetConfig(const JsonObject & settings)
if(debugTelePeriod != settings[FPSTR(F_DEBUG_TELEPERIOD)].as<uint16_t>()) changed = true; if(debugTelePeriod != settings[FPSTR(F_DEBUG_TELEPERIOD)].as<uint16_t>()) changed = true;
settings[FPSTR(F_DEBUG_TELEPERIOD)] = debugTelePeriod; settings[FPSTR(F_DEBUG_TELEPERIOD)] = debugTelePeriod;
#if HASP_USE_SYSLOG != 0 #if HASP_USE_SYSLOG > 0
if(strcmp(debugSyslogHost, settings[FPSTR(F_CONFIG_HOST)].as<String>().c_str()) != 0) changed = true; if(strcmp(debugSyslogHost, settings[FPSTR(F_CONFIG_HOST)].as<String>().c_str()) != 0) changed = true;
settings[FPSTR(F_CONFIG_HOST)] = debugSyslogHost; settings[FPSTR(F_CONFIG_HOST)] = debugSyslogHost;
@ -196,7 +196,7 @@ bool debugSetConfig(const JsonObject & settings)
changed |= configSet(debugTelePeriod, settings[FPSTR(F_DEBUG_TELEPERIOD)], PSTR("debugTelePeriod")); changed |= configSet(debugTelePeriod, settings[FPSTR(F_DEBUG_TELEPERIOD)], PSTR("debugTelePeriod"));
/* Syslog Settings*/ /* Syslog Settings*/
#if HASP_USE_SYSLOG != 0 #if HASP_USE_SYSLOG > 0
if(!settings[FPSTR(F_CONFIG_HOST)].isNull()) { if(!settings[FPSTR(F_CONFIG_HOST)].isNull()) {
changed |= strcmp(debugSyslogHost, settings[FPSTR(F_CONFIG_HOST)]) != 0; changed |= strcmp(debugSyslogHost, settings[FPSTR(F_CONFIG_HOST)]) != 0;
strncpy(debugSyslogHost, settings[FPSTR(F_CONFIG_HOST)], sizeof(debugSyslogHost)); strncpy(debugSyslogHost, settings[FPSTR(F_CONFIG_HOST)], sizeof(debugSyslogHost));

View File

@ -38,7 +38,7 @@ void dispatchLoop()
void dispatchStatusUpdate() void dispatchStatusUpdate()
{ {
#if HASP_USE_MQTT #if HASP_USE_MQTT>0
mqtt_send_statusupdate(); mqtt_send_statusupdate();
#endif #endif
} }
@ -308,7 +308,7 @@ void dispatch_button(uint8_t id, const char * event)
#else #else
Log.notice(F("OUT: input%d = %s"), id, event); Log.notice(F("OUT: input%d = %s"), id, event);
#endif #endif
#if HASP_USE_TASMOTA_SLAVE #if HASP_USE_TASMOTA_SLAVE>0
slave_send_input(id, event); slave_send_input(id, event);
#endif #endif
} }

View File

@ -18,7 +18,7 @@
//#include "lv_ex_conf.h" //#include "lv_ex_conf.h"
//#include "tpcal.h" //#include "tpcal.h"
#if HASP_USE_PNGDECODE #if HASP_USE_PNGDECODE > 0
#include "png_decoder.h" #include "png_decoder.h"
#endif #endif
@ -26,7 +26,7 @@
#define TOUCH_DRIVER 0 #define TOUCH_DRIVER 0
#endif #endif
#if HASP_USE_SPIFFS #if HASP_USE_SPIFFS > 0
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
#include "SPIFFS.h" #include "SPIFFS.h"
#endif #endif
@ -664,7 +664,7 @@ void guiSetup()
#endif #endif
/* Initialize PNG decoder */ /* Initialize PNG decoder */
#if HASP_USE_PNGDECODE != 0 #if HASP_USE_PNGDECODE > 0
png_decoder_init(); png_decoder_init();
#endif #endif

View File

@ -13,10 +13,10 @@
#include "hasp_config.h" #include "hasp_config.h"
#include "hasp_conf.h" #include "hasp_conf.h"
#if HASP_USE_MQTT #if HASP_USE_MQTT>0
#include "hasp_mqtt.h" #include "hasp_mqtt.h"
#endif #endif
#if HASP_USE_MDNS #if HASP_USE_MDNS>0
#include "hasp_mdns.h" #include "hasp_mdns.h"
#endif #endif

View File

@ -10,11 +10,11 @@
#include "hasp_conf.h" #include "hasp_conf.h"
#if HASP_USE_MQTT #if HASP_USE_MQTT>0
#include "hasp_mqtt.h" #include "hasp_mqtt.h"
#endif #endif
#if HASP_USE_MDNS #if HASP_USE_MDNS>0
#include "hasp_mdns.h" #include "hasp_mdns.h"
#endif #endif

View File

@ -21,15 +21,15 @@ void setup()
***************************/ ***************************/
/* Init Storage */ /* Init Storage */
#if HASP_USE_EEPROM #if HASP_USE_EEPROM>0
eepromSetup(); // Don't start at boot, only at write eepromSetup(); // Don't start at boot, only at write
#endif #endif
#if HASP_USE_SPIFFS #if HASP_USE_SPIFFS>0
spiffsSetup(); spiffsSetup();
#endif #endif
#if HASP_USE_SDCARD #if HASP_USE_SDCARD>0
sdcardSetup(); sdcardSetup();
#endif #endif
@ -43,11 +43,11 @@ void setup()
***************************/ ***************************/
debugSetup(); debugSetup();
#if HASP_USE_GPIO #if HASP_USE_GPIO>0
gpioSetup(); gpioSetup();
#endif #endif
#if HASP_USE_WIFI #if HASP_USE_WIFI>0
wifiSetup(); wifiSetup();
#endif #endif
@ -55,11 +55,11 @@ void setup()
oobeSetup(); oobeSetup();
haspSetup(); haspSetup();
#if HASP_USE_MDNS #if HASP_USE_MDNS>0
mdnsSetup(); mdnsSetup();
#endif #endif
#if HASP_USE_OTA #if HASP_USE_OTA>0
otaSetup(); otaSetup();
#endif #endif
@ -67,11 +67,11 @@ void setup()
ethernetSetup(); ethernetSetup();
#endif #endif
#if HASP_USE_MQTT #if HASP_USE_MQTT>0
mqttSetup(); mqttSetup();
#endif #endif
#if HASP_USE_HTTP #if HASP_USE_HTTP>0
httpSetup(); httpSetup();
#endif #endif
@ -79,7 +79,7 @@ void setup()
telnetSetup(); telnetSetup();
#endif #endif
#if HASP_USE_TASMOTA_SLAVE #if HASP_USE_TASMOTA_SLAVE>0
slaveSetup(); slaveSetup();
#endif #endif
@ -90,15 +90,15 @@ void loop()
{ {
/* Storage Loops */ /* Storage Loops */
/* /*
#if HASP_USE_EEPROM #if HASP_USE_EEPROM>0
// eepromLoop(); // Not used // eepromLoop(); // Not used
#endif #endif
#if HASP_USE_SPIFFS #if HASP_USE_SPIFFS>0
// spiffsLoop(); // Not used // spiffsLoop(); // Not used
#endif #endif
#if HASP_USE_SDCARD #if HASP_USE_SDCARD>0
// sdcardLoop(); // Not used // sdcardLoop(); // Not used
#endif #endif
@ -112,7 +112,7 @@ void loop()
// haspLoop(); // haspLoop();
debugLoop(); debugLoop();
#if HASP_USE_GPIO #if HASP_USE_GPIO>0
gpioLoop(); gpioLoop();
#endif #endif
@ -121,19 +121,19 @@ void loop()
ethernetLoop(); ethernetLoop();
#endif #endif
#if HASP_USE_MQTT #if HASP_USE_MQTT>0
mqttLoop(); mqttLoop();
#endif // MQTT #endif // MQTT
#if HASP_USE_HTTP #if HASP_USE_HTTP>0
httpLoop(); httpLoop();
#endif // HTTP #endif // HTTP
#if HASP_USE_MDNS #if HASP_USE_MDNS>0
mdnsLoop(); mdnsLoop();
#endif // MDNS #endif // MDNS
#if HASP_USE_OTA #if HASP_USE_OTA>0
otaLoop(); otaLoop();
#endif // OTA #endif // OTA
@ -141,7 +141,7 @@ void loop()
telnetLoop(); telnetLoop();
#endif // TELNET #endif // TELNET
#if HASP_USE_TASMOTA_SLAVE #if HASP_USE_TASMOTA_SLAVE>0
slaveLoop(); slaveLoop();
#endif // TASMOTASLAVE #endif // TASMOTASLAVE
@ -150,7 +150,7 @@ void loop()
/* Timer Loop */ /* Timer Loop */
if(millis() - mainLastLoopTime >= 1000) { if(millis() - mainLastLoopTime >= 1000) {
/* Run Every Second */ /* Run Every Second */
#if HASP_USE_OTA #if HASP_USE_OTA>0
otaEverySecond(); otaEverySecond();
#endif #endif
debugEverySecond(); debugEverySecond();