diff --git a/config.default.json b/config.default.json new file mode 100644 index 0000000..56dd866 --- /dev/null +++ b/config.default.json @@ -0,0 +1,86 @@ +{ + "general": { + "port": 3000, + "configPort": 3001, + "configWebInterfaceEnabled": true + }, + "connectors": { + "dummy": { + "enabled": true, + "duplexTimeout": 300 + }, + "pocsag": { + "enabled": false, + "duplexTimeout": 300, + "mqttserver": "mqtt://host:1883", + "username": "", + "password": "", + "topic": "pocsagtx/transmit" + }, + "pagernetzAT": { + "enabled": false, + "duplexTimeout": 300 + }, + "ecityruf": { + "enabled": false, + "duplexTimeout": 180 + }, + "emPuppettering": { + "enabled": false, + "duplexTimeout": "250" + }, + "emessage": { + "enabled": false, + "username": "", + "password": "", + "duplexTimeout": 180, + "responseTimeout": 320, + "startInterval": 5, + "2wayS_BackChannel": true + }, + "lorawan": { + "enabled": false, + "duplexTimeout": 1800, + "mqttserver": "mqtt://eu1.cloud.thethings.network:1883", + "username": "", + "password": "" + }, + "dapnet": { + "enabled": false, + "endpoint": "http://:8080/calls", + "username": "test", + "password": "testsucks", + "duplexTimeout": 300 + }, + "pnet": { + "enabled": false, + "duplexTimeout": 10 + }, + "tetracontrol": { + "enabled": false, + "endpoint": ":80", + "username": "user", + "password": "password", + "duplexTimeout": 300 + } + }, + "pagers": { + "birdyslim": { + "enabled": false, + "rxchain": { + "lorawan": false, + "events": { + "webhook": false, + "mqtt": false + } + } + } + }, + "boskrypt": { + "enabled": false, + "keys": { + } + }, + "deliveryPresets": { + } +} diff --git a/html_config/index.html b/html_config/index.html index b5ba917..ddcd4cd 100644 --- a/html_config/index.html +++ b/html_config/index.html @@ -153,7 +153,7 @@ - + TETRACONTROL @@ -177,7 +177,7 @@ - + LoRaWAN @@ -202,7 +202,7 @@ - + e*Cityruf (inetgw) @@ -218,7 +218,7 @@ - + e*Message Puppeteering @@ -234,7 +234,7 @@ - + e*Message alertManager @@ -265,7 +265,7 @@ - + pagernetz.at @@ -387,9 +387,9 @@ }, pagers: { birdyslim: { - enabled: true, + enabled: false, rxchain: { - lorawan: true, + lorawan: false, events: { webhook: false, mqtt: false @@ -399,24 +399,36 @@ }, connectors: { dummy: { - enabled: null, duplexTimeout: null, + enabled: false, duplexTimeout: null, }, pocsag: { - enabled: null, duplexTimeout: null, + enabled: false, duplexTimeout: null, mqttserver: "", username: "", password: "", topic: "", }, dapnet: { - enabled: null, duplexTimeout: null, + enabled: false, duplexTimeout: null, endpoint: "", username: "", password: "", + }, + lorawan: { + enabled: false, duplexTimeout: null, mqttserver: "", username: "", password: "", }, tetracontrol: { - enabled: null, duplexTimeout: null, + enabled: false, duplexTimeout: null, endpoint: "", username: "", password: "", + }, + pnet: { + enabled: false, duplexTimeout: null, + }, + pagernetzAT: { + enabled: false, duplexTimeout: null, }, + emessage: { + enabled: false, duplexTimeout: null, + }, ecityruf: { - enabled: null, duplexTimeout: null, + enabled: false, duplexTimeout: null, }, emPuppettering: { - enabled: null, duplexTimeout: null, + enabled: false, duplexTimeout: null, }, } }, diff --git a/index.js b/index.js index 4356fbf..994fa18 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,13 @@ -// const amqp = require('amqp-connection-manager') const fs = require('fs') -const config = require('./config.json') +const actualConfig = require('./config.json') +const defaultConfig = require('./config.default.json') +const config = defaultConfig +Object.assign(config.deliveryPresets, actualConfig.deliveryPresets) +Object.assign(config.boskrypt, actualConfig.boskrypt) +Object.assign(config.general, actualConfig.general) +Object.assign(config.pagers, actualConfig.pagers) +Object.assign(config.connectors, actualConfig.connectors) - -// Create a connetion manager -// const connection = amqp.connect(config.general.amqp) -// connection.on('connect', () => console.log('Connected to AMQP.')) -// connection.on('disconnect', err => console.log('Disconnected from AMQP.', err.stack)) const connection = null const types = require('./types') // also initializes the registries, if they havent been loaded @@ -181,24 +182,31 @@ types.DeviceRegistry.events.on('event', (deviceType, deviceId, eventData) => { /** CONFIG Routes */ appConfig.get('/config', async (req, res) => { - const parsedConfig = JSON.parse(fs.readFileSync('config.json')) - parsedConfig.deliveryPresets = parsedConfig.deliveryPresets || { - 'example': { - "name": "Normal", - "params": { - "type": "duplex", - "routing": { - "device": "generic", - "connectors": [ - [ - "dummy", - "1234" - ] - ] - } - }, - } - } + const actualConfig = JSON.parse(fs.readFileSync('./config.json')) + const defaultConfig = JSON.parse(fs.readFileSync('./config.default.json')) + const parsedConfig = defaultConfig + Object.assign(parsedConfig.deliveryPresets, actualConfig.deliveryPresets) + Object.assign(parsedConfig.boskrypt, actualConfig.boskrypt) + Object.assign(parsedConfig.general, actualConfig.general) + Object.assign(parsedConfig.pagers, actualConfig.pagers) + Object.assign(parsedConfig.connectors, actualConfig.connectors) + // parsedConfig.deliveryPresets = parsedConfig.deliveryPresets || { + // 'example': { + // "name": "Normal", + // "params": { + // "type": "duplex", + // "routing": { + // "device": "generic", + // "connectors": [ + // [ + // "dummy", + // "1234" + // ] + // ] + // } + // }, + // } + // } return res.json(parsedConfig) }) appConfig.post('/config', async (req, res) => { diff --git a/types/connectors/POCSAGConnector.js b/types/connectors/POCSAGConnector.js index 812146b..6b27f65 100644 --- a/types/connectors/POCSAGConnector.js +++ b/types/connectors/POCSAGConnector.js @@ -17,7 +17,7 @@ class POCSAGConnector extends Connector { password: config.connectors.pocsag.password, connectTimeout: 10, }) - this.client.on('error', (x) => console.error(e)) + this.client.on('error', (e) => console.error(e)) this.client.on('connect', this.onMQTTConnect.bind(this)) this.client.on('message', this.onMQTTMessage.bind(this)) console.log("pocsag connector initalized", diff --git a/types/connectors/pNetConnector.js b/types/connectors/pNetConnector.js index 8286881..0d3ec12 100644 --- a/types/connectors/pNetConnector.js +++ b/types/connectors/pNetConnector.js @@ -1,8 +1,6 @@ const Connector = require("./Connector") const config = require('../../config.json') const md5 = require('md5') -const axios = require('axios') -const { io } = require("socket.io-client") class pNetConnector extends Connector { @@ -15,6 +13,7 @@ class pNetConnector extends Connector { async transmitMessage(msg, params) { console.log('pnet socket=',this.managementSocket) if (!this.managementSocket) { + const { io } = require("socket.io-client") console.log('starting pnet socket') this.managementSocket = io("wss://") this.managementSocket.on('smartpager:ingress:event', (evt) => {