added tetracontrol support

master
cheetah.cat 8 months ago
parent 2814584831
commit f6f376f268

@ -50,7 +50,14 @@
"username": "test",
"password": "testsucks",
"duplexTimeout": 300
}
},
"tetracontrol": {
"enabled": true,
"endpoint": "10.13.123.123:80",
"username": "user",
"password": "password",
"duplexTimeout": 300
}
},
"pagers": {
"birdyslim": {

@ -141,6 +141,32 @@
</v-list-item-action>
</v-list-item-content>
</v-list-item>
<v-list-item> <!-- TETRACONTROL-->
<v-list-item-content>
<v-list-item-title>TETRACONTROL</v-list-item-title>
<v-list-item-action>
<v-row cols="12">
<v-col cols="6" sm="6" md="6">
<v-switch v-model="configData.connectors.tetracontrol.enabled" label="Enabled"></v-switch>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-text-field type="number" :rules="validNumberRules" label="Duplex Timeout in seconds" v-model="configData.connectors.tetracontrol.duplexTimeout"></v-text-field>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-text-field label="Username" v-model="configData.connectors.tetracontrol.username"></v-text-field>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-text-field label="Password" type="password" v-model="configData.connectors.tetracontrol.password"></v-text-field>
</v-col>
<v-col cols="6" sm="6" md="6">
<v-text-field label="Endpoint" v-model="configData.connectors.tetracontrol.endpoint"></v-text-field>
</v-col>
</v-row>
</v-list-item-action>
</v-list-item-content>
</v-list-item>
<v-list-item> <!-- LoRaWAN-->
<v-list-item-content>
<v-list-item-title>LoRaWAN</v-list-item-title>
@ -330,6 +356,7 @@
{ k: 'Dummy', v: 'dummy' },
{ k: 'POCSAG GW', v: 'pocsag' },
{ k: 'DAPNET', v: 'dapnet' },
{ k: 'TETRAControl', v: 'tetracontrol' },
{ k: 'e*Cityruf inetgw', v: 'ecityruf' },
{ k: 'e*Cityruf Puppeteer', v: 'em-p-cityruf' },
@ -366,6 +393,11 @@
dapnet: {
enabled: null, duplexTimeout: null,
},
tetracontrol: {
enabled: null, duplexTimeout: null,
},
ecityruf: {
enabled: null, duplexTimeout: null,
},

@ -36,6 +36,9 @@ if (!!config.connectors.emPuppettering && config.connectors.emPuppettering.enabl
if (!!config.connectors.ecityruf && config.connectors.pagernetzAT.enabled === true) {
types.ConnectorRegistry.register(new types.Connectors.PagernetzConnetorAT(connection))
}
if (!!config.connectors.tetracontrol && config.connectors.tetracontrol.enabled === true) {
types.ConnectorRegistry.register(new types.Connectors.TetraControlConnector(connection))
}
types.ConnectorRegistry.register(new types.Connectors.DummyConnector())

@ -0,0 +1,58 @@
const Connector = require("./Connector")
const config = require('../../config.json')
const md5 = require('md5')
const axios = require('axios')
const WebSocket = require('ws')
class TetraControlConnector extends Connector {
constructor (amqpConnMngr) {
super(amqpConnMngr)
this.name = "tetracontrol"
this.duplexCapable = false
}
async transmitMessage(msg, params) {
const UUID = this.name+':'+md5(JSON.stringify([this.name,...params]))
if (params.length < 1) return false
const target = params[0]
//if (target.split('#').length !== 2) throw 'No valid DAPNET Parameter <transmitterGroup#callSign>'
//const transmitterGroup = target.split('#')[ 0 ], callsign = target.split('#')[ 1 ]
/*const dapnetRequest = {
text: msg.payload,
callSignNames: [ callsign ],
transmitterGroupNames: [ transmitterGroup ]
}*/
const token = Buffer.from(`${ config.connectors.tetracontrol.username }:${ config.connectors.tetracontrol.password }`, 'utf8').toString('base64');
const headers = {
Authorization: `Basic ${token}`,
}
const ws = new WebSocket(`ws://${ config.connectors.tetracontrol.endpoint }/live.json?MaxAlter=3600`, { headers });
return new Promise((res, rej) => {
ws.on('open', function open() {
console.log('WebSocket connected');
const jsonData = {
text: msg.payload,
destSSI: target + '',
ProtocolID: 9,
radioID: 1,
type: "sds"
}
ws.send(JSON.stringify(jsonData))
ws.close()
})
ws.on('close',res)
ws.on('error',rej)
})
.then(() => {
this.connectorRegistry.reportState(msg, UUID, 'routed')
return true
})
.catch((err) => {
console.error(err )
this.connectorRegistry.reportFail(msg, UUID)
return false
})
}
}
module.exports = TetraControlConnector

@ -23,6 +23,8 @@ module.exports = {
PagernetzConnetorAT: require('./PagernetzConnetorAT'),
TetraControlConnector: require("./TetraControlConnector"),
LoRaWANConnector: require("./LoRaWANConnector"),
POCSAGConnector: require("./POCSAGConnector"),
DummyConnector: require("./DummyConnector"),

Loading…
Cancel
Save