From be6c8023c57b25ca4bb5f04819f5d81103c318b1 Mon Sep 17 00:00:00 2001 From: Vladislav Ostapov Date: Sat, 28 Dec 2024 16:41:58 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B7=D0=B0=D1=89=D0=B8=D1=82=D1=83=20=D0=BE=D1=82=20=D0=B4?= =?UTF-8?q?=D0=B2=D0=BE=D0=B9=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BE=D0=B1=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=88=D0=B8=D0=B2=D0=BA=D0=B8,=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B8=20TCP-=D0=B0=D0=BA=D1=81=D0=B5=D0=BB=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B2=20=D0=B2=D0=B5=D0=B1=20(?= =?UTF-8?q?=D0=BE=D0=BD=D0=B8=20=D0=BF=D0=BE=D0=BA=D0=B0=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=B8=D0=B7?= =?UTF-8?q?-=D0=B7=D0=B0=20API)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front-generator/template/vue-data.js | 4 ++-- src/main.cpp | 23 +++++++++++++++++++++-- static/main-scpc.html | 6 +++--- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/front-generator/template/vue-data.js b/front-generator/template/vue-data.js index 3549ab0..7eb163b 100644 --- a/front-generator/template/vue-data.js +++ b/front-generator/template/vue-data.js @@ -105,8 +105,8 @@ cinc: { mode: null, // 'positional' | 'delay' - searchBandwidth: 0, // полоса поиска в кГц - position: { + searchBandwidth: 0, // полоса поиска в кГц + position: { station: { latitude: 0, longitude: 0 diff --git a/src/main.cpp b/src/main.cpp index a5fea58..3cae31a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -84,6 +84,8 @@ class ServerResources { std::unique_ptr api; http::auth::AuthProvider auth{}; + bool upgradeOrRebootRunning = false; + static void onUploadFirmware(const http::server::Request& req) { std::ofstream f("/tmp/firmware.zip", std::ios::binary); @@ -415,7 +417,7 @@ public: } })); - s.resources.emplace_back(std::make_unique("/api/reboot", this->auth, 0, [](const auto& req, auto& rep) { + s.resources.emplace_back(std::make_unique("/api/reboot", this->auth, 0, [this](const auto& req, auto& rep) { if (req.method != "POST") { http::server::stockReply(http::server::bad_request, rep); } @@ -424,6 +426,7 @@ public: rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)}); const std::string result = R"({"status":"ok"})"; rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size()); + this->upgradeOrRebootRunning = true; system(REBOOT_COMMAND); })); s.resources.emplace_back(std::make_unique("/api/resetSettings", this->auth, http::auth::User::SUPERUSER, [this](const auto& req, auto& rep) { @@ -439,10 +442,11 @@ public: system(REBOOT_COMMAND); })); - s.resources.emplace_back(std::make_unique("/api/firmwareUpdate", this->auth, http::auth::User::UPDATE_FIRMWARE, [](const auto& req, auto& rep) { + s.resources.emplace_back(std::make_unique("/api/firmwareUpdate", this->auth, http::auth::User::UPDATE_FIRMWARE, [this](const auto& req, auto& rep) { if (req.method != "PUT") { http::server::stockReply(http::server::bad_request, rep); } + this->upgradeOrRebootRunning = true; onUploadFirmware(req); rep.status = http::server::ok; @@ -454,12 +458,14 @@ public: result += http::utils::sha256(req.payload.data(), req.payload.size()); result += "\"}"; rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size()); + this->upgradeOrRebootRunning = false; })); s.resources.emplace_back(std::make_unique("/api/doFirmwareUpgrade", this->auth, http::auth::User::UPDATE_FIRMWARE, [this](const auto& req, auto& rep) { if (req.method != "POST") { http::server::stockReply(http::server::bad_request, rep); } + this->upgradeOrRebootRunning = true; doTerminalUpgrade(); rep.status = http::server::ok; rep.headers.clear(); @@ -467,6 +473,19 @@ public: const auto result = api->loadFirmwareVersion(); rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size()); })); + + s.resources.emplace_back(std::make_unique("/dev", this->auth, http::auth::User::SUPERUSER, [this](const auto& req, auto& rep) { + boost::ignore_unused(req); + sf->serve(INTERNET_JPG, rep); + })); + + s.resources.emplace_back(std::make_unique("/dev/fetchParams", this->auth, http::auth::User::SUPERUSER, [this](const auto& req, auto& rep) { + rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)}); + std::string result = R"({"status":"ok","fwsize":)"; + result += std::to_string(req.payload.size()); + result += R"(,"sha256":")"; + result += "\"}"; + })); } ~ServerResources() = default; diff --git a/static/main-scpc.html b/static/main-scpc.html index d412901..846e48b 100644 --- a/static/main-scpc.html +++ b/static/main-scpc.html @@ -540,8 +540,8 @@ - -

Настройки сети