mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
sonar recommendations
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -32,3 +32,4 @@ scripts/__pycache__
|
||||
# sonar
|
||||
.scannerwork/
|
||||
sonar/
|
||||
build_wrapper_output_directory/
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
# export SONAR_TOKEN=""
|
||||
|
||||
make clean
|
||||
build-wrapper-linux-x86-64 --out-dir sonar/build_wrapper_output_directory make all
|
||||
build-wrapper-linux-x86-64 --out-dir build_wrapper_output_directory make all
|
||||
sonar-scanner
|
||||
|
||||
@@ -64,12 +64,11 @@ void AnalogSensor::reload() {
|
||||
// load the list of analog sensors from the customization service
|
||||
// and store them locally and then activate them
|
||||
EMSESP::webCustomizationService.read([&](WebCustomization & settings) {
|
||||
auto sensors = settings.analogCustomizations;
|
||||
auto it = sensors_.begin();
|
||||
for (auto & sensor_ : sensors_) {
|
||||
// update existing sensors
|
||||
bool found = false;
|
||||
for (auto & sensor : sensors) { //search customlist
|
||||
for (const auto & sensor : settings.analogCustomizations) { //search customlist
|
||||
if (sensor_.id() == sensor.id) {
|
||||
// for output sensors set value to new start-value
|
||||
if ((sensor.type == AnalogType::COUNTER || sensor.type >= AnalogType::DIGITAL_OUT)
|
||||
@@ -90,10 +89,11 @@ void AnalogSensor::reload() {
|
||||
}
|
||||
it++;
|
||||
}
|
||||
|
||||
// add new sensors from list
|
||||
for (auto & sensor : sensors) {
|
||||
for (const auto & sensor : settings.analogCustomizations) {
|
||||
bool found = false;
|
||||
for (auto & sensor_ : sensors_) {
|
||||
for (const auto & sensor_ : sensors_) {
|
||||
if (sensor_.id() == sensor.id) {
|
||||
found = true;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
|
||||
return_code = Command::call(device_type, command_p, Helpers::itoa((int16_t)data.as<int>(), data_str), is_admin, id_n, output);
|
||||
} else if (data.is<float>()) {
|
||||
char data_str[10];
|
||||
return_code = Command::call(device_type, command_p, Helpers::render_value(data_str, (float)data.as<float>(), 2), is_admin, id_n, output);
|
||||
return_code = Command::call(device_type, command_p, Helpers::render_value(data_str, data.as<float>(), 2), is_admin, id_n, output);
|
||||
} else if (data.isNull()) {
|
||||
return_code = Command::call(device_type, command_p, "", is_admin, id_n, output); // empty, will do a query instead
|
||||
} else {
|
||||
@@ -160,23 +160,18 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
|
||||
return return_code;
|
||||
}
|
||||
|
||||
const std::string Command::return_code_string(const uint8_t return_code) {
|
||||
std::string Command::return_code_string(const uint8_t return_code) {
|
||||
switch (return_code) {
|
||||
case CommandRet::ERROR:
|
||||
return read_flash_string(F("Error"));
|
||||
break;
|
||||
case CommandRet::OK:
|
||||
return read_flash_string(F("OK"));
|
||||
break;
|
||||
case CommandRet::NOT_FOUND:
|
||||
return read_flash_string(F("Not Found"));
|
||||
break;
|
||||
case CommandRet::NOT_ALLOWED:
|
||||
return read_flash_string(F("Not Authorized"));
|
||||
break;
|
||||
case CommandRet::FAIL:
|
||||
return read_flash_string(F("Failed"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -367,7 +362,7 @@ bool Command::list(const uint8_t device_type, JsonObject & output) {
|
||||
}
|
||||
sorted_cmds.sort();
|
||||
|
||||
for (auto & cl : sorted_cmds) {
|
||||
for (const auto & cl : sorted_cmds) {
|
||||
for (const auto & cf : cmdfunctions_) {
|
||||
if ((cf.device_type_ == device_type) && !cf.has_flags(CommandFlag::HIDDEN) && cf.description_ && (cl == read_flash_string(cf.cmd_))) {
|
||||
output[cl] = cf.description_;
|
||||
@@ -396,7 +391,7 @@ void Command::show(uuid::console::Shell & shell, uint8_t device_type, bool verbo
|
||||
|
||||
// if not in verbose mode, just print them on a single line
|
||||
if (!verbose) {
|
||||
for (auto & cl : sorted_cmds) {
|
||||
for (const auto & cl : sorted_cmds) {
|
||||
shell.print(cl);
|
||||
shell.print(" ");
|
||||
}
|
||||
@@ -406,7 +401,7 @@ void Command::show(uuid::console::Shell & shell, uint8_t device_type, bool verbo
|
||||
|
||||
// verbose mode
|
||||
shell.println();
|
||||
for (auto & cl : sorted_cmds) {
|
||||
for (const auto & cl : sorted_cmds) {
|
||||
// find and print the description
|
||||
for (const auto & cf : cmdfunctions_) {
|
||||
if ((cf.device_type_ == device_type) && !cf.has_flags(CommandFlag::HIDDEN) && cf.description_ && (cl == read_flash_string(cf.cmd_))) {
|
||||
@@ -543,7 +538,7 @@ void Command::show_all(uuid::console::Shell & shell) {
|
||||
// e.g. //one/two////three/// becomes /one/two/three
|
||||
std::string SUrlParser::path() {
|
||||
std::string s = "/"; // set up the beginning slash
|
||||
for (std::string & f : m_folders) {
|
||||
for (const std::string & f : m_folders) {
|
||||
s += f;
|
||||
s += "/";
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ class Command {
|
||||
|
||||
static const char * parse_command_string(const char * command, int8_t & id);
|
||||
|
||||
static const std::string return_code_string(const uint8_t return_code);
|
||||
static std::string return_code_string(const uint8_t return_code);
|
||||
|
||||
private:
|
||||
static uuid::log::Logger logger_;
|
||||
@@ -134,13 +134,13 @@ class Command {
|
||||
|
||||
inline static uint8_t message(uint8_t error_code, const char * message, const JsonObject & output) {
|
||||
output.clear();
|
||||
output["message"] = (const char *)message;
|
||||
output["message"] = message;
|
||||
return error_code;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::unordered_map<std::string, std::string> KeyValueMap_t;
|
||||
typedef std::vector<std::string> Folder_t;
|
||||
using KeyValueMap_t = std::unordered_map<std::string, std::string>;
|
||||
using Folder_t = std::vector<std::string>;
|
||||
|
||||
class SUrlParser {
|
||||
private:
|
||||
|
||||
@@ -467,7 +467,7 @@ void Console::load_standard_commands(unsigned int context) {
|
||||
flash_string_vector{F("test")},
|
||||
flash_string_vector{F_(name_optional), F_(data_optional)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments.size() == 0) {
|
||||
if (arguments.empty()) {
|
||||
Test::run_test(shell, "default");
|
||||
} else if (arguments.size() == 1) {
|
||||
Test::run_test(shell, arguments.front());
|
||||
@@ -487,7 +487,7 @@ void Console::load_standard_commands(unsigned int context) {
|
||||
flash_string_vector{F_(debug)},
|
||||
flash_string_vector{F_(name_optional)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments.size() == 0) {
|
||||
if (arguments.empty()) {
|
||||
Test::debug(shell, "default");
|
||||
} else {
|
||||
Test::debug(shell, arguments.front());
|
||||
|
||||
@@ -354,7 +354,7 @@ bool DallasSensor::command_commands(const char * value, const int8_t id, JsonObj
|
||||
// creates JSON doc from values
|
||||
// returns false if there are no sensors
|
||||
bool DallasSensor::command_info(const char * value, const int8_t id, JsonObject & output) {
|
||||
if (sensors_.size() == 0) {
|
||||
if (sensors_.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -535,8 +535,8 @@ std::string DallasSensor::Sensor::name() const {
|
||||
bool DallasSensor::Sensor::apply_customization() {
|
||||
EMSESP::webCustomizationService.read([&](WebCustomization & settings) {
|
||||
auto sensors = settings.sensorCustomizations;
|
||||
if (sensors.size() != 0) {
|
||||
for (auto & sensor : sensors) {
|
||||
if (sensors.empty()) {
|
||||
for (const auto & sensor : sensors) {
|
||||
#if defined(EMSESP_DEBUG)
|
||||
LOG_DEBUG(F("Loading customization for dallas sensor %s"), sensor.id_str.c_str());
|
||||
#endif
|
||||
|
||||
@@ -85,7 +85,7 @@ class DallasSensor {
|
||||
bool get_value_info(JsonObject & output, const char * cmd, const int8_t id);
|
||||
|
||||
// return back reference to the sensor list, used by other classes
|
||||
const std::vector<Sensor> sensors() const {
|
||||
std::vector<Sensor> sensors() const {
|
||||
return sensors_;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class DallasSensor {
|
||||
}
|
||||
|
||||
bool have_sensors() {
|
||||
return (sensors_.size() > 0);
|
||||
return (!sensors_.empty());
|
||||
}
|
||||
|
||||
size_t no_sensors() {
|
||||
|
||||
@@ -325,7 +325,7 @@ std::shared_ptr<Thermostat::HeatingCircuit> Thermostat::heating_circuit(std::sha
|
||||
*/
|
||||
|
||||
// if it's the first set the status flag
|
||||
if (heating_circuits_.size() == 0) {
|
||||
if (heating_circuits_.empty()) {
|
||||
strlcpy(status_, "online", sizeof(status_));
|
||||
}
|
||||
|
||||
@@ -489,65 +489,44 @@ std::string Thermostat::mode_tostring(uint8_t mode) {
|
||||
switch (mode) {
|
||||
case HeatingCircuit::Mode::OFF:
|
||||
return read_flash_string(F_(off));
|
||||
break;
|
||||
case HeatingCircuit::Mode::MANUAL:
|
||||
return read_flash_string(F_(manual));
|
||||
break;
|
||||
case HeatingCircuit::Mode::DAY:
|
||||
return read_flash_string(F_(day));
|
||||
break;
|
||||
case HeatingCircuit::Mode::NIGHT:
|
||||
return read_flash_string(F_(night));
|
||||
break;
|
||||
case HeatingCircuit::Mode::ECO:
|
||||
return read_flash_string(F_(eco));
|
||||
break;
|
||||
case HeatingCircuit::Mode::COMFORT:
|
||||
return read_flash_string(F_(comfort));
|
||||
break;
|
||||
case HeatingCircuit::Mode::HEAT:
|
||||
return read_flash_string(F_(heat));
|
||||
break;
|
||||
case HeatingCircuit::Mode::HOLIDAY:
|
||||
return read_flash_string(F_(holiday));
|
||||
break;
|
||||
case HeatingCircuit::Mode::NOFROST:
|
||||
return read_flash_string(F_(nofrost));
|
||||
break;
|
||||
case HeatingCircuit::Mode::AUTO:
|
||||
return read_flash_string(F_(auto));
|
||||
break;
|
||||
case HeatingCircuit::Mode::SUMMER:
|
||||
return read_flash_string(F_(summer));
|
||||
break;
|
||||
case HeatingCircuit::Mode::OFFSET:
|
||||
return read_flash_string(F_(offset));
|
||||
break;
|
||||
case HeatingCircuit::Mode::DESIGN:
|
||||
return read_flash_string(F_(design));
|
||||
break;
|
||||
case HeatingCircuit::Mode::MINFLOW:
|
||||
return read_flash_string(F_(minflow));
|
||||
break;
|
||||
case HeatingCircuit::Mode::MAXFLOW:
|
||||
return read_flash_string(F_(maxflow));
|
||||
break;
|
||||
case HeatingCircuit::Mode::ROOMINFLUENCE:
|
||||
return read_flash_string(F_(roominfluence[0]));
|
||||
break;
|
||||
case HeatingCircuit::Mode::FLOWOFFSET:
|
||||
return read_flash_string(F_(flowtempoffset[0]));
|
||||
break;
|
||||
case HeatingCircuit::Mode::TEMPAUTO:
|
||||
return read_flash_string(F_(tempauto));
|
||||
break;
|
||||
case HeatingCircuit::Mode::NOREDUCE:
|
||||
return read_flash_string(F_(noreduce));
|
||||
break;
|
||||
default:
|
||||
case HeatingCircuit::Mode::UNKNOWN:
|
||||
return read_flash_string(F_(unknown));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1947,9 +1926,7 @@ bool Thermostat::set_mode_n(const uint8_t mode, const uint8_t hc_num) {
|
||||
set_mode_value = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
case HeatingCircuit::Mode::AUTO:
|
||||
case HeatingCircuit::Mode::ECO:
|
||||
default: // AUTO & ECO
|
||||
set_mode_value = 2;
|
||||
break;
|
||||
}
|
||||
@@ -2504,7 +2481,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
factor = 1;
|
||||
break;
|
||||
default:
|
||||
case HeatingCircuit::Mode::AUTO:
|
||||
// HeatingCircuit::Mode::AUTO:
|
||||
uint8_t mode_ = hc->get_mode();
|
||||
if (mode_ == HeatingCircuit::Mode::MANUAL) {
|
||||
offset = 0x0A; // manual offset
|
||||
@@ -2543,7 +2520,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
offset = EMS_OFFSET_RC20_2_Set_temp_day;
|
||||
break;
|
||||
default:
|
||||
case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code
|
||||
// automatic selection, if no type is defined, we use the standard code
|
||||
uint8_t mode_ = hc->get_mode();
|
||||
if (mode_ == HeatingCircuit::Mode::NIGHT) {
|
||||
offset = EMS_OFFSET_RC20_2_Set_temp_night;
|
||||
@@ -2614,7 +2591,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
factor = 1;
|
||||
break;
|
||||
default:
|
||||
case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code
|
||||
// automatic selection, if no type is defined, we use the standard code
|
||||
validate_typeid = monitor_typeids[hc->hc()]; //get setpoint roomtemp back
|
||||
if (model == EMS_DEVICE_FLAG_RC35) {
|
||||
uint8_t mode_ = hc->get_mode();
|
||||
@@ -2650,7 +2627,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
offset = EMS_OFFSET_JunkersSetMessage_day_temp;
|
||||
break;
|
||||
default:
|
||||
case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code
|
||||
// automatic selection, if no type is defined, we use the standard code
|
||||
uint8_t modetype = hc->get_mode_type();
|
||||
if (modetype == HeatingCircuit::Mode::NIGHT || modetype == HeatingCircuit::Mode::ECO) {
|
||||
offset = EMS_OFFSET_JunkersSetMessage_night_temp;
|
||||
@@ -2677,7 +2654,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
offset = EMS_OFFSET_JunkersSetMessage2_heat_temp;
|
||||
break;
|
||||
default:
|
||||
case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code
|
||||
// automatic selection, if no type is defined, we use the standard code
|
||||
uint8_t modetype = hc->get_mode_type();
|
||||
if (modetype == HeatingCircuit::Mode::NIGHT || modetype == HeatingCircuit::Mode::ECO) {
|
||||
offset = EMS_OFFSET_JunkersSetMessage2_eco_temp;
|
||||
@@ -2695,7 +2672,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
||||
if (offset != -1) {
|
||||
// add the write command to the Tx queue. value is *2
|
||||
// post validate is the corresponding monitor or set type IDs as they can differ per model
|
||||
write_command(set_typeid, offset, (uint8_t)((float)temperature * (float)factor), validate_typeid);
|
||||
write_command(set_typeid, offset, (uint8_t)(temperature * (float)factor), validate_typeid);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,32 +62,21 @@ std::string EMSdevice::brand_to_string() const {
|
||||
switch (brand_) {
|
||||
case EMSdevice::Brand::BOSCH:
|
||||
return read_flash_string(F("Bosch"));
|
||||
break;
|
||||
case EMSdevice::Brand::JUNKERS:
|
||||
return read_flash_string(F("Junkers"));
|
||||
break;
|
||||
case EMSdevice::Brand::BUDERUS:
|
||||
return read_flash_string(F("Buderus"));
|
||||
break;
|
||||
case EMSdevice::Brand::NEFIT:
|
||||
return read_flash_string(F("Nefit"));
|
||||
break;
|
||||
case EMSdevice::Brand::SIEGER:
|
||||
return read_flash_string(F("Sieger"));
|
||||
break;
|
||||
case EMSdevice::Brand::WORCESTER:
|
||||
return read_flash_string(F("Worcester"));
|
||||
break;
|
||||
case EMSdevice::Brand::IVT:
|
||||
return read_flash_string(F("IVT"));
|
||||
break;
|
||||
case EMSdevice::Brand::NO_BRAND:
|
||||
default:
|
||||
return read_flash_string(F(""));
|
||||
break;
|
||||
}
|
||||
|
||||
return std::string{};
|
||||
}
|
||||
|
||||
// returns the name of the MQTT topic to use for a specific device, without the base
|
||||
@@ -95,55 +84,30 @@ std::string EMSdevice::device_type_2_device_name(const uint8_t device_type) {
|
||||
switch (device_type) {
|
||||
case DeviceType::SYSTEM:
|
||||
return read_flash_string(F_(system));
|
||||
break;
|
||||
|
||||
case DeviceType::BOILER:
|
||||
return read_flash_string(F_(boiler));
|
||||
break;
|
||||
|
||||
case DeviceType::THERMOSTAT:
|
||||
return read_flash_string(F_(thermostat));
|
||||
break;
|
||||
|
||||
case DeviceType::HEATPUMP:
|
||||
return read_flash_string(F_(heatpump));
|
||||
break;
|
||||
|
||||
case DeviceType::SOLAR:
|
||||
return read_flash_string(F_(solar));
|
||||
break;
|
||||
|
||||
case DeviceType::CONNECT:
|
||||
return read_flash_string(F_(connect));
|
||||
break;
|
||||
|
||||
case DeviceType::MIXER:
|
||||
return read_flash_string(F_(mixer));
|
||||
break;
|
||||
|
||||
case DeviceType::DALLASSENSOR:
|
||||
return read_flash_string(F_(dallassensor));
|
||||
break;
|
||||
|
||||
case DeviceType::ANALOGSENSOR:
|
||||
return read_flash_string(F_(analogsensor));
|
||||
break;
|
||||
|
||||
case DeviceType::CONTROLLER:
|
||||
return read_flash_string(F_(controller));
|
||||
break;
|
||||
|
||||
case DeviceType::SWITCH:
|
||||
return read_flash_string(F_(switch));
|
||||
break;
|
||||
|
||||
case DeviceType::GATEWAY:
|
||||
return read_flash_string(F_(gateway));
|
||||
break;
|
||||
|
||||
default:
|
||||
return read_flash_string(F_(unknown));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,28 +171,20 @@ uint8_t EMSdevice::decode_brand(uint8_t value) {
|
||||
switch (value) {
|
||||
case 1:
|
||||
return EMSdevice::Brand::BOSCH;
|
||||
break;
|
||||
case 2:
|
||||
return EMSdevice::Brand::JUNKERS;
|
||||
break;
|
||||
case 3:
|
||||
return EMSdevice::Brand::BUDERUS;
|
||||
break;
|
||||
case 4:
|
||||
return EMSdevice::Brand::NEFIT;
|
||||
break;
|
||||
case 5:
|
||||
return EMSdevice::Brand::SIEGER;
|
||||
break;
|
||||
case 11:
|
||||
return EMSdevice::Brand::WORCESTER;
|
||||
break;
|
||||
case 13:
|
||||
return EMSdevice::Brand::IVT;
|
||||
break;
|
||||
default:
|
||||
return EMSdevice::Brand::NO_BRAND;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,7 +535,6 @@ void EMSdevice::publish_value(void * value_p) const {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case DeviceValueType::USHORT:
|
||||
Helpers::render_value(payload, *(uint16_t *)(value_p), divider, fahrenheit);
|
||||
break;
|
||||
@@ -603,11 +558,12 @@ void EMSdevice::publish_value(void * value_p) const {
|
||||
Helpers::render_value(payload, *(uint32_t *)(value_p), divider);
|
||||
break;
|
||||
case DeviceValueType::STRING:
|
||||
default:
|
||||
if (Helpers::hasValue((char *)(value_p))) {
|
||||
strlcpy(payload, (char *)(value_p), sizeof(payload));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (payload[0] != '\0') {
|
||||
|
||||
@@ -587,12 +587,12 @@ bool Helpers::value2bool(const char * v, bool & value) {
|
||||
|
||||
std::string bool_str = toLower(v); // convert to lower case
|
||||
|
||||
if ((bool_str == read_flash_string(F_(on))) || (bool_str == "1") or (bool_str == "true")) {
|
||||
if ((bool_str == read_flash_string(F_(on))) || (bool_str == "1") || (bool_str == "true")) {
|
||||
value = true;
|
||||
return true; // is a bool
|
||||
}
|
||||
|
||||
if ((bool_str == read_flash_string(F_(off))) || (bool_str == "0") or (bool_str == "false")) {
|
||||
if ((bool_str == read_flash_string(F_(off))) || (bool_str == "0") || (bool_str == "false")) {
|
||||
value = false;
|
||||
return true; // is a bool
|
||||
}
|
||||
|
||||
@@ -1313,7 +1313,7 @@ void Mqtt::publish_ha_climate_config(uint8_t tag, bool has_roomtemp, bool remove
|
||||
// based on the device and tag, create the MQTT topic name (without the basename)
|
||||
// differs based on whether MQTT nested is enabled
|
||||
// tag = EMSdevice::DeviceValueTAG
|
||||
const std::string Mqtt::tag_to_topic(uint8_t device_type, uint8_t tag) {
|
||||
std::string Mqtt::tag_to_topic(uint8_t device_type, uint8_t tag) {
|
||||
// the system device is treated differently. The topic is 'heartbeat' and doesn't follow the usual convention
|
||||
if (device_type == EMSdevice::DeviceType::SYSTEM) {
|
||||
return EMSdevice::tag_to_mqtt(tag);
|
||||
|
||||
@@ -220,7 +220,7 @@ class Mqtt {
|
||||
return mqtt_messages_.empty();
|
||||
}
|
||||
|
||||
static const std::string tag_to_topic(uint8_t device_type, uint8_t tag);
|
||||
static std::string tag_to_topic(uint8_t device_type, uint8_t tag);
|
||||
|
||||
struct QueuedMqttMessage {
|
||||
const uint32_t id_;
|
||||
|
||||
@@ -1135,9 +1135,11 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
||||
node["bus status"] = (F("connected, tx issues - try a different tx-mode"));
|
||||
break;
|
||||
case EMSESP::BUS_STATUS_CONNECTED:
|
||||
default:
|
||||
node["bus status"] = (F("connected"));
|
||||
break;
|
||||
default:
|
||||
node["bus status"] = (F("unknown"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (EMSESP::bus_status() != EMSESP::BUS_STATUS_OFFLINE) {
|
||||
@@ -1280,7 +1282,7 @@ bool System::command_restart(const char * value, const int8_t id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::string System::reset_reason(uint8_t cpu) {
|
||||
std::string System::reset_reason(uint8_t cpu) const {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
switch (rtc_get_reset_reason(cpu)) {
|
||||
case 1:
|
||||
|
||||
@@ -65,7 +65,7 @@ class System {
|
||||
static bool command_customizations(const char * value, const int8_t id, JsonObject & output);
|
||||
static bool command_commands(const char * value, const int8_t id, JsonObject & output);
|
||||
|
||||
const std::string reset_reason(uint8_t cpu);
|
||||
std::string reset_reason(uint8_t cpu) const;
|
||||
|
||||
void system_restart();
|
||||
void format(uuid::console::Shell & shell);
|
||||
|
||||
@@ -270,7 +270,7 @@ class RxService : public EMSbus {
|
||||
}
|
||||
};
|
||||
|
||||
const std::deque<QueuedRxTelegram> queue() const {
|
||||
std::deque<QueuedRxTelegram> queue() const {
|
||||
return rx_telegrams_;
|
||||
}
|
||||
|
||||
@@ -400,12 +400,12 @@ class TxService : public EMSbus {
|
||||
}
|
||||
};
|
||||
|
||||
const std::deque<QueuedTxTelegram> queue() const {
|
||||
std::deque<QueuedTxTelegram> queue() const {
|
||||
return tx_telegrams_;
|
||||
}
|
||||
|
||||
bool tx_queue_empty() const {
|
||||
return tx_telegrams_.size() == 0;
|
||||
return tx_telegrams_.empty();
|
||||
}
|
||||
|
||||
#if defined(EMSESP_DEBUG)
|
||||
|
||||
@@ -49,7 +49,7 @@ void WebAPIService::webAPIService_get(AsyncWebServerRequest * request) {
|
||||
// POST /{device}[/{hc|id}][/{name}]
|
||||
void WebAPIService::webAPIService_post(AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
// if no body then treat it as a secure GET
|
||||
if (not json.is<JsonObject>()) {
|
||||
if (!json.is<JsonObject>()) {
|
||||
webAPIService_get(request);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ void WebCustomizationService::devices(AsyncWebServerRequest * request) {
|
||||
JsonObject root = response->getRoot();
|
||||
|
||||
JsonArray devices = root.createNestedArray("devices");
|
||||
for (auto & emsdevice : EMSESP::emsdevices) {
|
||||
for (const auto & emsdevice : EMSESP::emsdevices) {
|
||||
if (emsdevice->has_entities()) {
|
||||
JsonObject obj = devices.createNestedObject();
|
||||
obj["i"] = emsdevice->unique_id(); // a unique id
|
||||
|
||||
@@ -76,7 +76,7 @@ void WebDataService::core_data(AsyncWebServerRequest * request) {
|
||||
// list is already sorted by device type
|
||||
// Ignore Contoller
|
||||
JsonArray devices = root.createNestedArray("devices");
|
||||
for (auto & emsdevice : EMSESP::emsdevices) {
|
||||
for (const auto & emsdevice : EMSESP::emsdevices) {
|
||||
if (emsdevice && emsdevice->device_type() != EMSdevice::DeviceType::CONTROLLER) {
|
||||
JsonObject obj = devices.createNestedObject();
|
||||
obj["i"] = emsdevice->unique_id(); // a unique id
|
||||
@@ -215,7 +215,7 @@ void WebDataService::write_value(AsyncWebServerRequest * request, JsonVariant &
|
||||
return_code = Command::call(device_type, cmd, Helpers::render_value(s, data.as<int16_t>(), 0), true, id, output);
|
||||
} else if (data.is<float>()) {
|
||||
char s[10];
|
||||
return_code = Command::call(device_type, cmd, Helpers::render_value(s, (float)data.as<float>(), 1), true, id, output);
|
||||
return_code = Command::call(device_type, cmd, Helpers::render_value(s, data.as<float>(), 1), true, id, output);
|
||||
} else if (data.is<bool>()) {
|
||||
return_code = Command::call(device_type, cmd, data.as<bool>() ? "true" : "false", true, id, output);
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ void WebLogService::fetchLog(AsyncWebServerRequest * request) {
|
||||
|
||||
// sets the values like level after a POST
|
||||
void WebLogService::setValues(AsyncWebServerRequest * request, JsonVariant & json) {
|
||||
if (not json.is<JsonObject>()) {
|
||||
if (!json.is<JsonObject>()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user