Commit 476afac3 authored by Orne Brocaar's avatar Orne Brocaar
Browse files

Handle fNS XmitDataAns as a TxAck.

Based on #561. See also #555.
parent 16439a4c
package ack
import (
"context"
"github.com/brocaar/chirpstack-api/go/v3/gw"
"github.com/brocaar/chirpstack-network-server/v3/internal/storage"
)
// HandleDownlinkXmitDataAns handles an ack as hNS.
func HandleRoamingTxAck(ctx context.Context, txAck gw.DownlinkTXAck) error {
actx := ackContext{
ctx: ctx,
DB: storage.DB(),
DownlinkTXAck: &txAck,
DownlinkTXAckStatus: gw.TxAckStatus_OK,
}
for _, t := range handleDownlinkTXAckTasks {
if err := t(&actx); err != nil {
return err
}
}
return nil
}
......@@ -22,6 +22,7 @@ import (
"github.com/brocaar/chirpstack-network-server/v3/internal/band"
"github.com/brocaar/chirpstack-network-server/v3/internal/channels"
"github.com/brocaar/chirpstack-network-server/v3/internal/config"
"github.com/brocaar/chirpstack-network-server/v3/internal/downlink/ack"
dwngateway "github.com/brocaar/chirpstack-network-server/v3/internal/downlink/gateway"
"github.com/brocaar/chirpstack-network-server/v3/internal/gps"
"github.com/brocaar/chirpstack-network-server/v3/internal/helpers"
......@@ -128,11 +129,11 @@ var responseTasks = []func(*dataContext) error{
),
isRoaming(true,
sendDownlinkFramePassiveRoaming,
deleteDeviceQueueItem,
),
saveDeviceSession,
isRoaming(false,
saveDownlinkFrame,
saveDownlinkFrame,
isRoaming(true,
handleRoamingTxAck,
),
}
......@@ -1507,18 +1508,6 @@ func sendDownlinkFramePassiveRoaming(ctx *dataContext) error {
return nil
}
func deleteDeviceQueueItem(ctx *dataContext) error {
if ctx.DeviceQueueItem == nil {
return nil
}
if err := storage.DeleteDeviceQueueItem(ctx.ctx, storage.DB(), ctx.DeviceQueueItem.ID); err != nil {
return errors.Wrap(err, "delete device queue-item error")
}
return nil
}
func saveDeviceSession(ctx *dataContext) error {
if err := storage.SaveDeviceSession(ctx.ctx, ctx.DeviceSession); err != nil {
return errors.Wrap(err, "save device-session error")
......@@ -1658,6 +1647,17 @@ func saveDownlinkFrame(ctx *dataContext) error {
return nil
}
func handleRoamingTxAck(ctx *dataContext) error {
if err := ack.HandleRoamingTxAck(ctx.ctx, gw.DownlinkTXAck{
Token: ctx.DownlinkFrame.Token,
DownlinkId: ctx.DownlinkFrame.DownlinkId,
}); err != nil {
return errors.Wrap(err, "Handle roaming tx ack")
}
return nil
}
// setDeviceQueueItemRetryAfter sets the retry_after field of the device-queue
// item. Note that there is no need to call this for Class-A devices, as the
// downlink is triggered only by an uplink event. The purpose of the retry_after
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment