diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a5ae99..04b3500 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,16 @@ else() message(FATAL_ERROR "You must set build type \"Debug\" or \"Release\". Another build types not supported!") endif() +if("${MODEM_TYPE}" STREQUAL "SCPC") + add_definitions(-DMODEM_IS_SCPC) + message(STATUS "Selected SCPC modem") +elseif ("${MODEM_TYPE}" STREQUAL "TDMA") + add_definitions(-DMODEM_IS_TDMA) + message(STATUS "Selected TDMA modem") +else() + message(FATAL_ERROR "You must set `MODEM_TYPE` \"SCPC\" or \"TDMA\"!") +endif() + add_compile_options(-Wall -Wextra -Wsign-conversion) # максимальный размер тела запроса 200mb diff --git a/src/main.cpp b/src/main.cpp index eed84dd..7c42d29 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -104,7 +104,13 @@ class ServerResources { } public: - static constexpr const char* INDEX_HTML = "/main.html"; +#if defined(MODEM_IS_TDMA) + static constexpr const char* INDEX_HTML = "/main-tdma.html"; +#elif defined(MODEM_IS_SCPC) + static constexpr const char* INDEX_HTML = "/main-scpc.html"; +#else +#error "Modem type not defined!" +#endif static constexpr const char* LOGIN_HTML = "/login.html"; // картинки, их даже можно кешировать @@ -114,6 +120,7 @@ public: // а эти стили нельзя кешировать в отладочной версии static constexpr const char* STYLE_CSS = "/style.css"; static constexpr const char* FIELDS_CSS = "/fields.css"; + static constexpr const char* INTERNET_JPG = "/internet.jpg"; ServerResources(const ServerResources&) = delete; @@ -127,6 +134,7 @@ public: sf->registerFile(staticFilesPath + FIELDS_CSS, FIELDS_CSS, mime_types::text_css, true); sf->registerFile(staticFilesPath + INDEX_HTML, INDEX_HTML, mime_types::text_html, false); sf->registerFile(staticFilesPath + LOGIN_HTML, LOGIN_HTML, mime_types::text_html, true); + sf->registerFile(staticFilesPath + INTERNET_JPG, INTERNET_JPG, mime_types::image_jpeg, true); } void registerResources(http::server::Server& s) { @@ -181,9 +189,10 @@ public: })); s.resources.emplace_back(std::make_unique("/favicon.ico", [this](const auto& req, auto& rep) { boost::ignore_unused(req); sf->serve(FAVICON_ICO, rep); })); - s.resources.emplace_back(std::make_unique("/style.css", [this](const auto& req, auto& rep) { boost::ignore_unused(req); sf->serve(STYLE_CSS, rep); })); - s.resources.emplace_back(std::make_unique("/fields.css", [this](const auto& req, auto& rep) { boost::ignore_unused(req); sf->serve(FIELDS_CSS, rep); })); - s.resources.emplace_back(std::make_unique("/js/vue.js", [this](const auto& req, auto& rep) { boost::ignore_unused(req); sf->serve(VUE_JS, rep); })); + s.resources.emplace_back(std::make_unique(STYLE_CSS, [this](const auto& req, auto& rep) { boost::ignore_unused(req); sf->serve(STYLE_CSS, rep); })); + s.resources.emplace_back(std::make_unique(FIELDS_CSS, [this](const auto& req, auto& rep) { boost::ignore_unused(req); sf->serve(FIELDS_CSS, rep); })); + s.resources.emplace_back(std::make_unique(VUE_JS, [this](const auto& req, auto& rep) { boost::ignore_unused(req); sf->serve(VUE_JS, rep); })); + s.resources.emplace_back(std::make_unique(INTERNET_JPG, [this](const auto& req, auto& rep) { boost::ignore_unused(req); sf->serve(INTERNET_JPG, rep); })); s.resources.emplace_back(std::make_unique("/api/get/statistics", this->auth, http::auth::User::WATCH_STATISTICS, [this](const auto& req, auto& rep) { if (req.method != "GET") { diff --git a/static/internet.jpg b/static/internet.jpg new file mode 100644 index 0000000..99436f7 Binary files /dev/null and b/static/internet.jpg differ diff --git a/static/main.html b/static/main-scpc.html similarity index 100% rename from static/main.html rename to static/main-scpc.html diff --git a/static/main-tdma.html b/static/main-tdma.html new file mode 100644 index 0000000..beb6037 --- /dev/null +++ b/static/main-tdma.html @@ -0,0 +1,1341 @@ + + + + + + RSCM-101 + + + + + + + + + + + \ No newline at end of file