Fixed request, better error handling
This commit is contained in:
@ -33,9 +33,8 @@ public:
|
||||
|
||||
void triggered() override
|
||||
{
|
||||
configs.write_config(configs.otaServerUrl, m_buildserver_url); // mir egal ob succeeded
|
||||
if (m_buildserver_url.substr(m_buildserver_url.length() - 4) == ".bin")
|
||||
configs.write_config(configs.otaUrl, m_buildserver_url); // mir egal ob es succeeded
|
||||
ESP_LOGE("BOBBY", "Saving buildserver url: %s", m_buildserver_url.c_str());
|
||||
configs.write_config(configs.otaServerUrl, m_buildserver_url);
|
||||
|
||||
url_for_latest.clear();
|
||||
url_for_hashes.clear();
|
||||
|
@ -8,6 +8,7 @@ constexpr const char * const TAG = "qrimport";
|
||||
|
||||
// displays/menus includes
|
||||
#include "displays/menus/greenpassmenu.h"
|
||||
#include "bobbyerrorhandler.h"
|
||||
|
||||
// local includes
|
||||
#include "qrimport.h"
|
||||
@ -76,15 +77,17 @@ void QrImportDisplay::redraw()
|
||||
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
||||
m_statuslabel.redraw("In progress");
|
||||
}
|
||||
else if (!m_result)
|
||||
else if (!m_result && !m_result.error().empty())
|
||||
{
|
||||
tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||
m_statuslabel.redraw(m_result.error());
|
||||
BobbyErrorHandler{}.errorOccured(fmt::format("Error: {}", m_result.error()));
|
||||
m_result.error().clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
m_statuslabel.redraw("OK");
|
||||
switchScreen<GreenPassMenu>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,13 +5,12 @@
|
||||
#include <nvs.h>
|
||||
|
||||
// 3rd party includes
|
||||
#include <ArduinoJson.h>
|
||||
#include <asynchttprequest.h>
|
||||
#include <cleanuphelper.h>
|
||||
#include <cpputils.h>
|
||||
#include <delayedconstruction.h>
|
||||
|
||||
// local includes
|
||||
#include "globals.h"
|
||||
#include "newsettings.h"
|
||||
|
||||
namespace qrimport {
|
||||
@ -110,7 +109,7 @@ tl::expected<void, std::string> start_qr_request()
|
||||
return tl::make_unexpected("request im oarsch");
|
||||
}
|
||||
|
||||
if (const auto res = http_request->start(fmt::format("http://api.bobbycar.cloud/qr/{}.qr", configs.otaUsername.value)); !res)
|
||||
if (auto res = http_request->start(fmt::format("http://qr.bobbycar.cloud/qr/{}.qr", configs.otaUsername.value)); !res)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
@ -137,9 +136,9 @@ tl::expected<std::string, std::string> check_request()
|
||||
}
|
||||
else if (http_request->statusCode() != 200)
|
||||
{
|
||||
return tl::make_unexpected(fmt::format("unexpected response status: {} {}",
|
||||
http_request->statusCode(),
|
||||
http_request->takeBuffer()));
|
||||
DynamicJsonDocument doc(256);
|
||||
deserializeJson(doc, http_request->takeBuffer());
|
||||
return tl::make_unexpected(fmt::format("{} {}", http_request->statusCode(), doc["error"].as<std::string>()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user