This commit is contained in:
Wolfgang Hottgenroth
2017-08-27 23:43:21 +02:00
parent 85db16a271
commit 6a364bd38a
7 changed files with 58 additions and 41 deletions

View File

@ -1,28 +1,21 @@
import * as log from './log'
import * as mqtt from './mqttdispatcher'
import * as callchain from './callchain'
import * as fs from 'fs'
import * as cmdargs from 'command-line-args'
import * as config from './config'
import * as EspThermToJson from './espthermtojson'
import * as MongoSave from './mongosave'
import * as MissingEventDetector from './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)
config.readConfig()
let dispatcher = new mqtt.MqttDispatcher(config.dict.brokerUrl,
config.dict.brokerUser, config.dict.brokerPass, config.dict.brokerCa)
const ESP_THERM_TOPIC : string = 'IoT/espThermometer2/#'
dispatcher.register(ESP_THERM_TOPIC, 'toJson', EspThermToJson.espThermToJson)
@ -31,8 +24,8 @@ let missingeventdetector : MissingEventDetector.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);
// let mongo : MongoSave.MongoSave = new MongoSave.MongoSave(config.dict.mongoDbUrl)
// dispatcher.register(ESP_THERM_TOPIC, 'MongoSave', mongo);
dispatcher.exec()