Skip to content

Commit d11e570

Browse files
Send also ack errors from mac only messages to AS. (brocaar#596)
Co-authored-by: Gerrit Brehmer <[email protected]>
1 parent bc949fd commit d11e570

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

internal/downlink/ack/ack.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ var handleDownlinkTXAckTasks = []func(*ackContext) error{
3737
forApplicationPayload(
3838
sendErrorToApplicationServerOnLastFrame,
3939
),
40+
forMACOnlyPayload(
41+
sendErrorToApplicationServerOnLastFrame,
42+
),
4043
forMulticastPayload(
4144
// TODO: For now we delete the multicast queue-item. What would be the best
4245
// way to retry? Multicast is a bit more complicated as the downlinks are
@@ -498,8 +501,7 @@ func sendTxAckToApplicationServer(ctx *ackContext) error {
498501

499502
func sendErrorToApplicationServerOnLastFrame(ctx *ackContext) error {
500503
// Only send an error to the AS on the last possible attempt.
501-
// We only want to send error for application payloads.
502-
if (len(ctx.DownlinkTXAck.Items) == 0 && len(ctx.DownlinkFrame.DownlinkFrame.Items) >= 2) || ctx.MACPayload == nil || ctx.MACPayload.FPort == nil || *ctx.MACPayload.FPort == 0 {
504+
if (len(ctx.DownlinkTXAck.Items) == 0 && len(ctx.DownlinkFrame.DownlinkFrame.Items) >= 2) || ctx.MACPayload == nil {
503505
return nil
504506
}
505507

internal/testsuite/downlink_tx_ack_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,11 @@ func (ts *DownlinkTXAckTestSuite) TestDownlinkTXAck() {
371371
},
372372
Assert: []Assertion{
373373
AssertNFCntDown(10),
374-
AssertASNoHandleErrorRequest(), // no error as this is mac-layer only
374+
AssertASHandleErrorRequest(as.HandleErrorRequest{
375+
DevEui: ts.Device.DevEUI[:],
376+
Type: as.ErrorType_DATA_DOWN_GATEWAY,
377+
Error: "TX_FREQ",
378+
}),
375379
AssertASNoHandleTxAckRequest(),
376380
AssertNCNoHandleDownlinkMetaDataRequest(),
377381
},

0 commit comments

Comments
 (0)