mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
formatting brackets
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
#ifdef ASYNCWEBSERVER_REGEX
|
||||
#define ASYNCWEBSERVER_REGEX_ATTRIBUTE
|
||||
#else
|
||||
#define ASYNCWEBSERVER_REGEX_ATTRIBUTE __attribute__(warning("ASYNCWEBSERVER_REGEX not defined"))
|
||||
#define ASYNCWEBSERVER_REGEX_ATTRIBUTE __attribute__((warning("ASYNCWEBSERVER_REGEX not defined")))
|
||||
#endif
|
||||
|
||||
#define DEBUGF(...) //Serial.printf(__VA_ARGS__)
|
||||
|
||||
@@ -123,12 +123,12 @@ void AnalogSensor::reload() {
|
||||
for (auto & sensor : sensors_) {
|
||||
sensor.ha_registered = false; // force HA configs to be re-created
|
||||
if (sensor.type() == AnalogType::ADC) {
|
||||
LOG_DEBUG(("Adding analog ADC sensor on GPIO%d"), sensor.gpio());
|
||||
LOG_DEBUG("Adding analog ADC sensor on GPIO%d", sensor.gpio());
|
||||
// analogSetPinAttenuation does not work with analogReadMilliVolts
|
||||
sensor.analog_ = 0; // initialize
|
||||
sensor.last_reading_ = 0;
|
||||
} else if (sensor.type() == AnalogType::COUNTER) {
|
||||
LOG_DEBUG(("Adding analog I/O Counter sensor on GPIO%d"), sensor.gpio());
|
||||
LOG_DEBUG("Adding analog I/O Counter sensor on GPIO%d", sensor.gpio());
|
||||
pinMode(sensor.gpio(), INPUT_PULLUP);
|
||||
#ifndef ARDUINO_LOLIN_C3_MINI
|
||||
if (sensor.gpio() == 25 || sensor.gpio() == 26) {
|
||||
@@ -139,7 +139,7 @@ void AnalogSensor::reload() {
|
||||
sensor.poll_ = digitalRead(sensor.gpio());
|
||||
publish_sensor(sensor);
|
||||
} else if (sensor.type() == AnalogType::TIMER || sensor.type() == AnalogType::RATE) {
|
||||
LOG_DEBUG(("Adding analog Timer/Rate sensor on GPIO%d"), sensor.gpio());
|
||||
LOG_DEBUG("Adding analog Timer/Rate sensor on GPIO%d", sensor.gpio());
|
||||
pinMode(sensor.gpio(), INPUT_PULLUP);
|
||||
sensor.polltime_ = uuid::get_uptime();
|
||||
sensor.last_polltime_ = uuid::get_uptime();
|
||||
@@ -148,7 +148,7 @@ void AnalogSensor::reload() {
|
||||
sensor.set_value(0);
|
||||
publish_sensor(sensor);
|
||||
} else if (sensor.type() == AnalogType::DIGITAL_IN) {
|
||||
LOG_DEBUG(("Adding analog Read sensor on GPIO%d"), sensor.gpio());
|
||||
LOG_DEBUG("Adding analog Read sensor on GPIO%d", sensor.gpio());
|
||||
pinMode(sensor.gpio(), INPUT_PULLUP);
|
||||
sensor.set_value(digitalRead(sensor.gpio())); // initial value
|
||||
sensor.set_uom(0); // no uom, just for safe measures
|
||||
@@ -156,7 +156,7 @@ void AnalogSensor::reload() {
|
||||
sensor.poll_ = digitalRead(sensor.gpio());
|
||||
publish_sensor(sensor);
|
||||
} else if (sensor.type() == AnalogType::DIGITAL_OUT) {
|
||||
LOG_DEBUG(("Adding analog Write sensor on GPIO%d"), sensor.gpio());
|
||||
LOG_DEBUG("Adding analog Write sensor on GPIO%d", sensor.gpio());
|
||||
pinMode(sensor.gpio(), OUTPUT);
|
||||
if (sensor.gpio() == 25 || sensor.gpio() == 26) {
|
||||
if (sensor.offset() > 255) {
|
||||
@@ -175,7 +175,7 @@ void AnalogSensor::reload() {
|
||||
sensor.set_uom(0); // no uom, just for safe measures
|
||||
publish_sensor(sensor);
|
||||
} else if (sensor.type() >= AnalogType::PWM_0) {
|
||||
LOG_DEBUG(("Adding PWM output sensor on GPIO%d"), sensor.gpio());
|
||||
LOG_DEBUG("Adding PWM output sensor on GPIO%d", sensor.gpio());
|
||||
uint channel = sensor.type() - AnalogType::PWM_0;
|
||||
ledcSetup(channel, sensor.factor(), 13);
|
||||
ledcAttachPin(sensor.gpio(), channel);
|
||||
@@ -277,7 +277,7 @@ bool AnalogSensor::update(uint8_t gpio, const std::string & name, float offset,
|
||||
found_sensor = true; // found the record
|
||||
// see if it's marked for deletion
|
||||
if (type == AnalogType::MARK_DELETED) {
|
||||
LOG_DEBUG(("Removing analog sensor GPIO %d"), gpio);
|
||||
LOG_DEBUG("Removing analog sensor GPIO %d", gpio);
|
||||
settings.analogCustomizations.remove(AnalogCustomization);
|
||||
} else {
|
||||
// update existing record
|
||||
@@ -286,7 +286,7 @@ bool AnalogSensor::update(uint8_t gpio, const std::string & name, float offset,
|
||||
AnalogCustomization.factor = factor;
|
||||
AnalogCustomization.uom = uom;
|
||||
AnalogCustomization.type = type;
|
||||
LOG_DEBUG(("Customizing existing analog GPIO %d"), gpio);
|
||||
LOG_DEBUG("Customizing existing analog GPIO %d", gpio);
|
||||
}
|
||||
return StateUpdateResult::CHANGED; // persist the change
|
||||
}
|
||||
@@ -312,7 +312,7 @@ bool AnalogSensor::update(uint8_t gpio, const std::string & name, float offset,
|
||||
newSensor.uom = uom;
|
||||
newSensor.type = type;
|
||||
settings.analogCustomizations.push_back(newSensor);
|
||||
LOG_DEBUG(("Adding new customization for analog sensor GPIO %d"), gpio);
|
||||
LOG_DEBUG("Adding new customization for analog sensor GPIO %d", gpio);
|
||||
return StateUpdateResult::CHANGED; // persist the change
|
||||
},
|
||||
"local");
|
||||
@@ -353,7 +353,7 @@ void AnalogSensor::remove_ha_topic(const uint8_t gpio) const {
|
||||
return;
|
||||
}
|
||||
#ifdef EMSESP_DEBUG
|
||||
LOG_DEBUG(("Removing HA config for analog sensor GPIO %d"), gpio);
|
||||
LOG_DEBUG("Removing HA config for analog sensor GPIO %d", gpio);
|
||||
#endif
|
||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||
snprintf(topic, sizeof(topic), "sensor/%s/analogsensor_%d/config", Mqtt::basename().c_str(), gpio);
|
||||
@@ -403,7 +403,7 @@ void AnalogSensor::publish_values(const bool force) {
|
||||
|
||||
// create HA config
|
||||
if (Mqtt::ha_enabled() && (!sensor.ha_registered || force)) {
|
||||
LOG_DEBUG(("Recreating HA config for analog sensor GPIO %d"), sensor.gpio());
|
||||
LOG_DEBUG("Recreating HA config for analog sensor GPIO %d", sensor.gpio());
|
||||
|
||||
StaticJsonDocument<EMSESP_JSON_SIZE_MEDIUM> config;
|
||||
|
||||
@@ -447,7 +447,7 @@ void AnalogSensor::publish_values(const bool force) {
|
||||
}
|
||||
}
|
||||
|
||||
Mqtt::publish(("analogsensor_data"), doc.as<JsonObject>());
|
||||
Mqtt::publish("analogsensor_data", doc.as<JsonObject>());
|
||||
}
|
||||
|
||||
// called from emsesp.cpp, similar to the emsdevice->get_value_info
|
||||
|
||||
@@ -82,7 +82,7 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
|
||||
// validate the device, make sure it exists
|
||||
uint8_t device_type = EMSdevice::device_name_2_device_type(device_s);
|
||||
if (!device_has_commands(device_type)) {
|
||||
LOG_DEBUG(("Command failed: unknown device '%s'"), device_s);
|
||||
LOG_DEBUG("Command failed: unknown device '%s'", device_s);
|
||||
return message(CommandRet::ERROR, "unknown device", output);
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
|
||||
if ((device_type > EMSdevice::DeviceType::SYSTEM) && (!value || !strlen(value))) {
|
||||
if (!cf || !cf->cmdfunction_json_) {
|
||||
#if defined(EMSESP_DEBUG)
|
||||
LOG_DEBUG(("[DEBUG] Calling %s command '%s' to retrieve attributes"), dname.c_str(), cmd);
|
||||
LOG_DEBUG("[DEBUG] Calling %s command '%s' to retrieve attributes", dname.c_str(), cmd);
|
||||
#endif
|
||||
return EMSESP::get_device_value_info(output, cmd, id, device_type) ? CommandRet::OK : CommandRet::ERROR; // entity = cmd
|
||||
}
|
||||
@@ -294,7 +294,7 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
|
||||
}
|
||||
|
||||
// we didn't find the command and its not an endpoint, report error
|
||||
LOG_DEBUG(("Command failed: invalid command '%s'"), cmd);
|
||||
LOG_DEBUG("Command failed: invalid command '%s'", cmd);
|
||||
return message(CommandRet::NOT_FOUND, "invalid command", output);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,10 +60,10 @@ void EMSESPShell::stopped() {
|
||||
void EMSESPShell::display_banner() {
|
||||
println();
|
||||
printfln("┌──────────────────────────────────────┐");
|
||||
printfln(("│ %sEMS-ESP version %-10s%s │"), COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_BOLD_OFF);
|
||||
printfln(("│ %s%shttps://github.com/emsesp/EMS-ESP32%s │"), COLOR_BRIGHT_GREEN, COLOR_UNDERLINE, COLOR_RESET);
|
||||
printfln("│ %sEMS-ESP version %-10s%s │", COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_BOLD_OFF);
|
||||
printfln("│ %s%shttps://github.com/emsesp/EMS-ESP32%s │", COLOR_BRIGHT_GREEN, COLOR_UNDERLINE, COLOR_RESET);
|
||||
printfln("│ │");
|
||||
printfln(("│ type %shelp%s to show available commands │"), COLOR_UNDERLINE, COLOR_RESET);
|
||||
printfln("│ type %shelp%s to show available commands │", COLOR_UNDERLINE, COLOR_RESET);
|
||||
printfln("└──────────────────────────────────────┘");
|
||||
println();
|
||||
|
||||
@@ -102,7 +102,7 @@ void EMSESPShell::add_console_commands() {
|
||||
CommandFlags::USER,
|
||||
string_vector{F_(show)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
|
||||
shell.printfln(("%s%sEMS-ESP version %s%s"), COLOR_BRIGHT_GREEN, COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_RESET);
|
||||
shell.printfln("%s%sEMS-ESP version %s%s", COLOR_BRIGHT_GREEN, COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_RESET);
|
||||
shell.println();
|
||||
EMSESP::show_device_values(shell);
|
||||
EMSESP::show_sensor_values(shell);
|
||||
@@ -225,7 +225,7 @@ void EMSESPShell::add_console_commands() {
|
||||
string_vector{F_(set)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
|
||||
EMSESP::webSettingsService.read([&](WebSettings & settings) {
|
||||
shell.printfln(("Language: %s"), settings.locale.c_str());
|
||||
shell.printfln("Language: %s", settings.locale.c_str());
|
||||
shell.printfln(F_(tx_mode_fmt), settings.tx_mode);
|
||||
shell.printfln(F_(bus_id_fmt), settings.ems_bus_id);
|
||||
shell.printfln(F_(board_profile_fmt), settings.board_profile.c_str());
|
||||
@@ -266,7 +266,7 @@ void EMSESPShell::add_console_commands() {
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
uint16_t value = Helpers::atoint(arguments.front().c_str());
|
||||
telnet_.initial_idle_timeout(value * 60);
|
||||
shell.printfln(("Telnet timeout set to %d minutes"), value);
|
||||
shell.printfln("Telnet timeout set to %d minutes", value);
|
||||
});
|
||||
#endif
|
||||
|
||||
@@ -331,9 +331,9 @@ void EMSESPShell::add_console_commands() {
|
||||
|
||||
watch_id = EMSESP::watch_id();
|
||||
if (watch_id > 0x80) {
|
||||
shell.printfln(("Filtering only telegrams that match a telegram type of 0x%02X"), watch_id);
|
||||
shell.printfln("Filtering only telegrams that match a telegram type of 0x%02X", watch_id);
|
||||
} else if (watch_id != WATCH_ID_NONE) {
|
||||
shell.printfln(("Filtering only telegrams that match a deviceID or telegram type of 0x%02X"), watch_id);
|
||||
shell.printfln("Filtering only telegrams that match a deviceID or telegram type of 0x%02X", watch_id);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -763,14 +763,14 @@ EMSESPStreamConsole::EMSESPStreamConsole(Stream & stream, const IPAddress & addr
|
||||
snprintf(text.data(), text.size(), "pty%u", (uint16_t)pty_);
|
||||
name_ = text.data();
|
||||
#ifndef EMSESP_STANDALONE
|
||||
logger().info(("Allocated console %s for connection from [%s]:%u"), name_.c_str(), uuid::printable_to_string(addr_).c_str(), port_);
|
||||
logger().info("Allocated console %s for connection from [%s]:%u", name_.c_str(), uuid::printable_to_string(addr_).c_str(), port_);
|
||||
#endif
|
||||
}
|
||||
|
||||
EMSESPStreamConsole::~EMSESPStreamConsole() {
|
||||
if (pty_ != SIZE_MAX) {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
logger().info(("Shutdown console %s for connection from [%s]:%u"), name_.c_str(), uuid::printable_to_string(addr_).c_str(), port_);
|
||||
logger().info("Shutdown console %s for connection from [%s]:%u", name_.c_str(), uuid::printable_to_string(addr_).c_str(), port_);
|
||||
#endif
|
||||
ptys_[pty_] = false;
|
||||
ptys_.shrink_to_fit();
|
||||
|
||||
@@ -181,12 +181,12 @@ void DallasSensor::loop() {
|
||||
|
||||
default:
|
||||
sensorfails_++;
|
||||
LOG_ERROR(("Unknown dallas sensor %s"), Sensor(addr).id().c_str());
|
||||
LOG_ERROR("Unknown dallas sensor %s", Sensor(addr).id().c_str());
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
sensorfails_++;
|
||||
LOG_ERROR(("Invalid dallas sensor %s"), Sensor(addr).id().c_str());
|
||||
LOG_ERROR("Invalid dallas sensor %s", Sensor(addr).id().c_str());
|
||||
}
|
||||
} else {
|
||||
if (!parasite_) {
|
||||
@@ -230,7 +230,7 @@ bool DallasSensor::temperature_convert_complete() {
|
||||
int16_t DallasSensor::get_temperature_c(const uint8_t addr[]) {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
if (!bus_.reset()) {
|
||||
LOG_ERROR(("Bus reset failed before reading scratchpad from %s"), Sensor(addr).id().c_str());
|
||||
LOG_ERROR("Bus reset failed before reading scratchpad from %s", Sensor(addr).id().c_str());
|
||||
return EMS_VALUE_SHORT_NOTSET;
|
||||
}
|
||||
YIELD;
|
||||
@@ -242,13 +242,13 @@ int16_t DallasSensor::get_temperature_c(const uint8_t addr[]) {
|
||||
YIELD;
|
||||
|
||||
if (!bus_.reset()) {
|
||||
LOG_ERROR(("Bus reset failed after reading scratchpad from %s"), Sensor(addr).id().c_str());
|
||||
LOG_ERROR("Bus reset failed after reading scratchpad from %s", Sensor(addr).id().c_str());
|
||||
return EMS_VALUE_SHORT_NOTSET;
|
||||
}
|
||||
YIELD;
|
||||
|
||||
if (bus_.crc8(scratchpad, SCRATCHPAD_LEN - 1) != scratchpad[SCRATCHPAD_LEN - 1]) {
|
||||
LOG_WARNING(("Invalid scratchpad CRC: %02X%02X%02X%02X%02X%02X%02X%02X%02X from sensor %s"),
|
||||
LOG_WARNING("Invalid scratchpad CRC: %02X%02X%02X%02X%02X%02X%02X%02X%02X from sensor %s",
|
||||
scratchpad[0],
|
||||
scratchpad[1],
|
||||
scratchpad[2],
|
||||
@@ -315,7 +315,7 @@ bool DallasSensor::update(const std::string & id, const std::string & name, int1
|
||||
SensorCustomization.name = name;
|
||||
SensorCustomization.offset = offset;
|
||||
found = true;
|
||||
LOG_DEBUG(("Customizing existing sensor ID %s"), id.c_str());
|
||||
LOG_DEBUG("Customizing existing sensor ID %s", id.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -325,7 +325,7 @@ bool DallasSensor::update(const std::string & id, const std::string & name, int1
|
||||
newSensor.name = name;
|
||||
newSensor.offset = offset;
|
||||
settings.sensorCustomizations.push_back(newSensor);
|
||||
LOG_DEBUG(("Adding new customization for sensor ID %s"), id.c_str());
|
||||
LOG_DEBUG("Adding new customization for sensor ID %s", id.c_str());
|
||||
}
|
||||
sensor.ha_registered = false; // it's changed so we may need to recreate the HA config
|
||||
return StateUpdateResult::CHANGED;
|
||||
@@ -441,7 +441,7 @@ void DallasSensor::remove_ha_topic(const std::string & id) {
|
||||
return;
|
||||
}
|
||||
#ifdef EMSESP_DEBUG
|
||||
LOG_DEBUG(("Removing HA config for temperature sensor ID %s"), id.c_str());
|
||||
LOG_DEBUG("Removing HA config for temperature sensor ID %s", id.c_str());
|
||||
#endif
|
||||
// use '_' as HA doesn't like '-' in the topic name
|
||||
std::string sensorid = id;
|
||||
@@ -483,7 +483,7 @@ void DallasSensor::publish_values(const bool force) {
|
||||
// to e.g. homeassistant/sensor/ems-esp/dallassensor_28-233D-9497-0C03/config
|
||||
if (Mqtt::ha_enabled()) {
|
||||
if (!sensor.ha_registered || force) {
|
||||
LOG_DEBUG(("Recreating HA config for sensor ID %s"), sensor.id().c_str());
|
||||
LOG_DEBUG("Recreating HA config for sensor ID %s", sensor.id().c_str());
|
||||
|
||||
StaticJsonDocument<EMSESP_JSON_SIZE_MEDIUM> config;
|
||||
config["dev_cla"] = "temperature";
|
||||
@@ -530,7 +530,7 @@ void DallasSensor::publish_values(const bool force) {
|
||||
}
|
||||
}
|
||||
|
||||
Mqtt::publish(("dallassensor_data"), doc.as<JsonObject>());
|
||||
Mqtt::publish("dallassensor_data", doc.as<JsonObject>());
|
||||
}
|
||||
|
||||
|
||||
@@ -574,7 +574,7 @@ bool DallasSensor::Sensor::apply_customization() {
|
||||
if (!sensors.empty()) {
|
||||
for (const auto & sensor : sensors) {
|
||||
#if defined(EMSESP_DEBUG)
|
||||
LOG_DEBUG(("Loading customization for dallas sensor %s"), sensor.id.c_str());
|
||||
LOG_DEBUG("Loading customization for dallas sensor %s", sensor.id.c_str());
|
||||
#endif
|
||||
if (id_ == sensor.id) {
|
||||
set_name(sensor.name);
|
||||
|
||||
@@ -2081,7 +2081,7 @@ bool Boiler::set_ww_circulation_mode(const char * value, const int8_t id) {
|
||||
}
|
||||
|
||||
if (v < 7) {
|
||||
// LOG_INFO(("Setting dhw circulation mode %dx3min"), v);
|
||||
// LOG_INFO("Setting dhw circulation mode %dx3min", v);
|
||||
} else if (v == 7) {
|
||||
// LOG_INFO("Setting dhw circulation mode continuous");
|
||||
} else {
|
||||
@@ -2142,11 +2142,11 @@ bool Boiler::set_maintenance(const char * value, const int8_t id) {
|
||||
uint8_t month = (value[3] - '0') * 10 + (value[4] - '0');
|
||||
uint8_t year = (uint8_t)(Helpers::atoint(&value[6]) - 2000);
|
||||
if (day > 0 && day < 32 && month > 0 && month < 13) {
|
||||
LOG_INFO(("Setting maintenance date to %02d.%02d.%04d"), day, month, year + 2000);
|
||||
LOG_INFO("Setting maintenance date to %02d.%02d.%04d", day, month, year + 2000);
|
||||
uint8_t data[5] = {2, (uint8_t)(maintenanceTime_ / 100), day, month, year};
|
||||
write_command(0x15, 0, data, 5, 0x15);
|
||||
} else {
|
||||
LOG_WARNING(("Setting maintenance: wrong format %d.%d.%d"), day, month, year + 2000);
|
||||
LOG_WARNING("Setting maintenance: wrong format %d.%d.%d", day, month, year + 2000);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -2155,7 +2155,7 @@ bool Boiler::set_maintenance(const char * value, const int8_t id) {
|
||||
int hrs;
|
||||
if (Helpers::value2number(value, hrs)) {
|
||||
if (hrs > 99 && hrs < 25600) {
|
||||
LOG_INFO(("Setting maintenance time %d hours"), hrs);
|
||||
LOG_INFO("Setting maintenance time %d hours", hrs);
|
||||
uint8_t data[2] = {1, (uint8_t)(hrs / 100)};
|
||||
write_command(0x15, 0, data, 2, 0x15);
|
||||
return true;
|
||||
@@ -2164,7 +2164,7 @@ bool Boiler::set_maintenance(const char * value, const int8_t id) {
|
||||
|
||||
uint8_t num;
|
||||
if (Helpers::value2enum(value, num, FL_(enum_off_time_date_manual))) {
|
||||
LOG_INFO(("Setting maintenance type to %s"), value);
|
||||
LOG_INFO("Setting maintenance type to %s", value);
|
||||
write_command(0x15, 0, num, 0x15);
|
||||
return true;
|
||||
}
|
||||
@@ -2177,7 +2177,7 @@ bool Boiler::set_maintenancetime(const char * value, const int8_t id) {
|
||||
int hrs;
|
||||
if (Helpers::value2number(value, hrs)) {
|
||||
if (hrs > 99 && hrs < 25600) {
|
||||
LOG_INFO(("Setting maintenance time %d hours"), hrs);
|
||||
LOG_INFO("Setting maintenance time %d hours", hrs);
|
||||
uint8_t data[2] = {1, (uint8_t)(hrs / 100)};
|
||||
write_command(0x15, 0, data, 2, 0x15);
|
||||
return true;
|
||||
@@ -2194,11 +2194,11 @@ bool Boiler::set_maintenancedate(const char * value, const int8_t id) {
|
||||
uint8_t month = (value[3] - '0') * 10 + (value[4] - '0');
|
||||
uint8_t year = (uint8_t)(Helpers::atoint(&value[6]) - 2000);
|
||||
if (day > 0 && day < 32 && month > 0 && month < 13) {
|
||||
LOG_INFO(("Setting maintenance date to %02d.%02d.%04d"), day, month, year + 2000);
|
||||
LOG_INFO("Setting maintenance date to %02d.%02d.%04d", day, month, year + 2000);
|
||||
uint8_t data[5] = {2, (uint8_t)(maintenanceTime_ / 100), day, month, year};
|
||||
write_command(0x15, 0, data, 5, 0x15);
|
||||
} else {
|
||||
LOG_WARNING(("Setting maintenance: wrong format %d.%d.%d"), day, month, year + 2000);
|
||||
LOG_WARNING("Setting maintenance: wrong format %d.%d.%d", day, month, year + 2000);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -2215,7 +2215,7 @@ bool Boiler::set_pool_temp(const char * value, const int8_t id) {
|
||||
return false;
|
||||
}
|
||||
uint8_t v2 = ((v * 2) + 0.5);
|
||||
// LOG_INFO(("Setting pool temperature to %d.%d C"), v2 >> 1, (v2 & 0x01) * 5);
|
||||
// LOG_INFO("Setting pool temperature to %d.%d C", v2 >> 1, (v2 & 0x01) * 5);
|
||||
write_command(0x48A, 1, v2, 0x48A);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -664,7 +664,7 @@ void Solar::process_SM100ParamCfg(std::shared_ptr<const Telegram> telegram) {
|
||||
telegram->read_value(max, 13);
|
||||
telegram->read_value(cur, 17);
|
||||
|
||||
// LOG_DEBUG(("SM100ParamCfg param=0x%04X, offset=%d, min=%d, default=%d, max=%d, current=%d"), t_id, of, min, def, max, cur));
|
||||
// LOG_DEBUG("SM100ParamCfg param=0x%04X, offset=%d, min=%d, default=%d, max=%d, current=%d", t_id, of, min, def, max, cur));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1548,7 +1548,7 @@ bool Thermostat::set_calinttemp(const char * value, const int8_t id) {
|
||||
}
|
||||
|
||||
auto t = (int8_t)(ct * 10);
|
||||
LOG_DEBUG(("Calibrating internal temperature to %d.%d C"), t / 10, t < 0 ? -t % 10 : t % 10);
|
||||
LOG_DEBUG("Calibrating internal temperature to %d.%d C", t / 10, t < 0 ? -t % 10 : t % 10);
|
||||
|
||||
if (model() == EMS_DEVICE_FLAG_RC10) {
|
||||
write_command(0xB0, 0, t, 0xB0);
|
||||
@@ -2157,11 +2157,11 @@ bool Thermostat::set_datetime(const char * value, const int8_t id) {
|
||||
return false;
|
||||
}
|
||||
if (data[1] == 0 || data[1] > 12 || data[2] > 23 || data[3] == 0 || data[3] > 31 || data[4] > 59 || data[5] > 59 || data[6] > 6 || data[7] > 3) {
|
||||
LOG_WARNING(("Invalid date/time: %02d.%02d.2%03d-%02d:%02d:%02d-%d-%d"), data[3], data[1], data[0], data[2], data[4], data[5], data[6], data[7]);
|
||||
LOG_WARNING("Invalid date/time: %02d.%02d.2%03d-%02d:%02d:%02d-%d-%d", data[3], data[1], data[0], data[2], data[4], data[5], data[6], data[7]);
|
||||
return false;
|
||||
}
|
||||
|
||||
// LOG_INFO(("Setting date and time: %02d.%02d.2%03d-%02d:%02d:%02d-%d-%d"), data[3], data[1], data[0], data[2], data[4], data[5], data[6], data[7]);
|
||||
// LOG_INFO("Setting date and time: %02d.%02d.2%03d-%02d:%02d:%02d-%d-%d", data[3], data[1], data[0], data[2], data[4], data[5], data[6], data[7]);
|
||||
write_command(EMS_TYPE_time, 0, data, 8, EMS_TYPE_time);
|
||||
|
||||
return true;
|
||||
@@ -2634,7 +2634,7 @@ bool Thermostat::set_switchtime(const char * value, const uint16_t type_id, char
|
||||
day = 7;
|
||||
on = 7;
|
||||
time = 0x90;
|
||||
// LOG_INFO(("switchtime %02d cleared"), no);
|
||||
// LOG_INFO("switchtime %02d cleared", no);
|
||||
}
|
||||
} else {
|
||||
if (strlen(value) > 1) {
|
||||
@@ -2675,7 +2675,7 @@ bool Thermostat::set_switchtime(const char * value, const uint16_t type_id, char
|
||||
day = 7;
|
||||
on = 7;
|
||||
time = 0x90;
|
||||
// LOG_INFO(("switchtime %02d cleared"), no);
|
||||
// LOG_INFO("switchtime %02d cleared", no);
|
||||
}
|
||||
}
|
||||
uint8_t data[2] = {0xE7, 0x90}; // unset switchtime
|
||||
@@ -2691,8 +2691,8 @@ bool Thermostat::set_switchtime(const char * value, const uint16_t type_id, char
|
||||
max_on = 1;
|
||||
}
|
||||
if (no > 41 || time > 0x90 || ((on < min_on || on > max_on) && on != 7)) {
|
||||
// LOG_WARNING(("Setting switchtime: Invalid data: %s"), value);
|
||||
// LOG_WARNING(("Setting switchtime: Invalid data: %02d.%1d.0x%02X.%1d"), no, day, time, on);
|
||||
// LOG_WARNING("Setting switchtime: Invalid data: %s", value);
|
||||
// LOG_WARNING("Setting switchtime: Invalid data: %02d.%1d.0x%02X.%1d", no, day, time, on);
|
||||
return false;
|
||||
}
|
||||
if (data[0] != 0xE7) {
|
||||
|
||||
@@ -215,7 +215,7 @@ std::string EMSdevice::to_string_short() const {
|
||||
|
||||
// for each telegram that has the fetch value set (true) do a read request
|
||||
void EMSdevice::fetch_values() {
|
||||
EMSESP::logger().debug(("Fetching values for deviceID 0x%02X"), device_id());
|
||||
EMSESP::logger().debug("Fetching values for deviceID 0x%02X", device_id());
|
||||
|
||||
for (const auto & tf : telegram_functions_) {
|
||||
if (tf.fetch_) {
|
||||
@@ -226,7 +226,7 @@ void EMSdevice::fetch_values() {
|
||||
|
||||
// toggle on/off automatic fetch for a telegramID
|
||||
void EMSdevice::toggle_fetch(uint16_t telegram_id, bool toggle) {
|
||||
EMSESP::logger().debug(("Toggling fetch for deviceID 0x%02X, telegramID 0x%02X to %d"), device_id(), telegram_id, toggle);
|
||||
EMSESP::logger().debug("Toggling fetch for deviceID 0x%02X, telegramID 0x%02X to %d", device_id(), telegram_id, toggle);
|
||||
|
||||
for (auto & tf : telegram_functions_) {
|
||||
if (tf.telegram_type_id_ == telegram_id) {
|
||||
@@ -289,7 +289,7 @@ void EMSdevice::show_telegram_handlers(uuid::console::Shell & shell) const {
|
||||
}
|
||||
/*
|
||||
// colored list of type-ids
|
||||
shell.printf((" This %s will listen to telegram type IDs: "), device_type_name().c_str());
|
||||
shell.printf(" This %s will listen to telegram type IDs: ", device_type_name().c_str());
|
||||
for (const auto & tf : telegram_functions_) {
|
||||
if (tf.received_ && !tf.fetch_) {
|
||||
shell.printf(COLOR_BRIGHT_GREEN);
|
||||
@@ -298,34 +298,34 @@ void EMSdevice::show_telegram_handlers(uuid::console::Shell & shell) const {
|
||||
} else {
|
||||
shell.printf(COLOR_BRIGHT_RED);
|
||||
}
|
||||
shell.printf(("0x%02X "), tf.telegram_type_id_);
|
||||
shell.printf("0x%02X ", tf.telegram_type_id_);
|
||||
}
|
||||
shell.printf(COLOR_RESET);
|
||||
*/
|
||||
shell.printf(" Received telegram type IDs: ");
|
||||
for (const auto & tf : telegram_functions_) {
|
||||
if (tf.received_ && !tf.fetch_) {
|
||||
shell.printf(("0x%02X "), tf.telegram_type_id_);
|
||||
shell.printf("0x%02X ", tf.telegram_type_id_);
|
||||
}
|
||||
}
|
||||
shell.println();
|
||||
shell.printf(" Fetched telegram type IDs: ");
|
||||
for (const auto & tf : telegram_functions_) {
|
||||
if (tf.fetch_) {
|
||||
shell.printf(("0x%02X "), tf.telegram_type_id_);
|
||||
shell.printf("0x%02X ", tf.telegram_type_id_);
|
||||
}
|
||||
}
|
||||
shell.println();
|
||||
shell.printf(" Pending telegram type IDs: ");
|
||||
for (const auto & tf : telegram_functions_) {
|
||||
if (!tf.received_ && !tf.fetch_) {
|
||||
shell.printf(("0x%02X "), tf.telegram_type_id_);
|
||||
shell.printf("0x%02X ", tf.telegram_type_id_);
|
||||
}
|
||||
}
|
||||
shell.println();
|
||||
shell.printf(" Ignored telegram type IDs: ");
|
||||
for (auto handlers : handlers_ignored_) {
|
||||
shell.printf(("0x%02X "), handlers);
|
||||
shell.printf("0x%02X ", handlers);
|
||||
}
|
||||
shell.println();
|
||||
}
|
||||
@@ -1183,7 +1183,7 @@ bool EMSdevice::get_value_info(JsonObject & output, const char * cmd, const int8
|
||||
// if we're filtering on an attribute, go find it
|
||||
if (attribute_s) {
|
||||
#if defined(EMSESP_DEBUG)
|
||||
EMSESP::logger().debug(("[DEBUG] Attribute '%s'"), attribute_s);
|
||||
EMSESP::logger().debug("[DEBUG] Attribute '%s'", attribute_s);
|
||||
#endif
|
||||
if (json.containsKey(attribute_s)) {
|
||||
JsonVariant data = json[attribute_s];
|
||||
|
||||
@@ -248,17 +248,17 @@ void EMSESP::show_ems(uuid::console::Shell & shell) {
|
||||
|
||||
if (bus_status() != BUS_STATUS_OFFLINE) {
|
||||
shell.printfln("EMS Bus info:");
|
||||
EMSESP::webSettingsService.read([&](WebSettings & settings) { shell.printfln((" Tx mode: %d"), settings.tx_mode); });
|
||||
shell.printfln((" Bus protocol: %s"), EMSbus::is_ht3() ? ("HT3") : ("Buderus"));
|
||||
shell.printfln((" #recognized EMS devices: %d"), EMSESP::emsdevices.size());
|
||||
shell.printfln((" #telegrams received: %d"), rxservice_.telegram_count());
|
||||
shell.printfln((" #read requests sent: %d"), txservice_.telegram_read_count());
|
||||
shell.printfln((" #write requests sent: %d"), txservice_.telegram_write_count());
|
||||
shell.printfln((" #incomplete telegrams: %d"), rxservice_.telegram_error_count());
|
||||
EMSESP::webSettingsService.read([&](WebSettings & settings) { shell.printfln(" Tx mode: %d", settings.tx_mode); });
|
||||
shell.printfln(" Bus protocol: %s", EMSbus::is_ht3() ? ("HT3") : ("Buderus"));
|
||||
shell.printfln(" #recognized EMS devices: %d", EMSESP::emsdevices.size());
|
||||
shell.printfln(" #telegrams received: %d", rxservice_.telegram_count());
|
||||
shell.printfln(" #read requests sent: %d", txservice_.telegram_read_count());
|
||||
shell.printfln(" #write requests sent: %d", txservice_.telegram_write_count());
|
||||
shell.printfln(" #incomplete telegrams: %d", rxservice_.telegram_error_count());
|
||||
shell.printfln((" #read fails (after %d retries): %d"), TxService::MAXIMUM_TX_RETRIES, txservice_.telegram_read_fail_count());
|
||||
shell.printfln((" #write fails (after %d retries): %d"), TxService::MAXIMUM_TX_RETRIES, txservice_.telegram_write_fail_count());
|
||||
shell.printfln((" Rx line quality: %d%%"), rxservice_.quality());
|
||||
shell.printfln((" Tx line quality: %d%%"), (txservice_.read_quality() + txservice_.read_quality()) / 2);
|
||||
shell.printfln(" Rx line quality: %d%%", rxservice_.quality());
|
||||
shell.printfln(" Tx line quality: %d%%", (txservice_.read_quality() + txservice_.read_quality()) / 2);
|
||||
shell.println();
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ void EMSESP::show_ems(uuid::console::Shell & shell) {
|
||||
} else {
|
||||
shell.printfln(("Rx Queue (%ld telegram%s):"), rx_telegrams.size(), rx_telegrams.size() == 1 ? "" : "s");
|
||||
for (const auto & it : rx_telegrams) {
|
||||
shell.printfln((" [%02d] %s"), it.id_, pretty_telegram(it.telegram_).c_str());
|
||||
shell.printfln(" [%02d] %s", it.id_, pretty_telegram(it.telegram_).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ void EMSESP::show_ems(uuid::console::Shell & shell) {
|
||||
} else if ((it.telegram_->operation) == Telegram::Operation::TX_WRITE) {
|
||||
op = "WRITE";
|
||||
}
|
||||
shell.printfln((" [%02d%c] %s %s"), it.id_, ((it.retry_) ? '*' : ' '), op.c_str(), pretty_telegram(it.telegram_).c_str());
|
||||
shell.printfln(" [%02d%c] %s %s", it.id_, ((it.retry_) ? '*' : ' '), op.c_str(), pretty_telegram(it.telegram_).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -725,7 +725,7 @@ void EMSESP::process_UBADevices(std::shared_ptr<const Telegram> telegram) {
|
||||
// if we haven't already detected this device, request it's version details, unless its us (EMS-ESP)
|
||||
// when the version info is received, it will automagically add the device
|
||||
if ((device_id != EMSbus::ems_bus_id()) && !(EMSESP::device_exists(device_id))) {
|
||||
LOG_DEBUG(("New EMS device detected with ID 0x%02X. Requesting version information."), device_id);
|
||||
LOG_DEBUG("New EMS device detected with ID 0x%02X. Requesting version information.", device_id);
|
||||
send_read_request(EMSdevice::EMS_TYPE_VERSION, device_id);
|
||||
}
|
||||
}
|
||||
@@ -785,7 +785,7 @@ void EMSESP::process_version(std::shared_ptr<const Telegram> telegram) {
|
||||
bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
|
||||
// if watching or reading...
|
||||
if ((telegram->type_id == read_id_) && (telegram->dest == txservice_.ems_bus_id())) {
|
||||
LOG_INFO(("%s"), pretty_telegram(telegram).c_str());
|
||||
LOG_INFO("%s", pretty_telegram(telegram).c_str());
|
||||
if (Mqtt::send_response()) {
|
||||
publish_response(telegram);
|
||||
}
|
||||
@@ -797,12 +797,12 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
|
||||
} else if (watch() == WATCH_ON) {
|
||||
if ((watch_id_ == WATCH_ID_NONE) || (telegram->type_id == watch_id_)
|
||||
|| ((watch_id_ < 0x80) && ((telegram->src == watch_id_) || (telegram->dest == watch_id_)))) {
|
||||
LOG_NOTICE(("%s"), pretty_telegram(telegram).c_str());
|
||||
LOG_NOTICE("%s", pretty_telegram(telegram).c_str());
|
||||
} else if (!trace_raw_) {
|
||||
LOG_TRACE(("%s"), pretty_telegram(telegram).c_str());
|
||||
LOG_TRACE("%s", pretty_telegram(telegram).c_str());
|
||||
}
|
||||
} else if (!trace_raw_) {
|
||||
LOG_TRACE(("%s"), pretty_telegram(telegram).c_str());
|
||||
LOG_TRACE("%s", pretty_telegram(telegram).c_str());
|
||||
}
|
||||
|
||||
// only process broadcast telegrams or ones sent to us on request
|
||||
@@ -860,7 +860,7 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
|
||||
if (!found) {
|
||||
LOG_DEBUG(("No telegram type handler found for ID 0x%02X (src 0x%02X)"), telegram->type_id, telegram->src);
|
||||
if (watch() == WATCH_UNKNOWN) {
|
||||
LOG_NOTICE(("%s"), pretty_telegram(telegram).c_str());
|
||||
LOG_NOTICE("%s", pretty_telegram(telegram).c_str());
|
||||
}
|
||||
if (!wait_km_ && !knowndevice && (telegram->src != EMSbus::ems_bus_id()) && (telegram->message_length > 0)) {
|
||||
send_read_request(EMSdevice::EMS_TYPE_VERSION, telegram->src);
|
||||
@@ -905,7 +905,7 @@ void EMSESP::show_devices(uuid::console::Shell & shell) {
|
||||
for (const auto & device_class : EMSFactory::device_handlers()) {
|
||||
for (const auto & emsdevice : emsdevices) {
|
||||
if (emsdevice && (emsdevice->device_type() == device_class.first)) {
|
||||
shell.printf(("%s: %s"), emsdevice->device_type_name().c_str(), emsdevice->to_string().c_str());
|
||||
shell.printf("%s: %s", emsdevice->device_type_name().c_str(), emsdevice->to_string().c_str());
|
||||
shell.println();
|
||||
emsdevice->show_telegram_handlers(shell);
|
||||
|
||||
@@ -932,7 +932,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
|
||||
if (product_id == 0) { // update only with valid product_id
|
||||
return true;
|
||||
}
|
||||
LOG_DEBUG(("Updating details for already active deviceID 0x%02X"), device_id);
|
||||
LOG_DEBUG("Updating details for already active deviceID 0x%02X", device_id);
|
||||
emsdevice->product_id(product_id);
|
||||
emsdevice->version(version);
|
||||
// only set brand if it doesn't already exist
|
||||
@@ -1039,7 +1039,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
|
||||
fetch_device_values(device_id); // go and fetch its data
|
||||
|
||||
// Print to LOG showing we've added a new device
|
||||
LOG_INFO(("Recognized new %s with deviceID 0x%02X"), EMSdevice::device_type_2_device_name(device_type).c_str(), device_id);
|
||||
LOG_INFO("Recognized new %s with deviceID 0x%02X", EMSdevice::device_type_2_device_name(device_type).c_str(), device_id);
|
||||
|
||||
// add command commands for all devices, except for connect, controller and gateway
|
||||
if ((device_type == DeviceType::CONNECT) || (device_type == DeviceType::CONTROLLER) || (device_type == DeviceType::GATEWAY)) {
|
||||
@@ -1174,7 +1174,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
|
||||
Roomctrl::check((data[1] ^ 0x80 ^ rxservice_.ems_mask()), data);
|
||||
#ifdef EMSESP_UART_DEBUG
|
||||
// get_uptime is only updated once per loop, does not give the right time
|
||||
LOG_TRACE(("[UART_DEBUG] Echo after %d ms: %s"), ::millis() - rx_time_, Helpers::data_to_hex(data, length).c_str());
|
||||
LOG_TRACE("[UART_DEBUG] Echo after %d ms: %s", ::millis() - rx_time_, Helpers::data_to_hex(data, length).c_str());
|
||||
#endif
|
||||
// add to RxQueue for log/watch
|
||||
rxservice_.add(data, length);
|
||||
@@ -1248,11 +1248,11 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
|
||||
#ifdef EMSESP_UART_DEBUG
|
||||
char s[4];
|
||||
if (first_value & 0x80) {
|
||||
LOG_TRACE(("[UART_DEBUG] next Poll %s after %d ms"), Helpers::hextoa(s, first_value), ::millis() - rx_time_);
|
||||
LOG_TRACE("[UART_DEBUG] next Poll %s after %d ms", Helpers::hextoa(s, first_value), ::millis() - rx_time_);
|
||||
// time measurement starts here, use millis because get_uptime is only updated once per loop
|
||||
rx_time_ = ::millis();
|
||||
} else {
|
||||
LOG_TRACE(("[UART_DEBUG] Poll ack %s after %d ms"), Helpers::hextoa(s, first_value), ::millis() - rx_time_);
|
||||
LOG_TRACE("[UART_DEBUG] Poll ack %s after %d ms", Helpers::hextoa(s, first_value), ::millis() - rx_time_);
|
||||
}
|
||||
#endif
|
||||
// check for poll to us, if so send top message from Tx queue immediately and quit
|
||||
@@ -1264,7 +1264,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
|
||||
return;
|
||||
} else {
|
||||
#ifdef EMSESP_UART_DEBUG
|
||||
LOG_TRACE(("[UART_DEBUG] Reply after %d ms: %s"), ::millis() - rx_time_, Helpers::data_to_hex(data, length).c_str());
|
||||
LOG_TRACE("[UART_DEBUG] Reply after %d ms: %s", ::millis() - rx_time_, Helpers::data_to_hex(data, length).c_str());
|
||||
#endif
|
||||
Roomctrl::check((data[1] ^ 0x80 ^ rxservice_.ems_mask()), data); // check if there is a message for the roomcontroller
|
||||
|
||||
@@ -1292,7 +1292,7 @@ void EMSESP::start() {
|
||||
LOG_NOTICE("System is running in Debug mode");
|
||||
#endif
|
||||
|
||||
LOG_INFO(("Last system reset reason Core0: %s, Core1: %s"), system_.reset_reason(0).c_str(), system_.reset_reason(1).c_str());
|
||||
LOG_INFO("Last system reset reason Core0: %s, Core1: %s", system_.reset_reason(0).c_str(), system_.reset_reason(1).c_str());
|
||||
|
||||
// do any system upgrades
|
||||
if (system_.check_upgrade()) {
|
||||
|
||||
44
src/mqtt.cpp
44
src/mqtt.cpp
@@ -186,15 +186,15 @@ void Mqtt::loop() {
|
||||
|
||||
// print MQTT log and other stuff to console
|
||||
void Mqtt::show_mqtt(uuid::console::Shell & shell) {
|
||||
shell.printfln(("MQTT is %s"), connected() ? F_(connected) : F_(disconnected));
|
||||
shell.printfln("MQTT is %s", connected() ? F_(connected) : F_(disconnected));
|
||||
|
||||
shell.printfln(("MQTT publish errors: %lu"), mqtt_publish_fails_);
|
||||
shell.printfln("MQTT publish errors: %lu", mqtt_publish_fails_);
|
||||
shell.println();
|
||||
|
||||
// show subscriptions
|
||||
shell.printfln("MQTT topic subscriptions:");
|
||||
for (const auto & mqtt_subfunction : mqtt_subfunctions_) {
|
||||
shell.printfln((" %s/%s"), mqtt_base_.c_str(), mqtt_subfunction.topic_.c_str());
|
||||
shell.printfln(" %s/%s", mqtt_base_.c_str(), mqtt_subfunction.topic_.c_str());
|
||||
}
|
||||
shell.println();
|
||||
|
||||
@@ -266,14 +266,14 @@ void Mqtt::on_message(const char * topic, const char * payload, size_t len) cons
|
||||
if (len) {
|
||||
LOG_DEBUG(("Received topic `%s` => payload `%s` (length %d)"), topic, message, len);
|
||||
} else {
|
||||
LOG_DEBUG(("Received topic `%s`"), topic);
|
||||
LOG_DEBUG("Received topic `%s`", topic);
|
||||
}
|
||||
#endif
|
||||
// remove HA topics if we don't use discovery
|
||||
if (strncmp(topic, discovery_prefix().c_str(), discovery_prefix().size()) == 0) {
|
||||
if (!ha_enabled_ && len) { // don't ping pong the empty message
|
||||
queue_publish_message(topic, "", true);
|
||||
LOG_DEBUG(("Remove topic %s"), topic);
|
||||
LOG_DEBUG("Remove topic %s", topic);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -285,7 +285,7 @@ void Mqtt::on_message(const char * topic, const char * payload, size_t len) cons
|
||||
snprintf(full_topic, sizeof(full_topic), "%s/%s", mqtt_base_.c_str(), mf.topic_.c_str());
|
||||
if ((!strcmp(topic, full_topic)) && (mf.mqtt_subfunction_)) {
|
||||
if (!(mf.mqtt_subfunction_)(message)) {
|
||||
LOG_ERROR(("error: invalid payload %s for this topic %s"), message, topic);
|
||||
LOG_ERROR("error: invalid payload %s for this topic %s", message, topic);
|
||||
if (send_response_) {
|
||||
Mqtt::publish(F_(response), "error: invalid data");
|
||||
}
|
||||
@@ -344,7 +344,7 @@ void Mqtt::show_topic_handlers(uuid::console::Shell & shell, const uint8_t devic
|
||||
// shell.print(" Subscribed MQTT topics: ");
|
||||
// for (const auto & mqtt_subfunction : mqtt_subfunctions_) {
|
||||
// if (mqtt_subfunction.device_type_ == device_type) {
|
||||
// shell.printf(("%s "), mqtt_subfunction.topic_.c_str());
|
||||
// shell.printf("%s ", mqtt_subfunction.topic_.c_str());
|
||||
// }
|
||||
// }
|
||||
shell.println();
|
||||
@@ -358,7 +358,7 @@ void Mqtt::on_publish(uint16_t packetId) const {
|
||||
// find the MQTT message in the queue and remove it
|
||||
if (mqtt_messages_.empty()) {
|
||||
#if defined(EMSESP_DEBUG)
|
||||
LOG_DEBUG(("[DEBUG] No message stored for ACK pid %d"), packetId);
|
||||
LOG_DEBUG("[DEBUG] No message stored for ACK pid %d", packetId);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@@ -374,12 +374,12 @@ void Mqtt::on_publish(uint16_t packetId) const {
|
||||
}
|
||||
|
||||
if (mqtt_message.packet_id_ != packetId) {
|
||||
LOG_ERROR(("Mismatch, expecting PID %d, got %d"), mqtt_message.packet_id_, packetId);
|
||||
LOG_ERROR("Mismatch, expecting PID %d, got %d", mqtt_message.packet_id_, packetId);
|
||||
mqtt_publish_fails_++; // increment error count
|
||||
}
|
||||
|
||||
#if defined(EMSESP_DEBUG)
|
||||
LOG_DEBUG(("[DEBUG] ACK pid %d"), packetId);
|
||||
LOG_DEBUG("[DEBUG] ACK pid %d", packetId);
|
||||
#endif
|
||||
|
||||
mqtt_messages_.pop_front(); // always remove from queue, regardless if there was a successful ACK
|
||||
@@ -460,7 +460,7 @@ void Mqtt::start() {
|
||||
} else if (reason == AsyncMqttClientDisconnectReason::MQTT_NOT_AUTHORIZED) {
|
||||
LOG_WARNING("MQTT disconnected: Not authorized");
|
||||
} else {
|
||||
LOG_WARNING(("MQTT disconnected: code %d"), reason);
|
||||
LOG_WARNING("MQTT disconnected: code %d", reason);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -767,7 +767,7 @@ void Mqtt::publish_ha(const std::string & topic) {
|
||||
|
||||
std::string fulltopic = Mqtt::discovery_prefix() + topic;
|
||||
#if defined(EMSESP_DEBUG)
|
||||
LOG_DEBUG(("[DEBUG] Publishing empty HA topic=%s"), fulltopic.c_str());
|
||||
LOG_DEBUG("[DEBUG] Publishing empty HA topic=%s", fulltopic.c_str());
|
||||
#endif
|
||||
|
||||
queue_publish_message(fulltopic, "", true); // publish with retain to remove from broker
|
||||
@@ -785,9 +785,9 @@ void Mqtt::publish_ha(const std::string & topic, const JsonObject & payload) {
|
||||
|
||||
std::string fulltopic = Mqtt::discovery_prefix() + topic;
|
||||
#if defined(EMSESP_STANDALONE)
|
||||
LOG_DEBUG(("Publishing HA topic=%s, payload=%s"), fulltopic.c_str(), payload_text.c_str());
|
||||
LOG_DEBUG("Publishing HA topic=%s, payload=%s", fulltopic.c_str(), payload_text.c_str());
|
||||
#elif defined(EMSESP_DEBUG)
|
||||
LOG_DEBUG(("[debug] Publishing HA topic=%s, payload=%s"), fulltopic.c_str(), payload_text.c_str());
|
||||
LOG_DEBUG("[debug] Publishing HA topic=%s, payload=%s", fulltopic.c_str(), payload_text.c_str());
|
||||
#endif
|
||||
|
||||
// queue messages if the MQTT connection is not yet established. to ensure we don't miss messages
|
||||
@@ -827,13 +827,13 @@ void Mqtt::process_queue() {
|
||||
|
||||
// if we're subscribing...
|
||||
if (message->operation == Operation::SUBSCRIBE) {
|
||||
LOG_DEBUG(("Subscribing to topic '%s'"), topic);
|
||||
LOG_DEBUG("Subscribing to topic '%s'", topic);
|
||||
uint16_t packet_id = mqttClient_->subscribe(topic, mqtt_qos_);
|
||||
if (!packet_id) {
|
||||
if (++mqtt_messages_.front().retry_count_ < MQTT_PUBLISH_MAX_RETRY) {
|
||||
return;
|
||||
}
|
||||
LOG_ERROR(("Error subscribing to topic '%s'"), topic);
|
||||
LOG_ERROR("Error subscribing to topic '%s'", topic);
|
||||
mqtt_publish_fails_++; // increment failure counter
|
||||
}
|
||||
|
||||
@@ -844,13 +844,13 @@ void Mqtt::process_queue() {
|
||||
|
||||
// if we're unsubscribing...
|
||||
if (message->operation == Operation::UNSUBSCRIBE) {
|
||||
LOG_DEBUG(("Subscribing to topic '%s'"), topic);
|
||||
LOG_DEBUG("Subscribing to topic '%s'", topic);
|
||||
uint16_t packet_id = mqttClient_->unsubscribe(topic);
|
||||
if (!packet_id) {
|
||||
if (++mqtt_messages_.front().retry_count_ < MQTT_PUBLISH_MAX_RETRY) {
|
||||
return;
|
||||
}
|
||||
LOG_ERROR(("Error unsubscribing to topic '%s'"), topic);
|
||||
LOG_ERROR("Error unsubscribing to topic '%s'", topic);
|
||||
mqtt_publish_fails_++; // increment failure counter
|
||||
}
|
||||
|
||||
@@ -872,14 +872,14 @@ void Mqtt::process_queue() {
|
||||
if (packet_id == 0) {
|
||||
// it failed. if we retried n times, give up. remove from queue
|
||||
if (mqtt_message.retry_count_ == (MQTT_PUBLISH_MAX_RETRY - 1)) {
|
||||
LOG_ERROR(("Failed to publish to %s after %d attempts"), topic, mqtt_message.retry_count_ + 1);
|
||||
LOG_ERROR("Failed to publish to %s after %d attempts", topic, mqtt_message.retry_count_ + 1);
|
||||
mqtt_publish_fails_++; // increment failure counter
|
||||
mqtt_messages_.pop_front(); // delete
|
||||
return;
|
||||
} else {
|
||||
// update the record
|
||||
mqtt_messages_.front().retry_count_++;
|
||||
LOG_DEBUG(("Failed to publish to %s. Trying again, #%d"), topic, mqtt_message.retry_count_ + 1);
|
||||
LOG_DEBUG("Failed to publish to %s. Trying again, #%d", topic, mqtt_message.retry_count_ + 1);
|
||||
return; // leave on queue for next time so it gets republished
|
||||
}
|
||||
}
|
||||
@@ -889,7 +889,7 @@ void Mqtt::process_queue() {
|
||||
if (mqtt_qos_ != 0) {
|
||||
mqtt_messages_.front().packet_id_ = packet_id;
|
||||
#if defined(EMSESP_DEBUG)
|
||||
LOG_DEBUG(("[DEBUG] Setting packetID for ACK to %d"), packet_id);
|
||||
LOG_DEBUG("[DEBUG] Setting packetID for ACK to %d", packet_id);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@@ -1036,7 +1036,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdevice
|
||||
// if we're asking to remove this topic, send an empty payload and exit
|
||||
// https://github.com/emsesp/EMS-ESP32/issues/196
|
||||
if (remove) {
|
||||
LOG_DEBUG(("Removing HA config for %s"), uniq);
|
||||
LOG_DEBUG("Removing HA config for %s", uniq);
|
||||
publish_ha(topic);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ void Shower::loop() {
|
||||
char s[50];
|
||||
snprintf(s, 50, "%d minutes and %d seconds", (uint8_t)(duration_ / 60000), (uint8_t)((duration_ / 1000) % 60));
|
||||
doc["duration"] = s;
|
||||
Mqtt::publish(("shower_data"), doc.as<JsonObject>());
|
||||
LOG_DEBUG(("[Shower] finished with duration %d"), duration_);
|
||||
Mqtt::publish("shower_data", doc.as<JsonObject>());
|
||||
LOG_DEBUG("[Shower] finished with duration %d", duration_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ void Shower::set_shower_state(bool state, bool force) {
|
||||
|
||||
// always publish as a string
|
||||
char s[7];
|
||||
Mqtt::publish(("shower_active"), Helpers::render_boolean(s, shower_state_)); // https://github.com/emsesp/EMS-ESP/issues/369
|
||||
Mqtt::publish("shower_active", Helpers::render_boolean(s, shower_state_)); // https://github.com/emsesp/EMS-ESP/issues/369
|
||||
|
||||
// send out HA MQTT Discovery config topic
|
||||
if ((Mqtt::ha_enabled()) && (!ha_configdone_ || force)) {
|
||||
|
||||
@@ -166,9 +166,9 @@ bool System::command_watch(const char * value, const int8_t id) {
|
||||
}
|
||||
if (Mqtt::publish_single() && w != EMSESP::watch()) {
|
||||
if (Mqtt::publish_single2cmd()) {
|
||||
Mqtt::publish(("system/watch"), EMSESP::system_.enum_format() == ENUM_FORMAT_INDEX ? Helpers::itoa(w) : (FL_(list_watch)[w]));
|
||||
Mqtt::publish("system/watch", EMSESP::system_.enum_format() == ENUM_FORMAT_INDEX ? Helpers::itoa(w) : (FL_(list_watch)[w]));
|
||||
} else {
|
||||
Mqtt::publish(("system_data/watch"), EMSESP::system_.enum_format() == ENUM_FORMAT_INDEX ? Helpers::itoa(w) : (FL_(list_watch)[w]));
|
||||
Mqtt::publish("system_data/watch", EMSESP::system_.enum_format() == ENUM_FORMAT_INDEX ? Helpers::itoa(w) : (FL_(list_watch)[w]));
|
||||
}
|
||||
}
|
||||
EMSESP::watch(w);
|
||||
@@ -176,9 +176,9 @@ bool System::command_watch(const char * value, const int8_t id) {
|
||||
} else if (i) {
|
||||
if (Mqtt::publish_single() && i != EMSESP::watch_id()) {
|
||||
if (Mqtt::publish_single2cmd()) {
|
||||
Mqtt::publish(("system/watch"), Helpers::hextoa(i));
|
||||
Mqtt::publish("system/watch", Helpers::hextoa(i));
|
||||
} else {
|
||||
Mqtt::publish(("system_data/watch"), Helpers::hextoa(i));
|
||||
Mqtt::publish("system_data/watch", Helpers::hextoa(i));
|
||||
}
|
||||
}
|
||||
EMSESP::watch_id(i);
|
||||
@@ -263,21 +263,21 @@ void System::syslog_init() {
|
||||
|
||||
if (Mqtt::publish_single()) {
|
||||
if (Mqtt::publish_single2cmd()) {
|
||||
Mqtt::publish(("system/syslog"), syslog_enabled_ ? (FL_(list_syslog_level)[syslog_level_ + 1]) : "off");
|
||||
Mqtt::publish("system/syslog", syslog_enabled_ ? (FL_(list_syslog_level)[syslog_level_ + 1]) : "off");
|
||||
if (EMSESP::watch_id() == 0 || EMSESP::watch() == 0) {
|
||||
Mqtt::publish(("system/watch"),
|
||||
Mqtt::publish("system/watch",
|
||||
EMSESP::system_.enum_format() == ENUM_FORMAT_INDEX ? Helpers::itoa(EMSESP::watch()) : (FL_(list_watch)[EMSESP::watch()]));
|
||||
} else {
|
||||
Mqtt::publish(("system/watch"), Helpers::hextoa(EMSESP::watch_id()));
|
||||
Mqtt::publish("system/watch", Helpers::hextoa(EMSESP::watch_id()));
|
||||
}
|
||||
|
||||
} else {
|
||||
Mqtt::publish(("system_data/syslog"), syslog_enabled_ ? (FL_(list_syslog_level)[syslog_level_ + 1]) : "off");
|
||||
Mqtt::publish("system_data/syslog", syslog_enabled_ ? (FL_(list_syslog_level)[syslog_level_ + 1]) : "off");
|
||||
if (EMSESP::watch_id() == 0 || EMSESP::watch() == 0) {
|
||||
Mqtt::publish(("system_data/watch"),
|
||||
Mqtt::publish("system_data/watch",
|
||||
EMSESP::system_.enum_format() == ENUM_FORMAT_INDEX ? Helpers::itoa(EMSESP::watch()) : (FL_(list_watch)[EMSESP::watch()]));
|
||||
} else {
|
||||
Mqtt::publish(("system_data/watch"), Helpers::hextoa(EMSESP::watch_id()));
|
||||
Mqtt::publish("system_data/watch", Helpers::hextoa(EMSESP::watch_id()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,7 +344,7 @@ void System::wifi_tweak() {
|
||||
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);
|
||||
LOG_DEBUG("[DEBUG] Adjusting WiFi - Tx power %d->%d, Sleep %d->%d", p1, p2, s1, s2);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -777,7 +777,7 @@ void System::show_users(uuid::console::Shell & shell) {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
EMSESP::esp8266React.getSecuritySettingsService()->read([&](SecuritySettings & securitySettings) {
|
||||
for (const User & user : securitySettings.users) {
|
||||
shell.printfln((" username: %s, password: %s, is_admin: %s"), user.username.c_str(), user.password.c_str(), user.admin ? ("yes") : ("no"));
|
||||
shell.printfln(" username: %s, password: %s, is_admin: %s", user.username.c_str(), user.password.c_str(), user.admin ? ("yes") : ("no"));
|
||||
}
|
||||
});
|
||||
#endif
|
||||
@@ -787,15 +787,15 @@ void System::show_users(uuid::console::Shell & shell) {
|
||||
|
||||
void System::show_system(uuid::console::Shell & shell) {
|
||||
shell.println("System:");
|
||||
shell.printfln((" Board profile: %s"), board_profile().c_str());
|
||||
shell.printfln((" Uptime: %s"), uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3).c_str());
|
||||
shell.printfln(" Board profile: %s", board_profile().c_str());
|
||||
shell.printfln(" Uptime: %s", uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3).c_str());
|
||||
#ifndef EMSESP_STANDALONE
|
||||
shell.printfln((" SDK version: %s"), ESP.getSdkVersion());
|
||||
shell.printfln((" CPU frequency: %lu MHz"), ESP.getCpuFreqMHz());
|
||||
shell.printfln((" Free heap: %lu KB"), (uint32_t)ESP.getFreeHeap() / 1024);
|
||||
shell.printfln((" App used/free: %lu KB / %lu KB"), appUsed(), appFree());
|
||||
shell.printfln(" SDK version: %s", ESP.getSdkVersion());
|
||||
shell.printfln(" CPU frequency: %lu MHz", ESP.getCpuFreqMHz());
|
||||
shell.printfln(" Free heap: %lu KB", (uint32_t)ESP.getFreeHeap() / 1024);
|
||||
shell.printfln(" App used/free: %lu KB / %lu KB", appUsed(), appFree());
|
||||
uint32_t FSused = LittleFS.usedBytes() / 1024;
|
||||
shell.printfln((" FS used/free: %lu KB / %lu KB"), FSused, FStotal() - FSused);
|
||||
shell.printfln(" FS used/free: %lu KB / %lu KB", FSused, FStotal() - FSused);
|
||||
shell.println();
|
||||
|
||||
shell.println("Network:");
|
||||
@@ -814,16 +814,16 @@ void System::show_system(uuid::console::Shell & shell) {
|
||||
|
||||
case WL_CONNECTED:
|
||||
shell.printfln(" Network: connected");
|
||||
shell.printfln((" SSID: %s"), WiFi.SSID().c_str());
|
||||
shell.printfln((" BSSID: %s"), WiFi.BSSIDstr().c_str());
|
||||
shell.printfln(" SSID: %s", WiFi.SSID().c_str());
|
||||
shell.printfln(" BSSID: %s", WiFi.BSSIDstr().c_str());
|
||||
shell.printfln((" RSSI: %d dBm (%d %%)"), WiFi.RSSI(), wifi_quality(WiFi.RSSI()));
|
||||
shell.printfln((" MAC address: %s"), WiFi.macAddress().c_str());
|
||||
shell.printfln((" Hostname: %s"), WiFi.getHostname());
|
||||
shell.printfln((" IPv4 address: %s/%s"), uuid::printable_to_string(WiFi.localIP()).c_str(), uuid::printable_to_string(WiFi.subnetMask()).c_str());
|
||||
shell.printfln((" IPv4 gateway: %s"), uuid::printable_to_string(WiFi.gatewayIP()).c_str());
|
||||
shell.printfln((" IPv4 nameserver: %s"), uuid::printable_to_string(WiFi.dnsIP()).c_str());
|
||||
shell.printfln(" MAC address: %s", WiFi.macAddress().c_str());
|
||||
shell.printfln(" Hostname: %s", WiFi.getHostname());
|
||||
shell.printfln(" IPv4 address: %s/%s", uuid::printable_to_string(WiFi.localIP()).c_str(), uuid::printable_to_string(WiFi.subnetMask()).c_str());
|
||||
shell.printfln(" IPv4 gateway: %s", uuid::printable_to_string(WiFi.gatewayIP()).c_str());
|
||||
shell.printfln(" IPv4 nameserver: %s", uuid::printable_to_string(WiFi.dnsIP()).c_str());
|
||||
if (WiFi.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
||||
shell.printfln((" IPv6 address: %s"), uuid::printable_to_string(WiFi.localIPv6()).c_str());
|
||||
shell.printfln(" IPv6 address: %s", uuid::printable_to_string(WiFi.localIPv6()).c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -849,13 +849,13 @@ void System::show_system(uuid::console::Shell & shell) {
|
||||
if (ethernet_connected_) {
|
||||
shell.println();
|
||||
shell.printfln(" Ethernet Network: connected");
|
||||
shell.printfln((" MAC address: %s"), ETH.macAddress().c_str());
|
||||
shell.printfln((" Hostname: %s"), ETH.getHostname());
|
||||
shell.printfln((" IPv4 address: %s/%s"), uuid::printable_to_string(ETH.localIP()).c_str(), uuid::printable_to_string(ETH.subnetMask()).c_str());
|
||||
shell.printfln((" IPv4 gateway: %s"), uuid::printable_to_string(ETH.gatewayIP()).c_str());
|
||||
shell.printfln((" IPv4 nameserver: %s"), uuid::printable_to_string(ETH.dnsIP()).c_str());
|
||||
shell.printfln(" MAC address: %s", ETH.macAddress().c_str());
|
||||
shell.printfln(" Hostname: %s", ETH.getHostname());
|
||||
shell.printfln(" IPv4 address: %s/%s", uuid::printable_to_string(ETH.localIP()).c_str(), uuid::printable_to_string(ETH.subnetMask()).c_str());
|
||||
shell.printfln(" IPv4 gateway: %s", uuid::printable_to_string(ETH.gatewayIP()).c_str());
|
||||
shell.printfln(" IPv4 nameserver: %s", uuid::printable_to_string(ETH.dnsIP()).c_str());
|
||||
if (ETH.localIPv6().toString() != "0000:0000:0000:0000:0000:0000:0000:0000") {
|
||||
shell.printfln((" IPv6 address: %s"), uuid::printable_to_string(ETH.localIPv6()).c_str());
|
||||
shell.printfln(" IPv6 address: %s", uuid::printable_to_string(ETH.localIPv6()).c_str());
|
||||
}
|
||||
}
|
||||
shell.println();
|
||||
@@ -864,17 +864,17 @@ void System::show_system(uuid::console::Shell & shell) {
|
||||
if (!syslog_enabled_) {
|
||||
shell.printfln(" Syslog: disabled");
|
||||
} else {
|
||||
shell.printfln((" Syslog: %s"), syslog_.started() ? "started" : "stopped");
|
||||
shell.printfln(" Syslog: %s", syslog_.started() ? "started" : "stopped");
|
||||
shell.print(" ");
|
||||
shell.printfln(F_(host_fmt), !syslog_host_.isEmpty() ? syslog_host_.c_str() : (F_(unset)));
|
||||
shell.printfln((" IP: %s"), uuid::printable_to_string(syslog_.ip()).c_str());
|
||||
shell.printfln(" IP: %s", uuid::printable_to_string(syslog_.ip()).c_str());
|
||||
shell.print(" ");
|
||||
shell.printfln(F_(port_fmt), syslog_port_);
|
||||
shell.print(" ");
|
||||
shell.printfln(F_(log_level_fmt), uuid::log::format_level_lowercase(static_cast<uuid::log::Level>(syslog_level_)));
|
||||
shell.print(" ");
|
||||
shell.printfln(F_(mark_interval_fmt), syslog_mark_interval_);
|
||||
shell.printfln((" Queued: %d"), syslog_.queued());
|
||||
shell.printfln(" Queued: %d", syslog_.queued());
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -954,7 +954,7 @@ bool System::saveSettings(const char * filename, const char * section, JsonObjec
|
||||
if (section_json) {
|
||||
File section_file = LittleFS.open(filename, "w");
|
||||
if (section_file) {
|
||||
LOG_INFO(("Applying new %s settings"), section);
|
||||
LOG_INFO("Applying new %s settings", section);
|
||||
serializeJson(section_json, section_file);
|
||||
section_file.close();
|
||||
return true; // reboot required
|
||||
|
||||
@@ -150,9 +150,9 @@ void RxService::add(uint8_t * data, uint8_t length) {
|
||||
if (data[length - 1] != crc) {
|
||||
if ((data[0] & 0x7F) != ems_bus_id()) { // do not count echos as errors
|
||||
telegram_error_count_++;
|
||||
LOG_WARNING(("Incomplete Rx: %s"), Helpers::data_to_hex(data, length - 1).c_str()); // exclude CRC
|
||||
LOG_WARNING("Incomplete Rx: %s", Helpers::data_to_hex(data, length - 1).c_str()); // exclude CRC
|
||||
} else {
|
||||
LOG_TRACE(("Incomplete Rx: %s"), Helpers::data_to_hex(data, length - 1).c_str()); // exclude CRC
|
||||
LOG_TRACE("Incomplete Rx: %s", Helpers::data_to_hex(data, length - 1).c_str()); // exclude CRC
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -203,16 +203,16 @@ void RxService::add(uint8_t * data, uint8_t length) {
|
||||
uint16_t trace_watch_id = EMSESP::watch_id();
|
||||
if ((trace_watch_id == WATCH_ID_NONE) || (type_id == trace_watch_id)
|
||||
|| ((trace_watch_id < 0x80) && ((src == trace_watch_id) || (dest == trace_watch_id)))) {
|
||||
LOG_NOTICE(("Rx: %s"), Helpers::data_to_hex(data, length).c_str());
|
||||
LOG_NOTICE("Rx: %s", Helpers::data_to_hex(data, length).c_str());
|
||||
} else if (EMSESP::trace_raw()) {
|
||||
LOG_TRACE(("Rx: %s"), Helpers::data_to_hex(data, length).c_str());
|
||||
LOG_TRACE("Rx: %s", Helpers::data_to_hex(data, length).c_str());
|
||||
}
|
||||
} else if (EMSESP::trace_raw()) {
|
||||
LOG_TRACE(("Rx: %s"), Helpers::data_to_hex(data, length).c_str());
|
||||
LOG_TRACE("Rx: %s", Helpers::data_to_hex(data, length).c_str());
|
||||
}
|
||||
|
||||
#ifdef EMSESP_DEBUG
|
||||
LOG_DEBUG(("[DEBUG] New Rx telegram, message length %d"), message_length);
|
||||
LOG_DEBUG("[DEBUG] New Rx telegram, message length %d", message_length);
|
||||
#endif
|
||||
|
||||
// if we don't have a type_id exit,
|
||||
@@ -262,7 +262,7 @@ void TxService::start() {
|
||||
|
||||
// sends a 1 byte poll which is our own deviceID
|
||||
void TxService::send_poll() const {
|
||||
//LOG_DEBUG(("Ack %02X"),ems_bus_id() ^ ems_mask());
|
||||
//LOG_DEBUG("Ack %02X",ems_bus_id() ^ ems_mask());
|
||||
if (tx_mode()) {
|
||||
EMSuart::send_poll(ems_bus_id() ^ ems_mask());
|
||||
}
|
||||
@@ -363,12 +363,12 @@ void TxService::send_telegram(const QueuedTxTelegram & tx_telegram) {
|
||||
|
||||
// if we're in simulation mode, don't send anything, just quit
|
||||
if (EMSESP::system_.readonly_mode() && (telegram->operation == Telegram::Operation::TX_WRITE)) {
|
||||
LOG_INFO(("[readonly] Sending write Tx telegram: %s"), Helpers::data_to_hex(telegram_raw, length - 1).c_str());
|
||||
LOG_INFO("[readonly] Sending write Tx telegram: %s", Helpers::data_to_hex(telegram_raw, length - 1).c_str());
|
||||
tx_state(Telegram::Operation::NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_DEBUG(("Sending %s Tx [#%d], telegram: %s"),
|
||||
LOG_DEBUG("Sending %s Tx [#%d], telegram: %s",
|
||||
(telegram->operation == Telegram::Operation::TX_WRITE) ? ("write") : ("read"),
|
||||
tx_telegram.id_,
|
||||
Helpers::data_to_hex(telegram_raw, length - 1).c_str()); // exclude the last CRC byte
|
||||
@@ -429,7 +429,7 @@ void TxService::add(const uint8_t operation,
|
||||
auto telegram = std::make_shared<Telegram>(operation, ems_bus_id(), dest, type_id, offset, message_data, message_length);
|
||||
|
||||
#ifdef EMSESP_DEBUG
|
||||
LOG_DEBUG(("[DEBUG] New Tx [#%d] telegram, length %d"), tx_telegram_id_, message_length);
|
||||
LOG_DEBUG("[DEBUG] New Tx [#%d] telegram, length %d", tx_telegram_id_, message_length);
|
||||
#endif
|
||||
|
||||
// if the queue is full, make room but removing the last one
|
||||
@@ -488,7 +488,7 @@ void TxService::add(uint8_t operation, const uint8_t * data, const uint8_t lengt
|
||||
// if we don't have a type_id or empty data block, exit
|
||||
if ((type_id == 0) || (message_length == 0)) {
|
||||
#ifdef EMSESP_DEBUG
|
||||
LOG_DEBUG(("[DEBUG] Tx telegram type %d failed, length %d"), type_id, message_length);
|
||||
LOG_DEBUG("[DEBUG] Tx telegram type %d failed, length %d", type_id, message_length);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@@ -511,7 +511,7 @@ void TxService::add(uint8_t operation, const uint8_t * data, const uint8_t lengt
|
||||
}
|
||||
|
||||
#ifdef EMSESP_DEBUG
|
||||
LOG_DEBUG(("[DEBUG] New Tx [#%d] telegram, length %d"), tx_telegram_id_, message_length);
|
||||
LOG_DEBUG("[DEBUG] New Tx [#%d] telegram, length %d", tx_telegram_id_, message_length);
|
||||
#endif
|
||||
|
||||
if (front) {
|
||||
@@ -528,7 +528,7 @@ void TxService::add(uint8_t operation, const uint8_t * data, const uint8_t lengt
|
||||
|
||||
// send a Tx telegram to request data from an EMS device
|
||||
void TxService::read_request(const uint16_t type_id, const uint8_t dest, const uint8_t offset, const uint8_t length) {
|
||||
LOG_DEBUG(("Tx read request to device 0x%02X for type ID 0x%02X"), dest, type_id);
|
||||
LOG_DEBUG("Tx read request to device 0x%02X for type ID 0x%02X", dest, type_id);
|
||||
|
||||
uint8_t message_data = (type_id > 0xFF) ? (EMS_MAX_TELEGRAM_MESSAGE_LENGTH - 2) : EMS_MAX_TELEGRAM_MESSAGE_LENGTH;
|
||||
// if length set, publish result and set telegram to front
|
||||
@@ -593,7 +593,7 @@ void TxService::retry_tx(const uint8_t operation, const uint8_t * data, const ui
|
||||
EMSESP::wait_validate(0); // do not wait for validation
|
||||
if (operation == Telegram::Operation::TX_READ) {
|
||||
if (telegram_last_->offset > 0) { // ignore errors for higher offsets
|
||||
LOG_DEBUG(("Last Tx Read operation failed after %d retries. Ignoring request: %s"), MAXIMUM_TX_RETRIES, telegram_last_->to_string().c_str());
|
||||
LOG_DEBUG("Last Tx Read operation failed after %d retries. Ignoring request: %s", MAXIMUM_TX_RETRIES, telegram_last_->to_string().c_str());
|
||||
return;
|
||||
}
|
||||
increment_telegram_read_fail_count(); // another Tx fail
|
||||
@@ -601,7 +601,7 @@ void TxService::retry_tx(const uint8_t operation, const uint8_t * data, const ui
|
||||
increment_telegram_write_fail_count(); // another Tx fail
|
||||
}
|
||||
|
||||
LOG_ERROR(("Last Tx %s operation failed after %d retries. Ignoring request: %s"),
|
||||
LOG_ERROR("Last Tx %s operation failed after %d retries. Ignoring request: %s",
|
||||
(operation == Telegram::Operation::TX_WRITE) ? ("Write") : ("Read"),
|
||||
MAXIMUM_TX_RETRIES,
|
||||
telegram_last_->to_string().c_str());
|
||||
@@ -613,7 +613,7 @@ void TxService::retry_tx(const uint8_t operation, const uint8_t * data, const ui
|
||||
}
|
||||
|
||||
#ifdef EMSESP_DEBUG
|
||||
LOG_DEBUG(("[DEBUG] Last Tx %s operation failed. Retry #%d. sent message: %s, received: %s"),
|
||||
LOG_DEBUG("[DEBUG] Last Tx %s operation failed. Retry #%d. sent message: %s, received: %s",
|
||||
(operation == Telegram::Operation::TX_WRITE) ? ("Write") : ("Read"),
|
||||
retry_count_,
|
||||
telegram_last_->to_string().c_str(),
|
||||
@@ -665,7 +665,7 @@ uint16_t TxService::post_send_query() {
|
||||
(this->telegram_last_->type_id > 0xFF) ? (EMS_MAX_TELEGRAM_MESSAGE_LENGTH - 2) : EMS_MAX_TELEGRAM_MESSAGE_LENGTH; // request all data, 32 bytes
|
||||
this->add(Telegram::Operation::TX_READ, dest, post_typeid, offset, &message_data, 1, 0, true); // add to top/front of queue
|
||||
// read_request(telegram_last_post_send_query_, dest, 0); // no offset
|
||||
LOG_DEBUG(("Sending post validate read, type ID 0x%02X to dest 0x%02X"), post_typeid, dest);
|
||||
LOG_DEBUG("Sending post validate read, type ID 0x%02X to dest 0x%02X", post_typeid, dest);
|
||||
set_post_send_query(0); // reset
|
||||
// delay the request if we have a different type_id for post_send_query
|
||||
delayed_send_ = (this->telegram_last_->type_id == post_typeid) ? 0 : (uuid::get_uptime() + POST_SEND_DELAY);
|
||||
|
||||
@@ -597,7 +597,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
||||
|
||||
// n=1 = EMSESP::system_.HEALTHCHECK_NO_BUS
|
||||
// n=2 = EMSESP::system_.HEALTHCHECK_NO_NETWORK
|
||||
shell.printfln(("Testing healthcheck with %d"), n);
|
||||
shell.printfln("Testing healthcheck with %d", n);
|
||||
EMSESP::system_.healthcheck(n);
|
||||
}
|
||||
|
||||
@@ -1339,8 +1339,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
||||
}
|
||||
doc.shrinkToFit();
|
||||
JsonObject jo = doc.as<JsonObject>();
|
||||
shell.printfln(("Size of JSON payload = %d"), jo.memoryUsage());
|
||||
shell.printfln(("Length of JSON payload = %d"), measureJson(jo));
|
||||
shell.printfln("Size of JSON payload = %d", jo.memoryUsage());
|
||||
shell.printfln("Length of JSON payload = %d", measureJson(jo));
|
||||
|
||||
Mqtt::publish("test", jo);
|
||||
Mqtt::show_mqtt(shell); // show queue
|
||||
@@ -1483,7 +1483,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
||||
#pragma GCC diagnostic ignored "-Wdiv-by-zero"
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
uint8_t a = 2 / 0;
|
||||
shell.printfln(("Testing %s"), a);
|
||||
shell.printfln("Testing %s", a);
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
||||
@@ -34,13 +34,13 @@ WebStatusService::WebStatusService(AsyncWebServer * server, SecurityManager * se
|
||||
void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||
switch (event) {
|
||||
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
|
||||
EMSESP::logger().warning(("WiFi disconnected. Reason code=%d"), info.wifi_sta_disconnected.reason); // IDF 4.0
|
||||
EMSESP::logger().warning("WiFi disconnected. Reason code=%d", info.wifi_sta_disconnected.reason); // IDF 4.0
|
||||
WiFi.disconnect(true);
|
||||
break;
|
||||
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
|
||||
#ifndef EMSESP_STANDALONE
|
||||
EMSESP::logger().info(("WiFi connected with IP=%s, hostname=%s"), WiFi.localIP().toString().c_str(), WiFi.getHostname());
|
||||
EMSESP::logger().info("WiFi connected with IP=%s, hostname=%s", WiFi.localIP().toString().c_str(), WiFi.getHostname());
|
||||
#endif
|
||||
// EMSESP::system_.send_heartbeat(); // send from mqtt start
|
||||
EMSESP::system_.syslog_init();
|
||||
@@ -64,7 +64,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||
// prevent double calls
|
||||
if (!EMSESP::system_.ethernet_connected()) {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
EMSESP::logger().info(("Ethernet connected with IP=%s, speed %d Mbps"), ETH.localIP().toString().c_str(), ETH.linkSpeed());
|
||||
EMSESP::logger().info("Ethernet connected with IP=%s, speed %d Mbps", ETH.localIP().toString().c_str(), ETH.linkSpeed());
|
||||
#endif
|
||||
// EMSESP::system_.send_heartbeat();
|
||||
EMSESP::system_.syslog_init();
|
||||
@@ -103,9 +103,9 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
|
||||
case ARDUINO_EVENT_ETH_GOT_IP6:
|
||||
if (EMSESP::system_.ethernet_connected()) {
|
||||
EMSESP::logger().info(("Ethernet connected with IPv6=%s, speed %d Mbps"), ETH.localIPv6().toString().c_str(), ETH.linkSpeed());
|
||||
EMSESP::logger().info("Ethernet connected with IPv6=%s, speed %d Mbps", ETH.localIPv6().toString().c_str(), ETH.linkSpeed());
|
||||
} else {
|
||||
EMSESP::logger().info(("WiFi connected with IPv6=%s, hostname=%s"), WiFi.localIPv6().toString().c_str(), WiFi.getHostname());
|
||||
EMSESP::logger().info("WiFi connected with IPv6=%s, hostname=%s", WiFi.localIPv6().toString().c_str(), WiFi.getHostname());
|
||||
}
|
||||
// EMSESP::system_.send_heartbeat();
|
||||
EMSESP::system_.syslog_init();
|
||||
|
||||
Reference in New Issue
Block a user