From ed3ba7d55c975c6cb7e2f70adae18767f6d51f40 Mon Sep 17 00:00:00 2001 From: arovak Date: Mon, 5 Apr 2021 21:31:51 +0200 Subject: [PATCH 1/4] Add user_override_sample.h with example settings --- include/hasp_conf.h | 4 ++ src/lang/lang.h | 9 ++- src/lang/nl_NL.h | 5 +- src/log/hasp_debug.cpp | 6 +- src/mqtt/hasp_mqtt_pubsubclient.cpp | 6 +- src/sys/net/hasp_network.cpp | 6 +- src/sys/net/hasp_wifi.cpp | 6 +- src/sys/svc/hasp_http.cpp | 6 +- src/user_config_override_sample.h | 85 +++++++++++++++++++++++++++++ 9 files changed, 114 insertions(+), 19 deletions(-) create mode 100644 src/user_config_override_sample.h diff --git a/include/hasp_conf.h b/include/hasp_conf.h index 52d2e081..fe34ab5d 100644 --- a/include/hasp_conf.h +++ b/include/hasp_conf.h @@ -1,6 +1,10 @@ #ifndef HASP_CONF_H #define HASP_CONF_H +#ifdef USE_CONFIG_OVERRIDE +#include "user_config_override.h" +#endif + // language specific defines #include "lang/lang.h" diff --git a/src/lang/lang.h b/src/lang/lang.h index 1b40b78f..74b95923 100644 --- a/src/lang/lang.h +++ b/src/lang/lang.h @@ -1,7 +1,14 @@ #ifndef HASP_LANG_H #define HASP_LANG_H -#include "en_US.h" +#ifndef HASP_LANGUAGE + #include "en_US.h" +#else + #define QUOTEME(x) QUOTEME_1(x) + #define QUOTEME_1(x) #x + #define INCLUDE_FILE(x) QUOTEME(x.h) + #include INCLUDE_FILE(HASP_LANGUAGE) +#endif // language independent defines #define D_PASSWORD_MASK "********" diff --git a/src/lang/nl_NL.h b/src/lang/nl_NL.h index e2b26fc7..514b2029 100644 --- a/src/lang/nl_NL.h +++ b/src/lang/nl_NL.h @@ -6,7 +6,7 @@ #define D_SSID "Ssid:" #define D_ERROR_OUT_OF_MEMORY "Geen geheugen bechikbaar" -#define D_ERROR_UNKNOWN "Unbekende fout" +#define D_ERROR_UNKNOWN "Onbekende fout" #define D_CONFIG_NOT_CHANGED "Instellingen ongewijzigd" #define D_CONFIG_CHANGED "Instellingen gewijzigd" @@ -51,7 +51,6 @@ #define D_TELNET_CLOSING_CONNECTION "Sessie sluiten van %s" #define D_TELNET_CLIENT_LOGIN_FROM "Client aangemeld van %s" #define D_TELNET_CLIENT_CONNECT_FROM "Client verbonden van %s" -#define D_TELNET_CLIENT_NOT_CONNECTED "Client NIET vzebonden" #define D_TELNET_AUTHENTICATION_FAILED "Autorisatie mislukt!" #define D_TELNET_INCORRECT_LOGIN_ATTEMPT "Aanmelding van %s mislukt" #define D_TELNET_STARTED "Telnet console gestart" @@ -125,7 +124,7 @@ #define D_HTTP_REBOOT "Herstarten" #define D_HTTP_CONFIGURATION "Configuratie" -#define D_OOBE_MSB "Raak het scherm aan om WiFi in te stellen of meld je aan op AP:" +#define D_OOBE_MSG "Raak het scherm aan om WiFi in te stellen of meld je aan op AP:" #define D_OOBE_SCAN_TO_CONNECT "Scan code" #endif \ No newline at end of file diff --git a/src/log/hasp_debug.cpp b/src/log/hasp_debug.cpp index f30989fc..a2c7071f 100644 --- a/src/log/hasp_debug.cpp +++ b/src/log/hasp_debug.cpp @@ -39,9 +39,9 @@ #include "hasp/hasp_dispatch.h" #include "hasp/hasp.h" -#ifdef USE_CONFIG_OVERRIDE -#include "user_config_override.h" -#endif +// #ifdef USE_CONFIG_OVERRIDE +// #include "user_config_override.h" +// #endif #ifndef SERIAL_SPEED #define SERIAL_SPEED 115200 diff --git a/src/mqtt/hasp_mqtt_pubsubclient.cpp b/src/mqtt/hasp_mqtt_pubsubclient.cpp index fd681b42..791387de 100644 --- a/src/mqtt/hasp_mqtt_pubsubclient.cpp +++ b/src/mqtt/hasp_mqtt_pubsubclient.cpp @@ -42,9 +42,9 @@ EthernetClient mqttNetworkClient; #include "../hasp/hasp_dispatch.h" -#ifdef USE_CONFIG_OVERRIDE -#include "user_config_override.h" -#endif +// #ifdef USE_CONFIG_OVERRIDE +// #include "user_config_override.h" +// #endif char mqttNodeTopic[24]; char mqttGroupTopic[24]; diff --git a/src/sys/net/hasp_network.cpp b/src/sys/net/hasp_network.cpp index ba6dd8b0..1001a5d6 100644 --- a/src/sys/net/hasp_network.cpp +++ b/src/sys/net/hasp_network.cpp @@ -3,9 +3,9 @@ #include #include -#ifdef USE_CONFIG_OVERRIDE -#include "user_config_override.h" -#endif +// #ifdef USE_CONFIG_OVERRIDE +// #include "user_config_override.h" +// #endif #ifndef MYTZ #define MYTZ "EST5EDT,M3.2.0/2,M11.1.0" #endif diff --git a/src/sys/net/hasp_wifi.cpp b/src/sys/net/hasp_wifi.cpp index 5746a0a2..c5317871 100644 --- a/src/sys/net/hasp_wifi.cpp +++ b/src/sys/net/hasp_wifi.cpp @@ -34,9 +34,9 @@ SPIClass espSPI(ESPSPI_MOSI, ESPSPI_MISO, ESPSPI_SCLK); // SPI port where esp is #endif //#include "DNSserver.h" -#ifdef USE_CONFIG_OVERRIDE -#include "user_config_override.h" -#endif +// #ifdef USE_CONFIG_OVERRIDE +// #include "user_config_override.h" +// #endif #ifdef WIFI_SSID char wifiSsid[32] = WIFI_SSID; diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp index 37689bca..ca90ff14 100644 --- a/src/sys/svc/hasp_http.cpp +++ b/src/sys/svc/hasp_http.cpp @@ -26,9 +26,9 @@ #if HASP_USE_HTTP > 0 -#ifdef USE_CONFIG_OVERRIDE -#include "user_config_override.h" -#endif +// #ifdef USE_CONFIG_OVERRIDE +// #include "user_config_override.h" +// #endif //default theme #ifndef D_HTTP_COLOR_TEXT diff --git a/src/user_config_override_sample.h b/src/user_config_override_sample.h new file mode 100644 index 00000000..25429883 --- /dev/null +++ b/src/user_config_override_sample.h @@ -0,0 +1,85 @@ +#ifndef HASP_USER_CONFIG_OVERRIDE_H +#define HASP_USER_CONFIG_OVERRIDE_H +/*************************************************** + Setup WiFi Settings + **************************************************/ +// #define WIFI_SSID "" // WiFi SSID +// #define WIFI_PASSW "" // WiFi Password + +/*************************************************** + MQTT Settings + **************************************************/ +// #define MQTT_HOST "" // MQTT server Address +// #define MQTT_PORT 1883 // MQTT server Port +// #define MQTT_USER "" // Optional Username +// #define MQTT_PASSW "" // Optional Password +// #define MQTT_GROUPNAME "plates" // MQTT Group topic for all plates to listen on, default: plates +// #define MQTT_PREFIX "hasp" // Prefix for all MQTT topics, default: hasp + +/*************************************************** + SYSLOG Settings + **************************************************/ +// #define SYSLOG_SERVER "" // Syslog server Address +// #define SYSLOG_PORT 514 // Syslog server Port + +/*************************************************** + Timezone Settings + **************************************************/ +// #define MYTZ "CET-1CEST,M3.5.0,M10.5.0/3" // A full list with possible timezones can be found here https://gist.github.com/alwynallan/24d96091655391107939 + +/*************************************************** + Interface Language Settings + **************************************************/ +// #define HASP_LANGUAGE en_US // English +// #define HASP_LANGUAGE nl_NL // Dutch +// #define HASP_LANGUAGE hu_HU // Hungarian +// #define HASP_LANGUAGE ro_RO // Romanian + +/*************************************************** + Web Interface Templates + **************************************************/ +/* +//default theme +#define D_HTTP_COLOR_TEXT "#000" // Global text color - Black +#define D_HTTP_COLOR_BACKGROUND "#fff" // Global background color - White +#define D_HTTP_COLOR_INPUT_TEXT "#000" // Input text color - Black +#define D_HTTP_COLOR_INPUT "#fff" // Input background color - White +#define D_HTTP_COLOR_INPUT_WARNING "#f00" // Warning text color - Red +#define D_HTTP_COLOR_BUTTON_TEXT "#fff" // Button text color - White +#define D_HTTP_COLOR_BUTTON "#1fa3ec" // Button color - Vivid blue +#define D_HTTP_COLOR_BUTTON_RESET "#f00" // Restart/Reset/Delete button color - red +*/ +/* +// Dark theme +#define D_HTTP_COLOR_TEXT "#eaeaea" // Global text color - Very light gray +#define D_HTTP_COLOR_BACKGROUND "#252525" // Global background color - Very dark gray (mostly black) +#define D_HTTP_COLOR_INPUT_TEXT "#000" // Input text color - Black +#define D_HTTP_COLOR_INPUT "#ddd" // Input background color - Very light gray +#define D_HTTP_COLOR_INPUT_WARNING "#ff5661" // Warning text color - Brick Red +#define D_HTTP_COLOR_BUTTON_TEXT "#faffff" // Button text color - Very pale (mostly white) cyan +#define D_HTTP_COLOR_BUTTON "#1fa3ec" // Button color - Vivid blue +#define D_HTTP_COLOR_BUTTON_RESET "#d43535" // Restart/Reset/Delete button color - Strong red +*/ +/* +// Purple theme +#define D_HTTP_COLOR_TEXT "#eaeaea" +#define D_HTTP_COLOR_BACKGROUND "#252525" +#define D_HTTP_COLOR_INPUT_TEXT "#eaeaea" +#define D_HTTP_COLOR_INPUT "#282531" +#define D_HTTP_COLOR_INPUT_WARNING "#ff5661" +#define D_HTTP_COLOR_BUTTON_TEXT "#faffff" +#define D_HTTP_COLOR_BUTTON "#694fa8" +#define D_HTTP_COLOR_BUTTON_RESET "#b73d5d" +*/ +/* +// Green theme +#define D_HTTP_COLOR_TEXT "#edddd4" +#define D_HTTP_COLOR_BACKGROUND "#283d3b" +#define D_HTTP_COLOR_INPUT_TEXT "#edddd4" +#define D_HTTP_COLOR_INPUT "#197278" +#define D_HTTP_COLOR_INPUT_WARNING "#772e25" +#define D_HTTP_COLOR_BUTTON_TEXT "#edddd4" +#define D_HTTP_COLOR_BUTTON "#197278" +#define D_HTTP_COLOR_BUTTON_RESET "#c44536" +*/ +#endif \ No newline at end of file From c818ad86800626f28544cd467efb7087ed84c78f Mon Sep 17 00:00:00 2001 From: arovak Date: Mon, 5 Apr 2021 23:32:31 +0200 Subject: [PATCH 2/4] combine user_override files --- include/user_config_override-template.h | 17 +++++ src/user_config_override_sample.h | 85 ------------------------- 2 files changed, 17 insertions(+), 85 deletions(-) delete mode 100644 src/user_config_override_sample.h diff --git a/include/user_config_override-template.h b/include/user_config_override-template.h index 2f1fd4a7..fd01a783 100644 --- a/include/user_config_override-template.h +++ b/include/user_config_override-template.h @@ -9,6 +9,8 @@ // // To use: Save a copy as user_config_override.h ***************************************************/ +#ifndef HASP_USER_CONFIG_OVERRIDE_H +#define HASP_USER_CONFIG_OVERRIDE_H #define SERIAL_SPEED 115200 @@ -48,6 +50,19 @@ #define SYSLOG_PORT 514 #define APP_NAME "HASP" +/*************************************************** + * Timezone Settings + **************************************************/ +#define MYTZ "CET-1CEST,M3.5.0,M10.5.0/3" // A full list with possible timezones can be found here https://gist.github.com/alwynallan/24d96091655391107939 + +/*************************************************** + * Interface Language Settings + **************************************************/ +#define HASP_LANGUAGE en_US // English +// #define HASP_LANGUAGE nl_NL // Dutch +// #define HASP_LANGUAGE hu_HU // Hungarian +// #define HASP_LANGUAGE ro_RO // Romanian + /*************************************************** * Web interface coloring **************************************************/ @@ -77,3 +92,5 @@ * Other Settings **************************************************/ //#define HASP_USE_HA // Enable Home Assistant auto-discovery + +#endif \ No newline at end of file diff --git a/src/user_config_override_sample.h b/src/user_config_override_sample.h deleted file mode 100644 index 25429883..00000000 --- a/src/user_config_override_sample.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef HASP_USER_CONFIG_OVERRIDE_H -#define HASP_USER_CONFIG_OVERRIDE_H -/*************************************************** - Setup WiFi Settings - **************************************************/ -// #define WIFI_SSID "" // WiFi SSID -// #define WIFI_PASSW "" // WiFi Password - -/*************************************************** - MQTT Settings - **************************************************/ -// #define MQTT_HOST "" // MQTT server Address -// #define MQTT_PORT 1883 // MQTT server Port -// #define MQTT_USER "" // Optional Username -// #define MQTT_PASSW "" // Optional Password -// #define MQTT_GROUPNAME "plates" // MQTT Group topic for all plates to listen on, default: plates -// #define MQTT_PREFIX "hasp" // Prefix for all MQTT topics, default: hasp - -/*************************************************** - SYSLOG Settings - **************************************************/ -// #define SYSLOG_SERVER "" // Syslog server Address -// #define SYSLOG_PORT 514 // Syslog server Port - -/*************************************************** - Timezone Settings - **************************************************/ -// #define MYTZ "CET-1CEST,M3.5.0,M10.5.0/3" // A full list with possible timezones can be found here https://gist.github.com/alwynallan/24d96091655391107939 - -/*************************************************** - Interface Language Settings - **************************************************/ -// #define HASP_LANGUAGE en_US // English -// #define HASP_LANGUAGE nl_NL // Dutch -// #define HASP_LANGUAGE hu_HU // Hungarian -// #define HASP_LANGUAGE ro_RO // Romanian - -/*************************************************** - Web Interface Templates - **************************************************/ -/* -//default theme -#define D_HTTP_COLOR_TEXT "#000" // Global text color - Black -#define D_HTTP_COLOR_BACKGROUND "#fff" // Global background color - White -#define D_HTTP_COLOR_INPUT_TEXT "#000" // Input text color - Black -#define D_HTTP_COLOR_INPUT "#fff" // Input background color - White -#define D_HTTP_COLOR_INPUT_WARNING "#f00" // Warning text color - Red -#define D_HTTP_COLOR_BUTTON_TEXT "#fff" // Button text color - White -#define D_HTTP_COLOR_BUTTON "#1fa3ec" // Button color - Vivid blue -#define D_HTTP_COLOR_BUTTON_RESET "#f00" // Restart/Reset/Delete button color - red -*/ -/* -// Dark theme -#define D_HTTP_COLOR_TEXT "#eaeaea" // Global text color - Very light gray -#define D_HTTP_COLOR_BACKGROUND "#252525" // Global background color - Very dark gray (mostly black) -#define D_HTTP_COLOR_INPUT_TEXT "#000" // Input text color - Black -#define D_HTTP_COLOR_INPUT "#ddd" // Input background color - Very light gray -#define D_HTTP_COLOR_INPUT_WARNING "#ff5661" // Warning text color - Brick Red -#define D_HTTP_COLOR_BUTTON_TEXT "#faffff" // Button text color - Very pale (mostly white) cyan -#define D_HTTP_COLOR_BUTTON "#1fa3ec" // Button color - Vivid blue -#define D_HTTP_COLOR_BUTTON_RESET "#d43535" // Restart/Reset/Delete button color - Strong red -*/ -/* -// Purple theme -#define D_HTTP_COLOR_TEXT "#eaeaea" -#define D_HTTP_COLOR_BACKGROUND "#252525" -#define D_HTTP_COLOR_INPUT_TEXT "#eaeaea" -#define D_HTTP_COLOR_INPUT "#282531" -#define D_HTTP_COLOR_INPUT_WARNING "#ff5661" -#define D_HTTP_COLOR_BUTTON_TEXT "#faffff" -#define D_HTTP_COLOR_BUTTON "#694fa8" -#define D_HTTP_COLOR_BUTTON_RESET "#b73d5d" -*/ -/* -// Green theme -#define D_HTTP_COLOR_TEXT "#edddd4" -#define D_HTTP_COLOR_BACKGROUND "#283d3b" -#define D_HTTP_COLOR_INPUT_TEXT "#edddd4" -#define D_HTTP_COLOR_INPUT "#197278" -#define D_HTTP_COLOR_INPUT_WARNING "#772e25" -#define D_HTTP_COLOR_BUTTON_TEXT "#edddd4" -#define D_HTTP_COLOR_BUTTON "#197278" -#define D_HTTP_COLOR_BUTTON_RESET "#c44536" -*/ -#endif \ No newline at end of file From b95e2d78f1387d1fc4b88853e40e9ee84d0a8149 Mon Sep 17 00:00:00 2001 From: arovak Date: Mon, 5 Apr 2021 23:34:54 +0200 Subject: [PATCH 3/4] rearrange some includes and defines --- src/dev/esp32/esp32.cpp | 3 ++- src/sys/net/hasp_network.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dev/esp32/esp32.cpp b/src/dev/esp32/esp32.cpp index 837a6bad..d591a407 100644 --- a/src/dev/esp32/esp32.cpp +++ b/src/dev/esp32/esp32.cpp @@ -7,13 +7,14 @@ #include #include "esp_system.h" +#include "hasp_conf.h" + #include "../device.h" #include "esp32.h" #include "driver/adc.h" #include "esp_adc_cal.h" -#include "hasp_conf.h" #include "hasp_debug.h" #include "hasp/hasp_utilities.h" diff --git a/src/sys/net/hasp_network.cpp b/src/sys/net/hasp_network.cpp index 1001a5d6..bdbc49c0 100644 --- a/src/sys/net/hasp_network.cpp +++ b/src/sys/net/hasp_network.cpp @@ -6,9 +6,6 @@ // #ifdef USE_CONFIG_OVERRIDE // #include "user_config_override.h" // #endif -#ifndef MYTZ -#define MYTZ "EST5EDT,M3.2.0/2,M11.1.0" -#endif #include #include "ArduinoLog.h" @@ -20,6 +17,10 @@ #include "hasp/hasp.h" #include "sys/svc/hasp_mdns.h" +#ifndef MYTZ +#define MYTZ "EST5EDT,M3.2.0/2,M11.1.0" +#endif + #if HASP_USE_ETHERNET > 0 || HASP_USE_WIFI > 0 void networkStart(void) { From 6abf19b1df41bdea4a6006ecf04b59bc758879df Mon Sep 17 00:00:00 2001 From: arovak Date: Mon, 5 Apr 2021 23:35:20 +0200 Subject: [PATCH 4/4] allow MQTT_NODENAME override --- src/dev/esp32/esp32.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/dev/esp32/esp32.h b/src/dev/esp32/esp32.h index 7c2b6797..72dde072 100644 --- a/src/dev/esp32/esp32.h +++ b/src/dev/esp32/esp32.h @@ -15,7 +15,11 @@ class Esp32Device : public BaseDevice { public: Esp32Device() { +#ifdef MQTT_NODENAME + _hostname = MQTT_NODENAME; +#else _hostname = "plate"; +#endif _backlight_power = 1; _backlight_level = 100; #ifdef TFT_BCKL