added eCityruf Connector

master
cheetah 4 years ago
parent 4616737483
commit 261c0b916b

@ -16,6 +16,10 @@
"enabled": true,
"duplexTimeout": 300
},
"ecityruf": {
"enabled": false,
"duplexTimeout": 180
},
"lorawan": {
"enabled": true,
"mqttserver": "mqtt://eu.thethings.network:1883",

@ -67,6 +67,14 @@
<label for="pocsag_duplex_timeout">Duplex Timeout(in seconds): [recommended 90s]</label>
<input type="number" min="10" max="1200" id="pocsag_duplex_timeout"/>
</fieldset>
<fieldset>
<legend>eCityruf Connector</legend>
<label for="ecityruf_enabled">Enabled:</label>
<input type="checkbox" id="ecityruf_enabled"/>
</br>
<label for="ecityruf_duplex_timeout">Duplex Timeout(in seconds): [recommended 180s]</label>
<input type="number" min="10" max="1200" id="ecityruf_duplex_timeout"/>
</fieldset>
<hr>
<!--
@ -102,6 +110,9 @@
$('#pocsag_enabled').attr('checked', config.connectors.pocsag.enabled)
$('#pocsag_duplex_timeout').val(config.connectors.pocsag.duplexTimeout)
$('#ecityruf_enabled').attr('checked', config.connectors.ecityruf.enabled)
$('#ecityruf_duplex_timeout').val(config.connectors.ecityruf.duplexTimeout)
}
async function saveConfigFromForm() {
let newConfig = await $.getJSON('/config') // make a copy from the current dispatcher config
@ -120,6 +131,9 @@
// connectors.pocsag
newConfig.connectors.pocsag.enabled = $('#pocsag_enabled').prop('checked')
newConfig.connectors.pocsag.duplexTimeout = parseInt($('#pocsag_duplex_timeout').val())
// connectors.ecityruf
newConfig.connectors.ecityruf.enabled = $('#ecityruf_enabled').prop('checked')
newConfig.connectors.ecityruf.duplexTimeout = parseInt($('#ecityruf_duplex_timeout').val())
console.log(newConfig)
await $.ajax({

@ -18,6 +18,9 @@ if (!!config.connectors.lorawan && config.connectors.lorawan.enabled === true) {
if (!!config.connectors.dapnet && config.connectors.dapnet.enabled === true) {
types.ConnectorRegistry.register(new types.Connectors.DAPNETConnector(connection))
}
if (!!config.connectors.ecityruf && config.connectors.ecityruf.enabled === true) {
types.ConnectorRegistry.register(new types.Connectors.eCityrufConnector(connection))
}
types.ConnectorRegistry.register(new types.Connectors.DummyConnector())
types.DeviceRegistry.register(new types.devices.GenericPager())

@ -24,6 +24,7 @@
"axios": "^0.21.1",
"express": "^4.17.1",
"md5": "^2.3.0",
"mqtt": "^4.2.6"
"mqtt": "^4.2.6",
"querystring": "^0.2.1"
}
}

@ -0,0 +1,52 @@
const Connector = require("./Connector")
const config = require('../../config.json')
const md5 = require('md5')
const axios = require('axios')
// [ "ecityruf", "123456789" ]
class eCityrufConnector extends Connector {
constructor (amqpConnMngr) {
super(amqpConnMngr)
this.name = "ecityruf"
this.duplexCapable = false
}
async transmitMessage(msg, params) {
const UUID = this.name+':'+md5(JSON.stringify([this.name,...params]))
if (params.length !== 1) return false
const cityrufRequest = require('querystring').stringify({
service: 1,
class: 7,
language: 'en',
action: 'SendMessage',
number: params[ 0 ],
message: msg.payload,
lengthAlert: '',
})
console.log(cityrufRequest)
return axios.post('https://inetgateway.emessage.de/cgi-bin/funkruf2.cgi', cityrufRequest, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-User': '?1',
'Sec-Fetch-Dest': 'document',
'Referer': 'https://inetgateway.emessage.de/cgi-bin/funkruf2.cgi'
}
})
.then((res) => {
if (res.status === 200) {
if (res.data.indexOf('OK. Your message has been sent') > -1) {
this.connectorRegistry.reportState(msg, UUID, 'routed')
return true
}
}
this.connectorRegistry.reportFail(msg, UUID)
return false
})
.catch((err) => {
console.error(err.response.data)
this.connectorRegistry.reportFail(msg, UUID)
return false
})
}
}
module.exports = eCityrufConnector

@ -1,5 +1,6 @@
module.exports = {
DAPNETConnector: require("./DAPNETConnector"),
eCityrufConnector: require('./eCityrufConnector'),
LoRaWANConnector: require("./LoRaWANConnector"),
POCSAGConnector: require("./POCSAGConnector"),
DummyConnector: require("./DummyConnector"),

Loading…
Cancel
Save