|
|
|
@ -56,7 +56,6 @@ class LoRaWANConnector extends Connector {
|
|
|
|
|
async onMQTTMessage(topic, message) {
|
|
|
|
|
//if (topic.indexOf('/up') > -1) return
|
|
|
|
|
const json = JSON.parse(Buffer.from(message).toString('utf-8'))
|
|
|
|
|
console.log(topic)
|
|
|
|
|
if (!!json.uplink_message) { // TTN v3
|
|
|
|
|
this.connectorRegistry.events.emit('response', {
|
|
|
|
|
...json.uplink_message.decoded_payload,
|
|
|
|
@ -66,15 +65,6 @@ class LoRaWANConnector extends Connector {
|
|
|
|
|
metadata: json,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if (!!json.app_id && json.app_id == config.connectors.lorawan.username) { // TTN v2
|
|
|
|
|
this.connectorRegistry.events.emit('response', {
|
|
|
|
|
...json.payload_fields,
|
|
|
|
|
port: json.port,
|
|
|
|
|
date: new Date(json.metadata.time),
|
|
|
|
|
device_id: json.dev_id,
|
|
|
|
|
metadata: json,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
module.exports = LoRaWANConnector
|