@@ -65,13 +65,13 @@ type Backend struct {
65
65
gatewayStatsFunc func (gw.GatewayStats )
66
66
rawPacketForwarderEventFunc func (gw.RawPacketForwarderEvent )
67
67
68
- band band.Band
69
- region band.Name
70
- netIDs []lorawan.NetID
71
- joinEUIs [][2 ]lorawan.EUI64
72
- frequencyMin uint32
73
- frequencyMax uint32
74
- routerConfig structs. RouterConfig
68
+ band band.Band
69
+ region band.Name
70
+ netIDs []lorawan.NetID
71
+ joinEUIs [][2 ]lorawan.EUI64
72
+ frequencyMin uint32
73
+ frequencyMax uint32
74
+ concentrators []config. BasicStationConcentrator
75
75
76
76
// Cache to store diid to UUIDs.
77
77
diidCache * cache.Cache
@@ -96,9 +96,10 @@ func NewBackend(conf config.Config) (*Backend, error) {
96
96
readTimeout : conf .Backend .BasicStation .ReadTimeout ,
97
97
writeTimeout : conf .Backend .BasicStation .WriteTimeout ,
98
98
99
- region : band .Name (conf .Backend .BasicStation .Region ),
100
- frequencyMin : conf .Backend .BasicStation .FrequencyMin ,
101
- frequencyMax : conf .Backend .BasicStation .FrequencyMax ,
99
+ region : band .Name (conf .Backend .BasicStation .Region ),
100
+ frequencyMin : conf .Backend .BasicStation .FrequencyMin ,
101
+ frequencyMax : conf .Backend .BasicStation .FrequencyMax ,
102
+ concentrators : config .C .Backend .BasicStation .Concentrators ,
102
103
103
104
diidCache : cache .New (time .Minute , time .Minute ),
104
105
}
@@ -129,11 +130,6 @@ func NewBackend(conf config.Config) (*Backend, error) {
129
130
return nil , errors .Wrap (err , "get band config error" )
130
131
}
131
132
132
- b .routerConfig , err = structs .GetRouterConfig (b .region , b .netIDs , b .joinEUIs , b .frequencyMin , b .frequencyMax , conf .Backend .BasicStation .Concentrators )
133
- if err != nil {
134
- return nil , errors .Wrap (err , "get router config error" )
135
- }
136
-
137
133
mux := http .NewServeMux ()
138
134
mux .HandleFunc ("/router-info" , func (w http.ResponseWriter , r * http.Request ) {
139
135
b .websocketWrap (b .handleRouterInfo , w , r )
@@ -309,6 +305,10 @@ func (b *Backend) Stop() error {
309
305
return b .ln .Close ()
310
306
}
311
307
308
+ func (b * Backend ) getRouterConfig () (structs.RouterConfig , error ) {
309
+ return structs .GetRouterConfig (b .region , b .netIDs , b .joinEUIs , b .frequencyMin , b .frequencyMax , b .concentrators )
310
+ }
311
+
312
312
func (b * Backend ) handleRouterInfo (r * http.Request , conn * connection ) {
313
313
websocketReceiveCounter ("router_info" ).Inc ()
314
314
var req structs.RouterInfoRequest
@@ -574,8 +574,14 @@ func (b *Backend) handleVersion(gatewayID lorawan.EUI64, pl structs.Version) {
574
574
// "features": pl.Features,
575
575
}).Info ("backend/basicstation: gateway version received" )
576
576
577
+ routerConfig , err := b .getRouterConfig ()
578
+ if err != nil {
579
+ log .WithError (err ).Error ("backend/basicstation: get router config error" )
580
+ return
581
+ }
582
+
577
583
websocketSendCounter ("router_config" ).Inc ()
578
- if err := b .sendToGateway (gatewayID , b . routerConfig ); err != nil {
584
+ if err := b .sendToGateway (gatewayID , routerConfig ); err != nil {
579
585
log .WithError (err ).Error ("backend/basicstation: send to gateway error" )
580
586
return
581
587
}
0 commit comments