Compare commits
2 Commits
50f82483fd
...
55fc322c13
Author | SHA1 | Date | |
---|---|---|---|
55fc322c13 | |||
f30e1adb49 |
@ -6,6 +6,11 @@
|
|||||||
// минимальный порог для сна в цикле событий демона
|
// минимальный порог для сна в цикле событий демона
|
||||||
static constexpr int64_t SLEEP_THRESHOLD = 10;
|
static constexpr int64_t SLEEP_THRESHOLD = 10;
|
||||||
|
|
||||||
|
int64_t api_driver::TimeNow() {
|
||||||
|
return std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace api_driver {
|
namespace api_driver {
|
||||||
/**
|
/**
|
||||||
* Обертка для объектов, доступных для обновления
|
* Обертка для объектов, доступных для обновления
|
||||||
@ -196,37 +201,26 @@ void api_driver::TerminalApiDaemon::getDeviceState(obj::TerminalDeviceState &des
|
|||||||
dest = stateDev;
|
dest = stateDev;
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::TerminalApiDaemon::getSettingsRxTx(obj::TerminalRxTxSettings &dest) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void api_driver::TerminalApiDaemon::getNetworkSettings(obj::TerminalNetworkSettings &dest) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void api_driver::TerminalApiDaemon::getQosSettings(bool &isEnabled, std::string &json) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void api_driver::TerminalApiDaemon::setSettingsRxTx(obj::TerminalRxTxSettings &s, bool readback) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void api_driver::TerminalApiDaemon::setSettingsDpdi(DPDI_parmeters &s, bool readback) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void api_driver::TerminalApiDaemon::setSettingsBucLnb(buc_lnb_settings &bucLnb, bool readback) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void api_driver::TerminalApiDaemon::setQosSettings(bool enabled, const std::string &str, bool readback) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void api_driver::TerminalApiDaemon::setNetworkSettings(obj::TerminalNetworkSettings &s, bool readback) {
|
|
||||||
}
|
|
||||||
|
|
||||||
api_driver::obj::TerminalFirmwareVersion api_driver::TerminalApiDaemon::getFirmware() {
|
api_driver::obj::TerminalFirmwareVersion api_driver::TerminalApiDaemon::getFirmware() {
|
||||||
|
obj::TerminalFirmwareVersion res;
|
||||||
|
{
|
||||||
|
std::shared_lock _olock(firmwareMutex);
|
||||||
|
res = firmware;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::TerminalApiDaemon::resetPacketStatistics() {
|
void api_driver::TerminalApiDaemon::resetPacketStatistics() {
|
||||||
|
std::lock_guard lock(this->cpApiMutex);
|
||||||
|
cp.getDmaDebug("reset_cnt_rx");
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::TerminalApiDaemon::resetDefaultSettings() {
|
void api_driver::TerminalApiDaemon::resetDefaultSettings() {
|
||||||
|
std::lock_guard lock(this->cpApiMutex);
|
||||||
|
cp.setDmaDebug("begin_save_config", "");
|
||||||
|
cp.setDmaDebug("default_params", "");
|
||||||
|
cp.setDmaDebug("save_config", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
api_driver::TerminalApiDaemon::~TerminalApiDaemon() {
|
api_driver::TerminalApiDaemon::~TerminalApiDaemon() {
|
||||||
|
@ -50,22 +50,20 @@ namespace api_driver {
|
|||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Получение настроек, копирует текущие значения в структуры, переданные по указателю. Если передан пустой указатель, копирования не произойдет.
|
// * Получение настроек, копирует текущие значения в структуры, переданные по указателю. Если передан пустой указатель, копирования не произойдет.
|
||||||
|
// * Установка настроек просто копирует настройки и устанавливает их текущими
|
||||||
// */
|
// */
|
||||||
void getSettingsRxTx(obj::TerminalRxTxSettings &dest);
|
obj::TerminalRxTxSettings getSettingsRxTx() const;
|
||||||
|
void setSettingsRxTx(obj::TerminalRxTxSettings &s);
|
||||||
|
|
||||||
void getNetworkSettings(obj::TerminalNetworkSettings &dest);
|
#ifdef API_OBJECT_NETWORK_SETTINGS_ENABLE
|
||||||
|
obj::TerminalNetworkSettings getNetworkSettings() const;
|
||||||
|
void setNetworkSettings(obj::TerminalNetworkSettings &s);
|
||||||
|
#endif
|
||||||
|
|
||||||
void getQosSettings(bool &isEnabled, std::string &json);
|
#ifdef API_OBJECT_QOS_SETTINGS_ENABLE
|
||||||
|
obj::TerminalQosSettings getQosSettings() const;
|
||||||
void setSettingsRxTx(obj::TerminalRxTxSettings &s, bool readback = true);
|
void setQosSettings(bool enabled, const std::string &str);
|
||||||
|
#endif
|
||||||
void setSettingsDpdi(DPDI_parmeters &s, bool readback = true);
|
|
||||||
|
|
||||||
void setSettingsBucLnb(buc_lnb_settings &bucLnb, bool readback = true);
|
|
||||||
|
|
||||||
void setQosSettings(bool enabled, const std::string &str, bool readback = true);
|
|
||||||
|
|
||||||
void setNetworkSettings(obj::TerminalNetworkSettings &s, bool readback = true);
|
|
||||||
|
|
||||||
obj::TerminalFirmwareVersion getFirmware();
|
obj::TerminalFirmwareVersion getFirmware();
|
||||||
|
|
||||||
|
@ -1,10 +1,119 @@
|
|||||||
#include "proxy.h"
|
#include "proxy.h"
|
||||||
|
#include "sstream"
|
||||||
|
|
||||||
//#define CPAPI_PROXY_CALL(proxy, func, ...) do { auto _res = func(proxy.sid, __VA_ARGS__); if (_res != OK) { BOOST_LOG_TRIVIAL(error) << "CP API error in " #func "(" #__VA_ARGS__ "): " << _res; } } while (0)
|
#define CPAPI_PROXY_CALL_HELPER(callfrom, func, funcArgs, throwArgs) do { lastCpError = func funcArgs; if (lastCpError != OK) { \
|
||||||
// void foo() {
|
std::stringstream err; err << callfrom ": CP Api error " #func "("; err << throwArgs; err << "): " << lastCpError;\
|
||||||
// api_driver::proxy::CpProxy proxy;
|
throw std::runtime_error(err.str());\
|
||||||
// std::string tmp;
|
} } while (0)
|
||||||
// CPAPI_PROXY_CALL(proxy, CP_GetDmaDebug, "fuck", &tmp);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
api_driver::proxy::CpProxy::CpProxy() = default;
|
||||||
|
|
||||||
|
api_driver::proxy::CpProxy::CpProxy(TSID s): sid(s) {}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::connect() {
|
||||||
|
unsigned int access{};
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::connect", CP_Login, ("admin", "pass", &sid, &access), R"("admin", "pass", &sid, &access)");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::disconnect() {
|
||||||
|
if (sid != 0) {
|
||||||
|
lastCpError = CP_Logout(sid);
|
||||||
|
sid = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string api_driver::proxy::CpProxy::getDmaDebug(const std::string &arg) {
|
||||||
|
std::string result;
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::getDmaDebug", CP_GetDmaDebug, (sid, arg.c_str(), &result), arg);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::setDmaDebug(const std::string &arg, const std::string &value) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::setDmaDebug", CP_SetDmaDebug, (sid, arg.c_str(), value), arg << ", \"" << value << "\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string api_driver::proxy::CpProxy::getNetwork(const std::string ¶m) {
|
||||||
|
std::string result;
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::getNetwork", CP_GetNetwork, (sid, param.c_str(), &result), param);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::setNetwork(const std::string ¶m, const std::string &value) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::setNetwork", CP_SetNetwork, (sid, param.c_str(), value.c_str()), param << ", \"" << value << "\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::getModState(modulator_state &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::getModState", CP_GetModulatorState, (sid, dest), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::getModSettings(modulator_settings &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::getModSettings", CP_GetModulatorSettings, (sid, dest), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::setModSettings(modulator_settings &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::setModSettings", CP_SetModulatorSettings, (sid, dest), "struct {...}");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::getDemodState(demodulator_state &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::getDemodState", CP_GetDemodulatorState, (sid, dest), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::getDemodSettings(demodulator_settings &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::getDemodSettings", CP_GetDemodulatorSettings, (sid, dest), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::setDemodSettings(demodulator_settings &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::setDemodSettings", CP_SetDemodulatorSettings, (sid, dest), "struct {...}");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::getAcmSettings(ACM_parameters_serv_ &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::getAcmSettings", CP_GetAcmParams, (sid, &dest), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::setAcmSettings(ACM_parameters_serv_ &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::setAcmSettings", CP_GetAcmParams, (sid, &dest), "struct {...}");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::getDeviceState(device_state &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::getDeviceState", CP_GetDeviceState, (sid, dest), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::tuple<std::string, bool> api_driver::proxy::CpProxy::getQosSettings() {
|
||||||
|
std::string rules;
|
||||||
|
bool en;
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::getQosSettings", CP_GetQoSSettings, (sid, rules, en), "");
|
||||||
|
return {rules, en};
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::setQosSettings(const std::string &rules, bool enable) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::setQosSettings", CP_SetQoSSettings, (sid, rules, enable), "`" << rules << "`, " << (enable ? "true" : "false"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::getDpdiSettings(DPDI_parmeters &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::getDpdiSettings", CP_GetDpdiParams, (sid, &dest), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::setDpdiSettings(DPDI_parmeters &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::setDpdiSettings", CP_SetDpdiParams, (sid, dest), "struct {...}");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::getBuclnbSettings(buc_lnb_settings &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::getBuclnbSettings", CP_GetBUC_LNB_settings, (sid, dest), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::setBuclnbSettings(buc_lnb_settings &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::setBuclnbSettings", CP_SetBUC_LNB_settings, (sid, dest), "struct {...}");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::getCincState(CinC_state &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::getCincState", CP_GetCinCState, (sid, dest), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::proxy::CpProxy::getDebugMetrics(debug_metrics &dest) {
|
||||||
|
CPAPI_PROXY_CALL_HELPER("CpProxy::getDebugMetrics", CP_GetDebugMetrics, (sid, dest), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
api_driver::proxy::CpProxy::~CpProxy() {
|
||||||
|
disconnect();
|
||||||
|
}
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
std::ostream& operator<<(std::ostream& out, CP_Result result);
|
std::ostream& operator<<(std::ostream& out, CP_Result result);
|
||||||
|
|
||||||
|
|
||||||
namespace api_driver::proxy {
|
namespace api_driver::proxy {
|
||||||
class CpProxy {
|
class CpProxy {
|
||||||
public:
|
public:
|
||||||
@ -41,8 +40,28 @@ namespace api_driver::proxy {
|
|||||||
void getDemodSettings(demodulator_settings& dest);
|
void getDemodSettings(demodulator_settings& dest);
|
||||||
void setDemodSettings(demodulator_settings& dest);
|
void setDemodSettings(demodulator_settings& dest);
|
||||||
|
|
||||||
|
#ifdef API_STRUCT_ACM_ENABLE
|
||||||
|
void getAcmSettings(ACM_parameters_serv_& dest);
|
||||||
|
void setAcmSettings(ACM_parameters_serv_& dest);
|
||||||
|
#endif
|
||||||
|
|
||||||
void getDeviceState(device_state& dest);
|
void getDeviceState(device_state& dest);
|
||||||
|
|
||||||
|
#ifdef API_OBJECT_QOS_SETTINGS_ENABLE
|
||||||
|
std::tuple<std::string, bool> getQosSettings();
|
||||||
|
void setQosSettings(const std::string& rules, bool enable);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef API_OBJECT_DPDI_SETTINGS_ENABLE
|
||||||
|
void getDpdiSettings(DPDI_parmeters& dest);
|
||||||
|
void setDpdiSettings(DPDI_parmeters& dest);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef API_OBJECT_BUCLNB_SETTINGS_ENABLE
|
||||||
|
void getBuclnbSettings(buc_lnb_settings& dest);
|
||||||
|
void setBuclnbSettings(buc_lnb_settings& dest);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MODEM_IS_SCPC
|
#ifdef MODEM_IS_SCPC
|
||||||
void getCincState(CinC_state& dest);
|
void getCincState(CinC_state& dest);
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
#define API_OBJECT_DEBUG_METRICS_ENABLE
|
#define API_OBJECT_DEBUG_METRICS_ENABLE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MODEM_IS_SCPC)
|
||||||
|
#define API_STRUCT_ACM_ENABLE
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MODEM_IS_SCPC) || defined(MODEM_IS_TDMA)
|
#if defined(MODEM_IS_SCPC) || defined(MODEM_IS_TDMA)
|
||||||
#define API_OBJECT_NETWORK_SETTINGS_ENABLE
|
#define API_OBJECT_NETWORK_SETTINGS_ENABLE
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,10 +11,6 @@
|
|||||||
|
|
||||||
typedef boost::property_tree::ptree::path_type json_path;
|
typedef boost::property_tree::ptree::path_type json_path;
|
||||||
|
|
||||||
double translateCoordinates(uint8_t deg, uint8_t min) {
|
|
||||||
return static_cast<double>(deg) + static_cast<double>(min) / 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
// static int calculateSubnetMask(const std::string& subnet_mask) {
|
// static int calculateSubnetMask(const std::string& subnet_mask) {
|
||||||
// int mask = 0;
|
// int mask = 0;
|
||||||
// std::istringstream iss(subnet_mask);
|
// std::istringstream iss(subnet_mask);
|
||||||
@ -108,10 +104,10 @@ std::string api_driver::obj::StatisticsLogger::getSettings() {
|
|||||||
return res.str();
|
return res.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::obj::StatisticsLogger::setSettings(boost::property_tree::ptree &pt) {
|
void api_driver::obj::StatisticsLogger::setSettings(const nlohmann::json& data) {
|
||||||
const bool newEn = pt.get<bool>("en");
|
const bool newEn = data.value("en", logEn);
|
||||||
const int newInterval = pt.get<int>("logPeriodMs");
|
const int newInterval = data.value("logPeriodMs", logPeriodMs.load());
|
||||||
const int newMaxAgeMs = pt.get<int>("maxAgeMs");
|
const int newMaxAgeMs = data.value("maxAgeMs", maxAgeMs.load());
|
||||||
|
|
||||||
std::lock_guard _lock(this->mutex);
|
std::lock_guard _lock(this->mutex);
|
||||||
this->logPeriodMs = newInterval;
|
this->logPeriodMs = newInterval;
|
||||||
@ -136,7 +132,11 @@ void api_driver::obj::StatisticsLogger::setSettings(boost::property_tree::ptree
|
|||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::obj::StatisticsLogger::updateCallback(proxy::CpProxy &cp) {
|
void api_driver::obj::StatisticsLogger::updateCallback(proxy::CpProxy &cp) {
|
||||||
|
if (!logEn) return;
|
||||||
|
|
||||||
|
debug_metrics dm{};
|
||||||
|
cp.getDebugMetrics(dm);
|
||||||
|
putItem(dm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::obj::StatisticsLogger::putItem(const debug_metrics &item) {
|
void api_driver::obj::StatisticsLogger::putItem(const debug_metrics &item) {
|
||||||
@ -217,7 +217,12 @@ void api_driver::obj::TerminalNetworkSettings::updateCallback(proxy::CpProxy &cp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::obj::TerminalNetworkSettings::updateFromPt(boost::property_tree::ptree &pt) {
|
void api_driver::obj::TerminalNetworkSettings::updateFromJson(nlohmann::json &data) {
|
||||||
|
managementIp = data.value("managementIp", managementIp);
|
||||||
|
isL2 = data.value("isL2", isL2);
|
||||||
|
dataIp = data.value("dataIp", dataIp);
|
||||||
|
dataMtu = data.value("dataMtu", dataMtu);
|
||||||
|
serverName = data.value("serverName", serverName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::obj::TerminalNetworkSettings::store(proxy::CpProxy& cp) {
|
void api_driver::obj::TerminalNetworkSettings::store(proxy::CpProxy& cp) {
|
||||||
@ -239,17 +244,22 @@ void api_driver::obj::TerminalNetworkSettings::store(proxy::CpProxy& cp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string api_driver::obj::TerminalNetworkSettings::asJson() {
|
nlohmann::json api_driver::obj::TerminalNetworkSettings::asJson() {
|
||||||
std::stringstream out;
|
nlohmann::json res;
|
||||||
|
res["isL2"] = isL2;
|
||||||
return out.str();
|
res["managementIp"] = managementIp;
|
||||||
|
res["managementGateway"] = managementGateway;
|
||||||
|
res["dataIp"] = dataIp;
|
||||||
|
res["dataMtu"] = dataMtu;
|
||||||
|
res["serverName"] = serverName;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
api_driver::obj::TerminalNetworkSettings::~TerminalNetworkSettings() = default;
|
api_driver::obj::TerminalNetworkSettings::~TerminalNetworkSettings() = default;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef API_OBJECT_QOS_SETTINGS_ENABLE
|
#ifdef API_OBJECT_QOS_SETTINGS_ENABLE
|
||||||
api_driver::obj::TerminalQosSettings::TerminalQosSettings() = default;
|
api_driver::obj::TerminalQosSettings::TerminalQosSettings(): qosSettingsJson(DEFAULT_QOS_CLASSES) {};
|
||||||
api_driver::obj::TerminalQosSettings::TerminalQosSettings(const TerminalQosSettings &src) = default;
|
api_driver::obj::TerminalQosSettings::TerminalQosSettings(const TerminalQosSettings &src) = default;
|
||||||
api_driver::obj::TerminalQosSettings & api_driver::obj::TerminalQosSettings::operator=(const TerminalQosSettings &src) = default;
|
api_driver::obj::TerminalQosSettings & api_driver::obj::TerminalQosSettings::operator=(const TerminalQosSettings &src) = default;
|
||||||
|
|
||||||
@ -259,20 +269,60 @@ void api_driver::obj::TerminalQosSettings::loadDefaults() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::obj::TerminalQosSettings::updateCallback(proxy::CpProxy &cp) {
|
void api_driver::obj::TerminalQosSettings::updateCallback(proxy::CpProxy &cp) {
|
||||||
|
auto [profile, en] = cp.getQosSettings();
|
||||||
|
qosEnabled = en;
|
||||||
|
try {
|
||||||
|
qosSettingsJson = nlohmann::json::parse(profile);
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
BOOST_LOG_TRIVIAL(warning) << "api_driver::obj::TerminalQosSettings::updateCallback(): Failed to parse QoS settings json: " << e.what();
|
||||||
|
qosSettingsJson = DEFAULT_QOS_CLASSES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::obj::TerminalQosSettings::updateFromPt(boost::property_tree::ptree &pt) {
|
void api_driver::obj::TerminalQosSettings::updateFromJson(nlohmann::json &data) {
|
||||||
|
qosEnabled = data.value("en", qosEnabled);
|
||||||
|
qosSettingsJson = data.value("profile", qosSettingsJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::obj::TerminalQosSettings::store(proxy::CpProxy &cp) {
|
void api_driver::obj::TerminalQosSettings::store(proxy::CpProxy &cp) {
|
||||||
|
cp.setQosSettings(qosSettingsJson.dump(), qosEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string api_driver::obj::TerminalQosSettings::asJson() {
|
nlohmann::json api_driver::obj::TerminalQosSettings::asJson() {
|
||||||
|
nlohmann::json res;
|
||||||
|
res["en"] = qosEnabled;
|
||||||
|
res["profile"] = qosSettingsJson;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
api_driver::obj::TerminalQosSettings::~TerminalQosSettings() = default;
|
api_driver::obj::TerminalQosSettings::~TerminalQosSettings() = default;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
api_driver::obj::TerminalFirmwareVersion::TerminalFirmwareVersion() = default;
|
||||||
|
api_driver::obj::TerminalFirmwareVersion::TerminalFirmwareVersion(const TerminalFirmwareVersion &src) = default;
|
||||||
|
api_driver::obj::TerminalFirmwareVersion & api_driver::obj::TerminalFirmwareVersion::operator=(const TerminalFirmwareVersion &src) = default;
|
||||||
|
|
||||||
|
void api_driver::obj::TerminalFirmwareVersion::load(proxy::CpProxy &cp) {
|
||||||
|
version = cp.getNetwork("version");
|
||||||
|
modemId = cp.getNetwork("chip_id");
|
||||||
|
rtrim(modemId);
|
||||||
|
modemSn = cp.getNetwork("serial");
|
||||||
|
macMang = cp.getNetwork("mac_eth0");
|
||||||
|
macData = cp.getNetwork("mac_eth1");
|
||||||
|
}
|
||||||
|
|
||||||
|
nlohmann::json api_driver::obj::TerminalFirmwareVersion::asJson() {
|
||||||
|
nlohmann::json res;
|
||||||
|
res["version"] = version;
|
||||||
|
res["modemId"] = modemId;
|
||||||
|
res["modemSn"] = modemSn;
|
||||||
|
res["macMang"] = macMang;
|
||||||
|
res["macData"] = macData;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
api_driver::obj::TerminalFirmwareVersion::~TerminalFirmwareVersion() = default;
|
||||||
|
|
||||||
|
|
||||||
api_driver::obj::TerminalState::TerminalState() = default;
|
api_driver::obj::TerminalState::TerminalState() = default;
|
||||||
|
|
||||||
@ -487,6 +537,397 @@ nlohmann::json api_driver::obj::TerminalDeviceState::asJson() const {
|
|||||||
api_driver::obj::TerminalDeviceState::~TerminalDeviceState() = default;
|
api_driver::obj::TerminalDeviceState::~TerminalDeviceState() = default;
|
||||||
|
|
||||||
|
|
||||||
|
api_driver::obj::TerminalRxTxSettings::TerminalRxTxSettings() = default;
|
||||||
|
api_driver::obj::TerminalRxTxSettings::TerminalRxTxSettings(const TerminalRxTxSettings &src) = default;
|
||||||
|
api_driver::obj::TerminalRxTxSettings & api_driver::obj::TerminalRxTxSettings::operator=(const TerminalRxTxSettings &src) = default;
|
||||||
|
|
||||||
|
void api_driver::obj::TerminalRxTxSettings::updateCallback(proxy::CpProxy &cp) {
|
||||||
|
cp.getModSettings(mod);
|
||||||
|
cp.getDemodSettings(dem);
|
||||||
|
#ifdef API_STRUCT_ACM_ENABLE
|
||||||
|
cp.getAcmSettings(acm);
|
||||||
|
#endif
|
||||||
|
#ifdef API_OBJECT_DPDI_SETTINGS_ENABLE
|
||||||
|
cp.getDpdiSettings(dpdi);
|
||||||
|
#endif
|
||||||
|
#ifdef API_OBJECT_BUCLNB_SETTINGS_ENABLE
|
||||||
|
cp.getBuclnbSettings(buclnb);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::obj::TerminalRxTxSettings::storeMainSettings(proxy::CpProxy &cp) {
|
||||||
|
cp.setModSettings(mod);
|
||||||
|
cp.setDemodSettings(dem);
|
||||||
|
#ifdef API_STRUCT_ACM_ENABLE
|
||||||
|
cp.setAcmSettings(acm);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct ModcodDef_t {const char* modulation; const char* speed;};
|
||||||
|
const static ModcodDef_t ModcodDefs[] = {
|
||||||
|
{.modulation = "dummy", .speed = "0"},
|
||||||
|
{.modulation = "qpsk", .speed = "1/4"},
|
||||||
|
{.modulation = "qpsk", .speed = "1/3"},
|
||||||
|
{.modulation = "qpsk", .speed = "2/5"},
|
||||||
|
{.modulation = "qpsk", .speed = "1/2"},
|
||||||
|
{.modulation = "qpsk", .speed = "3/5"},
|
||||||
|
{.modulation = "qpsk", .speed = "2/3"},
|
||||||
|
{.modulation = "qpsk", .speed = "3/4"},
|
||||||
|
{.modulation = "qpsk", .speed = "4/5"},
|
||||||
|
{.modulation = "qpsk", .speed = "5/6"},
|
||||||
|
{.modulation = "qpsk", .speed = "8/9"},
|
||||||
|
{.modulation = "qpsk", .speed = "9/10"},
|
||||||
|
{.modulation = "8psk", .speed = "3/5"},
|
||||||
|
{.modulation = "8psk", .speed = "2/3"},
|
||||||
|
{.modulation = "8psk", .speed = "3/4"},
|
||||||
|
{.modulation = "8psk", .speed = "5/6"},
|
||||||
|
{.modulation = "8psk", .speed = "8/9"},
|
||||||
|
{.modulation = "8psk", .speed = "9/10"},
|
||||||
|
{.modulation = "16apsk", .speed = "2/3"},
|
||||||
|
{.modulation = "16apsk", .speed = "3/4"},
|
||||||
|
{.modulation = "16apsk", .speed = "4/5"},
|
||||||
|
{.modulation = "16apsk", .speed = "5/6"},
|
||||||
|
{.modulation = "16apsk", .speed = "8/9"},
|
||||||
|
{.modulation = "16apsk", .speed = "9/10"},
|
||||||
|
{.modulation = "32apsk", .speed = "3/4"},
|
||||||
|
{.modulation = "32apsk", .speed = "4/5"},
|
||||||
|
{.modulation = "32apsk", .speed = "5/6"},
|
||||||
|
{.modulation = "32apsk", .speed = "8/9"},
|
||||||
|
{.modulation = "32apsk", .speed = "9/10"},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char* extractModcodModulation(uint32_t modcod, bool defaultQpsk1_4 = true) {
|
||||||
|
modcod >>= 2;
|
||||||
|
const auto* d = defaultQpsk1_4 ? ModcodDefs : ModcodDefs + 1;
|
||||||
|
if (modcod < (sizeof(ModcodDefs) / sizeof(ModcodDef_t))) {
|
||||||
|
d = ModcodDefs + modcod;
|
||||||
|
}
|
||||||
|
return d->modulation;
|
||||||
|
}
|
||||||
|
static const char* extractModcodSpeed(uint32_t modcod, bool defaultQpsk1_4 = true) {
|
||||||
|
modcod >>= 2;
|
||||||
|
const auto* d = defaultQpsk1_4 ? ModcodDefs : ModcodDefs + 1;
|
||||||
|
if (modcod < (sizeof(ModcodDefs) / sizeof(ModcodDef_t))) {
|
||||||
|
d = ModcodDefs + modcod;
|
||||||
|
}
|
||||||
|
return d->speed;
|
||||||
|
}
|
||||||
|
static bool extractModcodFrameSizeNormal(uint32_t modcod) { return (modcod & 2) == 0; }
|
||||||
|
static bool extractModcodIsPilots(uint32_t modcod) { return (modcod & 1) != 0; }
|
||||||
|
static uint32_t buildModcodFromJson(const nlohmann::json& data, uint32_t modcod, const std::string& name, bool isNormalFrame, bool isPilots = false) {
|
||||||
|
const std::string mod = data.value(name + "Modulation", extractModcodModulation(modcod));
|
||||||
|
const std::string speed = data.value(name + "Speed", extractModcodSpeed(modcod));
|
||||||
|
uint32_t _index = 0;
|
||||||
|
for (const auto& m: ModcodDefs) {
|
||||||
|
if (mod == m.modulation) {
|
||||||
|
if (modcod == 0) modcod = _index;
|
||||||
|
if (speed == m.speed) {
|
||||||
|
modcod = _index;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_index++;
|
||||||
|
}
|
||||||
|
return (modcod << 2)| (isNormalFrame ? 0 : 2) | (isPilots ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void api_driver::obj::TerminalRxTxSettings::updateMainSettings(const nlohmann::json &data) {
|
||||||
|
// для модулятора
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
mod.is_cinc = data.value("isCinC", mod.is_cinc);
|
||||||
|
#endif
|
||||||
|
mod.tx_is_on = data.value("txEn", mod.tx_is_on);
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
mod.is_save_current_state = data.value("txAutoStart", mod.is_save_current_state);
|
||||||
|
mod.is_test_data = data.value("txIsTestInput", mod.is_test_data);
|
||||||
|
#endif
|
||||||
|
mod.is_carrier = !data.value("txModulatorIsTest", !mod.is_carrier);
|
||||||
|
mod.central_freq_in_kGz = data.value("txCentralFreq", mod.central_freq_in_kGz);
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
mod.baudrate = data.value("txBaudrate", mod.baudrate);
|
||||||
|
mod.rollof = data.value("txRolloff", mod.rollof);
|
||||||
|
mod.gold_seq_is_active = data.value("txGoldan", mod.gold_seq_is_active);
|
||||||
|
#endif
|
||||||
|
mod.attenuation = data.value("txAttenuation", mod.attenuation);
|
||||||
|
|
||||||
|
#if defined(MODEM_IS_SCPC) || defined(MODEM_IS_SHPS)
|
||||||
|
bool acmIsFrameSizeNormal = extractModcodFrameSizeNormal(mod.modcod_tx);
|
||||||
|
bool acmIsPilots = extractModcodIsPilots(mod.modcod_tx);
|
||||||
|
|
||||||
|
acmIsFrameSizeNormal = data.value("txFrameSizeNormal", acmIsFrameSizeNormal);
|
||||||
|
acmIsPilots = data.value("txIsPilots", acmIsPilots);
|
||||||
|
mod.modcod_tx = buildModcodFromJson(data, mod.modcod_tx, "dvbCcm", acmIsFrameSizeNormal, acmIsPilots);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// демодулятор
|
||||||
|
dem.is_aru_on = data.value("rxAgcEn", dem.is_aru_on);
|
||||||
|
dem.gain = data.value("rxManualGain", dem.gain);
|
||||||
|
dem.is_rvt_iq = data.value("rxSpectrumInversion", dem.is_rvt_iq);
|
||||||
|
dem.central_freq_in_kGz = data.value("rxCentralFreq", dem.central_freq_in_kGz);
|
||||||
|
dem.baudrate = data.value("rxBaudrate", dem.baudrate);
|
||||||
|
dem.rollof = data.value("rxRolloff", dem.rollof);
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
dem.gold_seq_is_active = data.value("rxGoldan", dem.gold_seq_is_active);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef API_STRUCT_ACM_ENABLE
|
||||||
|
// ACM
|
||||||
|
#ifndef MODEM_IS_SHPS
|
||||||
|
// в ШПС этих настроек нет
|
||||||
|
acm.period_pack_acm = data.value("dvbServicePacketPeriod", acm.period_pack_acm);
|
||||||
|
acm.enable_acm = data.value("dvbIsAcm", acm.enable_acm);
|
||||||
|
acm.min_modcod_acm = buildModcodFromJson(data, acm.min_modcod_acm, "dvbAcmMin", acmIsFrameSizeNormal, acmIsPilots);
|
||||||
|
acm.min_modcod_acm = buildModcodFromJson(data, acm.max_modcod_acm, "dvbAcmMax", acmIsFrameSizeNormal, acmIsPilots);
|
||||||
|
acm.snr_threashold_acm = data.value("dvbSnrReserve", acm.snr_threashold_acm); // запас ОСШ
|
||||||
|
#endif
|
||||||
|
|
||||||
|
acm.enable_aupc = data.value("aupcEn", acm.enable_aupc);
|
||||||
|
acm.min_attenuation_aupc = data.value("aupcMinAttenuation", acm.min_attenuation_aupc);
|
||||||
|
acm.max_attenuation_aupc = data.value("aupcMaxAttenuation", acm.max_attenuation_aupc);
|
||||||
|
acm.snr_threashold_aupc = data.value("aupcRequiredSnr", acm.snr_threashold_aupc);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef API_OBJECT_DPDI_SETTINGS_ENABLE
|
||||||
|
static double translateCoordinates(uint8_t deg, uint8_t min) {
|
||||||
|
return static_cast<double>(deg) + static_cast<double>(min) / 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::tuple<uint8_t, uint8_t> translateCoordinates(double abs) {
|
||||||
|
auto deg = static_cast<uint8_t>(abs);
|
||||||
|
double min_double = (abs - deg) * 60;
|
||||||
|
auto min = static_cast<uint8_t>(min_double);
|
||||||
|
return std::make_tuple(deg, min);
|
||||||
|
}
|
||||||
|
|
||||||
|
void api_driver::obj::TerminalRxTxSettings::updateDpdiSettings(const nlohmann::json &data) {
|
||||||
|
dpdi.is_delay_window = !data.value("dpdiIsPositional", !dpdi.is_delay_window);
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
dpdi.freq_offset = data.value("dpdiSearchBandwidth", dpdi.freq_offset);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (data["dpdiPositionStationLatitude"]) {
|
||||||
|
const double pos = data["dpdiPositionStationLatitude"];
|
||||||
|
const auto [g, m] = translateCoordinates(pos);
|
||||||
|
dpdi.latitude_station_grad = g;
|
||||||
|
dpdi.latitude_station_minute = m;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data["dpdiPositionStationLongitude"]) {
|
||||||
|
const double pos = data["dpdiPositionStationLongitude"];
|
||||||
|
const auto [g, m] = translateCoordinates(pos);
|
||||||
|
dpdi.longitude_station_grad = g;
|
||||||
|
dpdi.longitude_station_minute = m;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data["dpdiPositionSatelliteLongitude"]) {
|
||||||
|
const double pos = data["dpdiPositionSatelliteLongitude"];
|
||||||
|
const auto [g, m] = translateCoordinates(pos);
|
||||||
|
dpdi.longitude_sattelite_grad = g;
|
||||||
|
dpdi.longitude_sattelite_minute = m;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
dpdi.min_delay = data.value("dpdiDelayMin", dpdi.min_delay);
|
||||||
|
dpdi.max_delay = data.value("dpdiDelayMax", dpdi.max_delay);
|
||||||
|
#else
|
||||||
|
s.min_delay = 0;
|
||||||
|
s.max_delay = data.value("dpdiDelay", dpdi.max_delay);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void api_driver::obj::TerminalRxTxSettings::storeDpdiSettings(proxy::CpProxy &cp) {
|
||||||
|
cp.setDpdiSettings(dpdi);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef API_OBJECT_BUCLNB_SETTINGS_ENABLE
|
||||||
|
void api_driver::obj::TerminalRxTxSettings::updateBuclnbSettings(const nlohmann::json &data) {
|
||||||
|
{
|
||||||
|
// напряжение buc
|
||||||
|
int oldVoltage = 0;
|
||||||
|
if (buclnb.buc == voltage_buc::_24V) { oldVoltage = 24; }
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
if (buclnb.buc == voltage_buc::_24V) { oldVoltage = 24; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
auto result = data.value("bucPowering", oldVoltage);
|
||||||
|
switch (result) {
|
||||||
|
case 24: buclnb.buc = voltage_buc::_24V; break;
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
case 48: buclnb.buc = voltage_buc::_48V; break;
|
||||||
|
#endif
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
buclnb.buc = voltage_buc::DISABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buclnb.is_ref_10MHz_buc = data.value("bucRefClk10M", buclnb.is_ref_10MHz_buc);
|
||||||
|
|
||||||
|
{
|
||||||
|
// напряжение lnb
|
||||||
|
int oldVoltage;
|
||||||
|
switch (buclnb.lnb) {
|
||||||
|
case voltage_lnb::_13V: oldVoltage = 13; break;
|
||||||
|
case voltage_lnb::_18V: oldVoltage = 18; break;
|
||||||
|
case voltage_lnb::_24V: oldVoltage = 24; break;
|
||||||
|
default: oldVoltage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto result = data.value("lnbPowering", oldVoltage);
|
||||||
|
switch (result) {
|
||||||
|
case 13: buclnb.lnb = voltage_lnb::_13V; break;
|
||||||
|
case 18: buclnb.lnb = voltage_lnb::_18V; break;
|
||||||
|
case 24: buclnb.lnb = voltage_lnb::_24V; break;
|
||||||
|
default: buclnb.lnb = voltage_lnb::DISABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buclnb.is_ref_10MHz_lnb = data.value("lnbRefClk10M", buclnb.is_ref_10MHz_lnb);
|
||||||
|
|
||||||
|
buclnb.is_ref_10MHz_output = data.value("srvRefClk10M", buclnb.is_ref_10MHz_output);
|
||||||
|
buclnb.is_save_current_state = data.value("bucLnbAutoStart", buclnb.is_save_current_state);
|
||||||
|
}
|
||||||
|
void api_driver::obj::TerminalRxTxSettings::storeBuclnbSettings(proxy::CpProxy &cp) {
|
||||||
|
cp.setBuclnbSettings(buclnb);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void api_driver::obj::TerminalRxTxSettings::storeAll(proxy::CpProxy &cp) {
|
||||||
|
storeMainSettings(cp);
|
||||||
|
#ifdef API_OBJECT_DPDI_SETTINGS_ENABLE
|
||||||
|
storeDpdiSettings(cp);
|
||||||
|
#endif
|
||||||
|
#ifdef API_OBJECT_BUCLNB_SETTINGS_ENABLE
|
||||||
|
storeBuclnbSettings(cp);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nlohmann::json api_driver::obj::TerminalRxTxSettings::asJson() const {
|
||||||
|
nlohmann::json res;
|
||||||
|
|
||||||
|
// RX TX
|
||||||
|
{
|
||||||
|
auto& rxtx = res["rxtx"];
|
||||||
|
// для модулятора
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
rxtx["isCinC"] = mod.is_cinc;
|
||||||
|
#endif
|
||||||
|
rxtx["txEn"] = mod.tx_is_on;
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
rxtx["txAutoStart"] = mod.is_save_current_state;
|
||||||
|
rxtx["txIsTestInput"] = mod.is_test_data;
|
||||||
|
#endif
|
||||||
|
rxtx["txModulatorIsTest"] = !mod.is_carrier;
|
||||||
|
rxtx["txCentralFreq"] = mod.central_freq_in_kGz;
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
rxtx["txBaudrate"] = mod.baudrate;
|
||||||
|
rxtx["txRolloff"] = mod.rollof;
|
||||||
|
rxtx["txGoldan"] = mod.gold_seq_is_active;
|
||||||
|
#endif
|
||||||
|
rxtx["txAttenuation"] = mod.attenuation;
|
||||||
|
|
||||||
|
#if defined(MODEM_IS_SCPC) || defined(MODEM_IS_SHPS)
|
||||||
|
const bool acmIsFrameSizeNormal = extractModcodFrameSizeNormal(mod.modcod_tx);
|
||||||
|
const bool acmIsPilots = extractModcodIsPilots(mod.modcod_tx);
|
||||||
|
|
||||||
|
rxtx["txFrameSizeNormal"] = acmIsFrameSizeNormal;
|
||||||
|
rxtx["txIsPilots"] = acmIsPilots;
|
||||||
|
|
||||||
|
rxtx["dvbCcmModulation"] = extractModcodModulation(mod.modcod_tx);
|
||||||
|
rxtx["dvbCcmSpeed"] = extractModcodSpeed(mod.modcod_tx);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// демодулятор
|
||||||
|
rxtx["rxAgcEn"] = dem.is_aru_on;
|
||||||
|
rxtx["rxManualGain"] = dem.gain;
|
||||||
|
rxtx["rxSpectrumInversion"] = dem.is_rvt_iq;
|
||||||
|
rxtx["rxCentralFreq"] = dem.central_freq_in_kGz;
|
||||||
|
rxtx["rxBaudrate"] = dem.baudrate;
|
||||||
|
rxtx["rxRolloff"] = dem.rollof;
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
rxtx["rxGoldan"] = dem.gold_seq_is_active;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef API_STRUCT_ACM_ENABLE
|
||||||
|
// ACM
|
||||||
|
#ifndef MODEM_IS_SHPS
|
||||||
|
// в ШПС этих настроек нет
|
||||||
|
rxtx["dvbServicePacketPeriod"] = acm.period_pack_acm;
|
||||||
|
rxtx["dvbIsAcm"] = acm.enable_acm;
|
||||||
|
|
||||||
|
rxtx["dvbAcmMinModulation"] = extractModcodModulation(acm.min_modcod_acm);
|
||||||
|
rxtx["dvbAcmMinSpeed"] = extractModcodSpeed(acm.min_modcod_acm);
|
||||||
|
|
||||||
|
rxtx["dvbAcmMaxModulation"] = extractModcodModulation(acm.max_modcod_acm);
|
||||||
|
rxtx["dvbAcmMaxSpeed"] = extractModcodSpeed(acm.max_modcod_acm);
|
||||||
|
|
||||||
|
rxtx["dvbSnrReserve"] = acm.snr_threashold_acm; // запас ОСШ
|
||||||
|
#endif
|
||||||
|
|
||||||
|
rxtx["aupcEn"] = acm.enable_aupc;
|
||||||
|
rxtx["aupcMinAttenuation"] = acm.min_attenuation_aupc;
|
||||||
|
rxtx["aupcMaxAttenuation"] = acm.max_attenuation_aupc;
|
||||||
|
rxtx["aupcRequiredSnr"] = acm.snr_threashold_aupc;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef API_OBJECT_DPDI_SETTINGS_ENABLE
|
||||||
|
{
|
||||||
|
auto& dp = res["dpdi"];
|
||||||
|
|
||||||
|
dp["dpdiIsPositional"] = !dpdi.is_delay_window;
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
dp["dpdiSearchBandwidth"] = dpdi.freq_offset;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dp["dpdiPositionStationLatitude"] = translateCoordinates(dpdi.latitude_station_grad, dpdi.latitude_station_minute);
|
||||||
|
dp["dpdiPositionStationLongitude"] = translateCoordinates(dpdi.longitude_station_grad, dpdi.longitude_station_minute);
|
||||||
|
dp["dpdiPositionSatelliteLongitude"] = translateCoordinates(dpdi.longitude_sattelite_grad, dpdi.longitude_sattelite_minute);
|
||||||
|
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
dp["dpdiDelayMin"] = dpdi.min_delay;
|
||||||
|
dp["dpdiDelayMax"] = dpdi.max_delay;
|
||||||
|
#else
|
||||||
|
dp["dpdiDelay"] = dpdi.max_delay;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// BucLnb
|
||||||
|
#ifdef API_OBJECT_BUCLNB_SETTINGS_ENABLE
|
||||||
|
{
|
||||||
|
auto& bl = res["buclnb"];
|
||||||
|
switch (buclnb.buc) {
|
||||||
|
case voltage_buc::_24V: bl["bucPowering"] = 24; break;
|
||||||
|
#ifdef MODEM_IS_SCPC
|
||||||
|
case voltage_buc::_48V: bl["bucPowering"] = 48; break;
|
||||||
|
#endif
|
||||||
|
default: bl["bucPowering"] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bl["bucRefClk10M"] = buclnb.is_ref_10MHz_buc;
|
||||||
|
switch (buclnb.lnb) {
|
||||||
|
case voltage_lnb::_13V: bl["lnbPowering"] = 13; break;
|
||||||
|
case voltage_lnb::_18V: bl["lnbPowering"] = 18; break;
|
||||||
|
case voltage_lnb::_24V: bl["lnbPowering"] = 24; break;
|
||||||
|
default: bl["lnbPowering"] = 0;
|
||||||
|
}
|
||||||
|
bl["lnbRefClk10M"] = buclnb.is_ref_10MHz_lnb;
|
||||||
|
|
||||||
|
bl["srvRefClk10M"] = buclnb.is_ref_10MHz_output;
|
||||||
|
bl["bucLnbAutoStart"] = buclnb.is_save_current_state;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
api_driver::obj::TerminalRxTxSettings::~TerminalRxTxSettings() = default;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <boost/log/trivial.hpp>
|
//#include <boost/property_tree/ptree_fwd.hpp>
|
||||||
#include <boost/property_tree/ptree_fwd.hpp>
|
|
||||||
|
|
||||||
#include "common/nlohmann/json.hpp"
|
#include "common/nlohmann/json.hpp"
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ namespace api_driver::obj {
|
|||||||
* @return {"en": bool, "logPeriodMs": int, "maxAgeMs": int}
|
* @return {"en": bool, "logPeriodMs": int, "maxAgeMs": int}
|
||||||
*/
|
*/
|
||||||
std::string getSettings();
|
std::string getSettings();
|
||||||
void setSettings(boost::property_tree::ptree &pt);
|
void setSettings(const nlohmann::json& data);
|
||||||
|
|
||||||
void updateCallback(proxy::CpProxy& cp);
|
void updateCallback(proxy::CpProxy& cp);
|
||||||
/**
|
/**
|
||||||
@ -60,7 +59,7 @@ namespace api_driver::obj {
|
|||||||
static constexpr const char* DEFAULT_SERVER_NAME = "RSCM-101";
|
static constexpr const char* DEFAULT_SERVER_NAME = "RSCM-101";
|
||||||
#elif defined(MODEM_IS_TDMA)
|
#elif defined(MODEM_IS_TDMA)
|
||||||
static constexpr const char* DEFAULT_SERVER_NAME = "TDMA Abonent";
|
static constexpr const char* DEFAULT_SERVER_NAME = "TDMA Abonent";
|
||||||
#elif defined(MODEM_IS_SHPC)
|
#elif defined(MODEM_IS_SHPS)
|
||||||
static constexpr const char* DEFAULT_SERVER_NAME = "SHPS Terminal";
|
static constexpr const char* DEFAULT_SERVER_NAME = "SHPS Terminal";
|
||||||
#else
|
#else
|
||||||
#error "Selected modem type not supported!"
|
#error "Selected modem type not supported!"
|
||||||
@ -80,9 +79,9 @@ namespace api_driver::obj {
|
|||||||
void loadDefaults();
|
void loadDefaults();
|
||||||
|
|
||||||
void updateCallback(proxy::CpProxy& cp);
|
void updateCallback(proxy::CpProxy& cp);
|
||||||
void updateFromPt(boost::property_tree::ptree &pt);
|
void updateFromJson(nlohmann::json& data);
|
||||||
void store(proxy::CpProxy& cp);
|
void store(proxy::CpProxy& cp);
|
||||||
std::string asJson();
|
nlohmann::json asJson();
|
||||||
|
|
||||||
~TerminalNetworkSettings();
|
~TerminalNetworkSettings();
|
||||||
};
|
};
|
||||||
@ -92,7 +91,7 @@ namespace api_driver::obj {
|
|||||||
class TerminalQosSettings {
|
class TerminalQosSettings {
|
||||||
public:
|
public:
|
||||||
static constexpr const char* DEFAULT_QOS_CLASSES = R"({"rt1":[],"rt2":[],"rt3":[],"cd":[]})";
|
static constexpr const char* DEFAULT_QOS_CLASSES = R"({"rt1":[],"rt2":[],"rt3":[],"cd":[]})";
|
||||||
std::string qosSettingsJson;
|
nlohmann::json qosSettingsJson;
|
||||||
bool qosEnabled = false;
|
bool qosEnabled = false;
|
||||||
|
|
||||||
TerminalQosSettings();
|
TerminalQosSettings();
|
||||||
@ -102,9 +101,9 @@ namespace api_driver::obj {
|
|||||||
void loadDefaults();
|
void loadDefaults();
|
||||||
|
|
||||||
void updateCallback(proxy::CpProxy& cp);
|
void updateCallback(proxy::CpProxy& cp);
|
||||||
void updateFromPt(boost::property_tree::ptree &pt);
|
void updateFromJson(nlohmann::json& data);
|
||||||
void store(proxy::CpProxy& cp);
|
void store(proxy::CpProxy& cp);
|
||||||
std::string asJson();
|
nlohmann::json asJson();
|
||||||
|
|
||||||
~TerminalQosSettings();
|
~TerminalQosSettings();
|
||||||
};
|
};
|
||||||
@ -116,18 +115,12 @@ namespace api_driver::obj {
|
|||||||
|
|
||||||
TerminalFirmwareVersion();
|
TerminalFirmwareVersion();
|
||||||
TerminalFirmwareVersion(const TerminalFirmwareVersion& src);
|
TerminalFirmwareVersion(const TerminalFirmwareVersion& src);
|
||||||
~TerminalFirmwareVersion();
|
|
||||||
|
|
||||||
// logCpApiError("api_driver::TerminalApiDaemon::connectToApi()->CP_GetNetwork(version)", CP_GetNetwork(sid, "version", &f.version));
|
|
||||||
// logCpApiError("api_driver::TerminalApiDaemon::connectToApi()->CP_GetNetwork(chip_id)", CP_GetNetwork(sid, "chip_id", &f.modemId));
|
|
||||||
// rtrim(f.modemId);
|
|
||||||
// logCpApiError("api_driver::TerminalApiDaemon::connectToApi()->CP_GetNetwork(serial)", CP_GetNetwork(sid, "serial", &f.modemSn));
|
|
||||||
// logCpApiError("api_driver::TerminalApiDaemon::connectToApi()->CP_GetNetwork(mac_eth0)", CP_GetNetwork(sid, "mac_eth0", &f.macMang));
|
|
||||||
// logCpApiError("api_driver::TerminalApiDaemon::connectToApi()->CP_GetNetwork(mac_eth1)", CP_GetNetwork(sid, "mac_eth1", &f.macData));
|
|
||||||
void load(proxy::CpProxy& cp);
|
|
||||||
std::string asJson();
|
|
||||||
|
|
||||||
TerminalFirmwareVersion& operator= (const TerminalFirmwareVersion& src);
|
TerminalFirmwareVersion& operator= (const TerminalFirmwareVersion& src);
|
||||||
|
|
||||||
|
void load(proxy::CpProxy& cp);
|
||||||
|
nlohmann::json asJson();
|
||||||
|
|
||||||
|
~TerminalFirmwareVersion();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,42 +135,42 @@ namespace api_driver::obj {
|
|||||||
bool fIsCinC = false;
|
bool fIsCinC = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool fRxState;
|
bool fRxState{};
|
||||||
bool fRxSymSyncLock;
|
bool fRxSymSyncLock{};
|
||||||
bool fRxFreqSearchLock;
|
bool fRxFreqSearchLock{};
|
||||||
bool fRxAfcLock;
|
bool fRxAfcLock{};
|
||||||
bool fRxPktSync;
|
bool fRxPktSync{};
|
||||||
|
|
||||||
float fRxSnr;
|
float fRxSnr{};
|
||||||
float fRxRssi;
|
float fRxRssi{};
|
||||||
uint16_t fRxModcod;
|
uint16_t fRxModcod{};
|
||||||
bool fRxFrameSizeNormal;
|
bool fRxFrameSizeNormal{};
|
||||||
bool fRxIsPilots;
|
bool fRxIsPilots{};
|
||||||
|
|
||||||
double fRxSymError;
|
double fRxSymError{};
|
||||||
double fRxFreqErr;
|
double fRxFreqErr{};
|
||||||
double fRxFreqErrAcc;
|
double fRxFreqErrAcc{};
|
||||||
double fRxInputSignalLevel;
|
double fRxInputSignalLevel{};
|
||||||
double fRxPllError;
|
double fRxPllError{};
|
||||||
double fRxSpeedOnRxKbit;
|
double fRxSpeedOnRxKbit{};
|
||||||
double fRxSpeedOnIifKbit;
|
double fRxSpeedOnIifKbit{};
|
||||||
uint32_t fRxPacketsOk;
|
uint32_t fRxPacketsOk{};
|
||||||
uint32_t fRxPacketsBad;
|
uint32_t fRxPacketsBad{};
|
||||||
uint32_t fRxPacketsDummy;
|
uint32_t fRxPacketsDummy{};
|
||||||
|
|
||||||
uint16_t fTxModcod;
|
uint16_t fTxModcod{};
|
||||||
double fTxSpeedOnTxKbit;
|
double fTxSpeedOnTxKbit{};
|
||||||
double fTxSpeedOnIifKbit;
|
double fTxSpeedOnIifKbit{};
|
||||||
#ifdef MODEM_IS_SCPC
|
#ifdef MODEM_IS_SCPC
|
||||||
float fTxSnr;
|
float fTxSnr{};
|
||||||
bool fTxFrameSizeNormal;
|
bool fTxFrameSizeNormal{};
|
||||||
bool fTxIsPilots;
|
bool fTxIsPilots{};
|
||||||
double fCincOcc;
|
double fCincOcc{};
|
||||||
bool fCincCorrelator;
|
bool fCincCorrelator{};
|
||||||
uint32_t fCincCorrelatorFails;
|
uint32_t fCincCorrelatorFails{};
|
||||||
int32_t fCincFreqErr;
|
int32_t fCincFreqErr{};
|
||||||
int32_t fCincFreqErrAcc;
|
int32_t fCincFreqErrAcc{};
|
||||||
float fCincChannelDelay;
|
float fCincChannelDelay{};
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODEM_IS_TDMA
|
#ifdef MODEM_IS_TDMA
|
||||||
double fTxCenterFreq;
|
double fTxCenterFreq;
|
||||||
@ -225,14 +218,40 @@ namespace api_driver::obj {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class TerminalRxTxSettings {
|
class TerminalRxTxSettings {
|
||||||
|
modulator_settings mod{};
|
||||||
|
demodulator_settings dem{};
|
||||||
|
#ifdef API_STRUCT_ACM_ENABLE
|
||||||
|
ACM_parameters_serv_ acm{};
|
||||||
|
#endif
|
||||||
|
#ifdef API_OBJECT_DPDI_SETTINGS_ENABLE
|
||||||
|
DPDI_parmeters dpdi{};
|
||||||
|
#endif
|
||||||
|
#ifdef API_OBJECT_BUCLNB_SETTINGS_ENABLE
|
||||||
|
buc_lnb_settings buclnb{};
|
||||||
|
#endif
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// TODO описать все параметры для всех терминалов
|
TerminalRxTxSettings();
|
||||||
|
TerminalRxTxSettings(const TerminalRxTxSettings& src);
|
||||||
|
TerminalRxTxSettings& operator= (const TerminalRxTxSettings& src);
|
||||||
|
|
||||||
void updateCallback(proxy::CpProxy& cp);
|
void updateCallback(proxy::CpProxy& cp);
|
||||||
void updateFromPt(boost::property_tree::ptree &pt);
|
|
||||||
void store(proxy::CpProxy& cp);
|
void updateMainSettings(const nlohmann::json& data);
|
||||||
std::string asJson();
|
void storeMainSettings(proxy::CpProxy& cp);
|
||||||
|
|
||||||
|
#ifdef API_OBJECT_DPDI_SETTINGS_ENABLE
|
||||||
|
void updateDpdiSettings(const nlohmann::json& data);
|
||||||
|
void storeDpdiSettings(proxy::CpProxy& cp);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef API_OBJECT_BUCLNB_SETTINGS_ENABLE
|
||||||
|
void updateBuclnbSettings(const nlohmann::json& data);
|
||||||
|
void storeBuclnbSettings(proxy::CpProxy& cp);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void storeAll(proxy::CpProxy& cp);
|
||||||
|
nlohmann::json asJson() const;
|
||||||
|
|
||||||
~TerminalRxTxSettings();
|
~TerminalRxTxSettings();
|
||||||
};
|
};
|
||||||
|
180
src/main.cpp
180
src/main.cpp
@ -11,7 +11,6 @@
|
|||||||
#include <boost/log/utility/setup/formatter_parser.hpp>
|
#include <boost/log/utility/setup/formatter_parser.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/asio/ssl/context.hpp>
|
#include <boost/asio/ssl/context.hpp>
|
||||||
#include <boost/property_tree/json_parser.hpp>
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -178,11 +177,9 @@ public:
|
|||||||
rep.headers.clear();
|
rep.headers.clear();
|
||||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||||
try {
|
try {
|
||||||
std::istringstream is(std::string(req.payload.data(), req.payload.size()));
|
auto reqJson = nlohmann::json::parse(std::string(req.payload.begin(), req.payload.end()));
|
||||||
boost::property_tree::ptree pt;
|
|
||||||
read_json(is, pt);
|
|
||||||
|
|
||||||
auto u = auth.doAuth(pt.get<std::string>("username"), pt.get<std::string>("password"), req, rep);
|
auto u = auth.doAuth(reqJson["username"], reqJson["username"], req, rep);
|
||||||
if (u == nullptr) {
|
if (u == nullptr) {
|
||||||
throw std::runtime_error("invalid session");
|
throw std::runtime_error("invalid session");
|
||||||
}
|
}
|
||||||
@ -266,6 +263,7 @@ public:
|
|||||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
#ifdef API_OBJECT_QOS_SETTINGS_ENABLE
|
||||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/qos", this->auth, http::auth::User::SETUP_QOS, [this](const auto& req, auto& rep) {
|
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/qos", this->auth, http::auth::User::SETUP_QOS, [this](const auto& req, auto& rep) {
|
||||||
if (req.method != "POST") {
|
if (req.method != "POST") {
|
||||||
http::server::stockReply(http::server::bad_request, rep);
|
http::server::stockReply(http::server::bad_request, rep);
|
||||||
@ -274,26 +272,26 @@ public:
|
|||||||
|
|
||||||
rep.status = http::server::ok;
|
rep.status = http::server::ok;
|
||||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||||
|
nlohmann::json resultJson;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::stringstream ss;
|
auto reqJson = nlohmann::json::parse(std::string(req.payload.begin(), req.payload.end()));
|
||||||
ss.str(std::string(req.payload.begin(), req.payload.end()));
|
api->setQosSettings(reqJson);
|
||||||
boost::property_tree::ptree pt;
|
resultJson["status"] = "ok";
|
||||||
read_json(ss, pt);
|
resultJson["settings"] = api->loadSettings();
|
||||||
|
|
||||||
api->setQosSettings(pt);
|
|
||||||
|
|
||||||
std::string result = R"({"status":"ok","settings":)";
|
|
||||||
result += api->loadSettings();
|
|
||||||
result += "}";
|
|
||||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/qos): Can't set QoS settings: " << e.what();
|
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/qos): Can't set QoS settings: " << e.what();
|
||||||
const std::string result = R"({"status": "error", "error": )" + api_driver::buildEscapedString(e.what()) + "}";
|
resultJson.clear();
|
||||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
resultJson["status"] = "error";
|
||||||
|
resultJson["error"] = e.what();
|
||||||
}
|
}
|
||||||
}));
|
|
||||||
|
|
||||||
|
auto result = resultJson.dump();
|
||||||
|
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||||
|
}));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef API_OBJECT_BUCLNB_SETTINGS_ENABLE
|
||||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/buclnb", this->auth, http::auth::User::EDIT_SETTINGS, [this](const auto& req, auto& rep) {
|
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/buclnb", this->auth, http::auth::User::EDIT_SETTINGS, [this](const auto& req, auto& rep) {
|
||||||
if (req.method != "POST") {
|
if (req.method != "POST") {
|
||||||
http::server::stockReply(http::server::bad_request, rep);
|
http::server::stockReply(http::server::bad_request, rep);
|
||||||
@ -303,25 +301,26 @@ public:
|
|||||||
rep.status = http::server::ok;
|
rep.status = http::server::ok;
|
||||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||||
|
|
||||||
|
nlohmann::json resultJson;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::stringstream ss;
|
auto reqJson = nlohmann::json::parse(std::string(req.payload.begin(), req.payload.end()));
|
||||||
ss.str(std::string(req.payload.begin(), req.payload.end()));
|
api->setBucLnbSettings(reqJson);
|
||||||
boost::property_tree::ptree pt;
|
resultJson["status"] = "ok";
|
||||||
read_json(ss, pt);
|
resultJson["settings"] = api->loadSettings();
|
||||||
|
|
||||||
api->setBucLnbSettings(pt);
|
|
||||||
|
|
||||||
std::string result = R"({"status":"ok","settings":)";
|
|
||||||
result += api->loadSettings();
|
|
||||||
result += "}";
|
|
||||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/buclnb): Can't set BUC LNB settings: " << e.what();
|
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/buclnb): Can't set BUC LNB settings: " << e.what();
|
||||||
const std::string result = R"({"status": "error", "error": )" + api_driver::buildEscapedString(e.what()) + "}";
|
resultJson.clear();
|
||||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
resultJson["status"] = "error";
|
||||||
|
resultJson["error"] = e.what();
|
||||||
}
|
}
|
||||||
}));
|
|
||||||
|
|
||||||
|
auto result = resultJson.dump();
|
||||||
|
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||||
|
}));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef API_OBJECT_DPDI_SETTINGS_ENABLE
|
||||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/dpdi", this->auth, http::auth::User::EDIT_SETTINGS, [this](const auto& req, auto& rep) {
|
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/dpdi", this->auth, http::auth::User::EDIT_SETTINGS, [this](const auto& req, auto& rep) {
|
||||||
if (req.method != "POST") {
|
if (req.method != "POST") {
|
||||||
http::server::stockReply(http::server::bad_request, rep);
|
http::server::stockReply(http::server::bad_request, rep);
|
||||||
@ -330,25 +329,24 @@ public:
|
|||||||
|
|
||||||
rep.status = http::server::ok;
|
rep.status = http::server::ok;
|
||||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||||
|
nlohmann::json resultJson;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::stringstream ss;
|
auto reqJson = nlohmann::json::parse(std::string(req.payload.begin(), req.payload.end()));
|
||||||
ss.str(std::string(req.payload.begin(), req.payload.end()));
|
api->setDpdiSettings(reqJson);
|
||||||
boost::property_tree::ptree pt;
|
resultJson["status"] = "ok";
|
||||||
read_json(ss, pt);
|
resultJson["settings"] = api->loadSettings();
|
||||||
|
|
||||||
api->setDpdiSettings(pt);
|
|
||||||
|
|
||||||
std::string result = R"({"status":"ok","settings":)";
|
|
||||||
result += api->loadSettings();
|
|
||||||
result += "}";
|
|
||||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/dpdi): Can't set DPDI settings: " << e.what();
|
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/dpdi): Can't set DPDI settings: " << e.what();
|
||||||
const std::string result = R"({"status": "error", "error": )" + api_driver::buildEscapedString(e.what()) + "}";
|
resultJson.clear();
|
||||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
resultJson["status"] = "error";
|
||||||
|
resultJson["error"] = e.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto result = resultJson.dump();
|
||||||
|
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||||
}));
|
}));
|
||||||
|
#endif
|
||||||
|
|
||||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/rxtx", this->auth, http::auth::User::EDIT_SETTINGS, [this](const auto& req, auto& rep) {
|
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/rxtx", this->auth, http::auth::User::EDIT_SETTINGS, [this](const auto& req, auto& rep) {
|
||||||
if (req.method != "POST") {
|
if (req.method != "POST") {
|
||||||
@ -358,26 +356,25 @@ public:
|
|||||||
|
|
||||||
rep.status = http::server::ok;
|
rep.status = http::server::ok;
|
||||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||||
|
nlohmann::json resultJson;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::stringstream ss;
|
auto reqJson = nlohmann::json::parse(std::string(req.payload.begin(), req.payload.end()));
|
||||||
ss.str(std::string(req.payload.begin(), req.payload.end()));
|
api->setRxTxSettings(reqJson);
|
||||||
boost::property_tree::ptree pt;
|
resultJson["status"] = "ok";
|
||||||
read_json(ss, pt);
|
resultJson["settings"] = api->loadSettings();
|
||||||
|
|
||||||
api->setRxTxSettings(pt);
|
|
||||||
|
|
||||||
std::string result = R"({"status":"ok","settings":)";
|
|
||||||
result += api->loadSettings();
|
|
||||||
result += "}";
|
|
||||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/rxtx): Can't set RX/TX settings: " << e.what();
|
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/rxtx): Can't set RX/TX settings: " << e.what();
|
||||||
const std::string result = R"({"status": "error", "error": )" + api_driver::buildEscapedString(e.what()) + "}";
|
resultJson.clear();
|
||||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
resultJson["status"] = "error";
|
||||||
|
resultJson["error"] = e.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto result = resultJson.dump();
|
||||||
|
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
#ifdef API_OBJECT_NETWORK_SETTINGS_ENABLE
|
||||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/network", this->auth, http::auth::User::EDIT_SETTINGS, [this](const auto& req, auto& rep) {
|
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/network", this->auth, http::auth::User::EDIT_SETTINGS, [this](const auto& req, auto& rep) {
|
||||||
if (req.method != "POST") {
|
if (req.method != "POST") {
|
||||||
http::server::stockReply(http::server::bad_request, rep);
|
http::server::stockReply(http::server::bad_request, rep);
|
||||||
@ -386,25 +383,24 @@ public:
|
|||||||
|
|
||||||
rep.status = http::server::ok;
|
rep.status = http::server::ok;
|
||||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||||
|
nlohmann::json resultJson;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::stringstream ss;
|
auto reqJson = nlohmann::json::parse(std::string(req.payload.begin(), req.payload.end()));
|
||||||
ss.str(std::string(req.payload.begin(), req.payload.end()));
|
api->setNetworkSettings(reqJson);
|
||||||
boost::property_tree::ptree pt;
|
resultJson["status"] = "ok";
|
||||||
read_json(ss, pt);
|
resultJson["settings"] = api->loadSettings();
|
||||||
|
|
||||||
api->setNetworkSettings(pt);
|
|
||||||
|
|
||||||
std::string result = R"({"status":"ok","settings":)";
|
|
||||||
result += api->loadSettings();
|
|
||||||
result += "}";
|
|
||||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/network): Can't set network settings: " << e.what();
|
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/network): Can't set network settings: " << e.what();
|
||||||
const std::string result = R"({"status": "error", "error": )" + api_driver::buildEscapedString(e.what()) + "}";
|
resultJson.clear();
|
||||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
resultJson["status"] = "error";
|
||||||
|
resultJson["error"] = e.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto result = resultJson.dump();
|
||||||
|
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||||
}));
|
}));
|
||||||
|
#endif
|
||||||
|
|
||||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/reboot", this->auth, 0, [this](const auto& req, auto& rep) {
|
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") {
|
if (req.method != "POST") {
|
||||||
@ -511,34 +507,38 @@ public:
|
|||||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||||
}));
|
}));
|
||||||
#ifdef MODEM_IS_SCPC
|
#ifdef API_OBJECT_DEBUG_METRICS_ENABLE
|
||||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/dev/settings", this->auth, http::auth::User::DEVELOPER, [this](const auto& req, auto& rep) {
|
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/dev/settings", this->auth, http::auth::User::DEVELOPER, [this](const auto& req, auto& rep) {
|
||||||
std::string result;
|
nlohmann::json resultJson;
|
||||||
|
|
||||||
|
try {
|
||||||
if (req.method == "GET") {
|
if (req.method == "GET") {
|
||||||
result = R"({"status":"ok","logstat":)";
|
resultJson["status"] = "ok";
|
||||||
result += this->api->getLoggingStatisticsSettings();
|
resultJson["logstat"] = api->getLoggingStatisticsSettings();
|
||||||
result += "}";
|
|
||||||
} else if (req.method == "POST") {
|
} else if (req.method == "POST") {
|
||||||
std::stringstream ss;
|
auto reqJson = nlohmann::json::parse(std::string(req.payload.begin(), req.payload.end()));
|
||||||
ss.str(std::string(req.payload.begin(), req.payload.end()));
|
api->setQosSettings(reqJson);
|
||||||
boost::property_tree::ptree pt;
|
|
||||||
read_json(ss, pt);
|
|
||||||
|
|
||||||
api->setLoggingStatisticsSettings(pt);
|
resultJson["status"] = "ok";
|
||||||
|
resultJson["logstat"] = api->getLoggingStatisticsSettings();
|
||||||
result = R"({"status":"ok","logstat":)";
|
|
||||||
result += this->api->getLoggingStatisticsSettings();
|
|
||||||
result += "}";
|
|
||||||
} else {
|
} else {
|
||||||
http::server::stockReply(http::server::bad_request, rep);
|
rep.status = http::server::bad_request;
|
||||||
return;
|
resultJson["status"] = "error";
|
||||||
|
resultJson["error"] = "unsupported request type";
|
||||||
|
}
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/qos): Can't set QoS settings: " << e.what();
|
||||||
|
resultJson.clear();
|
||||||
|
resultJson["status"] = "error";
|
||||||
|
resultJson["error"] = e.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
rep.status = http::server::ok;
|
auto result = resultJson.dump();
|
||||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
|
||||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||||
}));
|
}));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef API_OBJECT_DEBUG_METRICS_ENABLE
|
||||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/dev/logs.csv", this->auth, http::auth::User::DEVELOPER, [this](const auto& req, auto& rep) {
|
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/dev/logs.csv", this->auth, http::auth::User::DEVELOPER, [this](const auto& req, auto& rep) {
|
||||||
if (req.method != "GET") {
|
if (req.method != "GET") {
|
||||||
http::server::stockReply(http::server::bad_request, rep);
|
http::server::stockReply(http::server::bad_request, rep);
|
||||||
|
@ -44,7 +44,7 @@ std::tuple<uint8_t, uint8_t> translateCoordinates(double abs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string api_driver::ApiDriver::loadTerminalState() const {
|
nlohmann::json api_driver::ApiDriver::loadTerminalState() const {
|
||||||
if (daemon == nullptr) {
|
if (daemon == nullptr) {
|
||||||
return R"({"error": "api daemon not started!"})";
|
return R"({"error": "api daemon not started!"})";
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ std::string api_driver::ApiDriver::loadTerminalState() const {
|
|||||||
|
|
||||||
auto res = state.asJson();
|
auto res = state.asJson();
|
||||||
res["device"] = devState.asJson();
|
res["device"] = devState.asJson();
|
||||||
return res.dump();
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -64,121 +64,67 @@ void api_driver::ApiDriver::resetPacketStatistics() const {
|
|||||||
this->daemon->resetPacketStatistics();
|
this->daemon->resetPacketStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODEM_IS_SCPC
|
nlohmann::json api_driver::ApiDriver::loadSettings() const {
|
||||||
struct ModcodDef_t {const char* modulation; const char* speed;};
|
|
||||||
const static ModcodDef_t ModcodDefs[] = {
|
|
||||||
{.modulation = "dummy", .speed = "0"},
|
|
||||||
{.modulation = "qpsk", .speed = "1/4"},
|
|
||||||
{.modulation = "qpsk", .speed = "1/3"},
|
|
||||||
{.modulation = "qpsk", .speed = "2/5"},
|
|
||||||
{.modulation = "qpsk", .speed = "1/2"},
|
|
||||||
{.modulation = "qpsk", .speed = "3/5"},
|
|
||||||
{.modulation = "qpsk", .speed = "2/3"},
|
|
||||||
{.modulation = "qpsk", .speed = "3/4"},
|
|
||||||
{.modulation = "qpsk", .speed = "4/5"},
|
|
||||||
{.modulation = "qpsk", .speed = "5/6"},
|
|
||||||
{.modulation = "qpsk", .speed = "8/9"},
|
|
||||||
{.modulation = "qpsk", .speed = "9/10"},
|
|
||||||
{.modulation = "8psk", .speed = "3/5"},
|
|
||||||
{.modulation = "8psk", .speed = "2/3"},
|
|
||||||
{.modulation = "8psk", .speed = "3/4"},
|
|
||||||
{.modulation = "8psk", .speed = "5/6"},
|
|
||||||
{.modulation = "8psk", .speed = "8/9"},
|
|
||||||
{.modulation = "8psk", .speed = "9/10"},
|
|
||||||
{.modulation = "16apsk", .speed = "2/3"},
|
|
||||||
{.modulation = "16apsk", .speed = "3/4"},
|
|
||||||
{.modulation = "16apsk", .speed = "4/5"},
|
|
||||||
{.modulation = "16apsk", .speed = "5/6"},
|
|
||||||
{.modulation = "16apsk", .speed = "8/9"},
|
|
||||||
{.modulation = "16apsk", .speed = "9/10"},
|
|
||||||
{.modulation = "32apsk", .speed = "3/4"},
|
|
||||||
{.modulation = "32apsk", .speed = "4/5"},
|
|
||||||
{.modulation = "32apsk", .speed = "5/6"},
|
|
||||||
{.modulation = "32apsk", .speed = "8/9"},
|
|
||||||
{.modulation = "32apsk", .speed = "9/10"},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char* extractModcodModulation(uint32_t modcod, bool defaultQpsk1_4 = true) {
|
|
||||||
modcod >>= 2;
|
|
||||||
const auto* d = defaultQpsk1_4 ? ModcodDefs : ModcodDefs + 1;
|
|
||||||
if (modcod < (sizeof(ModcodDefs) / sizeof(ModcodDef_t))) {
|
|
||||||
d = ModcodDefs + modcod;
|
|
||||||
}
|
|
||||||
return d->modulation;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char* extractModcodSpeed(uint32_t modcod, bool defaultQpsk1_4 = true) {
|
|
||||||
modcod >>= 2;
|
|
||||||
const auto* d = defaultQpsk1_4 ? ModcodDefs : ModcodDefs + 1;
|
|
||||||
if (modcod < (sizeof(ModcodDefs) / sizeof(ModcodDef_t))) {
|
|
||||||
d = ModcodDefs + modcod;
|
|
||||||
}
|
|
||||||
return d->speed;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string api_driver::ApiDriver::loadSettings() const {
|
|
||||||
if (daemon == nullptr) {
|
if (daemon == nullptr) {
|
||||||
return R"({"error": "api daemon not started!"})";
|
return R"({"error": "api daemon not started!"})";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO сделать получение настроек
|
nlohmann::json res = daemon->getSettingsRxTx().asJson();
|
||||||
return "{}";
|
#ifdef API_OBJECT_QOS_SETTINGS_ENABLE
|
||||||
|
res.update(daemon->getQosSettings().asJson());
|
||||||
|
#endif
|
||||||
|
#ifdef API_OBJECT_NETWORK_SETTINGS_ENABLE
|
||||||
|
res.update(daemon->getNetworkSettings().asJson());
|
||||||
|
#endif
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string api_driver::ApiDriver::loadFirmwareVersion() const {
|
nlohmann::json api_driver::ApiDriver::loadFirmwareVersion() const {
|
||||||
if (daemon == nullptr) {
|
if (daemon == nullptr) {
|
||||||
return R"({"error": "api daemon not started!"})";
|
return R"({"error": "api daemon not started!"})";
|
||||||
}
|
}
|
||||||
|
return daemon->getFirmware().asJson();
|
||||||
std::stringstream result;
|
|
||||||
auto firmware = daemon->getFirmware();
|
|
||||||
result << "{\n\"fw.version\":" << buildEscapedString(firmware.version);
|
|
||||||
result << ",\"fw.modemId\":" << buildEscapedString(firmware.modemId);
|
|
||||||
result << ",\"fw.modemSn\":" << buildEscapedString(firmware.modemSn);
|
|
||||||
result << ",\"fw.macMang\":" << buildEscapedString(firmware.macMang);
|
|
||||||
result << ",\"fw.macData\":" << buildEscapedString(firmware.macData);
|
|
||||||
result << "\n}";
|
|
||||||
return result.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODEM_IS_SCPC
|
void api_driver::ApiDriver::setRxTxSettings(const nlohmann::json& data) {
|
||||||
static uint32_t buildModcodFromPt(const boost::property_tree::ptree& pt, const std::string& name, bool isShortFrame, bool isPilots = false) {
|
auto rxtx = daemon->getSettingsRxTx();
|
||||||
uint32_t modcod = 0;
|
rxtx.updateMainSettings(data);
|
||||||
const auto mod = pt.get<std::string>(name + "Modulation");
|
|
||||||
const auto speed = pt.get<std::string>(name + "Speed");
|
std::lock_guard _lapi(this->daemon->cpApiMutex);
|
||||||
uint32_t _index = 0;
|
this->daemon->cp.setDmaDebug("begin_save_config", "");
|
||||||
for (const auto& m: ModcodDefs) {
|
rxtx.storeMainSettings(this->daemon->cp);
|
||||||
if (mod == m.modulation) {
|
this->daemon->cp.setDmaDebug("save_config", "");
|
||||||
if (modcod == 0) modcod = _index;
|
rxtx.updateCallback(this->daemon->cp);
|
||||||
if (speed == m.speed) {
|
{
|
||||||
modcod = _index;
|
daemon->setSettingsRxTx(rxtx);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_index++;
|
|
||||||
|
#ifdef API_OBJECT_DPDI_SETTINGS_ENABLE
|
||||||
|
void api_driver::ApiDriver::setDpdiSettings(const nlohmann::json& data) {
|
||||||
|
auto rxtx = daemon->getSettingsRxTx();
|
||||||
|
rxtx.updateDpdiSettings(data);
|
||||||
|
|
||||||
|
std::lock_guard _lapi(this->daemon->cpApiMutex);
|
||||||
|
this->daemon->cp.setDmaDebug("begin_save_config", "");
|
||||||
|
rxtx.storeMainSettings(this->daemon->cp);
|
||||||
|
this->daemon->cp.setDmaDebug("save_config", "");
|
||||||
|
rxtx.updateCallback(this->daemon->cp);
|
||||||
|
{
|
||||||
|
daemon->setSettingsRxTx(rxtx);
|
||||||
}
|
}
|
||||||
return (modcod << 2)| (isShortFrame ? 2 : 0) | (isPilots ? 1 : 0);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void api_driver::ApiDriver::setRxTxSettings(boost::property_tree::ptree &pt) {
|
void api_driver::ApiDriver::setBucLnbSettings(const nlohmann::json& data) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::ApiDriver::setDpdiSettings(boost::property_tree::ptree &pt) {
|
void api_driver::ApiDriver::setQosSettings(const nlohmann::json& data) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::ApiDriver::setBucLnbSettings(boost::property_tree::ptree &pt) {
|
void api_driver::ApiDriver::setNetworkSettings(const nlohmann::json& data) {
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void api_driver::ApiDriver::setQosSettings(boost::property_tree::ptree &pt) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void api_driver::ApiDriver::setNetworkSettings(boost::property_tree::ptree &pt) {
|
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,8 +154,8 @@ std::string api_driver::ApiDriver::getLoggingStatisticsSettings() {
|
|||||||
return this->daemon->statsLogs.getSettings();
|
return this->daemon->statsLogs.getSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void api_driver::ApiDriver::setLoggingStatisticsSettings(boost::property_tree::ptree &pt) {
|
void api_driver::ApiDriver::setLoggingStatisticsSettings(const nlohmann::json& data) {
|
||||||
this->daemon->statsLogs.setSettings(pt);
|
this->daemon->statsLogs.setSettings(data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
#include "api-driver/proxy.h"
|
#include "api-driver/proxy.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <boost/property_tree/ptree.hpp>
|
|
||||||
|
|
||||||
|
#include "common/nlohmann/json.hpp"
|
||||||
|
|
||||||
namespace api_driver {
|
namespace api_driver {
|
||||||
constexpr int CACHE_STATISTICS_UPDATE_MS = 500; ///< время обновления кеша статистики модулятора/демодулятора
|
constexpr int CACHE_STATISTICS_UPDATE_MS = 500; ///< время обновления кеша статистики модулятора/демодулятора
|
||||||
@ -30,48 +30,47 @@ namespace api_driver {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Запросить общее состояние терминала
|
* Запросить общее состояние терминала
|
||||||
* @return {"txState":false,"rxState":false,"rx.sym_sync_lock":false,"rx.freq_search_lock":false,"rx.afc_lock":false,"rx.pkt_sync":false}
|
|
||||||
*/
|
*/
|
||||||
std::string loadTerminalState() const;
|
nlohmann::json loadTerminalState() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Сбросить статистику пакетов
|
* Сбросить статистику пакетов
|
||||||
*/
|
*/
|
||||||
void resetPacketStatistics() const;
|
void resetPacketStatistics() const;
|
||||||
|
|
||||||
std::string loadSettings() const;
|
nlohmann::json loadSettings() const;
|
||||||
|
|
||||||
std::string loadFirmwareVersion() const;
|
nlohmann::json loadFirmwareVersion() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Установить настройки RX/TX, readback можно получить используя loadTerminalState
|
* Установить настройки RX/TX, readback можно получить используя loadTerminalState
|
||||||
*/
|
*/
|
||||||
void setRxTxSettings(boost::property_tree::ptree &pt);
|
void setRxTxSettings(const nlohmann::json& data);
|
||||||
|
|
||||||
#ifdef API_OBJECT_DPDI_SETTINGS_ENABLE
|
#ifdef API_OBJECT_DPDI_SETTINGS_ENABLE
|
||||||
/**
|
/**
|
||||||
* Установить настройки DPDI, readback можно получить используя loadTerminalState.
|
* Установить настройки DPDI, readback можно получить используя loadTerminalState.
|
||||||
* @note Для TDMA и SCPC модемов эти настройки доступны
|
* @note Для TDMA и SCPC модемов эти настройки доступны
|
||||||
*/
|
*/
|
||||||
void setDpdiSettings(boost::property_tree::ptree &pt);
|
void setDpdiSettings(const nlohmann::json& data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef API_OBJECT_BUCLNB_SETTINGS_ENABLE
|
#ifdef API_OBJECT_BUCLNB_SETTINGS_ENABLE
|
||||||
/**
|
/**
|
||||||
* Установить настройки BUC и LNB, readback можно получить используя loadTerminalState.
|
* Установить настройки BUC и LNB, readback можно получить используя loadTerminalState.
|
||||||
*/
|
*/
|
||||||
void setBucLnbSettings(boost::property_tree::ptree &pt);
|
void setBucLnbSettings(const nlohmann::json& data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef API_OBJECT_QOS_SETTINGS_ENABLE
|
#ifdef API_OBJECT_QOS_SETTINGS_ENABLE
|
||||||
/**
|
/**
|
||||||
* Установить настройки QoS, readback можно получить используя loadTerminalState.
|
* Установить настройки QoS, readback можно получить используя loadTerminalState.
|
||||||
*/
|
*/
|
||||||
void setQosSettings(boost::property_tree::ptree &pt);
|
void setQosSettings(const nlohmann::json& data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef API_OBJECT_NETWORK_SETTINGS_ENABLE
|
#ifdef API_OBJECT_NETWORK_SETTINGS_ENABLE
|
||||||
void setNetworkSettings(boost::property_tree::ptree &pt);
|
void setNetworkSettings(const nlohmann::json& data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void resetDefaultSettings();
|
void resetDefaultSettings();
|
||||||
@ -80,7 +79,7 @@ namespace api_driver {
|
|||||||
|
|
||||||
#ifdef API_OBJECT_DEBUG_METRICS_ENABLE
|
#ifdef API_OBJECT_DEBUG_METRICS_ENABLE
|
||||||
std::string getLoggingStatisticsSettings();
|
std::string getLoggingStatisticsSettings();
|
||||||
void setLoggingStatisticsSettings(boost::property_tree::ptree &pt);
|
void setLoggingStatisticsSettings(const nlohmann::json& data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Получить статистику в формате json. Выход будет дописан в вектор
|
* Получить статистику в формате json. Выход будет дописан в вектор
|
||||||
|
Loading…
x
Reference in New Issue
Block a user