From 6c4f8a78a0fa6c1203cc7c7c8834b93f907cb14a Mon Sep 17 00:00:00 2001 From: Yurii Date: Thu, 24 Oct 2024 04:00:06 +0300 Subject: [PATCH] refactor: added defaults for serial & telnet --- platformio.ini | 6 ++++-- secrets.default.ini | 6 ++++-- src/Settings.h | 8 ++++---- src/defines.h | 16 ++++++++++++---- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/platformio.ini b/platformio.ini index 30fe1a6..fc4a10d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -35,8 +35,10 @@ build_flags = ;-D DEBUG_ESP_CORE -D DEBUG_ESP_WIFI -D DEBUG_ESP_HTTP_SERVER -D DEBUG_ESP_PORT=Serial -D BUILD_VERSION='"${this.version}"' -D BUILD_ENV='"$PIOENV"' - -D USE_SERIAL=${secrets.use_serial} - -D USE_TELNET=${secrets.use_telnet} + -D DEFAULT_SERIAL_ENABLE=${secrets.serial_enable} + -D DEFAULT_SERIAL_BAUD=${secrets.serial_baud} + -D DEFAULT_TELNET_ENABLE=${secrets.telnet_enable} + -D DEFAULT_TELNET_PORT=${secrets.telnet_port} -D DEFAULT_LOG_LEVEL=${secrets.log_level} -D DEFAULT_HOSTNAME='"${secrets.hostname}"' -D DEFAULT_AP_SSID='"${secrets.ap_ssid}"' diff --git a/secrets.default.ini b/secrets.default.ini index 24aa295..4ba0b64 100644 --- a/secrets.default.ini +++ b/secrets.default.ini @@ -1,6 +1,8 @@ [secrets] -use_serial = true -use_telnet = true +serial_enable = true +serial_baud = 115200 +telnet_enable = true +telnet_port = 23 log_level = 5 hostname = opentherm diff --git a/src/Settings.h b/src/Settings.h index 6ca872e..bd717cd 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -27,13 +27,13 @@ struct Settings { uint8_t logLevel = DEFAULT_LOG_LEVEL; struct { - bool enable = USE_SERIAL; - unsigned int baudrate = 115200; + bool enable = DEFAULT_SERIAL_ENABLE; + unsigned int baudrate = DEFAULT_SERIAL_BAUD; } serial; struct { - bool enable = USE_TELNET; - unsigned short port = 23; + bool enable = DEFAULT_TELNET_ENABLE; + unsigned short port = DEFAULT_TELNET_PORT; } telnet; UnitSystem unitSystem = UnitSystem::METRIC; diff --git a/src/defines.h b/src/defines.h index 2d0ad48..b4a69a0 100644 --- a/src/defines.h +++ b/src/defines.h @@ -30,12 +30,20 @@ #define BUILD_ENV "undefined" #endif -#ifndef USE_SERIAL - #define USE_SERIAL true +#ifndef DEFAULT_SERIAL_ENABLE + #define DEFAULT_SERIAL_ENABLE true #endif -#ifndef USE_TELNET - #define USE_TELNET true +#ifndef DEFAULT_SERIAL_BAUD + #define DEFAULT_SERIAL_BAUD 115200 +#endif + +#ifndef DEFAULT_TELNET_ENABLE + #define DEFAULT_TELNET_ENABLE true +#endif + +#ifndef DEFAULT_TELNET_PORT + #define DEFAULT_TELNET_PORT 23 #endif #ifndef USE_BLE