-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
43 lines (34 loc) · 1.13 KB
/
main.cpp
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
#include <QCoreApplication>
#include <Tufao/HttpServer>
#include <QtCore/QUrl>
#include <Tufao/HttpServerRequest>
#include <Tufao/HttpServerRequestRouter>
#include <Tufao/Headers>
#include "mainhandler.h"
#include "pidiscoverybeacon.h"
#define BEACON_INTERVAL 30*1000 // 30sec
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Tufao::HttpServer server;
QString discoveryMessage("raspberry picam");
MainHandler h;
if (qEnvironmentVariableIsSet("thermal_cam")) {
discoveryMessage += " thermal";
h.setThermalEnabled(true);
}
if (qEnvironmentVariableIsEmpty("mavproxy")) {
discoveryMessage += " mavproxy";
h.setMavProxyEnabled(true);
}
Tufao::HttpServerRequestRouter router{
{QRegularExpression{"^/([^/]+)$"}, h},
{QRegularExpression{".*"}, h}
};
QObject::connect(&server, &Tufao::HttpServer::requestReady,
&router, &Tufao::HttpServerRequestRouter::handleRequest);
server.listen(QHostAddress::Any, 8080);
PiDiscoveryBeacon beacon(discoveryMessage, BEACON_INTERVAL);
Q_UNUSED(beacon)
return a.exec();
}