File tree 5 files changed +16
-10
lines changed
cmd/chirpstack-gateway-bridge/cmd 5 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,12 @@ type="{{ .Backend.Type }}"
88
88
# the time would otherwise be unset.
89
89
fake_rx_time={{ .Backend.SemtechUDP.FakeRxTime }}
90
90
91
+ # Connection timeout duration
92
+ #
93
+ # ChirpStack Gateway Bridge keeps a list of connected gateways. If a gateway does not send any
94
+ # UDP data within the configured timeout, then ChirpStack Gateway Bridge will consider the gateway
95
+ # disconnected and it will unsubscribe from the gateway MQTT topic and cleanup the UDP docket.
96
+ connection_timeout_duration={{ .Backend.SemtechUDP.CleanupDuration }}
91
97
92
98
# ChirpStack Concentratord backend.
93
99
[backend.concentratord]
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ func init() {
39
39
viper .SetDefault ("general.log_level" , 4 )
40
40
viper .SetDefault ("backend.type" , "semtech_udp" )
41
41
viper .SetDefault ("backend.semtech_udp.udp_bind" , "0.0.0.0:1700" )
42
+ viper .SetDefault ("backend.semtech_udp.cleanup_duration" , time .Minute )
42
43
43
44
viper .SetDefault ("backend.concentratord.crc_check" , true )
44
45
viper .SetDefault ("backend.concentratord.event_url" , "ipc:///tmp/concentratord_event" )
Original file line number Diff line number Diff line change @@ -67,7 +67,8 @@ func NewBackend(conf config.Config) (*Backend, error) {
67
67
conn : conn ,
68
68
udpSendChan : make (chan udpPacket ),
69
69
gateways : gateways {
70
- gateways : make (map [lorawan.EUI64 ]gateway ),
70
+ gateways : make (map [lorawan.EUI64 ]gateway ),
71
+ cleanupDuration : time .Duration (conf .Backend .SemtechUDP .CleanupDuration ),
71
72
},
72
73
fakeRxTime : conf .Backend .SemtechUDP .FakeRxTime ,
73
74
skipCRCCheck : conf .Backend .SemtechUDP .SkipCRCCheck ,
Original file line number Diff line number Diff line change 16
16
errGatewayDoesNotExist = errors .New ("gateway does not exist" )
17
17
)
18
18
19
- // gatewayCleanupDuration contains the duration after which the gateway is
20
- // cleaned up from the registry after no activity
21
- var gatewayCleanupDuration = - 1 * time .Minute
22
-
23
19
// gateway contains a connection and meta-data for a gateway connection.
24
20
type gateway struct {
25
21
stats * stats.Collector
@@ -31,7 +27,8 @@ type gateway struct {
31
27
// gateways contains the gateways registry.
32
28
type gateways struct {
33
29
sync.RWMutex
34
- gateways map [lorawan.EUI64 ]gateway
30
+ gateways map [lorawan.EUI64 ]gateway
31
+ cleanupDuration time.Duration
35
32
36
33
subscribeEventFunc func (events.Subscribe )
37
34
}
@@ -82,7 +79,7 @@ func (c *gateways) cleanup() error {
82
79
defer c .Unlock ()
83
80
84
81
for gatewayID := range c .gateways {
85
- if c .gateways [gatewayID ].lastSeen .Before (time .Now ().Add (gatewayCleanupDuration )) {
82
+ if c .gateways [gatewayID ].lastSeen .Before (time .Now ().Add (c . cleanupDuration )) {
86
83
disconnectCounter ().Inc ()
87
84
88
85
if c .subscribeEventFunc != nil {
Original file line number Diff line number Diff line change @@ -21,9 +21,10 @@ type Config struct {
21
21
Type string `mapstructure:"type"`
22
22
23
23
SemtechUDP struct {
24
- UDPBind string `mapstructure:"udp_bind"`
25
- SkipCRCCheck bool `mapstructure:"skip_crc_check"`
26
- FakeRxTime bool `mapstructure:"fake_rx_time"`
24
+ UDPBind string `mapstructure:"udp_bind"`
25
+ SkipCRCCheck bool `mapstructure:"skip_crc_check"`
26
+ FakeRxTime bool `mapstructure:"fake_rx_time"`
27
+ CleanupDuration int `mapstructure:"connection_timeout_duration"`
27
28
} `mapstructure:"semtech_udp"`
28
29
29
30
BasicStation struct {
You can’t perform that action at this time.
0 commit comments