added eCityruf Connector

master
cheetah 4 years ago
parent 4616737483
commit 261c0b916b

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

@ -67,7 +67,15 @@
<label for="pocsag_duplex_timeout">Duplex Timeout(in seconds): [recommended 90s]</label> <label for="pocsag_duplex_timeout">Duplex Timeout(in seconds): [recommended 90s]</label>
<input type="number" min="10" max="1200" id="pocsag_duplex_timeout"/> <input type="number" min="10" max="1200" id="pocsag_duplex_timeout"/>
</fieldset> </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> <hr>
<!-- <!--
<button>Check Settings</button> <button>Check Settings</button>
@ -102,6 +110,9 @@
$('#pocsag_enabled').attr('checked', config.connectors.pocsag.enabled) $('#pocsag_enabled').attr('checked', config.connectors.pocsag.enabled)
$('#pocsag_duplex_timeout').val(config.connectors.pocsag.duplexTimeout) $('#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() { async function saveConfigFromForm() {
let newConfig = await $.getJSON('/config') // make a copy from the current dispatcher config let newConfig = await $.getJSON('/config') // make a copy from the current dispatcher config
@ -120,7 +131,10 @@
// connectors.pocsag // connectors.pocsag
newConfig.connectors.pocsag.enabled = $('#pocsag_enabled').prop('checked') newConfig.connectors.pocsag.enabled = $('#pocsag_enabled').prop('checked')
newConfig.connectors.pocsag.duplexTimeout = parseInt($('#pocsag_duplex_timeout').val()) 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) console.log(newConfig)
await $.ajax({ await $.ajax({
type: 'POST', type: 'POST',

@ -18,6 +18,9 @@ if (!!config.connectors.lorawan && config.connectors.lorawan.enabled === true) {
if (!!config.connectors.dapnet && config.connectors.dapnet.enabled === true) { if (!!config.connectors.dapnet && config.connectors.dapnet.enabled === true) {
types.ConnectorRegistry.register(new types.Connectors.DAPNETConnector(connection)) 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.ConnectorRegistry.register(new types.Connectors.DummyConnector())
types.DeviceRegistry.register(new types.devices.GenericPager()) types.DeviceRegistry.register(new types.devices.GenericPager())

@ -24,6 +24,7 @@
"axios": "^0.21.1", "axios": "^0.21.1",
"express": "^4.17.1", "express": "^4.17.1",
"md5": "^2.3.0", "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 = { module.exports = {
DAPNETConnector: require("./DAPNETConnector"), DAPNETConnector: require("./DAPNETConnector"),
eCityrufConnector: require('./eCityrufConnector'),
LoRaWANConnector: require("./LoRaWANConnector"), LoRaWANConnector: require("./LoRaWANConnector"),
POCSAGConnector: require("./POCSAGConnector"), POCSAGConnector: require("./POCSAGConnector"),
DummyConnector: require("./DummyConnector"), DummyConnector: require("./DummyConnector"),

Loading…
Cancel
Save