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

Function AppendJoinAcceptPayload

pkg/encoding/lorawan/messages.go:305–333  ·  view source on GitHub ↗

AppendJoinAcceptPayload appends encoded msg to dst.

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

Source from the content-addressed store, hash-verified

303
304// AppendJoinAcceptPayload appends encoded msg to dst.
305func AppendJoinAcceptPayload(dst []byte, msg *ttnpb.JoinAcceptPayload) ([]byte, error) {
306 if n := len(msg.JoinNonce); n != 3 {
307 return nil, errExpectedLengthEqual("JoinNonce", 3)(n)
308 }
309 dst = appendReverse(dst, msg.JoinNonce...)
310 if n := len(msg.NetId); n != 3 {
311 return nil, errExpectedLengthEqual("NetID", 3)(n)
312 }
313 dst = appendReverse(dst, msg.NetId...)
314 if n := len(msg.DevAddr); n != 4 {
315 return nil, errExpectedLengthEqual("DevAddr", 4)(n)
316 }
317 dst = appendReverse(dst, msg.DevAddr...)
318 dst, err := AppendDLSettings(dst, msg.DlSettings)
319 if err != nil {
320 return nil, errFailedEncoding("DLSettings").WithCause(err)
321 }
322 if msg.RxDelay > math.MaxUint8 {
323 return nil, errExpectedLowerOrEqual("RxDelay", math.MaxUint8)(msg.RxDelay)
324 }
325 dst = append(dst, byte(msg.RxDelay))
326 if msg.GetCfList() != nil {
327 dst, err = AppendCFList(dst, msg.CfList)
328 if err != nil {
329 return nil, errFailedEncoding("CFList").WithCause(err)
330 }
331 }
332 return dst, nil
333}
334
335// MarshalJoinAcceptPayload returns encoded msg.
336func MarshalJoinAcceptPayload(msg *ttnpb.JoinAcceptPayload) ([]byte, error) {

Calls 8

errExpectedLengthEqualFunction · 0.85
appendReverseFunction · 0.85
AppendDLSettingsFunction · 0.85
errFailedEncodingFunction · 0.85
AppendCFListFunction · 0.85
errExpectedLowerOrEqualFunction · 0.70
WithCauseMethod · 0.45
GetCfListMethod · 0.45