условно компилируемый проект после рефактора, еще нет настроек rxtx
This commit is contained in:
30
src/main.cpp
30
src/main.cpp
@@ -21,6 +21,7 @@
|
||||
#include "auth/resources.h"
|
||||
#include "auth/jwt.h"
|
||||
#include "auth/utils.h"
|
||||
#include "common/nlohmann/json.hpp"
|
||||
|
||||
|
||||
namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp>
|
||||
@@ -76,19 +77,19 @@ class ServerResources {
|
||||
}
|
||||
|
||||
void doTerminalUpgrade() const {
|
||||
api->executeInApi([](TSID sid) {
|
||||
CP_SetDmaDebug(sid, "begin_save_config", "");
|
||||
api->executeInApi([](api_driver::proxy::CpProxy& cp) {
|
||||
cp.setDmaDebug("begin_save_config", "");
|
||||
std::string cmd(UPGRADE_COMMAND);
|
||||
cmd += " ";
|
||||
cmd += FIRMWARE_LOCATION;
|
||||
system(cmd.c_str());
|
||||
CP_SetDmaDebug(sid, "save_config", "");
|
||||
cp.setDmaDebug("begin_save_config", "");
|
||||
});
|
||||
}
|
||||
|
||||
#ifdef MODEM_IS_TDMA
|
||||
void doTerminalUpgradeOta() const {
|
||||
api->executeInApi([&](TSID sid) {
|
||||
api->executeInApi([&](proxy::CpProxy&) {
|
||||
CP_SetDmaDebug(sid, "begin_save_config", "");
|
||||
std::string cmd(UPGRADE_COMMAND);
|
||||
cmd += " ";
|
||||
@@ -222,11 +223,7 @@ public:
|
||||
|
||||
rep.status = http::server::ok;
|
||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||
std::string result = R"({"mainState":)";
|
||||
result += api->loadTerminalState();
|
||||
result += R"(,"sysinfo":)";
|
||||
result += api->loadSysInfo();
|
||||
result += "}";
|
||||
const auto result = api->loadTerminalState();
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
}));
|
||||
|
||||
@@ -494,17 +491,16 @@ public:
|
||||
if (func == "SetDmaDebug") {
|
||||
if (req.url->params.find("param") == req.url->params.end()) { http::server::stockReply(http::server::bad_request, rep); return; }
|
||||
if (req.url->params.find("value") == req.url->params.end()) { http::server::stockReply(http::server::bad_request, rep); return; }
|
||||
this->api->executeInApi([&](auto sid) {
|
||||
CP_SetDmaDebug(sid, req.url->params["param"].c_str(), req.url->params["value"]);
|
||||
this->api->executeInApi([&](auto& cp) {
|
||||
cp.setDmaDebug(req.url->params["param"], req.url->params["value"]);
|
||||
});
|
||||
} else if (func == "GetDmaDebug") {
|
||||
if (req.url->params.find("param") == req.url->params.end()) { http::server::stockReply(http::server::bad_request, rep); return; }
|
||||
this->api->executeInApi([&](auto sid) {
|
||||
std::string tmp{};
|
||||
CP_GetDmaDebug(sid, req.url->params["param"].c_str(), &tmp);
|
||||
result = R"({"status":"ok","result":)";
|
||||
result += api_driver::buildEscapedString(tmp);
|
||||
result += "}";
|
||||
this->api->executeInApi([&](auto& cp) {
|
||||
nlohmann::json tmp;
|
||||
tmp["status"] = "ok";
|
||||
tmp["result"] = cp.getDmaDebug(req.url->params["param"]);
|
||||
result = tmp.dump();
|
||||
});
|
||||
} else {
|
||||
http::server::stockReply(http::server::not_implemented, rep);
|
||||
|
||||
Reference in New Issue
Block a user