mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 09:19:51 +03:00
compile with EMSESP_TEST to run tests (not DEBUG)
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
#include "emsesp.h"
|
||||
#include "version.h"
|
||||
|
||||
#if defined(EMSESP_DEBUG)
|
||||
#if defined(EMSESP_TEST)
|
||||
#include "test/test.h"
|
||||
#endif
|
||||
|
||||
@@ -66,13 +66,9 @@ static std::vector<std::string> log_level_autocomplete(Shell & shell, const std:
|
||||
}
|
||||
|
||||
static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
// add for all contexts
|
||||
// log, exit, help
|
||||
for (unsigned int context = ShellContext::MAIN; context < ShellContext::END; context++) {
|
||||
commands->add_command(context, CommandFlags::USER, {F_(exit)}, EMSESPShell::main_exit_function);
|
||||
commands->add_command(context, CommandFlags::USER, {F_(help)}, EMSESPShell::main_help_function);
|
||||
}
|
||||
|
||||
commands->add_command(ShellContext::MAIN, CommandFlags::USER, {F_(exit)}, EMSESPShell::main_exit_function);
|
||||
commands->add_command(ShellContext::MAIN, CommandFlags::USER, {F_(help)}, EMSESPShell::main_help_function);
|
||||
commands->add_command(ShellContext::MAIN, CommandFlags::USER, {F_(log)}, {F_(log_level_optional)}, console_log_level, log_level_autocomplete);
|
||||
|
||||
//
|
||||
@@ -125,7 +121,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
// System commands
|
||||
//
|
||||
|
||||
#if defined(EMSESP_DEBUG)
|
||||
#if defined(EMSESP_TEST)
|
||||
// create commands test
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::USER,
|
||||
@@ -238,7 +234,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifdef EMSESP_DEBUG
|
||||
#if defined(EMSESP_DEBUG)
|
||||
// only for debug
|
||||
commands->add_command(
|
||||
ShellContext::MAIN,
|
||||
|
||||
@@ -189,7 +189,7 @@ MAKE_NOTRANSLATION(tpl_date, "Format: < dd.mm.yyyy >")
|
||||
MAKE_NOTRANSLATION(tpl_input, "Format: <inv>[<evu1><evu2><evu3><comp><aux><cool><heat><dhw><pv>]")
|
||||
MAKE_NOTRANSLATION(tpl_input4, "Format: <inv>[<comp><aux><cool><heat><dhw><pv>]")
|
||||
|
||||
#if defined(EMSESP_DEBUG)
|
||||
#if defined(EMSESP_TEST)
|
||||
MAKE_NOTRANSLATION(test_cmd, "run a test")
|
||||
#endif
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include <semver200.h>
|
||||
|
||||
#if defined(EMSESP_DEBUG)
|
||||
#if defined(EMSESP_TEST)
|
||||
#include "test/test.h"
|
||||
#endif
|
||||
|
||||
@@ -54,7 +54,7 @@ Adafruit_NeoPixel pixels(1, 7, NEO_GRB + NEO_KHZ800);
|
||||
namespace emsesp {
|
||||
|
||||
// Languages supported. Note: the order is important and must match locale_translations.h
|
||||
#ifdef EMSESP_DEBUG
|
||||
#if defined(EMSESP_DEBUG)
|
||||
// in Debug mode use one language (en) to save flash memory needed for the tests
|
||||
const char * const languages[] = {EMSESP_LOCALE_EN};
|
||||
#else
|
||||
@@ -260,7 +260,6 @@ void System::syslog_init() {
|
||||
syslog_.destination(syslog_host_.c_str(), syslog_port_);
|
||||
syslog_.hostname(hostname().c_str());
|
||||
|
||||
// register the command
|
||||
// removed in 3.6.0
|
||||
// Command::add(EMSdevice::DeviceType::SYSTEM, F_(syslog), System::command_syslog_level, FL_(changeloglevel_cmd), CommandFlag::ADMIN_ONLY);
|
||||
|
||||
@@ -356,9 +355,7 @@ void System::wifi_tweak() {
|
||||
bool s1 = WiFi.getSleep();
|
||||
WiFi.setSleep(false); // turn off sleep - WIFI_PS_NONE
|
||||
bool s2 = WiFi.getSleep();
|
||||
#if defined(EMSESP_DEBUG)
|
||||
LOG_DEBUG("[DEBUG] Adjusting WiFi - Tx power %d->%d, Sleep %d->%d", p1, p2, s1, s2);
|
||||
#endif
|
||||
LOG_DEBUG("Adjusting WiFi - Tx power %d->%d, Sleep %d->%d", p1, p2, s1, s2);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -420,7 +417,7 @@ void System::start() {
|
||||
void System::button_OnClick(PButton & b) {
|
||||
LOG_DEBUG("Button pressed - single click");
|
||||
|
||||
#ifdef EMSESP_DEBUG
|
||||
#if defined(EMSESP_DEBUG)
|
||||
#ifndef EMSESP_STANDALONE
|
||||
Test::listDir(LittleFS, FS_CONFIG_DIRECTORY, 3);
|
||||
#endif
|
||||
@@ -749,7 +746,7 @@ void System::commands_init() {
|
||||
// restart and watch (and test) are also exposed as Console commands
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(restart), System::command_restart, FL_(restart_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(watch), System::command_watch, FL_(watch_cmd));
|
||||
#if defined(EMSESP_DEBUG)
|
||||
#if defined(EMSESP_TEST)
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, ("test"), System::command_test, FL_(test_cmd));
|
||||
#endif
|
||||
|
||||
@@ -1045,9 +1042,7 @@ bool System::check_upgrade(bool factory_settings) {
|
||||
// see if we're missing a version, will be < 3.5.0b13 from Dec 23 2022
|
||||
missing_version = (settingsVersion.empty() || (settingsVersion.length() < 5));
|
||||
if (missing_version) {
|
||||
#ifdef EMSESP_DEBUG
|
||||
LOG_DEBUG("No version information found (%s)", settingsVersion.c_str());
|
||||
#endif
|
||||
settingsVersion = "3.4.4"; // this was the last stable version
|
||||
}
|
||||
}
|
||||
@@ -1085,9 +1080,7 @@ bool System::check_upgrade(bool factory_settings) {
|
||||
|
||||
// if we're coming from 3.4.4 or 3.5.0b14 then we need to apply new settings
|
||||
if (missing_version) {
|
||||
#ifdef EMSESP_DEBUG
|
||||
LOG_DEBUG("Setting MQTT ID Entity to v3.4 format");
|
||||
#endif
|
||||
EMSESP::esp8266React.getMqttSettingsService()->update(
|
||||
[&](MqttSettings & mqttSettings) {
|
||||
mqttSettings.entity_format = 0; // use old Entity ID format from v3.4
|
||||
@@ -1400,7 +1393,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(EMSESP_DEBUG)
|
||||
#if defined(EMSESP_TEST)
|
||||
// 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) {
|
||||
return Test::run_test(value, id);
|
||||
|
||||
@@ -55,14 +55,13 @@ class System {
|
||||
static bool command_publish(const char * value, const int8_t id);
|
||||
static bool command_fetch(const char * value, const int8_t id);
|
||||
static bool command_restart(const char * value, const int8_t id);
|
||||
#if defined(EMSESP_DEBUG)
|
||||
static bool command_test(const char * value, const int8_t id);
|
||||
#endif
|
||||
static bool command_syslog_level(const char * value, const int8_t id);
|
||||
static bool command_watch(const char * value, const int8_t id);
|
||||
|
||||
static bool command_info(const char * value, const int8_t id, JsonObject & output);
|
||||
static bool command_commands(const char * value, const int8_t id, JsonObject & output);
|
||||
#if defined(EMSESP_TEST)
|
||||
static bool command_test(const char * value, const int8_t id);
|
||||
#endif
|
||||
|
||||
std::string reset_reason(uint8_t cpu) const;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(EMSESP_DEBUG) || defined(EMSESP_STANDALONE)
|
||||
#if defined(EMSESP_STANDALONE) || defined(EMSESP_TEST)
|
||||
|
||||
#include "test.h"
|
||||
|
||||
@@ -1785,7 +1785,7 @@ void Test::add_device(uint8_t device_id, uint8_t product_id) {
|
||||
uart_telegram({device_id, EMSESP_DEFAULT_EMS_BUS_ID, EMSdevice::EMS_TYPE_VERSION, 0, product_id, 1, 0});
|
||||
}
|
||||
|
||||
#ifdef EMSESP_DEBUG
|
||||
#ifdef EMSESP_TEST
|
||||
#ifndef EMSESP_STANDALONE
|
||||
void Test::listDir(fs::FS & fs, const char * dirname, uint8_t levels) {
|
||||
Serial.println();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(EMSESP_DEBUG) || defined(EMSESP_STANDALONE)
|
||||
#if defined(EMSESP_STANDALONE) || defined(EMSESP_TEST)
|
||||
|
||||
#ifndef EMSESP_TEST_H
|
||||
#define EMSESP_TEST_H
|
||||
|
||||
Reference in New Issue
Block a user