Skip to content

Commit 2f9d840

Browse files
committed
Configure semtechudp cache expiration and cleanup interval
1 parent ea8985d commit 2f9d840

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

cmd/chirpstack-gateway-bridge/cmd/configfile.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ type="{{ .Backend.Type }}"
9595
# disconnected and it will unsubscribe from the gateway MQTT topic and cleanup the UDP docket.
9696
connection_timeout_duration={{ .Backend.SemtechUDP.CleanupDuration }}
9797
98+
# Cache expiration
99+
#
100+
# ChirpStack Gateway Bridge temporarily store downlinks. If a gateway does not send any
101+
# UDP data within the configured timeout the downlink is discarded.
102+
cache_default_expiration={{ .Backend.SemtechUDP.CacheDefaultExpiration }}
103+
104+
# Cache cleanup interval
105+
#
106+
# ChirpStack Gateway Bridge temporarily store downlinks in a cache. The cache is cleaned in
107+
# the configured interval.
108+
cache_cleanup_interval={{ .Backend.SemtechUDP.CacheCleanupInterval }}
109+
98110
# ChirpStack Concentratord backend.
99111
[backend.concentratord]
100112

cmd/chirpstack-gateway-bridge/cmd/root.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ func init() {
4141
viper.SetDefault("backend.semtech_udp.udp_bind", "0.0.0.0:1700")
4242
viper.SetDefault("backend.semtech_udp.cleanup_duration", time.Minute)
4343

44+
viper.SetDefault("backend.semtech_udp.cache_default_expiration", 15*time.Second)
45+
viper.SetDefault("backend.semtech_udp.cache_cleanup_interval", 15*time.Second)
46+
4447
viper.SetDefault("backend.concentratord.crc_check", true)
4548
viper.SetDefault("backend.concentratord.event_url", "ipc:///tmp/concentratord_event")
4649
viper.SetDefault("backend.concentratord.command_url", "ipc:///tmp/concentratord_command")

internal/backend/semtechudp/backend.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ func NewBackend(conf config.Config) (*Backend, error) {
7272
},
7373
fakeRxTime: conf.Backend.SemtechUDP.FakeRxTime,
7474
skipCRCCheck: conf.Backend.SemtechUDP.SkipCRCCheck,
75-
cache: cache.New(15*time.Second, 15*time.Second),
75+
cache: cache.New(
76+
time.Duration(conf.Backend.SemtechUDP.CacheDefaultExpiration),
77+
time.Duration(conf.Backend.SemtechUDP.CacheCleanupInterval),
78+
),
7679
}
7780

7881
go func() {

internal/config/config.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ type Config struct {
2121
Type string `mapstructure:"type"`
2222

2323
SemtechUDP struct {
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"`
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"`
28+
CacheDefaultExpiration int `mapstructure:"cache_default_expiration"`
29+
CacheCleanupInterval int `mapstructure:"cache_cleanup_interval"`
2830
} `mapstructure:"semtech_udp"`
2931

3032
BasicStation struct {

0 commit comments

Comments
 (0)