@@ -63,13 +63,13 @@ type Backend struct {
6363 gatewayStatsFunc func (* gw.GatewayStats )
6464 rawPacketForwarderEventFunc func (* gw.RawPacketForwarderEvent )
6565
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
7373
7474 // Cache to store diid to UUIDs.
7575 diidCache * cache.Cache
@@ -94,9 +94,10 @@ func NewBackend(conf config.Config) (*Backend, error) {
9494 readTimeout : conf .Backend .BasicStation .ReadTimeout ,
9595 writeTimeout : conf .Backend .BasicStation .WriteTimeout ,
9696
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 ,
100101
101102 diidCache : cache .New (time .Minute , time .Minute ),
102103 }
@@ -127,11 +128,6 @@ func NewBackend(conf config.Config) (*Backend, error) {
127128 return nil , errors .Wrap (err , "get band config error" )
128129 }
129130
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-
135131 mux := http .NewServeMux ()
136132 mux .HandleFunc ("/router-info" , func (w http.ResponseWriter , r * http.Request ) {
137133 b .websocketWrap (b .handleRouterInfo , w , r )
@@ -295,6 +291,10 @@ func (b *Backend) Stop() error {
295291 return b .ln .Close ()
296292}
297293
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+
298298func (b * Backend ) handleRouterInfo (r * http.Request , conn * connection ) {
299299 websocketReceiveCounter ("router_info" ).Inc ()
300300 var req structs.RouterInfoRequest
@@ -553,8 +553,14 @@ func (b *Backend) handleVersion(gatewayID lorawan.EUI64, pl structs.Version) {
553553 // "features": pl.Features,
554554 }).Info ("backend/basicstation: gateway version received" )
555555
556+ routerConfig , err := b .getRouterConfig ()
557+ if err != nil {
558+ log .WithError (err ).Error ("backend/basicstation: get router config error" )
559+ return
560+ }
561+
556562 websocketSendCounter ("router_config" ).Inc ()
557- if err := b .sendToGateway (gatewayID , b . routerConfig ); err != nil {
563+ if err := b .sendToGateway (gatewayID , routerConfig ); err != nil {
558564 log .WithError (err ).Error ("backend/basicstation: send to gateway error" )
559565 return
560566 }
0 commit comments