This repository has been archived by the owner on Oct 1, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 79
/
app.js
49 lines (44 loc) · 1.57 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const Configuration = require("./lib/Configuration");
const Logger = require("./lib/Logger");
const MqttClient = require("./lib/MqttClient");
const WebServer = require("./lib/Webserver");
const conf = new Configuration();
/*
This is a global variable because we need some way of transferring the data received via mqtt to the webserver
without connecting those two directly
*/
const mapData = {
raw: undefined,
img: undefined,
base64: undefined
};
try {
Logger.LogLevel = conf.get("logLevel");
} catch (e) {
Logger.error("Initialising Logger: " + e);
}
if (conf.get("mqtt")) {
// eslint-disable-next-line no-unused-vars
const mqttClient = new MqttClient({
brokerURL: conf.get("mqtt").broker_url,
caPath: conf.get("mqtt").caPath,
identifier: conf.get("mqtt").identifier,
topicPrefix: conf.get("mqtt").topicPrefix,
autoconfPrefix: conf.get("mqtt").autoconfPrefix,
mapSettings: conf.get("mapSettings"),
mapDataTopic: conf.get("mqtt").mapDataTopic,
minMillisecondsBetweenMapUpdates: conf.get("mqtt").minMillisecondsBetweenMapUpdates,
publishMapImage: conf.get("mqtt").publishMapImage,
publishAsBase64: conf.get("mqtt").publishAsBase64,
mapData: mapData
});
if (conf.get("webserver") && conf.get("webserver").enabled === true) {
// eslint-disable-next-line no-unused-vars
const webServer = new WebServer({
port: conf.get("webserver").port,
mapData: mapData
});
}
} else {
Logger.error("Missing configuration.mqtt!");
}