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

Function AppendMHDR

pkg/encoding/lorawan/messages.go:28–36  ·  view source on GitHub ↗

AppendMHDR appends encoded msg to dst.

(dst []byte, msg *ttnpb.MHDR)

Source from the content-addressed store, hash-verified

26
27// AppendMHDR appends encoded msg to dst.
28func AppendMHDR(dst []byte, msg *ttnpb.MHDR) ([]byte, error) {
29 if msg.GetMType() > 7 {
30 return nil, errExpectedLowerOrEqual("MType", 7)(msg.GetMType())
31 }
32 if msg.GetMajor() > 4 {
33 return nil, errExpectedLowerOrEqual("Major", 4)(msg.GetMajor())
34 }
35 return append(dst, byte(msg.GetMType())<<5|byte(msg.GetMajor())), nil
36}
37
38// MarshalMHDR returns encoded msg.
39func MarshalMHDR(msg *ttnpb.MHDR) ([]byte, error) {

Callers 3

HandleJoinMethod · 0.92
MarshalMHDRFunction · 0.85
AppendMessageFunction · 0.85

Calls 3

GetMajorMethod · 0.80
errExpectedLowerOrEqualFunction · 0.70
GetMTypeMethod · 0.45

Tested by

no test coverage detected