diff --git a/main/accessorhelpers.h b/main/accessorhelpers.h index e48ca7c..768a550 100644 --- a/main/accessorhelpers.h +++ b/main/accessorhelpers.h @@ -20,7 +20,7 @@ struct RefAccessorSaveSettings : public virtual espgui::RefAccessor espgui::RefAccessor::setValue(value); if (!saveProfileSettings()) - return tl::make_unexpected("saveProfileSettings() failed!"); + return std::unexpected("saveProfileSettings() failed!"); return {}; }; diff --git a/main/accessors/settingsaccessors.h b/main/accessors/settingsaccessors.h index d12394b..ad3ffa0 100644 --- a/main/accessors/settingsaccessors.h +++ b/main/accessors/settingsaccessors.h @@ -32,7 +32,7 @@ struct NMotMaxKmhAccessor : public virtual espgui::AccessorInterface { profileSettings.limits.nMotMax = convertFromKmh(value); if (!saveProfileSettings()) - return tl::make_unexpected("saveProfileSettings() failed!"); + return std::unexpected("saveProfileSettings() failed!"); return {}; } }; @@ -80,7 +80,7 @@ struct WheelDiameterInchAccessor : public virtual espgui::AccessorInterface>::type set_config(ConfigWrapper &config, std::string_view newValue) { - return tl::make_unexpected("Unsupported config type"); + return std::unexpected("Unsupported config type"); } template @@ -211,7 +211,7 @@ set_config(ConfigWrapper &config, std::string_view newValue) if (cpputils::is_in(newValue, "true", "false")) return configs.write_config(config, newValue == "true"); else - return tl::make_unexpected(fmt::format("only true and false allowed, not {}", newValue)); + return std::unexpected(fmt::format("only true and false allowed, not {}", newValue)); } template @@ -224,7 +224,7 @@ set_config(ConfigWrapper &config, std::string_view newValue) if (auto parsed = cpputils::fromString(newValue)) return configs.write_config(config, *parsed); else - return tl::make_unexpected(fmt::format("could not parse {}", newValue)); + return std::unexpected(fmt::format("could not parse {}", newValue)); } template @@ -245,7 +245,7 @@ set_config(ConfigWrapper &config, std::string_view newValue) if (const auto parsed = wifi_stack::fromString(newValue); parsed) return configs.write_config(config, *parsed); else - return tl::make_unexpected(parsed.error()); + return std::unexpected(parsed.error()); } template @@ -257,7 +257,7 @@ set_config(ConfigWrapper &config, std::string_view newValue) if (const auto parsed = wifi_stack::fromString(newValue); parsed) return configs.write_config(config, *parsed); else - return tl::make_unexpected(parsed.error()); + return std::unexpected(parsed.error()); } template @@ -271,7 +271,7 @@ set_config(ConfigWrapper &config, std::string_view newValue) else if (const auto parsed = wifi_stack::fromString(newValue); parsed) return configs.write_config(config, *parsed); else - return tl::make_unexpected(parsed.error()); + return std::unexpected(parsed.error()); } template @@ -290,7 +290,7 @@ set_config(ConfigWrapper &config, std::string_view newValue) if (auto parsed = cpputils::fromString>(newValue)) return configs.write_config(config, T(*parsed)); else - return tl::make_unexpected(fmt::format("could not parse {}", newValue)); + return std::unexpected(fmt::format("could not parse {}", newValue)); } void send_config(uint32_t skipCount) @@ -448,7 +448,7 @@ void send_information() if (const auto *display = currentDisplay->asMenuDisplay()) { - displayObject["name"] = display->text(); + displayObject["name"] = display->title(); } } else diff --git a/main/displays/menus/candebugmenu.cpp b/main/displays/menus/candebugmenu.cpp index 23c3b8d..4c35b09 100644 --- a/main/displays/menus/candebugmenu.cpp +++ b/main/displays/menus/candebugmenu.cpp @@ -273,7 +273,7 @@ void CanDebugMenu::update() if (const auto result = twai_get_status_info(&status_info); result != ESP_OK) { ESP_LOGE(TAG, "twai_get_status_info() failed with %s", esp_err_to_name(result)); - m_last_can_status_info = tl::make_unexpected(result); + m_last_can_status_info = std::unexpected(result); } else { diff --git a/main/displays/menus/dynamicdebugmenu.cpp b/main/displays/menus/dynamicdebugmenu.cpp index d84ad67..3e1e422 100644 --- a/main/displays/menus/dynamicdebugmenu.cpp +++ b/main/displays/menus/dynamicdebugmenu.cpp @@ -203,7 +203,7 @@ const MenuItemIcon *RandomIcon::icon() const std::expected ToggleAccessor::setValue(bool value) { if (toggleLocked) - return tl::make_unexpected("cannot be changed while is locked!"); + return std::unexpected("cannot be changed while is locked!"); toggle = value; return {}; } diff --git a/main/displays/qrimportdisplay.cpp b/main/displays/qrimportdisplay.cpp index 100bcfc..c62bbc5 100644 --- a/main/displays/qrimportdisplay.cpp +++ b/main/displays/qrimportdisplay.cpp @@ -21,7 +21,7 @@ void QrImportDisplay::start() else { ESP_LOGE(TAG, "could not start request: %.*s", result.error().size(), result.error().data()); - m_result = tl::make_unexpected(std::move(result).error()); + m_result = std::unexpected(std::move(result).error()); } } @@ -43,7 +43,7 @@ void QrImportDisplay::update() { ESP_LOGI(TAG, "%.*s => %.*s", m_nvs_key.size(), m_nvs_key.data(), m_result->size(), m_result->data()); if (const auto result = qrimport::set_qr_code(m_nvs_key, *m_result); !result) - m_result = tl::make_unexpected(fmt::format("saving qr failed: {}", esp_err_to_name(result.error()))); + m_result = std::unexpected(fmt::format("saving qr failed: {}", esp_err_to_name(result.error()))); } else ESP_LOGW(TAG, "failed %.*s => %.*s", m_nvs_key.size(), m_nvs_key.data(), m_result.error().size(), m_result.error().data()); diff --git a/main/ota.cpp b/main/ota.cpp index 58bf437..9e5c581 100644 --- a/main/ota.cpp +++ b/main/ota.cpp @@ -29,7 +29,7 @@ void handleOta() std::expected triggerOta(std::string_view url) { if (!configs.feature.ota.isEnabled.value()) - return tl::make_unexpected("OTA is not enabled!"); + return std::unexpected("OTA is not enabled!"); ESP_LOGI(TAG, "%.*s", url.size(), url.data()); @@ -41,14 +41,14 @@ std::expected triggerOta(std::string_view url) if (const auto result = asyncOta->startTask(); !result) { ESP_LOGE(TAG, "starting OTA task failed: %.*s", result.error().size(), result.error().data()); - return tl::make_unexpected(fmt::format("starting OTA task failed: {}", result.error())); + return std::unexpected(fmt::format("starting OTA task failed: {}", result.error())); } asyncOtaTaskStarted = true; } if (const auto result = asyncOta->trigger(url, {}, {}, {}); !result) - return tl::make_unexpected(std::move(result).error()); + return std::unexpected(std::move(result).error()); wifi_stack::delete_scan_result(); diff --git a/main/qrimport.cpp b/main/qrimport.cpp index bcf91b8..b988ae2 100644 --- a/main/qrimport.cpp +++ b/main/qrimport.cpp @@ -46,7 +46,7 @@ std::expected get_qr_code(std::string_view key) { if (result != ESP_ERR_NVS_NOT_FOUND) ESP_LOGW(TAG, "nvs_get_str() size-only for key %.*s failed with %s", key.size(), key.data(), esp_err_to_name(result)); - return tl::make_unexpected(result); + return std::unexpected(result); } // empty string optimization @@ -58,7 +58,7 @@ std::expected get_qr_code(std::string_view key) if (const esp_err_t result = nvs_get_str(handle, key.data(), buf.data(), &length); result != ESP_OK) { ESP_LOGW(TAG, "nvs_get_str() for key %.*s failed with %s", key.size(), key.data(), esp_err_to_name(result)); - return tl::make_unexpected(result); + return std::unexpected(result); } if (buf.back() == '\n') @@ -74,7 +74,7 @@ std::expected set_qr_code(std::string_view key, std::string_vie if (const esp_err_t result = nvs_set_str(handle, key.data(), qrcode.data()); result != ESP_OK) { ESP_LOGW(TAG, "nvs_set_str() for key %.*s failed with %s", key.size(), key.data(), esp_err_to_name(result)); - return tl::make_unexpected(result); + return std::unexpected(result); } return {}; @@ -87,7 +87,7 @@ std::expected delete_qr_code(std::string_view key) if (const esp_err_t result = nvs_erase_key(handle, key.data()); result != ESP_OK) { ESP_LOGW(TAG, "nvs_erase_key() for key %.*s failed with %s", key.size(), key.data(), esp_err_to_name(result)); - return tl::make_unexpected(result); + return std::unexpected(result); } return {}; @@ -106,7 +106,7 @@ std::expected start_qr_request() { if (!http_request.constructed()) { - return tl::make_unexpected("request im oarsch"); + return std::unexpected("request im oarsch"); } if (auto res = http_request->start(fmt::format("http://qr.bobbycar.cloud/qr/{}.qr", configs.otaUsername.value())); !res) @@ -120,25 +120,25 @@ std::expected check_request() { if (!http_request.constructed()) { - return tl::make_unexpected("request im oarsch"); + return std::unexpected("request im oarsch"); } if (!http_request->finished()) { - return tl::make_unexpected("request has not finished"); + return std::unexpected("request has not finished"); } const auto helper = cpputils::makeCleanupHelper([](){ http_request->clearFinished(); }); if (const auto result = http_request->result(); !result) { - return tl::make_unexpected(result.error()); + return std::unexpected(result.error()); } else if (http_request->statusCode() != 200) { DynamicJsonDocument doc(256); deserializeJson(doc, http_request->takeBuffer()); - return tl::make_unexpected(fmt::format("{} {}", http_request->statusCode(), doc["error"].as())); + return std::unexpected(fmt::format("{} {}", http_request->statusCode(), doc["error"].as())); } else { diff --git a/main/taskmanager.cpp b/main/taskmanager.cpp index 5a817eb..3cde501 100644 --- a/main/taskmanager.cpp +++ b/main/taskmanager.cpp @@ -123,7 +123,7 @@ std::expected checkInitializedByName(const std::string& name) if (schedulerTask.name() == name) return schedulerTask.isInitialized(); } - return tl::make_unexpected("Task not found: " + std::string{name}); + return std::unexpected("Task not found: " + std::string{name}); } bool checkEnabledByName(const std::string& name) { diff --git a/main/time_bobbycar.cpp b/main/time_bobbycar.cpp index 42d47bd..e3ba57f 100644 --- a/main/time_bobbycar.cpp +++ b/main/time_bobbycar.cpp @@ -102,7 +102,7 @@ std::expected time_requestSync() { ESP_LOGI("BOBBY", "called"); if (!sntp_restart()) - return tl::make_unexpected("sntp_restart() failed"); + return std::unexpected("sntp_restart() failed"); return {}; } diff --git a/main/webserver_newsettings.cpp b/main/webserver_newsettings.cpp index b637265..fe62ad2 100644 --- a/main/webserver_newsettings.cpp +++ b/main/webserver_newsettings.cpp @@ -358,7 +358,7 @@ typename std::enable_if< , std::expected>::type saveSetting(ConfigWrapper &config, std::string_view newValue) { - return tl::make_unexpected("Unsupported config type"); + return std::unexpected("Unsupported config type"); } template @@ -370,7 +370,7 @@ saveSetting(ConfigWrapper &config, std::string_view newValue) if (cpputils::is_in(newValue, "true", "false")) return configs.write_config(config, newValue == "true"); else - return tl::make_unexpected(fmt::format("only true and false allowed, not {}", newValue)); + return std::unexpected(fmt::format("only true and false allowed, not {}", newValue)); } template @@ -383,7 +383,7 @@ saveSetting(ConfigWrapper &config, std::string_view newValue) if (auto parsed = cpputils::fromString(newValue)) return configs.write_config(config, *parsed); else - return tl::make_unexpected(fmt::format("could not parse {}", newValue)); + return std::unexpected(fmt::format("could not parse {}", newValue)); } template @@ -404,7 +404,7 @@ saveSetting(ConfigWrapper &config, std::string_view newValue) if (const auto parsed = wifi_stack::fromString(newValue); parsed) return configs.write_config(config, *parsed); else - return tl::make_unexpected(parsed.error()); + return std::unexpected(parsed.error()); } template @@ -416,7 +416,7 @@ saveSetting(ConfigWrapper &config, std::string_view newValue) if (const auto parsed = wifi_stack::fromString(newValue); parsed) return configs.write_config(config, *parsed); else - return tl::make_unexpected(parsed.error()); + return std::unexpected(parsed.error()); } template @@ -430,7 +430,7 @@ saveSetting(ConfigWrapper &config, std::string_view newValue) else if (const auto parsed = wifi_stack::fromString(newValue); parsed) return configs.write_config(config, *parsed); else - return tl::make_unexpected(parsed.error()); + return std::unexpected(parsed.error()); } template @@ -448,7 +448,7 @@ saveSetting(ConfigWrapper &config, std::string_view newValue) if (auto parsed = cpputils::fromString>(newValue)) return configs.write_config(config, T(*parsed)); else - return tl::make_unexpected(fmt::format("could not parse {}", newValue)); + return std::unexpected(fmt::format("could not parse {}", newValue)); } } // namespace