исправил тестовое состояние, исправил логику работы TDMA-морды, мелкие исправления в именовании параметров
This commit is contained in:
@@ -30,10 +30,10 @@ http::auth::jwt::Jwt http::auth::jwt::Jwt::fromCookies(const std::string &cookie
|
||||
const auto auth = pc.at("auth");
|
||||
std::string::size_type firstDot = std::string::npos;
|
||||
std::string::size_type secondDot = std::string::npos;
|
||||
for (size_t i = 0; i < auth.size(); i++) {
|
||||
for (std::string::size_type i = 0; i < auth.size(); i++) {
|
||||
if (auth[i] == '.') {
|
||||
if (firstDot == std::string::npos) { firstDot = static_cast<int>(i); }
|
||||
else if (secondDot == std::string::npos) { secondDot = static_cast<int>(i); }
|
||||
if (firstDot == std::string::npos) { firstDot = i; }
|
||||
else if (secondDot == std::string::npos) { secondDot = i; }
|
||||
else {
|
||||
// так быть не должно
|
||||
return t;
|
||||
|
25
src/main.cpp
25
src/main.cpp
@@ -28,25 +28,6 @@ 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);
|
||||
if (!is) {
|
||||
throw std::runtime_error("File not found");
|
||||
}
|
||||
|
||||
std::vector<char> content;
|
||||
for (;;) {
|
||||
char buf[512];
|
||||
auto len = is.read(buf, sizeof(buf)).gcount();
|
||||
if (len <= 0) {
|
||||
break;
|
||||
}
|
||||
content.insert(content.end(), buf, buf + len);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
namespace mime_types = http::server::mime_types;
|
||||
|
||||
void init_logging() {
|
||||
@@ -515,9 +496,9 @@ int main(int argc, char *argv[]) {
|
||||
s->run();
|
||||
|
||||
} else if (strcmp(argv[1], "ssl") == 0) {
|
||||
const auto cert = loadFile("cert.pem");
|
||||
const auto key = loadFile("key.pem");
|
||||
const auto dh = loadFile("dh.pem");
|
||||
std::vector<char> cert; http::resource::loadFile("cert.pem", cert);
|
||||
std::vector<char> key; http::resource::loadFile("key.pem", key);
|
||||
std::vector<char> dh; http::resource::loadFile("dh.pem", dh);
|
||||
|
||||
auto ctx = std::make_shared<ssl::context>(ssl::context::tlsv12);
|
||||
|
||||
|
@@ -3,10 +3,10 @@
|
||||
#include <fstream>
|
||||
#include <utility>
|
||||
|
||||
static void loadFile(const std::string& path, std::vector<char>& content) {
|
||||
void http::resource::loadFile(const std::string& path, std::vector<char>& content) {
|
||||
std::ifstream is(path, std::ios::in | std::ios::binary);
|
||||
if (!is) {
|
||||
throw std::runtime_error("File not found");
|
||||
throw std::runtime_error("File not found " + path);
|
||||
}
|
||||
|
||||
content.clear();
|
||||
|
@@ -62,6 +62,8 @@ namespace http::resource {
|
||||
|
||||
~GenericResource() override;
|
||||
};
|
||||
|
||||
void loadFile(const std::string& path, std::vector<char>& content);
|
||||
}
|
||||
|
||||
#endif //RESOURCE_H
|
||||
|
@@ -469,6 +469,15 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
bool isTest() {
|
||||
std::shared_lock lock(this->settingsMutex);
|
||||
return !modSettings.is_carrier
|
||||
#ifdef MODEM_IS_SCPC
|
||||
|| this->modSettings.is_test_data
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
void getNetworkSettings(TerminalNetworkSettings& dest) {
|
||||
std::shared_lock lock(this->networkSettingsMutex);
|
||||
dest = this->networkSettings;
|
||||
@@ -690,6 +699,7 @@ std::string api_driver::ApiDriver::loadTerminalState() const {
|
||||
std::stringstream result;
|
||||
|
||||
result << "{\n\"initState\":" << buildEscapedString(daemon->getDeviceInitState());
|
||||
result << ",\n\"testState\":" << boolAsStr(daemon->isTest());
|
||||
|
||||
modulator_state modulator{};
|
||||
demodulator_state demodulator{};
|
||||
@@ -873,15 +883,15 @@ std::string api_driver::ApiDriver::loadSettings() const {
|
||||
|
||||
std::stringstream result;
|
||||
result << "{\n\"txAutoStart\":" << boolAsStr(modSettings.is_save_current_state);
|
||||
#ifdef MODEM_IS_SCPC
|
||||
result << ",\"txEn\":" << boolAsStr(modSettings.tx_is_on);
|
||||
result << ",\"txModulatorIsTest\":" << boolAsStr(!modSettings.is_carrier);
|
||||
#endif
|
||||
#ifdef MODEM_IS_SCPC
|
||||
result << ",\"txIsTestInput\":" << boolAsStr(modSettings.is_test_data);
|
||||
#endif
|
||||
result << ",\"txModulatorIsTest\":" << boolAsStr(!modSettings.is_carrier);
|
||||
result << ",\"txCentralFreq\":"; writeDouble(result, modSettings.central_freq_in_kGz);
|
||||
#ifdef MODEM_IS_SCPC
|
||||
result << ",\"txBaudrate\":" << modSettings.baudrate;
|
||||
result << ",\"txRolloff\":" << static_cast<int>(modSettings.rollof);
|
||||
#ifdef MODEM_IS_SCPC
|
||||
result << ",\"txGoldan\":" << static_cast<int>(modSettings.gold_seq_is_active);
|
||||
#endif
|
||||
result << ",\"txAttenuation\":"; writeDouble(result, modSettings.attenuation);
|
||||
@@ -1017,13 +1027,13 @@ void api_driver::ApiDriver::setRxTxSettings(boost::property_tree::ptree &pt) {
|
||||
mod.tx_is_on = pt.get<bool>("txEn");
|
||||
#ifdef MODEM_IS_SCPC
|
||||
mod.is_save_current_state = pt.get<bool>("txAutoStart");
|
||||
mod.is_carrier = !pt.get<bool>("txModulatorIsTest");
|
||||
#endif
|
||||
mod.is_test_data = pt.get<bool>("txIsTestInput");
|
||||
#endif
|
||||
mod.is_carrier = !pt.get<bool>("txModulatorIsTest");
|
||||
mod.central_freq_in_kGz = pt.get<double>("txCentralFreq");
|
||||
mod.baudrate = pt.get<uint32_t>("txBaudrate");
|
||||
mod.rollof = pt.get<int>("txRolloff");
|
||||
#ifdef MODEM_IS_SCPC
|
||||
mod.baudrate = pt.get<uint32_t>("txBaudrate");
|
||||
mod.rollof = pt.get<unsigned int>("txRolloff");
|
||||
mod.gold_seq_is_active = pt.get<bool>("txGoldan");
|
||||
#endif
|
||||
mod.attenuation = pt.get<double>("txAttenuation");
|
||||
@@ -1036,10 +1046,10 @@ void api_driver::ApiDriver::setRxTxSettings(boost::property_tree::ptree &pt) {
|
||||
// демодулятор
|
||||
demod.is_aru_on = pt.get<bool>("rxAgcEn");
|
||||
demod.gain = pt.get<double>("rxManualGain");
|
||||
demod.is_rvt_iq = pt.get<bool>("aupcEn");
|
||||
demod.is_rvt_iq = pt.get<bool>("rxSpectrumInversion");
|
||||
demod.central_freq_in_kGz = pt.get<double>("rxCentralFreq");
|
||||
demod.baudrate = pt.get<uint32_t>("rxBaudrate");
|
||||
demod.rollof = pt.get<int>("rxRolloff");
|
||||
demod.rollof = pt.get<unsigned int>("rxRolloff");
|
||||
#ifdef MODEM_IS_SCPC
|
||||
demod.gold_seq_is_active = pt.get<bool>("rxGoldan");
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user