40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import * as log from './log'
|
|
import * as mqtt from './mqttdispatcher'
|
|
import * as callchain from './callchain'
|
|
import * as config from './config'
|
|
|
|
import * as EspThermToJson from './espthermtojson'
|
|
import * as MongoSave from './mongosave'
|
|
import * as MissingEventDetector from './missingeventdetector'
|
|
|
|
|
|
|
|
|
|
log.info("Dispatcher starting")
|
|
|
|
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)
|
|
|
|
let missingeventdetector : MissingEventDetector.MissingEventDetector =
|
|
new MissingEventDetector.MissingEventDetector()
|
|
dispatcher.register(ESP_THERM_TOPIC, 'MissingEventDetector', missingeventdetector)
|
|
|
|
if (! config.dict.disableDatabaseAccess) {
|
|
let mongo : MongoSave.MongoSave = new MongoSave.MongoSave(config.dict.mongoDbUrl)
|
|
dispatcher.register(ESP_THERM_TOPIC, 'MongoSave', mongo);
|
|
}
|
|
|
|
dispatcher.exec()
|
|
log.info("Dispatcher running")
|
|
|
|
|
|
|
|
|
|
|
|
|