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>
<template v-slot:expanded-item="{ headers, item }"> <template v-slot:expanded-item="{ headers, item }">
<td :colspan="headers.length"> <td :colspan="headers.length">
<pre> <v-btn :disabled="item._routerData.recvAck" @click="apiACKMessage(item.id, 'recv')">manual RECV ACK</v-btn>
Message ID: {{ item.id }} <v-btn :disabled="item._routerData.readAck" @click="apiACKMessage(item.id, 'read')">manual READ ACK</v-btn>
{{ item }} <pre>{{ item }}</pre>
</pre>
</td> </td>
</template> </template>
</v-data-table> </v-data-table>
@ -123,8 +122,10 @@ Message ID: {{ item.id }}
} }
}, },
created() { created() {
//this.refreshDevices() this.refreshDevices()
setInterval(this.refreshDevices, 1e3) setInterval(this.refreshDevices, 1e3)
this.refreshMessages()
setInterval(this.refreshMessages, 1e3) setInterval(this.refreshMessages, 1e3)
}, },
methods: { methods: {
@ -163,6 +164,11 @@ Message ID: {{ item.id }}
}, response => { }, 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 app.get('/api/message/status/:id', async (req, res) => { //TODO: make this fancy
return res.json(types.MessageManager.messages[ req.params.id ]) return res.json(types.MessageManager.messages[ req.params.id ])
}) })
app.get('/api/message/recent', async (req, res) => { app.get('/api/message/recent', async (req, res) => {
let msgs = Object.values(types.MessageManager.messages) let msgs = Object.values(types.MessageManager.messages)
.sort((a,b) => b.date-a.date) .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) => { app.get('/api/message/ack/recv/:id', async (req, res) => {
types.ConnectorRegistry.reportDelivered({ id: req.params.id }, 'http') types.ConnectorRegistry.reportDelivered({ id: req.params.id }, 'http')
require('../MessageManager').attachMetadata(req.params.id, { types.MessageManager.attachMetadata(req.params.id, {
ack: 'recv', ack: 'recv',
rssi: 0x00, rssi: 0x00,
date: new Date(), 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) => { app.get('/api/message/ack/read/:id', async (req, res) => {
types.MessageManager.markMessageRead(req.params.id) types.MessageManager.markMessageRead(req.params.id)
require('../MessageManager').attachMetadata(req.params.id, { types.MessageManager.attachMetadata(req.params.id, {
ack: 'read', ack: 'read',
date: new Date(), date: new Date(),
metadata: { http: true }, metadata: { http: true },

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

Loading…
Cancel
Save