A private doorbell project to serve an Android app with webcam pictures and microphone recordings when someone presses the button. Information is being spread via MQTT. https://www.taibsu.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
heimdall/main.cpp

68 lines
1.8 KiB

#include "heimdall.h"
#include "config.h"
#include "mqttClient.h"
// see https://de.pinout.xyz/pinout/pin10_gpio15 for details
#define GPIO_DOORBELL 15
#define GPIO_OPENER 18
int main(int argc, char* argv[]) {
/*
Choose which options we want to parse from the config file.
The keys provided here will be passed to the config options map
and have their values parsed as well.
TODO: add log level (may need re-implementation of logger class)
*/
std::vector<std::string> configOptions {
"logfile",
"mqttClientId",
"mqttHost",
"mqttPort",
"mqttTopic",
"mqttToken",
"mqttUser",
"mqttPass",
"mqttMessage",
"soundFilePath",
"rtspServerHome",
"tg_notify",
"tg_notifMessage",
"tg_botId",
"tg_chatIds",
"openOnButtonPush",
"pictureType",
"motion_apiKey",
"motion_webcamUrl"
};
std::shared_ptr<tai::config> conf { std::make_shared<tai::config>(configOptions) };
// create our log file
std::string const& logfile { conf->options("logfile") };
if (!freopen(logfile.c_str(), "w", stderr)) {
// we can still write to stderr.
LOG_ERR("[main] Unable to create log file! Continuing without log.");
}
LOG_INF("[main] Starting heimdall program execution.");
LOG_DBG("[main] Log file: " + logfile);
// our doorbell class instance
tai::heimdall bell(GPIO_DOORBELL, GPIO_OPENER, conf);
std::shared_ptr<tai::mqttClient> mqttClient(bell.getMqttClient());
LOG_DBG("[main] Entering main loop.");
// stay alive!
while (true) {
// yippieeeeeeeeeee
mqttClient->loop();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
LOG_INF("[main] heimdall program execution stopped.");
}