diff --git a/include/lv_conf_v7.h b/include/lv_conf_v7.h index e2adf67e..764be7bd 100644 --- a/include/lv_conf_v7.h +++ b/include/lv_conf_v7.h @@ -80,8 +80,10 @@ typedef int16_t lv_coord_t; #define LV_FS_SEEK(x, y) lv_fs_seek(x, y) #define _lv_img_decoder_t _lv_img_decoder +#ifndef LV_MEM_CUSTOM /* 1: use custom malloc/free, 0: use the built-in `lv_mem_alloc` and `lv_mem_free` */ #define LV_MEM_CUSTOM 0 +#endif #if LV_MEM_CUSTOM == 0 /* Size of the memory used by `lv_mem_alloc` in bytes (>= 2kB)*/ diff --git a/include/lv_conf_v8.h b/include/lv_conf_v8.h index 4cb1442c..494982d7 100644 --- a/include/lv_conf_v8.h +++ b/include/lv_conf_v8.h @@ -86,8 +86,10 @@ typedef int16_t lv_coord_t; /* LittelvGL's internal memory manager's settings. * The graphical objects and other related data are stored here. */ +#ifndef LV_MEM_CUSTOM /* 1: use custom malloc/free, 0: use the built-in `lv_mem_alloc` and `lv_mem_free` */ #define LV_MEM_CUSTOM 0 +#endif #if LV_MEM_CUSTOM == 0 /* Size of the memory used by `lv_mem_alloc` in bytes (>= 2kB)*/ //# define LV_MEM_SIZE (32U * 1024U) diff --git a/src/lang/de_DE.h b/src/lang/de_DE.h index 1aac4666..efd70477 100644 --- a/src/lang/de_DE.h +++ b/src/lang/de_DE.h @@ -93,7 +93,7 @@ #define D_ATTRIBUTE_UNKNOWN "Unbekannte Eigenschaft %s" // D_ATTRIBUTE_OBSOLETE D_ATTRIBUTE_INSTEAD can be used together or just D_ATTRIBUTE_OBSOLETE alone #define D_ATTRIBUTE_OBSOLETE "%s ist veraltet" -#define D_ATTRIBUTE_INSTEAD ", benutze stattdessen %s +#define D_ATTRIBUTE_INSTEAD ", benutze stattdessen %s" #define D_ATTRIBUTE_READ_ONLY "%s ist schreibgeschützt" #define D_ATTRIBUTE_PAGE_METHOD_INVALID "Unerlaubter Aufruf auf Seite %s" #define D_ATTRIBUTE_ALIGN_INVALID "Ungültige Ausrichtung: %s" @@ -187,7 +187,7 @@ #define D_INFO_CLIENTID "Client ID" // #define D_INFO_CONNECTED "Verbunden" // #define D_INFO_DISCONNECTED "Getrennt" -#define D_INFO_REECEIVED "Empfangen" +#define D_INFO_RECEIVED "Empfangen" #define D_INFO_PUBLISHED "Veröffentlicht" #define D_INFO_FAILED "Fehlerhaft" #define D_INFO_ETHERNET "Ethernet" diff --git a/src/mqtt/hasp_mqtt_esp.cpp b/src/mqtt/hasp_mqtt_esp.cpp index eac10380..453d3a33 100644 --- a/src/mqtt/hasp_mqtt_esp.cpp +++ b/src/mqtt/hasp_mqtt_esp.cpp @@ -320,6 +320,7 @@ static int mqttSubscribeTo(String topic) return err; } +/* String mqttGetTopic(Preferences preferences, String subtopic, String key, String value, bool add_slash) { String topic = preferences.getString(key.c_str(), value); @@ -334,6 +335,20 @@ String mqttGetTopic(Preferences preferences, String subtopic, String key, String } return topic; } +*/ + +void mqttParseTopic(String *topic, String subtopic, bool add_slash) +{ + + topic->replace(F("%hostname%"), haspDevice.get_hostname()); + topic->replace(F("%hwid%"), haspDevice.get_hardware_id()); + topic->replace(F("%topic%"), subtopic); + topic->replace(F("%prefix%"), MQTT_PREFIX); + + if(add_slash && !topic->endsWith("/")) { + *topic += "/"; + } +} void onMqttConnect(esp_mqtt_client_handle_t client) { @@ -521,23 +536,29 @@ void mqttStart() nvsOldGroup += "/%topic%"; subtopic = F(MQTT_TOPIC_COMMAND); - mqttNodeCommandTopic = - mqttGetTopic(preferences, subtopic, FP_CONFIG_NODE_TOPIC, MQTT_DEFAULT_NODE_TOPIC, false); - mqttGroupCommandTopic = mqttGetTopic(preferences, subtopic, FP_CONFIG_GROUP_TOPIC, nvsOldGroup.c_str(), false); + mqttNodeCommandTopic = preferences.getString(FP_CONFIG_NODE_TOPIC, MQTT_DEFAULT_NODE_TOPIC); + mqttParseTopic(&mqttNodeCommandTopic, subtopic, false); + mqttGroupCommandTopic = preferences.getString(FP_CONFIG_GROUP_TOPIC, nvsOldGroup.c_str()); + mqttParseTopic(&mqttGroupCommandTopic, subtopic, false); + #ifdef HASP_USE_BROADCAST - mqttBroadcastCommandTopic = - mqttGetTopic(preferences, subtopic, FP_CONFIG_BROADCAST_TOPIC, MQTT_DEFAULT_BROADCAST_TOPIC, false); + mqttBroadcastCommandTopic = preferences.getString(FP_CONFIG_BROADCAST_TOPIC, MQTT_DEFAULT_BROADCAST_TOPIC); + mqttParseTopic(&mqttBroadcastCommandTopic, subtopic, false); + #endif subtopic = F(MQTT_TOPIC_STATE); - mqttNodeStateTopic = mqttGetTopic(preferences, subtopic, FP_CONFIG_NODE_TOPIC, MQTT_DEFAULT_NODE_TOPIC, true); + mqttNodeStateTopic = preferences.getString(FP_CONFIG_NODE_TOPIC, MQTT_DEFAULT_NODE_TOPIC); + mqttParseTopic(&mqttNodeStateTopic, subtopic, true); subtopic = F(MQTT_TOPIC_LWT); - mqttNodeLwtTopic = mqttGetTopic(preferences, subtopic, FP_CONFIG_NODE_TOPIC, MQTT_DEFAULT_NODE_TOPIC, false); + mqttNodeLwtTopic = preferences.getString(FP_CONFIG_NODE_TOPIC, MQTT_DEFAULT_NODE_TOPIC); + mqttParseTopic(&mqttNodeLwtTopic, subtopic, false); LOG_WARNING(TAG_MQTT, mqttNodeLwtTopic.c_str()); subtopic = F(MQTT_TOPIC_LWT); - mqttHassLwtTopic = mqttGetTopic(preferences, subtopic, FP_CONFIG_HASS_TOPIC, MQTT_DEFAULT_HASS_TOPIC, false); + mqttHassLwtTopic = preferences.getString(FP_CONFIG_HASS_TOPIC, MQTT_DEFAULT_HASS_TOPIC); + mqttParseTopic(&mqttHassLwtTopic, subtopic, false); LOG_WARNING(TAG_MQTT, mqttNodeLwtTopic.c_str()); preferences.end();