@@ -63,13 +63,13 @@ type Backend struct {
63
63
gatewayStatsFunc func (* gw.GatewayStats )
64
64
rawPacketForwarderEventFunc func (* gw.RawPacketForwarderEvent )
65
65
66
- band band.Band
67
- region band.Name
68
- netIDs []lorawan.NetID
69
- joinEUIs [][2 ]lorawan.EUI64
70
- frequencyMin uint32
71
- frequencyMax uint32
72
- routerConfig structs. RouterConfig
66
+ band band.Band
67
+ region band.Name
68
+ netIDs []lorawan.NetID
69
+ joinEUIs [][2 ]lorawan.EUI64
70
+ frequencyMin uint32
71
+ frequencyMax uint32
72
+ concentrators []config. BasicStationConcentrator
73
73
74
74
// Cache to store diid to UUIDs.
75
75
diidCache * cache.Cache
@@ -94,9 +94,10 @@ func NewBackend(conf config.Config) (*Backend, error) {
94
94
readTimeout : conf .Backend .BasicStation .ReadTimeout ,
95
95
writeTimeout : conf .Backend .BasicStation .WriteTimeout ,
96
96
97
- region : band .Name (conf .Backend .BasicStation .Region ),
98
- frequencyMin : conf .Backend .BasicStation .FrequencyMin ,
99
- frequencyMax : conf .Backend .BasicStation .FrequencyMax ,
97
+ region : band .Name (conf .Backend .BasicStation .Region ),
98
+ frequencyMin : conf .Backend .BasicStation .FrequencyMin ,
99
+ frequencyMax : conf .Backend .BasicStation .FrequencyMax ,
100
+ concentrators : config .C .Backend .BasicStation .Concentrators ,
100
101
101
102
diidCache : cache .New (time .Minute , time .Minute ),
102
103
}
@@ -127,11 +128,6 @@ func NewBackend(conf config.Config) (*Backend, error) {
127
128
return nil , errors .Wrap (err , "get band config error" )
128
129
}
129
130
130
- b .routerConfig , err = structs .GetRouterConfig (b .region , b .netIDs , b .joinEUIs , b .frequencyMin , b .frequencyMax , conf .Backend .BasicStation .Concentrators )
131
- if err != nil {
132
- return nil , errors .Wrap (err , "get router config error" )
133
- }
134
-
135
131
mux := http .NewServeMux ()
136
132
mux .HandleFunc ("/router-info" , func (w http.ResponseWriter , r * http.Request ) {
137
133
b .websocketWrap (b .handleRouterInfo , w , r )
@@ -295,6 +291,10 @@ func (b *Backend) Stop() error {
295
291
return b .ln .Close ()
296
292
}
297
293
294
+ func (b * Backend ) getRouterConfig () (structs.RouterConfig , error ) {
295
+ return structs .GetRouterConfig (b .region , b .netIDs , b .joinEUIs , b .frequencyMin , b .frequencyMax , b .concentrators )
296
+ }
297
+
298
298
func (b * Backend ) handleRouterInfo (r * http.Request , conn * connection ) {
299
299
websocketReceiveCounter ("router_info" ).Inc ()
300
300
var req structs.RouterInfoRequest
@@ -553,8 +553,14 @@ func (b *Backend) handleVersion(gatewayID lorawan.EUI64, pl structs.Version) {
553
553
// "features": pl.Features,
554
554
}).Info ("backend/basicstation: gateway version received" )
555
555
556
+ routerConfig , err := b .getRouterConfig ()
557
+ if err != nil {
558
+ log .WithError (err ).Error ("backend/basicstation: get router config error" )
559
+ return
560
+ }
561
+
556
562
websocketSendCounter ("router_config" ).Inc ()
557
- if err := b .sendToGateway (gatewayID , b . routerConfig ); err != nil {
563
+ if err := b .sendToGateway (gatewayID , routerConfig ); err != nil {
558
564
log .WithError (err ).Error ("backend/basicstation: send to gateway error" )
559
565
return
560
566
}
0 commit comments