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

Function Build

pkg/pfconfig/semtechudp/semtechudp.go:75–108  ·  view source on GitHub ↗

Build builds a packet forwarder configuration for the given gateway, using the given frequency plan store.

(gateway *ttnpb.Gateway, store *frequencyplans.Store)

Source from the content-addressed store, hash-verified

73
74// Build builds a packet forwarder configuration for the given gateway, using the given frequency plan store.
75func Build(gateway *ttnpb.Gateway, store *frequencyplans.Store) (*Config, error) {
76 var c Config
77
78 host, port, err := shared.ParseGatewayServerAddress(gateway.GatewayServerAddress)
79 if err != nil {
80 return nil, err
81 }
82
83 if gateway.GetIds().GetEui() != nil {
84 c.GatewayConf.GatewayID = types.MustEUI64(gateway.GetIds().GetEui()).String()
85 }
86 c.GatewayConf.ServerAddress = host
87 c.GatewayConf.ServerPortUp = uint32(port)
88 c.GatewayConf.ServerPortDown = uint32(port)
89 server := c.GatewayConf
90 server.Enabled = true
91 c.GatewayConf.Servers = append(c.GatewayConf.Servers, server)
92
93 c.SX1301Conf = make([]*shared.SX1301Config, 0, len(gateway.FrequencyPlanIds))
94 for _, frequencyPlanID := range gateway.FrequencyPlanIds {
95 frequencyPlan, err := store.GetByID(frequencyPlanID)
96 if err != nil {
97 return nil, err
98 }
99 if len(frequencyPlan.Radios) != 0 {
100 sx1301Config, err := shared.BuildSX1301Config(frequencyPlan)
101 if err != nil {
102 return nil, err
103 }
104 c.SX1301Conf = append(c.SX1301Conf, sx1301Config)
105 }
106 }
107 return &c, nil
108}

Callers 4

handleSemtechUDPFunction · 0.92
RegisterRoutesMethod · 0.92
TestWebFunction · 0.92
TestGRPCFunction · 0.92

Calls 7

MustEUI64Function · 0.92
BuildSX1301ConfigFunction · 0.92
GetEuiMethod · 0.65
StringMethod · 0.65
GetByIDMethod · 0.65
GetIdsMethod · 0.45

Tested by 2

TestWebFunction · 0.74
TestGRPCFunction · 0.74