кучка мелких фиксов + добавление перезагрузки модема и сброса настроек
This commit is contained in:
parent
6d076f03cd
commit
ccc7766e88
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,4 +4,4 @@ cmake-build-*
|
|||||||
cert.pem
|
cert.pem
|
||||||
key.pem
|
key.pem
|
||||||
dh.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>
|
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) {
|
static std::vector<char> loadFile(const std::string& path) {
|
||||||
std::ifstream is(path, std::ios::in | std::ios::binary);
|
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) {
|
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") {
|
if (req.method != "PUT") {
|
||||||
http::server::stockReply(http::server::bad_request, rep);
|
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);
|
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 {
|
class TerminalNetworkSettings {
|
||||||
public:
|
public:
|
||||||
std::string managementIp, managementGateway, mode, dataIp;
|
std::string managementIp, managementGateway, mode, dataIp;
|
||||||
@ -103,6 +109,7 @@ private:
|
|||||||
|
|
||||||
CP_GetNetwork(sid, "version", &version);
|
CP_GetNetwork(sid, "version", &version);
|
||||||
CP_GetNetwork(sid, "chip_id", &chip_id);
|
CP_GetNetwork(sid, "chip_id", &chip_id);
|
||||||
|
rtrim(chip_id);
|
||||||
CP_GetNetwork(sid, "serial", &sn);
|
CP_GetNetwork(sid, "serial", &sn);
|
||||||
CP_GetNetwork(sid, "mac_eth0", &mac0);
|
CP_GetNetwork(sid, "mac_eth0", &mac0);
|
||||||
CP_GetNetwork(sid, "mac_eth1", &mac1);
|
CP_GetNetwork(sid, "mac_eth1", &mac1);
|
||||||
@ -468,6 +475,13 @@ public:
|
|||||||
CP_GetDmaDebug(sid, "reset_cnt_rx", &tmp);
|
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() {
|
~TerminalApiDaemon() {
|
||||||
try {
|
try {
|
||||||
daemon.interrupt();
|
daemon.interrupt();
|
||||||
@ -873,6 +887,10 @@ void api_driver::ApiDriver::setDebugSendSettings(boost::property_tree::ptree &pt
|
|||||||
boost::ignore_unused(pt);
|
boost::ignore_unused(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void api_driver::ApiDriver::resetDefaultSettings() {
|
||||||
|
daemon->resetDefaultSettings();
|
||||||
|
}
|
||||||
|
|
||||||
bool api_driver::ApiDriver::getIsCinC() const {
|
bool api_driver::ApiDriver::getIsCinC() const {
|
||||||
modulator_settings s{};
|
modulator_settings s{};
|
||||||
daemon->getSettings(&s, nullptr, nullptr, nullptr, nullptr);
|
daemon->getSettings(&s, nullptr, nullptr, nullptr, nullptr);
|
||||||
|
@ -65,6 +65,8 @@ namespace api_driver {
|
|||||||
|
|
||||||
void setDebugSendSettings(boost::property_tree::ptree & pt);
|
void setDebugSendSettings(boost::property_tree::ptree & pt);
|
||||||
|
|
||||||
|
void resetDefaultSettings();
|
||||||
|
|
||||||
~ApiDriver();
|
~ApiDriver();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -167,7 +167,7 @@
|
|||||||
<h3>Параметры передачи</h3>
|
<h3>Параметры передачи</h3>
|
||||||
<label>
|
<label>
|
||||||
<span>Центральная частота, КГц</span>
|
<span>Центральная частота, КГц</span>
|
||||||
<input v-model="param.tx.centerFreq" type="number"/>
|
<input v-model="param.tx.centerFreq" type="number" step="0.001"/>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>Символьная скорость, Бод</span>
|
<span>Символьная скорость, Бод</span>
|
||||||
@ -316,7 +316,7 @@
|
|||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>Центральная частота, кГц</span>
|
<span>Центральная частота, кГц</span>
|
||||||
<input v-model="param.rx.centerFreq" type="number"/>
|
<input v-model="param.rx.centerFreq" type="number" step="0.001"/>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span>Символьная скорость, Бод</span>
|
<span>Символьная скорость, Бод</span>
|
||||||
@ -349,15 +349,15 @@
|
|||||||
<h3 v-show="param.cinc.mode === 'positional'">Настройки позиционирования</h3>
|
<h3 v-show="param.cinc.mode === 'positional'">Настройки позиционирования</h3>
|
||||||
<label v-show="param.cinc.mode === 'positional'">
|
<label v-show="param.cinc.mode === 'positional'">
|
||||||
<span>Широта станции</span>
|
<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>
|
||||||
<label v-show="param.cinc.mode === 'positional'">
|
<label v-show="param.cinc.mode === 'positional'">
|
||||||
<span>Долгота станции</span>
|
<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>
|
||||||
<label v-show="param.cinc.mode === 'positional'">
|
<label v-show="param.cinc.mode === 'positional'">
|
||||||
<span>Подспутниковая точка</span>
|
<span>Подспутниковая точка</span>
|
||||||
<input v-model="param.cinc.position.satelliteLongitude" type="number"/>
|
<input v-model="param.cinc.position.satelliteLongitude" type="number" step="0.0001"/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<h3 v-show="param.cinc.mode === 'delay'">Задержка до спутника</h3>
|
<h3 v-show="param.cinc.mode === 'delay'">Задержка до спутника</h3>
|
||||||
@ -589,15 +589,15 @@
|
|||||||
</label>
|
</label>
|
||||||
<label v-if="param.debugSend.en">
|
<label v-if="param.debugSend.en">
|
||||||
<span>IP адрес получателя</span>
|
<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>
|
||||||
<label>
|
<label>
|
||||||
<span>Порт для CinC</span>
|
<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>
|
||||||
<label>
|
<label>
|
||||||
<span>Порт для CinC</span>
|
<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>
|
||||||
<label>
|
<label>
|
||||||
<span>Таймаут</span>
|
<span>Таймаут</span>
|
||||||
@ -617,10 +617,10 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div>
|
<div>
|
||||||
<button class="dangerous-button">Перезагрузить модем</button>
|
<button class="dangerous-button" @click="fetch('/api/reboot', { method: 'POST' }).then((r) => { window.location.reload(); })">Перезагрузить модем</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button class="dangerous-button">Сбросить модем до заводских настроек</button>
|
<button class="dangerous-button" @click="fetch('/api/resetSettings', { method: 'POST' }).then((r) => { window.location.reload(); })">Сбросить модем до заводских настроек</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3>Обновление ПО</h3>
|
<h3>Обновление ПО</h3>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user