added smartPOC over MQTT
This commit is contained in:
parent
4c6b96fabd
commit
42b2d359ae
4 changed files with 56 additions and 40 deletions
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
"general": {
|
||||
"amqp": [
|
||||
"amqp://daemon:daemon@127.0.0.1:5672/"
|
||||
],
|
||||
"amqp": [],
|
||||
"port": 3000,
|
||||
"configPort": 3001,
|
||||
"configWebInterfaceEnabled": true
|
||||
|
|
|
@ -101,9 +101,9 @@
|
|||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
<v-divider></v-divider>
|
||||
<v-list-item> <!-- POCSAG-GW-->
|
||||
<v-list-item> <!-- POCSAG / "smartPOC"-->
|
||||
<v-list-item-content>
|
||||
<v-list-item-title>POCSAG-GW</v-list-item-title>
|
||||
<v-list-item-title>smartPOC</v-list-item-title>
|
||||
<v-list-item-action>
|
||||
<v-row cols="12">
|
||||
<v-col cols="6" sm="6" md="6">
|
||||
|
@ -112,6 +112,18 @@
|
|||
<v-col cols="6" sm="6" md="6">
|
||||
<v-text-field type="number" :rules="validNumberRules" label="Duplex Timeout in seconds" v-model="configData.connectors.pocsag.duplexTimeout"></v-text-field>
|
||||
</v-row>
|
||||
<v-col cols="6" sm="6" md="6">
|
||||
<v-text-field label="Username" v-model="configData.connectors.pocsag.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.pocsag.password"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="6" sm="6" md="6">
|
||||
<v-text-field label="MQTT Server" v-model="configData.connectors.pocsag.mqttserver"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="6" sm="6" md="6">
|
||||
<v-text-field label="MQTT Topic" v-model="configData.connectors.pocsag.topic"></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-list-item-action>
|
||||
</v-list-item-content>
|
||||
|
@ -141,7 +153,6 @@
|
|||
</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>
|
||||
|
@ -166,7 +177,6 @@
|
|||
</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>
|
||||
|
@ -449,11 +459,10 @@
|
|||
}, {})
|
||||
|
||||
this.$http.post(window.location.pathname + 'config', storeConfig).then(response => {
|
||||
this.$http.post(window.location.pathname + 'restart').then(() => {
|
||||
})
|
||||
.then(this.$http.post(window.location.pathname + 'restart'))
|
||||
.then(() => {
|
||||
document.body.style = 'display:none'
|
||||
setTimeout(() => window.location.reload(), 1e3)
|
||||
document.body.style = 'display:none'
|
||||
})
|
||||
},
|
||||
addDeliveryTarget(index) {
|
||||
|
|
16
index.js
16
index.js
|
@ -1,13 +1,13 @@
|
|||
const amqp = require('amqp-connection-manager')
|
||||
// const amqp = require('amqp-connection-manager')
|
||||
const fs = require('fs')
|
||||
const config = require('./config.json')
|
||||
|
||||
|
||||
// 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 = 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
|
||||
|
||||
if (!!config.connectors.pocsag && config.connectors.pocsag.enabled === true) {
|
||||
|
@ -33,11 +33,11 @@ if (!!config.connectors.emPuppettering && config.connectors.emPuppettering.enabl
|
|||
types.ConnectorRegistry.register(new types.Connectors.eMessagePuppeteerConnectorTwoWays(connection))
|
||||
}
|
||||
|
||||
if (!!config.connectors.ecityruf && config.connectors.pagernetzAT.enabled === true) {
|
||||
if (!!config.connectors.pagernetzAT && config.connectors.pagernetzAT.enabled === true) {
|
||||
types.ConnectorRegistry.register(new types.Connectors.PagernetzConnetorAT(connection))
|
||||
}
|
||||
if (!!config.connectors.ecityruf && config.connectors.pnet.enabled === true) {
|
||||
types.ConnectorRegistry.register(new types.Connectors.pNetConnector())
|
||||
if (!!config.connectors.pnet && config.connectors.pnet.enabled === true) {
|
||||
types.ConnectorRegistry.register(new types.Connectors.pNetConnector(connection))
|
||||
}
|
||||
if (!!config.connectors.tetracontrol && config.connectors.tetracontrol.enabled === true) {
|
||||
types.ConnectorRegistry.register(new types.Connectors.TetraControlConnector(connection))
|
||||
|
|
|
@ -3,6 +3,7 @@ const config = require('../../config.json')
|
|||
const boskrypt = require('../../boskrypt')
|
||||
const Connector = require("./Connector")
|
||||
const md5 = require('md5')
|
||||
const MQTT = require('async-mqtt')
|
||||
|
||||
class POCSAGConnector extends Connector {
|
||||
constructor (amqpConnMngr) {
|
||||
|
@ -10,12 +11,28 @@ class POCSAGConnector extends Connector {
|
|||
this.name = "pocsag"
|
||||
this.duplexCapable = false
|
||||
this.supportBOSkrypt = true
|
||||
this.channelWrapper = this.amqpConnMngr.createChannel({
|
||||
json: false,
|
||||
setup: function(channel) {
|
||||
return channel.assertQueue('tx_pocsag', { durable: true })
|
||||
}
|
||||
|
||||
this.client = MQTT.connect(config.connectors.pocsag.mqttserver, {
|
||||
username: config.connectors.pocsag.username,
|
||||
password: config.connectors.pocsag.password,
|
||||
connectTimeout: 10,
|
||||
})
|
||||
this.client.on('error', (x) => console.error(e))
|
||||
this.client.on('connect', this.onMQTTConnect.bind(this))
|
||||
this.client.on('message', this.onMQTTMessage.bind(this))
|
||||
console.log("pocsag connector initalized",
|
||||
config.connectors.pocsag.mqttserver,
|
||||
config.connectors.pocsag.username,
|
||||
config.connectors.pocsag.password
|
||||
)
|
||||
}
|
||||
async onMQTTConnect() {
|
||||
// await this.client.subscribe(`v3/${ config.connectors.pocsag.username }/devices/#`)
|
||||
// await this.client.subscribe(`${ config.connectors.pocsag.username }/devices/#`)
|
||||
console.log('[pocsag] subscribed')
|
||||
}
|
||||
async onMQTTMessage(topic, message) {
|
||||
console.log(topic, message)
|
||||
}
|
||||
async transmitMessage(msg, params) {
|
||||
const UUID = this.name+':'+md5(JSON.stringify([this.name,...params]))
|
||||
|
@ -25,18 +42,6 @@ class POCSAGConnector extends Connector {
|
|||
const addressPart = lastChar >= 0 && lastChar <= 3 ? RIC.substring(0, RIC.length - 1) : RIC
|
||||
const functionBits = lastChar >= 0 && lastChar <= 3 ? lastChar : 0
|
||||
|
||||
const headers = {
|
||||
ric: {
|
||||
'!': 'int64',
|
||||
value: addressPart
|
||||
},
|
||||
function: {
|
||||
'!': 'int64',
|
||||
value: functionBits
|
||||
},
|
||||
}
|
||||
if (params.length >= 2 && params[1] === true) headers.numeric = 1
|
||||
|
||||
let payloadBuffer = Buffer.from(msg.payload)
|
||||
|
||||
const $device = msg.routingParams.device
|
||||
|
@ -50,9 +55,13 @@ class POCSAGConnector extends Connector {
|
|||
}
|
||||
}
|
||||
|
||||
this.channelWrapper.sendToQueue('tx_pocsag', payloadBuffer, {
|
||||
headers
|
||||
})
|
||||
let payload = {
|
||||
ric: parseInt(addressPart, 10),
|
||||
fun: functionBits,
|
||||
msg: payloadBuffer.toString("ascii")
|
||||
}
|
||||
console.log (config.connectors.pocsag, payloadBuffer.toString("ascii"), payload)
|
||||
await this.client.publish(config.connectors.pocsag.topic, JSON.stringify(payload))
|
||||
.then(() => {
|
||||
this.connectorRegistry.reportState(msg, UUID, 'routed')
|
||||
return true
|
||||
|
|
Loading…
Add table
Reference in a new issue