mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
make all default settings configurable at build
This commit is contained in:
@@ -57,18 +57,6 @@ static String generateClientId() {
|
||||
#define FACTORY_MQTT_MAX_TOPIC_LENGTH 128
|
||||
#endif
|
||||
|
||||
#define EMSESP_DEFAULT_BOOL_FORMAT 1 // on/off
|
||||
#define EMSESP_DEFAULT_DALLAS_FORMAT 1 // sensorid
|
||||
#define EMSESP_DEFAULT_HA_CLIMATE_FORMAT 1 // current temp
|
||||
#define EMSESP_DEFAULT_MQTT_QOS 0
|
||||
#define EMSESP_DEFAULT_MQTT_RETAIN false
|
||||
#define EMSESP_DEFAULT_HA_ENABLED false
|
||||
#define EMSESP_DEFAULT_PUBLISH_TIME 10
|
||||
#define EMSESP_DEFAULT_NESTED_FORMAT true
|
||||
#define EMSESP_DEFAULT_SUBSCRIBE_FORMAT 0
|
||||
|
||||
#define EMSESP_DEFAULT_BOARD_PROFILE "S32"
|
||||
|
||||
class MqttSettings {
|
||||
public:
|
||||
// host and port - if enabled
|
||||
|
||||
2
makefile
2
makefile
@@ -33,7 +33,7 @@ CXX_STANDARD := -std=c++11
|
||||
#----------------------------------------------------------------------
|
||||
# Defined Symbols
|
||||
#----------------------------------------------------------------------
|
||||
DEFINES += -DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_TEST -DEMSESP_DEFAULT_BOARD_PROFILE=\"LOLIN\"
|
||||
DEFINES += -DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_DEBUG -DEMSESP_DEFAULT_BOARD_PROFILE=\"LOLIN\"
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Sources & Files
|
||||
|
||||
@@ -8,9 +8,9 @@ upload_flags =
|
||||
upload_port = 10.10.10.101
|
||||
|
||||
[common]
|
||||
; options are EMSESP_DEBUG EMSESP_UART_DEBUG EMSESP_TEST DEMSESP_DEFAULT_BOARD_PROFILE
|
||||
; debug_flags = -DEMSESP_DEBUG -DEMSESP_TEST
|
||||
; debug_flags = -DEMSESP_DEFAULT_BOARD_PROFILE=\"NODEMCU\"
|
||||
; options are EMSESP_DEBUG EMSESP_UART_DEBUG EMSESP_DEBUG_SENSOR
|
||||
; plus all the settings in default_settings.h, e.g. -DEMSESP_DEFAULT_BOARD_PROFILE=\"NODEMCU\"
|
||||
; debug_flags = -DEMSESP_DEBUG
|
||||
|
||||
[env:esp32]
|
||||
monitor_filters = esp32_exception_decoder
|
||||
|
||||
@@ -22,39 +22,12 @@
|
||||
#include <HttpEndpoint.h>
|
||||
#include <FSPersistence.h>
|
||||
|
||||
#include "default_settings.h"
|
||||
|
||||
#define EMSESP_SETTINGS_FILE "/config/emsespSettings.json"
|
||||
#define EMSESP_SETTINGS_SERVICE_PATH "/rest/emsespSettings"
|
||||
#define EMSESP_BOARD_PROFILE_SERVICE_PATH "/rest/boardProfile"
|
||||
|
||||
#define EMSESP_DEFAULT_TX_MODE 1 // EMS1.0
|
||||
#define EMSESP_DEFAULT_TX_DELAY 0 // no delay
|
||||
#define EMSESP_DEFAULT_EMS_BUS_ID 0x0B // service key
|
||||
#define EMSESP_DEFAULT_SYSLOG_ENABLED false
|
||||
#define EMSESP_DEFAULT_SYSLOG_LEVEL 3 // ERR
|
||||
#define EMSESP_DEFAULT_SYSLOG_MARK_INTERVAL 0
|
||||
#define EMSESP_DEFAULT_SYSLOG_HOST ""
|
||||
#define EMSESP_DEFAULT_SYSLOG_PORT 514
|
||||
#define EMSESP_DEFAULT_TRACELOG_RAW false
|
||||
#define EMSESP_DEFAULT_MASTER_THERMOSTAT 0 // not set
|
||||
#define EMSESP_DEFAULT_SHOWER_TIMER false
|
||||
#define EMSESP_DEFAULT_SHOWER_ALERT false
|
||||
#define EMSESP_DEFAULT_HIDE_LED false
|
||||
#define EMSESP_DEFAULT_DALLAS_PARASITE false
|
||||
#define EMSESP_DEFAULT_API_ENABLED false // turn off, because its insecure
|
||||
#define EMSESP_DEFAULT_BOOL_FORMAT 1 // on/off
|
||||
#define EMSESP_DEFAULT_ANALOG_ENABLED false
|
||||
|
||||
#ifndef EMSESP_DEFAULT_BOARD_PROFILE
|
||||
#define EMSESP_DEFAULT_BOARD_PROFILE "S32" // Gateway S32
|
||||
#endif
|
||||
|
||||
// Default GPIO PIN definitions - based on Wemos/Nodemcu
|
||||
#define EMSESP_DEFAULT_RX_GPIO 23 // D7
|
||||
#define EMSESP_DEFAULT_TX_GPIO 5 // D8
|
||||
#define EMSESP_DEFAULT_DALLAS_GPIO 18
|
||||
#define EMSESP_DEFAULT_LED_GPIO 2
|
||||
#define EMSESP_DEFAULT_PBUTTON_GPIO 0
|
||||
|
||||
namespace emsesp {
|
||||
|
||||
class WebSettings {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "emsesp.h"
|
||||
#include "version.h"
|
||||
|
||||
#if defined(EMSESP_TEST)
|
||||
#if defined(EMSESP_DEBUG)
|
||||
#include "test/test.h"
|
||||
#endif
|
||||
|
||||
@@ -447,7 +447,7 @@ void Console::enter_custom_context(Shell & shell, unsigned int context) {
|
||||
|
||||
// each custom context has the common commands like log, help, exit, su etc
|
||||
void Console::load_standard_commands(unsigned int context) {
|
||||
#if defined(EMSESP_TEST)
|
||||
#if defined(EMSESP_DEBUG)
|
||||
EMSESPShell::commands->add_command(context, CommandFlags::USER, flash_string_vector{F("test")}, flash_string_vector{F_(name_optional)}, [](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments.size() == 0) {
|
||||
Test::run_test(shell, "default");
|
||||
|
||||
155
src/default_settings.h
Normal file
155
src/default_settings.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* EMS-ESP - https://github.com/emsesp/EMS-ESP
|
||||
* Copyright 2020 Paul Derbyshire
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef EMSESP_DEFAULT_SETTINGS_H
|
||||
#define EMSESP_DEFAULT_SETTINGS_H
|
||||
|
||||
// GENERAL SETTINGS
|
||||
|
||||
#ifndef EMSESP_DEFAULT_TX_MODE
|
||||
#define EMSESP_DEFAULT_TX_MODE 1 // EMS1.0
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_TX_DELAY
|
||||
#define EMSESP_DEFAULT_TX_DELAY 0 // no delay
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_EMS_BUS_ID
|
||||
#define EMSESP_DEFAULT_EMS_BUS_ID 0x0B // service key
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_SYSLOG_ENABLED
|
||||
#define EMSESP_DEFAULT_SYSLOG_ENABLED false
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_SYSLOG_LEVEL
|
||||
#define EMSESP_DEFAULT_SYSLOG_LEVEL 3 // ERR
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_SYSLOG_MARK_INTERVAL
|
||||
#define EMSESP_DEFAULT_SYSLOG_MARK_INTERVAL 0
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_SYSLOG_HOST
|
||||
#define EMSESP_DEFAULT_SYSLOG_HOST ""
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_SYSLOG_PORT
|
||||
#define EMSESP_DEFAULT_SYSLOG_PORT 514
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_TRACELOG_RAW
|
||||
#define EMSESP_DEFAULT_TRACELOG_RAW false
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_MASTER_THERMOSTAT
|
||||
#define EMSESP_DEFAULT_MASTER_THERMOSTAT 0 // not set
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_SHOWER_TIMER
|
||||
#define EMSESP_DEFAULT_SHOWER_TIMER false
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_SHOWER_ALERT
|
||||
#define EMSESP_DEFAULT_SHOWER_ALERT false
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_HIDE_LED
|
||||
#define EMSESP_DEFAULT_HIDE_LED false
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_DALLAS_PARASITE
|
||||
#define EMSESP_DEFAULT_DALLAS_PARASITE false
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_API_ENABLED
|
||||
#define EMSESP_DEFAULT_API_ENABLED false // turn off, because its insecure
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_BOOL_FORMAT
|
||||
#define EMSESP_DEFAULT_BOOL_FORMAT 1 // on/off
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_ANALOG_ENABLED
|
||||
#define EMSESP_DEFAULT_ANALOG_ENABLED false
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_BOARD_PROFILE
|
||||
#define EMSESP_DEFAULT_BOARD_PROFILE "S32" // Gateway S32
|
||||
#endif
|
||||
|
||||
// Default GPIO PIN definitions - based on Wemos/Nodemcu
|
||||
|
||||
#ifndef EMSESP_DEFAULT_RX_GPIO
|
||||
#define EMSESP_DEFAULT_RX_GPIO 23 // D7
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_TX_GPIO
|
||||
#define EMSESP_DEFAULT_TX_GPIO 5 // D8
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_DALLAS_GPIO
|
||||
#define EMSESP_DEFAULT_DALLAS_GPIO 18
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_LED_GPIO
|
||||
#define EMSESP_DEFAULT_LED_GPIO 2
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_PBUTTON_GPIO
|
||||
#define EMSESP_DEFAULT_PBUTTON_GPIO 0
|
||||
#endif
|
||||
|
||||
// MQTT
|
||||
|
||||
#ifndef EMSESP_DEFAULT_BOOL_FORMAT
|
||||
#define EMSESP_DEFAULT_BOOL_FORMAT 1 // on/off
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_DALLAS_FORMAT
|
||||
#define EMSESP_DEFAULT_DALLAS_FORMAT 1 // sensorid
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_HA_CLIMATE_FORMAT
|
||||
#define EMSESP_DEFAULT_HA_CLIMATE_FORMAT 1 // current temp
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_MQTT_QOS
|
||||
#define EMSESP_DEFAULT_MQTT_QOS 0
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_MQTT_RETAIN
|
||||
#define EMSESP_DEFAULT_MQTT_RETAIN false
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_HA_ENABLED
|
||||
#define EMSESP_DEFAULT_HA_ENABLED false
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_PUBLISH_TIME
|
||||
#define EMSESP_DEFAULT_PUBLISH_TIME 10
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_NESTED_FORMAT
|
||||
#define EMSESP_DEFAULT_NESTED_FORMAT true
|
||||
#endif
|
||||
|
||||
#ifndef EMSESP_DEFAULT_SUBSCRIBE_FORMAT
|
||||
#define EMSESP_DEFAULT_SUBSCRIBE_FORMAT 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "mqtt.h"
|
||||
#include "dallassensor.h"
|
||||
#include "version.h"
|
||||
#include "default_settings.h"
|
||||
|
||||
// forward declarators
|
||||
// used to bind EMS-ESP functions to external frameworks
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "system.h"
|
||||
#include "emsesp.h" // for send_raw_telegram() command
|
||||
|
||||
#if defined(EMSESP_TEST)
|
||||
#if defined(EMSESP_DEBUG)
|
||||
#include "test/test.h"
|
||||
#endif
|
||||
|
||||
@@ -311,7 +311,7 @@ void System::button_OnVLongPress(PButton & b) {
|
||||
LOG_WARNING(F("Performing factory reset..."));
|
||||
EMSESP::console_.loop();
|
||||
|
||||
#ifdef EMSESP_TEST
|
||||
#ifdef EMSESP_DEBUG
|
||||
Test::listDir(LITTLEFS, FS_CONFIG_DIRECTORY, 3);
|
||||
#endif
|
||||
|
||||
@@ -591,7 +591,7 @@ void System::commands_init() {
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(fetch), System::command_fetch);
|
||||
Command::add_with_json(EMSdevice::DeviceType::SYSTEM, F_(info), System::command_info);
|
||||
Command::add_with_json(EMSdevice::DeviceType::SYSTEM, F_(settings), System::command_settings);
|
||||
#if defined(EMSESP_TEST)
|
||||
#if defined(EMSESP_DEBUG)
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F("test"), System::command_test);
|
||||
#endif
|
||||
}
|
||||
@@ -1043,7 +1043,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & json
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(EMSESP_TEST)
|
||||
#if defined(EMSESP_DEBUG)
|
||||
// run a test, e.g. http://ems-esp/api?device=system&cmd=test&data=boiler
|
||||
bool System::command_test(const char * value, const int8_t id) {
|
||||
Test::run_test(value, id);
|
||||
|
||||
@@ -55,7 +55,7 @@ class System {
|
||||
static bool command_fetch(const char * value, const int8_t id);
|
||||
static bool command_info(const char * value, const int8_t id, JsonObject & json);
|
||||
static bool command_settings(const char * value, const int8_t id, JsonObject & json);
|
||||
#if defined(EMSESP_TEST)
|
||||
#if defined(EMSESP_DEBUG)
|
||||
static bool command_test(const char * value, const int8_t id);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(EMSESP_TEST)
|
||||
#if defined(EMSESP_DEBUG)
|
||||
|
||||
#include "test.h"
|
||||
|
||||
@@ -191,7 +191,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
|
||||
|
||||
std::string command(20, '\0');
|
||||
if ((cmd.empty()) || (cmd == "default")) {
|
||||
command = EMSESP_TEST_DEFAULT;
|
||||
command = EMSESP_DEBUG_DEFAULT;
|
||||
} else {
|
||||
command = cmd;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(EMSESP_TEST)
|
||||
#if defined(EMSESP_DEBUG)
|
||||
|
||||
#ifndef EMSESP_TEST_H
|
||||
#define EMSESP_TEST_H
|
||||
@@ -25,16 +25,16 @@
|
||||
|
||||
namespace emsesp {
|
||||
|
||||
// #define EMSESP_TEST_DEFAULT "thermostat"
|
||||
// #define EMSESP_TEST_DEFAULT "solar"
|
||||
// #define EMSESP_TEST_DEFAULT "mixer"
|
||||
// #define EMSESP_TEST_DEFAULT "web"
|
||||
// #define EMSESP_TEST_DEFAULT "general"
|
||||
// #define EMSESP_TEST_DEFAULT "boiler"
|
||||
// #define EMSESP_TEST_DEFAULT "mqtt2"
|
||||
// #define EMSESP_TEST_DEFAULT "mqtt_nested"
|
||||
// #define EMSESP_TEST_DEFAULT "ha"
|
||||
#define EMSESP_TEST_DEFAULT "board_profile"
|
||||
// #define EMSESP_DEBUG_DEFAULT "thermostat"
|
||||
// #define EMSESP_DEBUG_DEFAULT "solar"
|
||||
// #define EMSESP_DEBUG_DEFAULT "mixer"
|
||||
// #define EMSESP_DEBUG_DEFAULT "web"
|
||||
// #define EMSESP_DEBUG_DEFAULT "general"
|
||||
// #define EMSESP_DEBUG_DEFAULT "boiler"
|
||||
// #define EMSESP_DEBUG_DEFAULT "mqtt2"
|
||||
// #define EMSESP_DEBUG_DEFAULT "mqtt_nested"
|
||||
// #define EMSESP_DEBUG_DEFAULT "ha"
|
||||
#define EMSESP_DEBUG_DEFAULT "board_profile"
|
||||
|
||||
class Test {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user