Skip to content

Commit bc3e09f

Browse files
committed
add software version to webpage
1 parent 1bccacb commit bc3e09f

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

core/WebServer/WebServer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ extern "C" int mg_log_level;
1111

1212
namespace core {
1313

14-
WebServer::WebServer(std::vector<monitor::Monitor*> &mons,
14+
WebServer::WebServer(const char* version, std::vector<monitor::Monitor*> &mons,
1515
contactor::Contactor* contactorPtr)
1616
: m_monitor(mons),
1717
m_main_contactor(contactorPtr),
18-
m_running(true)
18+
m_running(true),
19+
m_version(version)
1920

2021
{
2122
m_start_time = std::chrono::system_clock::now();
@@ -160,6 +161,7 @@ void WebServer::handleStatusPage(struct mg_connection *c, struct mg_http_message
160161

161162
html << "<p><b>Current Time:</b> " << std::ctime(&now_time) << "</p>";
162163
html << "<p><b>Run Time:</b> " << fmt1(hours,3) << " hours</p>";
164+
html << "<p><b>Software Version:</b> " << m_version << "</p>";
163165

164166
// ---- Main table ----
165167
html << "<table>";

core/WebServer/WebServer.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace core
2323
class WebServer {
2424
public:
2525
// monitors is a reference to your vbatterymon vector in main()
26-
WebServer(std::vector<monitor::Monitor*> &mons,
26+
WebServer(const char* version, std::vector<monitor::Monitor*> &mons,
2727
contactor::Contactor* contactorPtr);
2828
~WebServer();
2929

@@ -49,6 +49,7 @@ class WebServer {
4949
contactor::Contactor* m_main_contactor;
5050

5151
std::chrono::system_clock::time_point m_start_time;
52+
const char* m_version;
5253
};
5354

5455
} // namespace core

testcan.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
/* SPDX-License-Identifier: GPL-3.0-or-later */
22

3-
/*
4-
* This file is prototyping code - don't judge.
5-
*/
6-
73
#include <string.h>
84
#include <unistd.h>
95
#include <stdio.h>
106
#include <sys/epoll.h>
117
#include <fstream>
128
#include <vector>
139

10+
#define VERSION_NUMBER "0001"
1411
#include "packs/Nissan/LeafPack.hpp"
1512
#include "packs/Nissan/LeafMultiPack.hpp"
1613
// #include "can/services/SMA/MessageFactory.hpp"
@@ -86,6 +83,10 @@ int main(int argc, const char** argv)
8683
timer.setLogger(&logger);
8784
logger.info("------------------- BatteryController Started ------------------- ",__FILENAME__, __LINE__);
8885
std::string smsg;
86+
smsg.append("VERSION NUMBER: ");
87+
smsg += VERSION_NUMBER;
88+
logger.info(smsg);
89+
smsg.clear();
8990
smsg.append("LOGGER_LEVEL: ");
9091
smsg.append(argv[1]);
9192
logger.info(smsg);
@@ -194,7 +195,7 @@ int main(int argc, const char** argv)
194195

195196
logger.setMonitor(vbatterymon);
196197

197-
core::WebServer webserver(vbatterymon, &multi_pack.getMainContactor());
198+
core::WebServer webserver(VERSION_NUMBER, vbatterymon, &multi_pack.getMainContactor());
198199
ss << "Web server started on port: " << webserver.getWebServerPort();
199200
logger.info(ss);
200201

0 commit comments

Comments
 (0)