Skip to content

Commit

Permalink
Remote set mac-command set from scheduleNextQueueItemTasks.
Browse files Browse the repository at this point in the history
Per LoRaWAN 1.0.4 specs, Class-C downlinks shall not transport any
mac-commands. This does also remove sending mac-commands for Class-B.

Closes brocaar#543.
  • Loading branch information
brocaar committed Aug 9, 2021
1 parent c386dfd commit ad1c90a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 48 deletions.
3 changes: 1 addition & 2 deletions internal/downlink/data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ var scheduleNextQueueItemTasks = []func(*dataContext) error{
),
setToken,
getNextDeviceQueueItem,
setMACCommandsSet,
stopOnNothingToSend,
setPHYPayloads,
sendDownlinkFrame,
Expand Down Expand Up @@ -1393,7 +1392,7 @@ func setPHYPayloads(ctx *dataContext) error {
// Set MIC.
// If this is an ACK, then FCntUp has already been incremented by one. If
// this is not an ACK, then DownlinkDataMIC will zero out ConfFCnt.
if err := phy.SetDownlinkDataMIC(ctx.DeviceSession.GetMACVersion(), ctx.DeviceSession.FCntUp - 1, ctx.DeviceSession.SNwkSIntKey); err != nil {
if err := phy.SetDownlinkDataMIC(ctx.DeviceSession.GetMACVersion(), ctx.DeviceSession.FCntUp-1, ctx.DeviceSession.SNwkSIntKey); err != nil {
return errors.Wrap(err, "set MIC error")
}

Expand Down
46 changes: 0 additions & 46 deletions internal/testsuite/class_c_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package testsuite

import (
"context"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -182,51 +181,6 @@ func (ts *ClassCTestSuite) TestClassC() {
AssertNoDownlinkFrame,
},
},
{
Name: "containing mac-commands",
BeforeFunc: func(*DownlinkTest) error {
ts.ServiceProfile.DevStatusReqFreq = 1
if err := storage.UpdateServiceProfile(context.Background(), storage.DB(), ts.ServiceProfile); err != nil {
return err
}
if err := storage.FlushServiceProfileCache(context.Background(), ts.ServiceProfile.ID); err != nil {
return err
}

return nil
},
DeviceSession: *ts.DeviceSession,
DeviceQueueItems: []storage.DeviceQueueItem{
{DevEUI: ts.DeviceSession.DevEUI, FPort: 10, FCnt: 5, FRMPayload: []byte{5, 4, 3, 2, 1}},
},
Assert: []Assertion{
AssertFCntUp(8),
AssertNFCntDown(5),
AssertDownlinkFrame(ts.Gateway.GatewayID, txInfo, lorawan.PHYPayload{
MHDR: lorawan.MHDR{
MType: lorawan.UnconfirmedDataDown,
Major: lorawan.LoRaWANR1,
},
MIC: lorawan.MIC{115, 18, 33, 93},
MACPayload: &lorawan.MACPayload{
FHDR: lorawan.FHDR{
DevAddr: ts.DeviceSession.DevAddr,
FCnt: 5,
FCtrl: lorawan.FCtrl{
ADR: true,
},
FOpts: []lorawan.Payload{
&lorawan.MACCommand{CID: lorawan.CID(6)},
},
},
FPort: &fPortTen,
FRMPayload: []lorawan.Payload{
&lorawan.DataPayload{Bytes: []byte{5, 4, 3, 2, 1}},
},
},
}),
},
},
}

for _, tst := range tests {
Expand Down

0 comments on commit ad1c90a

Please sign in to comment.