diff --git a/cmd/chirpstack-gateway-bridge/cmd/configfile.go b/cmd/chirpstack-gateway-bridge/cmd/configfile.go index 0eeb9e9d..5bd34dad 100644 --- a/cmd/chirpstack-gateway-bridge/cmd/configfile.go +++ b/cmd/chirpstack-gateway-bridge/cmd/configfile.go @@ -95,6 +95,18 @@ type="{{ .Backend.Type }}" # disconnected and it will unsubscribe from the gateway MQTT topic and cleanup the UDP docket. connection_timeout_duration={{ .Backend.SemtechUDP.CleanupDuration }} + # Cache expiration + # + # ChirpStack Gateway Bridge temporarily store downlinks. If a gateway does not send any + # UDP data within the configured timeout the downlink is discarded. + cache_default_expiration={{ .Backend.SemtechUDP.CacheDefaultExpiration }} + + # Cache cleanup interval + # + # ChirpStack Gateway Bridge temporarily store downlinks in a cache. The cache is cleaned in + # the configured interval. + cache_cleanup_interval={{ .Backend.SemtechUDP.CacheCleanupInterval }} + # ChirpStack Concentratord backend. [backend.concentratord] diff --git a/cmd/chirpstack-gateway-bridge/cmd/root.go b/cmd/chirpstack-gateway-bridge/cmd/root.go index aa09c2b4..30a2fa67 100644 --- a/cmd/chirpstack-gateway-bridge/cmd/root.go +++ b/cmd/chirpstack-gateway-bridge/cmd/root.go @@ -41,6 +41,9 @@ func init() { viper.SetDefault("backend.semtech_udp.udp_bind", "0.0.0.0:1700") viper.SetDefault("backend.semtech_udp.cleanup_duration", time.Minute) + viper.SetDefault("backend.semtech_udp.cache_default_expiration", 15*time.Second) + viper.SetDefault("backend.semtech_udp.cache_cleanup_interval", 15*time.Second) + viper.SetDefault("backend.concentratord.crc_check", true) viper.SetDefault("backend.concentratord.event_url", "ipc:///tmp/concentratord_event") viper.SetDefault("backend.concentratord.command_url", "ipc:///tmp/concentratord_command") diff --git a/internal/backend/semtechudp/backend.go b/internal/backend/semtechudp/backend.go index 41bb3b05..9ed369b7 100644 --- a/internal/backend/semtechudp/backend.go +++ b/internal/backend/semtechudp/backend.go @@ -72,7 +72,10 @@ func NewBackend(conf config.Config) (*Backend, error) { }, fakeRxTime: conf.Backend.SemtechUDP.FakeRxTime, skipCRCCheck: conf.Backend.SemtechUDP.SkipCRCCheck, - cache: cache.New(15*time.Second, 15*time.Second), + cache: cache.New( + time.Duration(conf.Backend.SemtechUDP.CacheDefaultExpiration), + time.Duration(conf.Backend.SemtechUDP.CacheCleanupInterval), + ), } go func() { diff --git a/internal/config/config.go b/internal/config/config.go index d201bca4..fd26e55e 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -21,10 +21,12 @@ type Config struct { Type string `mapstructure:"type"` SemtechUDP struct { - UDPBind string `mapstructure:"udp_bind"` - SkipCRCCheck bool `mapstructure:"skip_crc_check"` - FakeRxTime bool `mapstructure:"fake_rx_time"` - CleanupDuration int `mapstructure:"connection_timeout_duration"` + UDPBind string `mapstructure:"udp_bind"` + SkipCRCCheck bool `mapstructure:"skip_crc_check"` + FakeRxTime bool `mapstructure:"fake_rx_time"` + CleanupDuration int `mapstructure:"connection_timeout_duration"` + CacheDefaultExpiration int `mapstructure:"cache_default_expiration"` + CacheCleanupInterval int `mapstructure:"cache_cleanup_interval"` } `mapstructure:"semtech_udp"` BasicStation struct {