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

Function AppendFCtrl

pkg/encoding/lorawan/messages.go:55–79  ·  view source on GitHub ↗

AppendFCtrl appends encoded msg to dst.

(dst []byte, msg *ttnpb.FCtrl, isUplink bool, fOptsLen uint8)

Source from the content-addressed store, hash-verified

53
54// AppendFCtrl appends encoded msg to dst.
55func AppendFCtrl(dst []byte, msg *ttnpb.FCtrl, isUplink bool, fOptsLen uint8) ([]byte, error) {
56 if fOptsLen > 15 {
57 return nil, errExpectedLowerOrEqual("FOptsLen", 15)(fOptsLen)
58 }
59 b := fOptsLen
60 if msg.GetAdr() {
61 b |= 1 << 7
62 }
63 if msg.GetAck() {
64 b |= 1 << 5
65 }
66 if isUplink {
67 if msg.GetAdrAckReq() {
68 b |= 1 << 6
69 }
70 if msg.GetClassB() {
71 b |= 1 << 4
72 }
73 } else {
74 if msg.GetFPending() {
75 b |= 1 << 4
76 }
77 }
78 return append(dst, b), nil
79}
80
81// UnmarshalFCtrl unmarshals b into msg.
82func UnmarshalFCtrl(b []byte, msg *ttnpb.FCtrl, isUplink bool) error {

Callers 2

AppendFHDRFunction · 0.85
TestFCtrlFunction · 0.85

Calls 6

GetClassBMethod · 0.80
GetFPendingMethod · 0.80
errExpectedLowerOrEqualFunction · 0.70
GetAdrMethod · 0.45
GetAckMethod · 0.45
GetAdrAckReqMethod · 0.45

Tested by 1

TestFCtrlFunction · 0.68