added manual READ/RECV ack to API Test

master
cheetah 4 years ago
parent 261c0b916b
commit b7ae41caa4

@ -69,10 +69,9 @@ Last LoRaWAN Packet:
</template>
<template v-slot:expanded-item="{ headers, item }">
<td :colspan="headers.length">
<pre>
Message ID: {{ item.id }}
{{ item }}
</pre>
<v-btn :disabled="item._routerData.recvAck" @click="apiACKMessage(item.id, 'recv')">manual RECV ACK</v-btn>
<v-btn :disabled="item._routerData.readAck" @click="apiACKMessage(item.id, 'read')">manual READ ACK</v-btn>
<pre>{{ item }}</pre>
</td>
</template>
</v-data-table>
@ -123,8 +122,10 @@ Message ID: {{ item.id }}
}
},
created() {
//this.refreshDevices()
this.refreshDevices()
setInterval(this.refreshDevices, 1e3)
this.refreshMessages()
setInterval(this.refreshMessages, 1e3)
},
methods: {
@ -163,6 +164,11 @@ Message ID: {{ item.id }}
}, response => {
})
},
apiACKMessage(id, ackType) {
this.$http.get(
'/api/message/ack/'+[ackType, id].join('/')
).then(x=>{})
}
}
})

@ -47,6 +47,7 @@ app.post('/api/message/advanced', async (req, res) => {
app.get('/api/message/status/:id', async (req, res) => { //TODO: make this fancy
return res.json(types.MessageManager.messages[ req.params.id ])
})
app.get('/api/message/recent', async (req, res) => {
let msgs = Object.values(types.MessageManager.messages)
.sort((a,b) => b.date-a.date)
@ -55,7 +56,7 @@ app.get('/api/message/recent', async (req, res) => {
app.get('/api/message/ack/recv/:id', async (req, res) => {
types.ConnectorRegistry.reportDelivered({ id: req.params.id }, 'http')
require('../MessageManager').attachMetadata(req.params.id, {
types.MessageManager.attachMetadata(req.params.id, {
ack: 'recv',
rssi: 0x00,
date: new Date(),
@ -65,7 +66,7 @@ app.get('/api/message/ack/recv/:id', async (req, res) => {
})
app.get('/api/message/ack/read/:id', async (req, res) => {
types.MessageManager.markMessageRead(req.params.id)
require('../MessageManager').attachMetadata(req.params.id, {
types.MessageManager.attachMetadata(req.params.id, {
ack: 'read',
date: new Date(),
metadata: { http: true },

@ -50,7 +50,7 @@ class BirdySlim extends PagerDevice {
break;
case 'operational':
require('../MessageManager').respondToMessage(data.msgid, data.operationalData)
break;
break;
}
// If we have had a Ack. Event, we should store some Metadata about it too
require('../MessageManager').attachMetadata(data.msgid, {

Loading…
Cancel
Save