mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
use log NOTICE for printing output from 'watch' command
This commit is contained in:
@@ -120,19 +120,20 @@ void EMSESP::show_emsbus(uuid::console::Shell & shell) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shell.printfln(F("EMS Bus info:"));
|
shell.printfln(F("EMS Bus info:"));
|
||||||
|
shell.printfln(F(" Tx mode: %d"), Settings().ems_tx_mode());
|
||||||
shell.printfln(F(" Bus protocol: %s"), EMSbus::is_ht3() ? F("HT3") : F("Buderus"));
|
shell.printfln(F(" Bus protocol: %s"), EMSbus::is_ht3() ? F("HT3") : F("Buderus"));
|
||||||
shell.printfln(F(" #telegrams received: %d"), rxservice_.telegram_count());
|
shell.printfln(F(" #telegrams received: %d"), rxservice_.telegram_count());
|
||||||
shell.printfln(F(" #read requests sent: %d"), txservice_.telegram_read_count());
|
shell.printfln(F(" #read requests sent: %d"), txservice_.telegram_read_count());
|
||||||
shell.printfln(F(" #write requests sent: %d"), txservice_.telegram_write_count());
|
shell.printfln(F(" #write requests sent: %d"), txservice_.telegram_write_count());
|
||||||
shell.printfln(F(" #incomplete telegrams: %d (%d%%)"), rxservice_.telegram_error_count(), success_rate);
|
shell.printfln(F(" #corrupted telegrams: %d (%d%%)"), rxservice_.telegram_error_count(), success_rate);
|
||||||
shell.printfln(F(" #tx fails (after 3 retries): %d"), txservice_.telegram_fail_count());
|
shell.printfln(F(" #tx fails (after %d retries): %d"), TxService::MAXIMUM_TX_RETRIES, txservice_.telegram_fail_count());
|
||||||
} else {
|
} else {
|
||||||
shell.printfln(F("EMS Bus is disconnected"));
|
shell.printfln(F("EMS Bus is disconnected."));
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.println();
|
shell.println();
|
||||||
|
|
||||||
// Rx
|
// Rx queue
|
||||||
auto rx_telegrams = rxservice_.queue();
|
auto rx_telegrams = rxservice_.queue();
|
||||||
if (rx_telegrams.empty()) {
|
if (rx_telegrams.empty()) {
|
||||||
shell.printfln(F("Rx Queue is empty"));
|
shell.printfln(F("Rx Queue is empty"));
|
||||||
@@ -145,7 +146,7 @@ void EMSESP::show_emsbus(uuid::console::Shell & shell) {
|
|||||||
|
|
||||||
shell.println();
|
shell.println();
|
||||||
|
|
||||||
// Tx
|
// Tx queue
|
||||||
auto tx_telegrams = txservice_.queue();
|
auto tx_telegrams = txservice_.queue();
|
||||||
if (tx_telegrams.empty()) {
|
if (tx_telegrams.empty()) {
|
||||||
shell.printfln(F("Tx Queue is empty"));
|
shell.printfln(F("Tx Queue is empty"));
|
||||||
@@ -393,9 +394,11 @@ void EMSESP::process_version(std::shared_ptr<const Telegram> telegram) {
|
|||||||
// We also check for common telgram types, like the Version(0x02)
|
// We also check for common telgram types, like the Version(0x02)
|
||||||
// returns false if there are none found
|
// returns false if there are none found
|
||||||
bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
|
bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
|
||||||
|
|
||||||
|
// if watching...
|
||||||
if (watch() == 1) {
|
if (watch() == 1) {
|
||||||
if ((watch_id_ == WATCH_NONE) || (telegram->src == watch_id_) || (telegram->dest == watch_id_) || (telegram->type_id == watch_id_)) {
|
if ((watch_id_ == WATCH_NONE) || (telegram->src == watch_id_) || (telegram->dest == watch_id_) || (telegram->type_id == watch_id_)) {
|
||||||
LOG_INFO(pretty_telegram(telegram).c_str());
|
LOG_NOTICE(pretty_telegram(telegram).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,8 +725,7 @@ void EMSESP::console_commands(Shell & shell, unsigned int context) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(
|
EMSESPShell::commands->add_command(ShellContext::EMS,
|
||||||
ShellContext::EMS,
|
|
||||||
CommandFlags::ADMIN,
|
CommandFlags::ADMIN,
|
||||||
flash_string_vector{F_(set), F_(tx_mode)},
|
flash_string_vector{F_(set), F_(tx_mode)},
|
||||||
flash_string_vector{F_(n_mandatory)},
|
flash_string_vector{F_(n_mandatory)},
|
||||||
@@ -740,9 +742,6 @@ void EMSESP::console_commands(Shell & shell, unsigned int context) {
|
|||||||
} else {
|
} else {
|
||||||
shell.println(F("Must be 1 for EMS generic, 2 for EMS+, 3 for HT3, 4 for experimental"));
|
shell.println(F("Must be 1 for EMS generic, 2 for EMS+, 3 for HT3, 4 for experimental"));
|
||||||
}
|
}
|
||||||
},
|
|
||||||
[](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments __attribute__((unused))) -> const std::vector<std::string> {
|
|
||||||
return std::vector<std::string>{read_flash_string(F("1")), read_flash_string(F("2")), read_flash_string(F("3")), read_flash_string(F("4"))};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(
|
EMSESPShell::commands->add_command(
|
||||||
@@ -858,7 +857,15 @@ void EMSESP::console_commands(Shell & shell, unsigned int context) {
|
|||||||
uint8_t watch = emsesp::EMSESP::watch();
|
uint8_t watch = emsesp::EMSESP::watch();
|
||||||
if (watch == 0) {
|
if (watch == 0) {
|
||||||
shell.printfln(F("Watch is off"));
|
shell.printfln(F("Watch is off"));
|
||||||
} else if (watch == 1) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if logging is off, the watch won't show anything, show force it back to INFO
|
||||||
|
if (!logger_.enabled(Level::NOTICE)) {
|
||||||
|
shell.log_level(Level::NOTICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (watch == 1) {
|
||||||
shell.printfln(F("Watching incoming telegrams, displayed in decoded format"));
|
shell.printfln(F("Watching incoming telegrams, displayed in decoded format"));
|
||||||
} else {
|
} else {
|
||||||
shell.printfln(F("Watching incoming telegrams, displayed as raw bytes"));
|
shell.printfln(F("Watching incoming telegrams, displayed as raw bytes"));
|
||||||
|
|||||||
@@ -72,8 +72,7 @@ void System::mqtt_commands(const char * message) {
|
|||||||
if (doc["send"] != nullptr) {
|
if (doc["send"] != nullptr) {
|
||||||
const char * data = doc["send"];
|
const char * data = doc["send"];
|
||||||
EMSESP::send_raw_telegram(data);
|
EMSESP::send_raw_telegram(data);
|
||||||
LOG_INFO(F("Sending raw: %s"),data);
|
LOG_INFO(F("Sending raw: %s"), data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
@@ -87,39 +86,60 @@ void System::mqtt_commands(const char * message) {
|
|||||||
const uint8_t d2_ = 21;
|
const uint8_t d2_ = 21;
|
||||||
const uint8_t d3_ = 17;
|
const uint8_t d3_ = 17;
|
||||||
#endif
|
#endif
|
||||||
if(doc["D0"] != nullptr) {
|
|
||||||
|
#ifndef EMSESP_STANDALONE
|
||||||
|
|
||||||
|
if (doc["D0"] != nullptr) {
|
||||||
const int8_t set = doc["D0"];
|
const int8_t set = doc["D0"];
|
||||||
pinMode(d0_, OUTPUT);
|
pinMode(d0_, OUTPUT);
|
||||||
if (set == 1) digitalWrite(d0_, HIGH);
|
if (set == 1) {
|
||||||
else if (set == 0) digitalWrite(d0_, LOW);
|
digitalWrite(d0_, HIGH);
|
||||||
LOG_INFO(F("Port D0 set to %d"),set);
|
} else if (set == 0) {
|
||||||
|
digitalWrite(d0_, LOW);
|
||||||
}
|
}
|
||||||
if(doc["D1"] != nullptr) {
|
LOG_INFO(F("Port D0 set to %d"), set);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc["D1"] != nullptr) {
|
||||||
const int8_t set = doc["D1"];
|
const int8_t set = doc["D1"];
|
||||||
pinMode(d1_, OUTPUT);
|
pinMode(d1_, OUTPUT);
|
||||||
if (set == 1) digitalWrite(d1_, HIGH);
|
if (set == 1) {
|
||||||
else if (set == 0) digitalWrite(d1_, LOW);
|
digitalWrite(d1_, HIGH);
|
||||||
LOG_INFO(F("Port D1 set to %d"),set);
|
} else if (set == 0) {
|
||||||
|
digitalWrite(d1_, LOW);
|
||||||
}
|
}
|
||||||
if(doc["D2"] != nullptr) {
|
LOG_INFO(F("Port D1 set to %d"), set);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc["D2"] != nullptr) {
|
||||||
const int8_t set = doc["D2"];
|
const int8_t set = doc["D2"];
|
||||||
pinMode(d2_, OUTPUT);
|
pinMode(d2_, OUTPUT);
|
||||||
if (set == 1) digitalWrite(d2_, HIGH);
|
if (set == 1) {
|
||||||
else if (set == 0) digitalWrite(d2_, LOW);
|
digitalWrite(d2_, HIGH);
|
||||||
LOG_INFO(F("Port D2 set to %d"),set);
|
} else if (set == 0) {
|
||||||
|
digitalWrite(d2_, LOW);
|
||||||
}
|
}
|
||||||
if(doc["D3"] != nullptr) {
|
LOG_INFO(F("Port D2 set to %d"), set);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc["D3"] != nullptr) {
|
||||||
const int8_t set = doc["D3"];
|
const int8_t set = doc["D3"];
|
||||||
pinMode(d3_, OUTPUT);
|
pinMode(d3_, OUTPUT);
|
||||||
if (set == 1) digitalWrite(d3_, HIGH);
|
if (set == 1) {
|
||||||
else if (set == 0) digitalWrite(d3_, LOW);
|
digitalWrite(d3_, HIGH);
|
||||||
LOG_INFO(F("Port D3 set to %d"),set);
|
} else if (set == 0) {
|
||||||
|
digitalWrite(d3_, LOW);
|
||||||
}
|
}
|
||||||
|
LOG_INFO(F("Port D3 set to %d"), set);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
const char * command = doc["cmd"];
|
const char * command = doc["cmd"];
|
||||||
if (command == nullptr) {
|
if (command == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send raw command
|
// send raw command
|
||||||
if (strcmp(command, "send") == 0) {
|
if (strcmp(command, "send") == 0) {
|
||||||
const char * data = doc["data"];
|
const char * data = doc["data"];
|
||||||
@@ -127,7 +147,7 @@ void System::mqtt_commands(const char * message) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EMSESP::send_raw_telegram(data);
|
EMSESP::send_raw_telegram(data);
|
||||||
LOG_INFO(F("Sending raw: %s"),data);
|
LOG_INFO(F("Sending raw: %s"), data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,11 +304,11 @@ void RxService::add(uint8_t * data, uint8_t length) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we're in "trace" and "raw" print out actual telegram as bytes to the console
|
// if we're watching and "raw" print out actual telegram as bytes to the console
|
||||||
if (EMSESP::watch() == 2) {
|
if (EMSESP::watch() == 2) {
|
||||||
uint16_t trace_watch_id = EMSESP::watch_id();
|
uint16_t trace_watch_id = EMSESP::watch_id();
|
||||||
if ((trace_watch_id == WATCH_NONE) || (src == trace_watch_id) || (dest == trace_watch_id) || (type_id == trace_watch_id)) {
|
if ((trace_watch_id == WATCH_NONE) || (src == trace_watch_id) || (dest == trace_watch_id) || (type_id == trace_watch_id)) {
|
||||||
LOG_INFO(F("Rx: %s"), Helpers::data_to_hex(data, length).c_str());
|
LOG_NOTICE(F("Rx: %s"), Helpers::data_to_hex(data, length).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +471,7 @@ void TxService::send_telegram(const QueuedTxTelegram & tx_telegram) {
|
|||||||
#ifdef EMSESP_DEBUG
|
#ifdef EMSESP_DEBUG
|
||||||
// if watching in 'raw' mode
|
// if watching in 'raw' mode
|
||||||
if (EMSESP::watch() == 2) {
|
if (EMSESP::watch() == 2) {
|
||||||
LOG_INFO(F("[DEBUG] Tx: %s"), Helpers::data_to_hex(telegram_raw, length).c_str());
|
LOG_NOTICE(F("[DEBUG] Tx: %s"), Helpers::data_to_hex(telegram_raw, length).c_str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user