MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / newMACUnmarshaler

Function newMACUnmarshaler

pkg/encoding/lorawan/mac.go:54–65  ·  view source on GitHub ↗
(cid ttnpb.MACCommandIdentifier, name string, n uint8, f func(band.Band, []byte, *ttnpb.MACCommand) error)

Source from the content-addressed store, hash-verified

52type MACCommandSpec map[ttnpb.MACCommandIdentifier]*MACCommandDescriptor
53
54func newMACUnmarshaler(cid ttnpb.MACCommandIdentifier, name string, n uint8, f func(band.Band, []byte, *ttnpb.MACCommand) error) func(phy band.Band, b []byte, cmd *ttnpb.MACCommand) error {
55 return func(phy band.Band, b []byte, cmd *ttnpb.MACCommand) error {
56 if len(b) != int(n) {
57 return errExpectedLengthEqual(name, int(n))(len(b))
58 }
59 cmd.Cid = cid
60 if f == nil {
61 return nil
62 }
63 return f(phy, b, cmd)
64 }
65}
66
67// DefaultMACCommands contains all the default MAC commands.
68var DefaultMACCommands = MACCommandSpec{

Callers 1

mac.goFile · 0.85

Calls 1

errExpectedLengthEqualFunction · 0.85

Tested by

no test coverage detected