Skip to content

Commit

Permalink
Configure semtechudp cache expiration and cleanup interval
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaskirner committed Dec 9, 2024
1 parent ea8985d commit 2f9d840
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
12 changes: 12 additions & 0 deletions cmd/chirpstack-gateway-bridge/cmd/configfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions cmd/chirpstack-gateway-bridge/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 4 additions & 1 deletion internal/backend/semtechudp/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
10 changes: 6 additions & 4 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2f9d840

Please sign in to comment.