|
|
|
@ -12,7 +12,7 @@ class BirdySlim extends PagerDevice {
|
|
|
|
|
this.name = "birdyslim"
|
|
|
|
|
}
|
|
|
|
|
RandID() {
|
|
|
|
|
return `B${ Str.random(4) }`
|
|
|
|
|
return `${ Str.random(5) }`
|
|
|
|
|
}
|
|
|
|
|
async formatTX(msg) {
|
|
|
|
|
msg.id = this.RandID()
|
|
|
|
@ -38,7 +38,6 @@ class BirdySlim extends PagerDevice {
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
@ -46,24 +45,28 @@ class BirdySlim extends PagerDevice {
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
try {
|
|
|
|
|
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,
|
|
|
|
|
})
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('failed to report lorawan data for message', data.msgid)
|
|
|
|
|
}
|
|
|
|
|
// 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':
|
|
|
|
@ -71,14 +74,11 @@ class BirdySlim extends PagerDevice {
|
|
|
|
|
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;
|
|
|
|
|