From 966cb4c5ed11e153524660b027a80f248182c98a Mon Sep 17 00:00:00 2001 From: cheetah Date: Sun, 20 Feb 2022 16:49:40 +0000 Subject: [PATCH] modified 2wayts pager definition --- types/devices/EMessage2Ways.js | 67 ---------------------------------- 1 file changed, 67 deletions(-) diff --git a/types/devices/EMessage2Ways.js b/types/devices/EMessage2Ways.js index feab770..e9e83b6 100644 --- a/types/devices/EMessage2Ways.js +++ b/types/devices/EMessage2Ways.js @@ -20,73 +20,6 @@ class EMessage2Ways extends PagerDevice { //msg.payload = msg.type === 'duplex' ? `${ msg.id }${ msg.payload }` : msg.payload // only if duplex wanted we add the id } async tryReceive(data, connector) { - if (typeof(data) === 'object' && !!data.type) { - const stateSet = { - lastSeen: data.date - } - // If we have a Battery Measurement or other Power Events, we should store it - if (!!data.battery) stateSet.battery = data.battery/1e1 - if (data.hasOwnProperty('isCharging')) stateSet.isCharging = data.isCharging - if (data.hasOwnProperty('poweredOn')) stateSet.poweredOn = data.poweredOn - - // the same if we have an rssi measurement - if (!!data.rssi) stateSet.rssi = data.rssi - // and if we have the 3 components of a GPS Block - if (!!data.latitude && !!data.longitude && !!data.lastGPSAcquisition) stateSet.gps = { - lastGPSAcquisition: data.lastGPSAcquisition, - latitude: data.latitude, - longitude: data.longitude, - } - stateSet.lastLoRaPacket = data.metadata - console.log(data, stateSet) - /*if (!!data.metadata && !!data.metadata.uplink_message.rx_metadata) { - const rx_metadata = data.metadata.uplink_message.rx_metadata - - }*/ - - switch (data.type) { - case 'ack': { - switch (data.ack) { - case 'recv': - require('../ConnectorRegistry').reportDelivered({ id: data.msgid }, `lorawan:${ data.device_id }`) - break; - case 'read': - require('../MessageManager').markMessageRead(data.msgid) - break; - case 'operational': - require('../MessageManager').respondToMessage(data.msgid, data.operationalData) - break; - } - // If we have had a Ack. Event, we should store some Metadata about it too - require('../MessageManager').attachMetadata(data.msgid, { - ack: data.ack, - rssi: data.rssi, - date: data.date, - metadata: data.metadata, - }) - } - break; - case 'sos': - stateSet.sos = { - sos: data.sos, - date: data.date, - } - break; - - case 'status': - case 'cannedMessage': - case 'low_battery': - case 'power': - case 'battery': - case 'sos': - case 'gps': - require('../DeviceRegistry').deviceEvent(this.name, data.device_id, data) - break; - } - require('../DeviceRegistry').stateSet(this.name, data.device_id, stateSet) - return true - } - return false } } module.exports = EMessage2Ways \ No newline at end of file