2017-08-25 17:03:25 +02:00

25 lines
1.3 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const log = require("./log");
const mqtt = require("./mqttdispatcher");
const fs = require("fs");
const cmdargs = require("command-line-args");
const EspThermToJson = require("./espthermtojson");
const MissingEventDetector = require("./missingeventdetector");
const OPTION_DEFINITIONS = [
{ name: 'verbose', alias: 'v', type: Boolean },
{ name: 'config', alias: 'c', type: String, defaultValue: '~/mqttDispatcher.conf' }
];
const OPTIONS = cmdargs(OPTION_DEFINITIONS);
const CONFIG = JSON.parse(fs.readFileSync(OPTIONS.config, "utf8"));
log.info("Dispatcher starting");
let dispatcher = new mqtt.MqttDispatcher(CONFIG.brokerUrl, CONFIG.brokerUser, CONFIG.brokerPass, CONFIG.brokerCa);
const ESP_THERM_TOPIC = 'IoT/espThermometer2/#';
dispatcher.register(ESP_THERM_TOPIC, 'toJson', EspThermToJson.espThermToJson);
let missingeventdetector = new MissingEventDetector.MissingEventDetector();
dispatcher.register(ESP_THERM_TOPIC, 'MissingEventDetector', missingeventdetector);
// let mongo : MongoSave.MongoSave = new MongoSave.MongoSave(CONFIG.mongoDbUrl)
// dispatcher.register(ESP_THERM_TOPIC, 'MongoSave', mongo);
dispatcher.exec();
log.info("Dispatcher running");
//# sourceMappingURL=main.js.map