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

Function AppendMACPayload

pkg/encoding/lorawan/messages.go:140–153  ·  view source on GitHub ↗

AppendMACPayload appends encoded msg to dst.

(dst []byte, msg *ttnpb.MACPayload, isUplink bool)

Source from the content-addressed store, hash-verified

138
139// AppendMACPayload appends encoded msg to dst.
140func AppendMACPayload(dst []byte, msg *ttnpb.MACPayload, isUplink bool) ([]byte, error) {
141 dst, err := AppendFHDR(dst, msg.FHdr, isUplink)
142 if err != nil {
143 return nil, errFailedEncoding("FHDR").WithCause(err)
144 }
145 if msg.FPort > math.MaxUint8 {
146 return nil, errExpectedLowerOrEqual("FPort", math.MaxUint8)(msg.FPort)
147 }
148 if len(msg.FrmPayload) > 0 || msg.FPort != 0 {
149 dst = append(dst, byte(msg.FPort))
150 }
151 dst = append(dst, msg.FrmPayload...)
152 return dst, nil
153}
154
155// MarshalMACPayload returns encoded msg.
156func MarshalMACPayload(msg *ttnpb.MACPayload, isUplink bool) ([]byte, error) {

Callers 2

MarshalMACPayloadFunction · 0.85
AppendMessageFunction · 0.85

Calls 4

AppendFHDRFunction · 0.85
errFailedEncodingFunction · 0.85
errExpectedLowerOrEqualFunction · 0.70
WithCauseMethod · 0.45

Tested by

no test coverage detected