From 73eddedf32f0035a56f07b8f4094f28058398693 Mon Sep 17 00:00:00 2001 From: Matthias Bolte Date: Fri, 13 Dec 2024 17:07:33 +0100 Subject: [PATCH] api: Unify variable name --- software/src/modules/certs/certs.cpp | 14 +++++++------- software/src/modules/em_v2/em_v2.cpp | 8 ++++---- .../modules/meters_sun_spec/meters_sun_spec.cpp | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/software/src/modules/certs/certs.cpp b/software/src/modules/certs/certs.cpp index 0c7c4482c..ebaeb07f9 100644 --- a/software/src/modules/certs/certs.cpp +++ b/software/src/modules/certs/certs.cpp @@ -163,9 +163,9 @@ void Certs::register_urls() { api.addState("certs/state", &state); - api.addCommand("certs/add", &add, {}, [this](String &error) { + api.addCommand("certs/add", &add, {}, [this](String &errmsg) { if (add.get("cert")->asString().length() == 0) { - error = "Adding an empty certificate is not allowed. Did you mean to call certs/modify?"; + errmsg = "Adding an empty certificate is not allowed. Did you mean to call certs/modify?"; return; } @@ -173,7 +173,7 @@ void Certs::register_urls() for (const auto &cert: state.get("certs")) { if (cert.get("id")->asUint() == cert_id) { - error = String("A certificate with ID ") + cert_id + " does already exist! Did you mean to call certs/modify?"; + errmsg = String("A certificate with ID ") + cert_id + " does already exist! Did you mean to call certs/modify?"; return; } } @@ -197,7 +197,7 @@ void Certs::register_urls() this->update_state(); }, true); - api.addCommand("certs/modify", &add, {}, [this](String &error) { + api.addCommand("certs/modify", &add, {}, [this](String &errmsg) { uint8_t cert_id = add.get("id")->asUint(); bool found = false; for (const auto &cert: state.get("certs")) { @@ -208,7 +208,7 @@ void Certs::register_urls() } if (!found) { - error = String("No cert with ID ") + cert_id + " found! Did you mean to call certs/add?"; + errmsg = String("No cert with ID ") + cert_id + " found! Did you mean to call certs/add?"; } { @@ -230,13 +230,13 @@ void Certs::register_urls() this->update_state(); }, true); - api.addCommand("certs/remove", &remove, {}, [this](String &error) { + api.addCommand("certs/remove", &remove, {}, [this](String &errmsg) { uint8_t cert_id = remove.get("id")->asUint(); String path = get_cert_path(cert_id); if (!LittleFS.exists(path)) { - error = String("No cert with ID ") + cert_id + " found!"; + errmsg = String("No cert with ID ") + cert_id + " found!"; return; } diff --git a/software/src/modules/em_v2/em_v2.cpp b/software/src/modules/em_v2/em_v2.cpp index c49a0b931..e70447172 100644 --- a/software/src/modules/em_v2/em_v2.cpp +++ b/software/src/modules/em_v2/em_v2.cpp @@ -178,7 +178,7 @@ void EMV2::register_urls() { this->DeviceModule::register_urls(); - api.addCommand("energy_manager/outputs_update", &outputs_update, {}, [this](String &error) { + api.addCommand("energy_manager/outputs_update", &outputs_update, {}, [this](String &errmsg) { // 2x SG Ready, 2x Relay uint8_t new_values[4]; this->outputs_update.fillUint8Array(new_values, ARRAY_SIZE(new_values)); @@ -188,7 +188,7 @@ void EMV2::register_urls() uint8_t new_value = new_values[i + 2]; if (new_value != 255) { if (new_value > 1) { - error += "Relay output value out of range [0, 1].\n"; + errmsg += "Relay output value out of range [0, 1].\n"; } else { set_relay_output(i, new_value); } @@ -201,7 +201,7 @@ void EMV2::register_urls() uint8_t new_value = new_values[i]; if (new_value != 255) { if (new_value > 1) { - error += "SG Ready output value out of range [0, 1].\n"; + errmsg += "SG Ready output value out of range [0, 1].\n"; } else { bool switching_blocked = false; @@ -214,7 +214,7 @@ void EMV2::register_urls() #endif if (switching_blocked) { - error += "Cannot control SG Ready output that is currently in use by heating control.\n"; + errmsg += "Cannot control SG Ready output that is currently in use by heating control.\n"; } else { set_sg_ready_output(i, new_value); } diff --git a/software/src/modules/meters_sun_spec/meters_sun_spec.cpp b/software/src/modules/meters_sun_spec/meters_sun_spec.cpp index 9bc5d3376..577bdf294 100644 --- a/software/src/modules/meters_sun_spec/meters_sun_spec.cpp +++ b/software/src/modules/meters_sun_spec/meters_sun_spec.cpp @@ -85,9 +85,9 @@ void MetersSunSpec::pre_setup() void MetersSunSpec::register_urls() { - api.addCommand("meters_sun_spec/scan", &scan_config, {}, [this](String &error) { + api.addCommand("meters_sun_spec/scan", &scan_config, {}, [this](String &errmsg) { if (scan_state != ScanState::Idle) { - error = "Another scan is already in progress, please try again later!"; + errmsg = "Another scan is already in progress, please try again later!"; return; } @@ -105,7 +105,7 @@ void MetersSunSpec::register_urls() scan_last_keep_alive = now_us(); }, true); - api.addCommand("meters_sun_spec/scan_continue", &scan_continue_config, {}, [this](String &error) { + api.addCommand("meters_sun_spec/scan_continue", &scan_continue_config, {}, [this](String &errmsg) { if (scan_state == ScanState::Idle) { return; } @@ -113,14 +113,14 @@ void MetersSunSpec::register_urls() uint32_t cookie = scan_continue_config.get("cookie")->asUint(); if (cookie != scan_cookie) { - error = "Cannot continue another scan"; + errmsg = "Cannot continue another scan"; return; } scan_last_keep_alive = now_us(); }, true); - api.addCommand("meters_sun_spec/scan_abort", &scan_abort_config, {}, [this](String &error) { + api.addCommand("meters_sun_spec/scan_abort", &scan_abort_config, {}, [this](String &errmsg) { if (scan_state == ScanState::Idle) { return; } @@ -128,7 +128,7 @@ void MetersSunSpec::register_urls() uint32_t cookie = scan_abort_config.get("cookie")->asUint(); if (cookie != scan_cookie) { - error = "Cannot abort another scan"; + errmsg = "Cannot abort another scan"; return; }