mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
Update formatting
This commit is contained in:
parent
9162ee122b
commit
e10a3af21c
@ -57,9 +57,9 @@ lib_ignore =
|
|||||||
|
|
||||||
build_flags =
|
build_flags =
|
||||||
;-Os ; Code Size Optimization
|
;-Os ; Code Size Optimization
|
||||||
-Og ; Code Debug Optimization
|
-Og ; Code Debug Optimization
|
||||||
;-w ; Suppress warnings
|
;-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
|
-I include ; include lv_conf.h and hasp_conf.h
|
||||||
; -- littlevgl build options ------------------------------
|
; -- littlevgl build options ------------------------------
|
||||||
-D LV_CONF_INCLUDE_SIMPLE
|
-D LV_CONF_INCLUDE_SIMPLE
|
||||||
|
@ -27,12 +27,12 @@ enum {
|
|||||||
|
|
||||||
TAG_FWUP = 50,
|
TAG_FWUP = 50,
|
||||||
|
|
||||||
TAG_ETH = 60,
|
TAG_ETH = 60,
|
||||||
TAG_WIFI = 61,
|
TAG_WIFI = 61,
|
||||||
TAG_HTTP = 62,
|
TAG_HTTP = 62,
|
||||||
TAG_OTA = 63,
|
TAG_OTA = 63,
|
||||||
TAG_MDNS = 64,
|
TAG_MDNS = 64,
|
||||||
TAG_MQTT = 65,
|
TAG_MQTT = 65,
|
||||||
TAG_MQTT_PUB = 66,
|
TAG_MQTT_PUB = 66,
|
||||||
TAG_MQTT_RCV = 67,
|
TAG_MQTT_RCV = 67,
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ enum {
|
|||||||
TAG_FONT = 92
|
TAG_FONT = 92
|
||||||
};
|
};
|
||||||
|
|
||||||
String debugHaspHeader(void);
|
void debugHaspHeader(Print * output);
|
||||||
|
|
||||||
void debugPreSetup(JsonObject settings);
|
void debugPreSetup(JsonObject settings);
|
||||||
void debugSetup();
|
void debugSetup();
|
||||||
|
@ -54,7 +54,7 @@ void dispatchGpioOutput(int output, bool state)
|
|||||||
int pin = 0;
|
int pin = 0;
|
||||||
|
|
||||||
if(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)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
ledcWrite(99, state ? 1023 : 0); // ledChannel and value
|
ledcWrite(99, state ? 1023 : 0); // ledChannel and value
|
||||||
@ -89,7 +89,7 @@ void dispatchParseJson(char * payload)
|
|||||||
// haspCommands.shrinkToFit();
|
// haspCommands.shrinkToFit();
|
||||||
|
|
||||||
if(jsonError) { // Couldn't parse incoming JSON command
|
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 {
|
} else {
|
||||||
|
|
||||||
JsonArray arr = haspCommands.as<JsonArray>();
|
JsonArray arr = haspCommands.as<JsonArray>();
|
||||||
@ -201,10 +201,12 @@ void dispatchCommand(const char * topic, const char * payload)
|
|||||||
} else if(topic == strstr_P(topic, PSTR("p["))) {
|
} else if(topic == strstr_P(topic, PSTR("p["))) {
|
||||||
dispatch_process_button_attribute(topic, payload);
|
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)) {
|
} else if(!strcmp_P(topic, F_CONFIG_SSID) || !strcmp_P(topic, F_CONFIG_PASS)) {
|
||||||
DynamicJsonDocument settings(45);
|
DynamicJsonDocument settings(45);
|
||||||
settings[topic] = payload;
|
settings[topic] = payload;
|
||||||
wifiSetConfig(settings.as<JsonObject>());
|
wifiSetConfig(settings.as<JsonObject>());
|
||||||
|
#endif
|
||||||
|
|
||||||
} else if(!strcmp_P(topic, PSTR("mqtthost")) || !strcmp_P(topic, PSTR("mqttport")) ||
|
} else if(!strcmp_P(topic, PSTR("mqtthost")) || !strcmp_P(topic, PSTR("mqttport")) ||
|
||||||
!strcmp_P(topic, PSTR("mqttuser")) || !strcmp_P(topic, PSTR("mqttpass"))) {
|
!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) {
|
if(strlen(payload) == 0) {
|
||||||
// dispatchTextLine(topic); // Could cause an infinite loop!
|
// 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)
|
void dispatch_output_idle_state(const char * state)
|
||||||
{
|
{
|
||||||
#if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE)
|
#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
|
#else
|
||||||
|
|
||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
@ -398,8 +400,8 @@ void dispatchReboot(bool saveConfig)
|
|||||||
#if HASP_USE_WIFI > 0
|
#if HASP_USE_WIFI > 0
|
||||||
wifiStop();
|
wifiStop();
|
||||||
#endif
|
#endif
|
||||||
Log.verbose(TAG_MSGR,F("-------------------------------------"));
|
Log.verbose(TAG_MSGR, F("-------------------------------------"));
|
||||||
Log.notice(TAG_MSGR,F("STOP: Properly Rebooting the MCU now!"));
|
Log.notice(TAG_MSGR, F("STOP: Properly Rebooting the MCU now!"));
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
halRestart();
|
halRestart();
|
||||||
}
|
}
|
||||||
@ -407,7 +409,7 @@ void dispatchReboot(bool saveConfig)
|
|||||||
void dispatch_button(uint8_t id, const char * event)
|
void dispatch_button(uint8_t id, const char * event)
|
||||||
{
|
{
|
||||||
#if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE)
|
#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
|
#else
|
||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
mqtt_send_input(id, event);
|
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
|
// send out value
|
||||||
#if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE)
|
#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
|
#else
|
||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
// mqtt_send_input(id, event);
|
// 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)
|
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)
|
#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
|
#else
|
||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
mqtt_send_obj_attribute_str(pageid, btnid, attribute, data);
|
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)
|
void dispatchWebUpdate(const char * espOtaUrl)
|
||||||
{
|
{
|
||||||
#if HASP_USE_OTA > 0
|
#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);
|
otaHttpUpdate(espOtaUrl);
|
||||||
#endif
|
#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)
|
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)
|
#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
|
#else
|
||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
mqtt_send_obj_attribute_str(pageid, btnid, attribute, data);
|
mqtt_send_obj_attribute_str(pageid, btnid, attribute, data);
|
||||||
@ -556,7 +558,7 @@ void dispatchConfig(const char * topic, const char * payload)
|
|||||||
} else {
|
} else {
|
||||||
DeserializationError jsonError = deserializeJson(doc, payload);
|
DeserializationError jsonError = deserializeJson(doc, payload);
|
||||||
if(jsonError) { // Couldn't parse incoming JSON command
|
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;
|
return;
|
||||||
}
|
}
|
||||||
settings = doc.as<JsonObject>();
|
settings = doc.as<JsonObject>();
|
||||||
@ -626,7 +628,7 @@ void dispatchConfig(const char * topic, const char * payload)
|
|||||||
settings.remove(F("pass")); // hide password in output
|
settings.remove(F("pass")); // hide password in output
|
||||||
size_t size = serializeJson(doc, buffer, sizeof(buffer));
|
size_t size = serializeJson(doc, buffer, sizeof(buffer));
|
||||||
#if !defined(HASP_USE_MQTT) && !defined(HASP_USE_TASMOTA_SLAVE)
|
#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
|
#else
|
||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
mqtt_send_state(F("config"), buffer);
|
mqtt_send_state(F("config"), buffer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user