кучка мелких фиксов + добавление перезагрузки модема и сброса настроек
This commit is contained in:
parent
6d076f03cd
commit
ccc7766e88
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,4 +4,4 @@ cmake-build-*
|
||||
cert.pem
|
||||
key.pem
|
||||
dh.pem
|
||||
/do-terminal-update.sh
|
||||
/web-action
|
||||
|
27
src/main.cpp
27
src/main.cpp
@ -24,6 +24,9 @@
|
||||
|
||||
namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp>
|
||||
|
||||
constexpr const char* REBOOT_COMMAND = "web-action reboot";
|
||||
constexpr const char* UPGRADE_COMMAND = "web-action upgrade";
|
||||
|
||||
|
||||
static std::vector<char> loadFile(const std::string& path) {
|
||||
std::ifstream is(path, std::ios::in | std::ios::binary);
|
||||
@ -407,6 +410,30 @@ public:
|
||||
}
|
||||
}));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/reboot", this->auth, 0, [this](const auto& req, auto& rep) {
|
||||
if (req.method != "POST") {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
}
|
||||
rep.status = http::server::ok;
|
||||
rep.headers.clear();
|
||||
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());
|
||||
system(REBOOT_COMMAND);
|
||||
}));
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/resetSettings", this->auth, http::auth::User::SUPERUSER, [this](const auto& req, auto& rep) {
|
||||
if (req.method != "POST") {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
}
|
||||
rep.status = http::server::ok;
|
||||
rep.headers.clear();
|
||||
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());
|
||||
api->resetDefaultSettings();
|
||||
system(REBOOT_COMMAND);
|
||||
}));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/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);
|
||||
|
@ -58,6 +58,12 @@ std::pair<std::string, std::string> splitIpAndMask(const std::string& input) {
|
||||
return std::make_pair(ip, mask_str);
|
||||
}
|
||||
|
||||
static inline void rtrim(std::string &s) {
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
|
||||
return !std::isspace(ch);
|
||||
}).base(), s.end());
|
||||
}
|
||||
|
||||
class TerminalNetworkSettings {
|
||||
public:
|
||||
std::string managementIp, managementGateway, mode, dataIp;
|
||||
@ -103,6 +109,7 @@ private:
|
||||
|
||||
CP_GetNetwork(sid, "version", &version);
|
||||
CP_GetNetwork(sid, "chip_id", &chip_id);
|
||||
rtrim(chip_id);
|
||||
CP_GetNetwork(sid, "serial", &sn);
|
||||
CP_GetNetwork(sid, "mac_eth0", &mac0);
|
||||
CP_GetNetwork(sid, "mac_eth1", &mac1);
|
||||
@ -468,6 +475,13 @@ public:
|
||||
CP_GetDmaDebug(sid, "reset_cnt_rx", &tmp);
|
||||
}
|
||||
|
||||
void resetDefaultSettings() {
|
||||
std::lock_guard lock(this->cpApiMutex);
|
||||
CP_SetDmaDebug(sid, "begin_save_config", " ");
|
||||
CP_SetDmaDebug(sid, "default_params", "");
|
||||
CP_SetDmaDebug(sid, "save_config", " ");
|
||||
}
|
||||
|
||||
~TerminalApiDaemon() {
|
||||
try {
|
||||
daemon.interrupt();
|
||||
@ -873,6 +887,10 @@ void api_driver::ApiDriver::setDebugSendSettings(boost::property_tree::ptree &pt
|
||||
boost::ignore_unused(pt);
|
||||
}
|
||||
|
||||
void api_driver::ApiDriver::resetDefaultSettings() {
|
||||
daemon->resetDefaultSettings();
|
||||
}
|
||||
|
||||
bool api_driver::ApiDriver::getIsCinC() const {
|
||||
modulator_settings s{};
|
||||
daemon->getSettings(&s, nullptr, nullptr, nullptr, nullptr);
|
||||
|
@ -65,6 +65,8 @@ namespace api_driver {
|
||||
|
||||
void setDebugSendSettings(boost::property_tree::ptree & pt);
|
||||
|
||||
void resetDefaultSettings();
|
||||
|
||||
~ApiDriver();
|
||||
|
||||
private:
|
||||
|
@ -167,7 +167,7 @@
|
||||
<h3>Параметры передачи</h3>
|
||||
<label>
|
||||
<span>Центральная частота, КГц</span>
|
||||
<input v-model="param.tx.centerFreq" type="number"/>
|
||||
<input v-model="param.tx.centerFreq" type="number" step="0.001"/>
|
||||
</label>
|
||||
<label>
|
||||
<span>Символьная скорость, Бод</span>
|
||||
@ -316,7 +316,7 @@
|
||||
</label>
|
||||
<label>
|
||||
<span>Центральная частота, кГц</span>
|
||||
<input v-model="param.rx.centerFreq" type="number"/>
|
||||
<input v-model="param.rx.centerFreq" type="number" step="0.001"/>
|
||||
</label>
|
||||
<label>
|
||||
<span>Символьная скорость, Бод</span>
|
||||
@ -349,15 +349,15 @@
|
||||
<h3 v-show="param.cinc.mode === 'positional'">Настройки позиционирования</h3>
|
||||
<label v-show="param.cinc.mode === 'positional'">
|
||||
<span>Широта станции</span>
|
||||
<input v-model="param.cinc.position.station.latitude" type="number"/>
|
||||
<input v-model="param.cinc.position.station.latitude" type="number" step="0.0001"/>
|
||||
</label>
|
||||
<label v-show="param.cinc.mode === 'positional'">
|
||||
<span>Долгота станции</span>
|
||||
<input v-model="param.cinc.position.station.longitude" type="number"/>
|
||||
<input v-model="param.cinc.position.station.longitude" type="number" step="0.0001"/>
|
||||
</label>
|
||||
<label v-show="param.cinc.mode === 'positional'">
|
||||
<span>Подспутниковая точка</span>
|
||||
<input v-model="param.cinc.position.satelliteLongitude" type="number"/>
|
||||
<input v-model="param.cinc.position.satelliteLongitude" type="number" step="0.0001"/>
|
||||
</label>
|
||||
|
||||
<h3 v-show="param.cinc.mode === 'delay'">Задержка до спутника</h3>
|
||||
@ -589,15 +589,15 @@
|
||||
</label>
|
||||
<label v-if="param.debugSend.en">
|
||||
<span>IP адрес получателя</span>
|
||||
<input v-model="param.debugSend.receiverIp" required type="text" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}$">
|
||||
<input v-model="param.debugSend.receiverIp" required type="text" pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}">
|
||||
</label>
|
||||
<label>
|
||||
<span>Порт для CinC</span>
|
||||
<input v-model="param.debugSend.portCinC" type="number" pattern="^[0-9]{1,5}$">
|
||||
<input v-model="param.debugSend.portCinC" type="number" min="0" max="65535">
|
||||
</label>
|
||||
<label>
|
||||
<span>Порт для CinC</span>
|
||||
<input v-model="param.debugSend.portData" type="number" pattern="^[0-9]{1,5}$">
|
||||
<input v-model="param.debugSend.portData" type="number" min="0" max="65535">
|
||||
</label>
|
||||
<label>
|
||||
<span>Таймаут</span>
|
||||
@ -617,10 +617,10 @@
|
||||
</tbody>
|
||||
</table>
|
||||
<div>
|
||||
<button class="dangerous-button">Перезагрузить модем</button>
|
||||
<button class="dangerous-button" @click="fetch('/api/reboot', { method: 'POST' }).then((r) => { window.location.reload(); })">Перезагрузить модем</button>
|
||||
</div>
|
||||
<div>
|
||||
<button class="dangerous-button">Сбросить модем до заводских настроек</button>
|
||||
<button class="dangerous-button" @click="fetch('/api/resetSettings', { method: 'POST' }).then((r) => { window.location.reload(); })">Сбросить модем до заводских настроек</button>
|
||||
</div>
|
||||
|
||||
<h3>Обновление ПО</h3>
|
||||
|
Loading…
x
Reference in New Issue
Block a user