Skip to content

Configure semtechudp cache expiration and cleanup interval #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmd/chirpstack-gateway-bridge/cmd/configfile.go
Original file line number Diff line number Diff line change
@@ -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]

3 changes: 3 additions & 0 deletions cmd/chirpstack-gateway-bridge/cmd/root.go
Original file line number Diff line number Diff line change
@@ -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")
5 changes: 4 additions & 1 deletion internal/backend/semtechudp/backend.go
Original file line number Diff line number Diff line change
@@ -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() {
10 changes: 6 additions & 4 deletions internal/config/config.go
Original file line number Diff line number Diff line change
@@ -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 {