mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
feedback for read-command and set tx_mode, move show mqtt,
This commit is contained in:
@@ -146,6 +146,11 @@ void EMSESPShell::add_console_commands() {
|
||||
flash_string_vector{F_(show), F_(values)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) { EMSESP::show_device_values(shell); });
|
||||
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::USER,
|
||||
flash_string_vector{F_(show), F_(mqtt)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) { Mqtt::show_mqtt(shell); });
|
||||
|
||||
commands->add_command(
|
||||
ShellContext::MAIN,
|
||||
CommandFlags::ADMIN,
|
||||
@@ -186,10 +191,10 @@ void EMSESPShell::add_console_commands() {
|
||||
EMSESP::emsespSettingsService.update(
|
||||
[&](EMSESPSettings & settings) {
|
||||
settings.tx_mode = tx_mode;
|
||||
shell.printfln(F_(tx_mode_fmt), settings.tx_mode);
|
||||
return StateUpdateResult::CHANGED;
|
||||
},
|
||||
"local");
|
||||
EMSESP::reset_tx(); // reset counters and set tx_mode
|
||||
});
|
||||
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
@@ -318,6 +323,8 @@ void Console::load_standard_commands(unsigned int context) {
|
||||
shell.printfln(F_(invalid_log_level));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
shell.printfln(F_(log_level_list));
|
||||
}
|
||||
shell.printfln(F_(log_level_fmt), uuid::log::format_level_uppercase(shell.log_level()));
|
||||
},
|
||||
|
||||
@@ -863,6 +863,7 @@ void Boiler::console_commands(Shell & shell, unsigned int context) {
|
||||
flash_string_vector{F_(typeid_mandatory)},
|
||||
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
|
||||
uint16_t type_id = Helpers::hextoint(arguments.front().c_str());
|
||||
EMSESP::set_read_id(type_id);
|
||||
EMSESP::send_read_request(type_id, get_device_id());
|
||||
});
|
||||
|
||||
|
||||
@@ -1130,6 +1130,7 @@ void Thermostat::console_commands(Shell & shell, unsigned int context) {
|
||||
flash_string_vector{F_(typeid_mandatory)},
|
||||
[=](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
|
||||
uint16_t type_id = Helpers::hextoint(arguments.front().c_str());
|
||||
EMSESP::set_read_id(type_id);
|
||||
EMSESP::send_read_request(type_id, this->get_device_id());
|
||||
});
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ Shower EMSESP::shower_; // Shower logic
|
||||
uint8_t EMSESP::actual_master_thermostat_ = EMSESP_DEFAULT_MASTER_THERMOSTAT; // which thermostat leads when multiple found
|
||||
uint16_t EMSESP::watch_id_ = WATCH_ID_NONE; // for when log is TRACE. 0 means no trace set
|
||||
uint8_t EMSESP::watch_ = 0; // trace off
|
||||
uint16_t EMSESP::read_id_ = WATCH_ID_NONE;
|
||||
bool EMSESP::tap_water_active_ = false; // for when Boiler states we having running warm water. used in Shower()
|
||||
uint32_t EMSESP::last_fetch_ = 0;
|
||||
uint8_t EMSESP::unique_id_count_ = 0;
|
||||
@@ -467,7 +468,10 @@ void EMSESP::process_version(std::shared_ptr<const Telegram> telegram) {
|
||||
// returns false if there are none found
|
||||
bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
|
||||
// if watching...
|
||||
if (watch() == WATCH_ON) {
|
||||
if (telegram->type_id == read_id_) {
|
||||
LOG_NOTICE(pretty_telegram(telegram).c_str());
|
||||
read_id_ = WATCH_ID_NONE;
|
||||
} else if (watch() == WATCH_ON) {
|
||||
if ((watch_id_ == WATCH_ID_NONE) || (telegram->src == watch_id_) || (telegram->dest == watch_id_) || (telegram->type_id == watch_id_)) {
|
||||
LOG_NOTICE(pretty_telegram(telegram).c_str());
|
||||
}
|
||||
|
||||
@@ -123,6 +123,9 @@ class EMSESP {
|
||||
static uint8_t watch() {
|
||||
return watch_;
|
||||
}
|
||||
static void set_read_id(uint16_t id) {
|
||||
read_id_ = id;
|
||||
}
|
||||
|
||||
enum Bus_status : uint8_t { BUS_STATUS_CONNECTED = 0, BUS_STATUS_TX_ERRORS, BUS_STATUS_OFFLINE };
|
||||
static uint8_t bus_status();
|
||||
@@ -187,6 +190,7 @@ class EMSESP {
|
||||
static uint8_t actual_master_thermostat_;
|
||||
static uint16_t watch_id_;
|
||||
static uint8_t watch_;
|
||||
static uint16_t read_id_;
|
||||
static bool tap_water_active_;
|
||||
|
||||
static uint8_t unique_id_count_;
|
||||
|
||||
@@ -87,8 +87,8 @@ MAKE_PSTR(hc_optional, "[heating circuit]")
|
||||
MAKE_PSTR(master_thermostat_fmt, "Master Thermostat Device ID = %s")
|
||||
MAKE_PSTR(host_fmt, "Host = %s")
|
||||
MAKE_PSTR(hostname_fmt, "WiFi Hostname = %s")
|
||||
MAKE_PSTR(mark_interval_fmt, "Mark interval = %lus");
|
||||
MAKE_PSTR(wifi_ssid_fmt, "WiFi SSID = %s");
|
||||
MAKE_PSTR(mark_interval_fmt, "Mark interval = %lus")
|
||||
MAKE_PSTR(wifi_ssid_fmt, "WiFi SSID = %s")
|
||||
MAKE_PSTR(wifi_password_fmt, "WiFi Password = %S")
|
||||
MAKE_PSTR(system_heartbeat_fmt, "MQTT Heartbeat is %s")
|
||||
MAKE_PSTR(cmd_optional, "[cmd]")
|
||||
@@ -110,6 +110,7 @@ MAKE_PSTR(typeid_mandatory, "<type ID>")
|
||||
MAKE_PSTR(deviceid_mandatory, "<device ID>")
|
||||
MAKE_PSTR(deviceid_optional, "[device ID]")
|
||||
MAKE_PSTR(invalid_log_level, "Invalid log level")
|
||||
MAKE_PSTR(log_level_list,"OFF EMERG ALERT CRIT ERR WARNING NOTICE INFO DEBUG TRACE ALL")
|
||||
MAKE_PSTR(log_level_fmt, "Log level = %s")
|
||||
MAKE_PSTR(log_level_optional, "[level]")
|
||||
MAKE_PSTR(name_mandatory, "<name>")
|
||||
|
||||
@@ -554,12 +554,12 @@ void System::console_commands(Shell & shell, unsigned int context) {
|
||||
shell.printfln(F_(wifi_password_fmt), wifiSettings.ssid.isEmpty() ? F_(unset) : F_(asterisks));
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||
CommandFlags::USER,
|
||||
flash_string_vector{F_(show), F_(mqtt)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) { Mqtt::show_mqtt(shell); });
|
||||
|
||||
*/
|
||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||
CommandFlags::ADMIN,
|
||||
flash_string_vector{F_(show), F_(users)},
|
||||
|
||||
Reference in New Issue
Block a user