diff --git a/platformio.ini b/platformio.ini index 0d5ebb32..8ea76a4a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -57,9 +57,9 @@ lib_ignore = build_flags = ;-Os ; Code Size Optimization - -Og ; Code Debug Optimization + -Og ; Code Debug Optimization ;-w ; Suppress warnings - -D CORE_DEBUG_LEVEL=1 ; Errors + -D CORE_DEBUG_LEVEL=1 ; 0=Silent, 1=Errors -I include ; include lv_conf.h and hasp_conf.h ; -- littlevgl build options ------------------------------ -D LV_CONF_INCLUDE_SIMPLE diff --git a/src/hasp_debug.h b/src/hasp_debug.h index 622d61fd..ff2d473d 100644 --- a/src/hasp_debug.h +++ b/src/hasp_debug.h @@ -27,12 +27,12 @@ enum { TAG_FWUP = 50, - TAG_ETH = 60, - TAG_WIFI = 61, - TAG_HTTP = 62, - TAG_OTA = 63, - TAG_MDNS = 64, - TAG_MQTT = 65, + TAG_ETH = 60, + TAG_WIFI = 61, + TAG_HTTP = 62, + TAG_OTA = 63, + TAG_MDNS = 64, + TAG_MQTT = 65, TAG_MQTT_PUB = 66, TAG_MQTT_RCV = 67, @@ -41,7 +41,7 @@ enum { TAG_FONT = 92 }; -String debugHaspHeader(void); +void debugHaspHeader(Print * output); void debugPreSetup(JsonObject settings); void debugSetup(); diff --git a/src/hasp_dispatch.cpp b/src/hasp_dispatch.cpp index d7cd1351..e8055e14 100644 --- a/src/hasp_dispatch.cpp +++ b/src/hasp_dispatch.cpp @@ -54,7 +54,7 @@ void dispatchGpioOutput(int output, bool state) int pin = 0; if(pin >= 0) { - Log.notice(TAG_MSGR,F("PIN OUTPUT STATE %d"), state); + Log.notice(TAG_MSGR, F("PIN OUTPUT STATE %d"), state); #if defined(ARDUINO_ARCH_ESP32) ledcWrite(99, state ? 1023 : 0); // ledChannel and value @@ -89,7 +89,7 @@ void dispatchParseJson(char * payload) // haspCommands.shrinkToFit(); if(jsonError) { // Couldn't parse incoming JSON command - Log.warning(TAG_MSGR,F("JSON: Failed to parse incoming JSON command with error: %s"), jsonError.c_str()); + Log.warning(TAG_MSGR, F("JSON: Failed to parse incoming JSON command with error: %s"), jsonError.c_str()); } else { JsonArray arr = haspCommands.as(); @@ -201,10 +201,12 @@ void dispatchCommand(const char * topic, const char * payload) } else if(topic == strstr_P(topic, PSTR("p["))) { dispatch_process_button_attribute(topic, payload); +#if HASP_USE_WIFI > 0 } else if(!strcmp_P(topic, F_CONFIG_SSID) || !strcmp_P(topic, F_CONFIG_PASS)) { DynamicJsonDocument settings(45); settings[topic] = payload; wifiSetConfig(settings.as()); +#endif } else if(!strcmp_P(topic, PSTR("mqtthost")) || !strcmp_P(topic, PSTR("mqttport")) || !strcmp_P(topic, PSTR("mqttuser")) || !strcmp_P(topic, PSTR("mqttpass"))) { @@ -219,7 +221,7 @@ void dispatchCommand(const char * topic, const char * payload) if(strlen(payload) == 0) { // dispatchTextLine(topic); // Could cause an infinite loop! } - Log.warning(TAG_MSGR,F(LOG_CMND_CTR "Command not found %s => %s"), topic, payload); + Log.warning(TAG_MSGR, F(LOG_CMND_CTR "Command not found %s => %s"), topic, payload); } } @@ -373,7 +375,7 @@ void dispatchTextLine(const char * cmnd) void dispatch_output_idle_state(const char * state) { #if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE) - Log.notice(TAG_MSGR,F("idle = %s"), state); + Log.notice(TAG_MSGR, F("idle = %s"), state); #else #if HASP_USE_MQTT > 0 @@ -398,8 +400,8 @@ void dispatchReboot(bool saveConfig) #if HASP_USE_WIFI > 0 wifiStop(); #endif - Log.verbose(TAG_MSGR,F("-------------------------------------")); - Log.notice(TAG_MSGR,F("STOP: Properly Rebooting the MCU now!")); + Log.verbose(TAG_MSGR, F("-------------------------------------")); + Log.notice(TAG_MSGR, F("STOP: Properly Rebooting the MCU now!")); Serial.flush(); halRestart(); } @@ -407,7 +409,7 @@ void dispatchReboot(bool saveConfig) void dispatch_button(uint8_t id, const char * event) { #if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE) - Log.notice(TAG_MSGR,F("input%d = %s"), id, event); + Log.notice(TAG_MSGR, F("input%d = %s"), id, event); #else #if HASP_USE_MQTT > 0 mqtt_send_input(id, event); @@ -477,7 +479,7 @@ void dispatch_send_group_event(uint8_t groupid, uint8_t eventid, bool update_has // send out value #if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE) - Log.notice(TAG_MSGR,F("group%d = %s"), groupid, eventid); + Log.notice(TAG_MSGR, F("group%d = %s"), groupid, eventid); #else #if HASP_USE_MQTT > 0 // mqtt_send_input(id, event); @@ -494,7 +496,7 @@ void dispatch_send_group_event(uint8_t groupid, uint8_t eventid, bool update_has void IRAM_ATTR dispatch_send_obj_attribute_str(uint8_t pageid, uint8_t btnid, const char * attribute, const char * data) { #if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE) - Log.notice(TAG_MSGR,F("json = {\"p[%u].b[%u].%s\":\"%s\"}"), pageid, btnid, attribute, data); + Log.notice(TAG_MSGR, F("json = {\"p[%u].b[%u].%s\":\"%s\"}"), pageid, btnid, attribute, data); #else #if HASP_USE_MQTT > 0 mqtt_send_obj_attribute_str(pageid, btnid, attribute, data); @@ -520,7 +522,7 @@ void dispatch_send_object_event(uint8_t pageid, uint8_t objid, uint8_t eventid) void dispatchWebUpdate(const char * espOtaUrl) { #if HASP_USE_OTA > 0 - Log.verbose(TAG_MSGR,F("Checking for updates at URL: %s"), espOtaUrl); + Log.verbose(TAG_MSGR, F("Checking for updates at URL: %s"), espOtaUrl); otaHttpUpdate(espOtaUrl); #endif } @@ -529,7 +531,7 @@ void dispatchWebUpdate(const char * espOtaUrl) void IRAM_ATTR dispatch_obj_attribute_str(uint8_t pageid, uint8_t btnid, const char * attribute, const char * data) { #if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE) - Log.notice(TAG_MSGR,F("json = {\"p[%u].b[%u].%s\":\"%s\"}"), pageid, btnid, attribute, data); + Log.notice(TAG_MSGR, F("json = {\"p[%u].b[%u].%s\":\"%s\"}"), pageid, btnid, attribute, data); #else #if HASP_USE_MQTT > 0 mqtt_send_obj_attribute_str(pageid, btnid, attribute, data); @@ -556,7 +558,7 @@ void dispatchConfig(const char * topic, const char * payload) } else { DeserializationError jsonError = deserializeJson(doc, payload); if(jsonError) { // Couldn't parse incoming JSON command - Log.warning(TAG_MSGR,F("JSON: Failed to parse incoming JSON command with error: %s"), jsonError.c_str()); + Log.warning(TAG_MSGR, F("JSON: Failed to parse incoming JSON command with error: %s"), jsonError.c_str()); return; } settings = doc.as(); @@ -626,7 +628,7 @@ void dispatchConfig(const char * topic, const char * payload) settings.remove(F("pass")); // hide password in output size_t size = serializeJson(doc, buffer, sizeof(buffer)); #if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE) - Log.notice(TAG_MSGR,F("config %s = %s"), topic, buffer); + Log.notice(TAG_MSGR, F("config %s = %s"), topic, buffer); #else #if HASP_USE_MQTT > 0 mqtt_send_state(F("config"), buffer);